public static Player fromXml(Node playerRoot, int num, Color color) { StrategyPlayer player = new StrategyPlayer(StrategyPlayer.class.getSimpleName(), num, color); NamedNodeMap attrs = playerRoot.getAttributes(); if (attrs.getNamedItem("strategy") != null) { try { Field field = PlayoutStrategy.class.getField(attrs.getNamedItem("strategy").getNodeValue()); player.description = String.format("strategy=%s", field.getName()); player.strategy = (PlayoutStrategy) field.get(null); } catch (Exception e) { e.printStackTrace(); } } return player; }
@Override public StrategyPlayer clone() { StrategyPlayer player = new StrategyPlayer(getName(), getNumber(), getColor()); player.setStrategy(strategy); return player; }