@Override public void saveToSnapshot(Document doc, Element node) { for (Road tunnel : tunnels) { if (tunnel.getTile().getPosition() != null && tunnel.getTunnelEnd() != Road.OPEN_TUNNEL) { Element el = doc.createElement("tunnel"); node.appendChild(el); XmlUtils.injectPosition(el, tunnel.getTile().getPosition()); el.setAttribute("location", tunnel.getLocation().toString()); el.setAttribute("player", "" + (tunnel.getTunnelEnd() % 100)); el.setAttribute("b", tunnel.getTunnelEnd() > 100 ? "yes" : "no"); } } }
@Override public void prepareActions(List<PlayerAction<?>> actions, Set<FeaturePointer> commonSites) { if (isTunnelUsedThisTurn()) return; if (getOpenTunnels().isEmpty()) return; List<TunnelAction> tunnelActions = new ArrayList<>(2); TunnelAction tunnelAction = null; if (getTunnelTokens(game.getActivePlayer(), false) > 0) { tunnelActions.add(new TunnelAction(false)); } if (getTunnelTokens(game.getActivePlayer(), true) > 0) { tunnelActions.add(new TunnelAction(true)); } for (TunnelAction ta : tunnelActions) { for (Road tunnelEnd : getOpenTunnels()) { ta.add(new FeaturePointer(getTile().getPosition(), tunnelEnd.getLocation())); } } actions.addAll(tunnelActions); }