/** 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);
}
}
}
}