Esempio n. 1
0
  public void setTurn(ITurn turn) {
    checkPlayer(turn.getPlayer());

    int score = calculateScore(turn);

    playerScores.put(turn.getPlayer(), score);
  }
Esempio n. 2
0
  protected int getValueCount(ITurn turn, int value) {
    int count = 0;

    for (IDice dice : turn.getDiceList()) {
      if (dice.hasValue()) {
        if (dice.getValue() == value) {
          count++;
        }
      }
    }

    return count;
  }
Esempio n. 3
0
  protected int[] getValueCount(ITurn turn, int... values) {
    int[] counts = new int[values.length];

    for (IDice dice : turn.getDiceList()) {
      if (dice.hasValue()) {
        for (int i = 0; i < values.length; i++) {
          int value = values[i];
          if (dice.getValue() == value) {
            counts[i]++;
          }
        }
      }
    }

    return counts;
  }
Esempio n. 4
0
  /** Get values sorted byt natural order so smallest is first and largest is last */
  protected List<Integer> getValues(ITurn turn) {
    List<Integer> values = new ArrayList<Integer>();

    for (IDice dice : turn.getDiceList()) {
      if (dice.hasValue()) {
        int value = dice.getValue();
        if (values.contains(value) == false) {
          values.add(value);
        }
      }
    }

    Collections.sort(values);

    return values;
  }