@Override public void initFeature(Tile tile, Feature feature, Element xml) { if (!(feature instanceof Road)) return; Road road = (Road) feature; if (road.isTunnelEnd()) { tunnels.add(road); } }
@Override public void loadFromSnapshot(Document doc, Element node) { NodeList nl = node.getElementsByTagName("tunnel"); for (int i = 0; i < nl.getLength(); i++) { Element el = (Element) nl.item(i); Position pos = XmlUtils.extractPosition(el); Location loc = Location.valueOf(el.getAttribute("location")); Road road = (Road) getBoard().get(pos).getFeature(loc); if (!road.isTunnelEnd()) { logger.error("Tunnel end does not exist."); continue; } Player player = game.getPlayer(Integer.parseInt(el.getAttribute("player"))); boolean isB = "yes".equals(el.getAttribute("b")); road.setTunnelEnd(getTunnelId(player, isB)); game.post(new TunnelPiecePlacedEvent(player, pos, loc, isB)); } }