Exemplo n.º 1
0
 /** merge this to another tile - method argument is tile placed before */
 protected void merge(Tile tile, Location loc) {
   if (logger.isDebugEnabled()) logger.debug("Merging " + id + " with " + tile.getId());
   Location oppositeLoc = loc.rev();
   MultiTileFeature oppositePiece = (MultiTileFeature) tile.getFeaturePartOf(oppositeLoc);
   if (oppositePiece != null) {
     if (isAbbeyTile()) {
       oppositePiece.setAbbeyEdge(oppositeLoc);
     } else {
       MultiTileFeature thisPiece = (MultiTileFeature) getFeaturePartOf(loc);
       oppositePiece.setEdge(oppositeLoc, thisPiece);
       thisPiece.setEdge(loc, oppositePiece);
     }
   }
   for (int i = 0; i < 2; i++) {
     Location halfSide = i == 0 ? loc.getLeftFarm() : loc.getRightFarm();
     Location oppositeHalfSide = halfSide.rev();
     oppositePiece = (MultiTileFeature) tile.getFeaturePartOf(oppositeHalfSide);
     if (oppositePiece != null) {
       if (isAbbeyTile()) {
         oppositePiece.setAbbeyEdge(oppositeHalfSide);
       } else {
         MultiTileFeature thisPiece = (MultiTileFeature) getFeaturePartOf(halfSide);
         oppositePiece.setEdge(oppositeHalfSide, thisPiece);
         thisPiece.setEdge(halfSide, oppositePiece);
       }
     }
   }
 }
Exemplo n.º 2
0
	private void createTileElements(Game game) {
		tileElemens = new HashMap<Position, Element>();
		Element parent = doc.createElement("tiles");
		if (game.getCurrentTile() != null) {
			parent.setAttribute("next", game.getCurrentTile().getId());
		}
		root.appendChild(parent);
		//for()
		for(String group : game.getTilePack().getGroups()) {
			Element el = doc.createElement("group");
			el.setAttribute("name", group);
			el.setAttribute("active", "" + game.getTilePack().isGroupActive(group));
			parent.appendChild(el);
		}
		for(Tile tile : game.getBoard().getAllTiles()) {
			Element el = doc.createElement("tile");
			el.setAttribute("name", tile.getId());
			el.setAttribute("rotation", tile.getRotation().name());
			XmlUtils.injectPosition(el, tile.getPosition());
			parent.appendChild(el);
			tileElemens.put(tile.getPosition(), el);
		}
		for(String tileId : game.getBoard().getDiscardedTiles()) {
			Element el = doc.createElement("discard");
			el.setAttribute("name", tileId);
			parent.appendChild(el);
		}
	}