コード例 #1
0
ファイル: Game.java プロジェクト: paleber/Catan
  public Game(IGameControl control, String... playerNames) {
    players = new Player[playerNames.length];
    for (int i = 0; i < players.length; i++) {
      players[i] = new Player(playerNames[i], i, Color.PINK, control, this);
    }

    this.control = control;

    IBoardBuilder builder = new EasyBoardBuilder();
    Collections.addAll(intersections, builder.getIntersections());
    Collections.addAll(paths, builder.getPaths());
    terrains = builder.getTerrains();

    for (Intersection i : intersections) {
      control.sendGameEvent(i.createSetupEvent());
    }

    for (Path p : paths) {
      control.sendGameEvent(p.createSetupEvent());
    }

    for (Terrain t : terrains) {
      control.sendGameEvent(t.createSetupEvent());
    }

    control.sendGameEvent(new PreparationSettlementPhaseEvent(curPlayerIndex));
  }
コード例 #2
0
ファイル: Game.java プロジェクト: paleber/Catan
 private Intersection findIntersection(int intersectionId) {
   for (Intersection s : intersections) {
     if (s.getId() == intersectionId) {
       return s;
     }
   }
   return null;
 }
コード例 #3
0
ファイル: Game.java プロジェクト: paleber/Catan
  private void finishSettlementBuilding(Intersection s) {
    control.sendGameEvent(new BuildSettlementEvent(curPlayerIndex, s.getId()));

    intersections.remove(s);
    for (Intersection i : s.getNeighborIntersections()) {
      if (intersections.contains(i)) {
        intersections.remove(i);
        control.sendGameEvent(new WaypointBlockedEvent(i.getId()));
      }
    }
  }