コード例 #1
0
 /** restarts the Game with the same settings */
 public void restart() {
   loadGames();
   for (final Player player : mPlayers) {
     player.setPoints(0);
   }
   mGameCycle.start();
 }
コード例 #2
0
  /**
   * calculates the Winner of the Game
   *
   * @return Winner
   */
  private int getWinner() {

    // TODO return Player as a List of Players
    Player winner = new Player(-1);
    for (final Player player : mPlayers) {

      if (player.getPoints() > winner.getPoints()) {
        winner = player;
      }
    }
    return winner.getId();
  }
コード例 #3
0
  private void linkPlayerAndButtons() {

    for (int i = 1; i <= mPlayerNumber; i++) {
      final Player player = new Player(i);
      player.setBuzzer(mBuzzer.get(i - 1));
      mPlayers.add(player);
      player.getBuzzer().setPlayer(player);
      player.getBuzzer().setText("0");
    }

    while (mBuzzer.size() > mPlayerNumber) {
      mBuzzer.get(mPlayerNumber).setVisibility(View.GONE);
      mBuzzer.remove(mPlayerNumber);
    }
  }
コード例 #4
0
  // TODO here or in PointProvider?
  protected void dealPoints(final Correctness correctness, final Player player) {
    switch (correctness) {
      case correct:
        player.setPoints(player.getPoints() + 1);
        break;

      case incorrect:
        player.setPoints(player.getPoints() - 1);
        break;

      case toolate:
        break;

      case unclear:
        player.getBuzzer().disable(true);
        break;

      case tooearly:
        player.setPoints(player.getPoints() - 1);
        break;

      default:
        break;
    }
  }