コード例 #1
0
ファイル: TileUtils.java プロジェクト: svenmeys/Carcassonne
  private static final void connectBorders(Tile t1, int b1, Tile t2, int b2) {
    t1.getBorder()[b1].setZone(
        t1.getBorder()[b1].getZone().mergeInto(t2.getBorder()[b2].getZone()));

    t1.getBorderConnections()[b1] = t2.getBorder()[b2];
    t2.getBorderConnections()[b2] = t1.getBorder()[b1];
  }
コード例 #2
0
ファイル: TileUtils.java プロジェクト: svenmeys/Carcassonne
  public static final int countSurroundingTiles(Tile tile) {
    int counter = 0;

    boolean tl = false;
    boolean tr = false;
    boolean bl = false;
    boolean br = false;

    for (int i = 0; i < 4; i++) {
      Area a = tile.getBorderConnections()[i * 3];
      if (a == null) continue;
      counter++;

      if (i == 0) {
        tl = (a.getLocation().getBorderConnections()[10] != null);
        tr = (a.getLocation().getBorderConnections()[4] == null);
      }
      if (i == 1) {
        tr = (a.getLocation().getBorderConnections()[1] != null);
        br = (a.getLocation().getBorderConnections()[7] != null);
      }
      if (i == 2) {
        br = (a.getLocation().getBorderConnections()[4] != null);
        bl = (a.getLocation().getBorderConnections()[10] != null);
      }
      if (i == 3) {
        bl = (a.getLocation().getBorderConnections()[7] != null);
        tl = (a.getLocation().getBorderConnections()[1] != null);
      }
    }
    return counter + (tl ? 1 : 0) + (bl ? 1 : 0) + (tr ? 1 : 0) + (br ? 1 : 0);
  }