Beispiel #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);
       }
     }
   }
 }
Beispiel #2
0
 private void scoreCompletedNearAbbey(Position pos) {
   for (Entry<Location, Tile> e : getBoard().getAdjacentTilesMap(pos).entrySet()) {
     Tile tile = e.getValue();
     Feature feature = tile.getFeaturePartOf(e.getKey().rev());
     if (feature instanceof Completable) {
       scoreCompleted((Completable) feature, false);
     }
   }
 }
Beispiel #3
0
 protected void unmerge(Tile tile, Location loc) {
   Location oppositeLoc = loc.rev();
   MultiTileFeature oppositePiece = (MultiTileFeature) tile.getFeaturePartOf(oppositeLoc);
   if (oppositePiece != null) {
     oppositePiece.setEdge(oppositeLoc, null);
     if (!isAbbeyTile()) {
       MultiTileFeature thisPiece = (MultiTileFeature) getFeaturePartOf(loc);
       thisPiece.setEdge(loc, null);
     }
   }
   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) {
       oppositePiece.setEdge(oppositeHalfSide, null);
       if (!isAbbeyTile()) {
         MultiTileFeature thisPiece = (MultiTileFeature) getFeaturePartOf(halfSide);
         thisPiece.setEdge(halfSide, null);
       }
     }
   }
 }