示例#1
0
文件: Game.java 项目: paleber/Catan
        @Override
        public void buildStreet(int pathId) {
          Path path = findPathForBuilding(pathId);
          players[curPlayerIndex].buildSetupStreet(path);
          finishStreetBuilding(path);

          if (players[curPlayerIndex].getSettlements().length <= 1) {

            // Forward Preparation Round
            if (curPlayerIndex < players.length - 1) {
              curPlayerIndex++;
            }
            gamePhase = preparationSettlementPhase;
            control.sendGameEvent(new PreparationSettlementPhaseEvent(curPlayerIndex));

          } else {

            // Backward Preparation Round
            if (curPlayerIndex > 0) {
              curPlayerIndex--;
              gamePhase = preparationSettlementPhase;
              control.sendGameEvent(new PreparationSettlementPhaseEvent(curPlayerIndex));
            } else {
              for (Player p : players) {
                p.collectStartResources();
              }
              gamePhase = resourcePhase;
              control.sendGameEvent(new ResourcePhaseEvent(curPlayerIndex));
            }
          }
        }
示例#2
0
文件: Game.java 项目: paleber/Catan
        @Override
        void rollDice() {
          Random r = new Random();
          int n1 = r.nextInt(6) + 1;
          int n2 = r.nextInt(6) + 1;
          control.sendGameEvent(new RollDiceEvent(n1, n2));

          if (n1 + n2 != 7) {
            for (Player p : players) {
              p.collectMaterial(n1 + n2);
            }
          } else {
            // TODO Knight
          }

          gamePhase = actionPhase;
        }