View Javadoc

1   package net.sourceforge.simplegamenet.dice;
2   
3   import java.io.Serializable;
4   
5   public class DicePlayerScore implements Serializable {
6   
7       private boolean bonusFilled;
8       private boolean fOAKFilled;
9       private int[] playerScore;
10      // 0   ones
11      // 1   twos
12      // 2   threes
13      // 3   fours
14      // 4   fives
15      // 5   sixes
16      // 6   bonus
17      // 7   three of a kind
18      // 8   four of a kind
19      // 9   full house
20      // 10  small street
21      // 11  big street
22      // 12  five of a kind
23      // 13  chance
24  
25      public DicePlayerScore() {
26          playerScore = new int[14];
27          for (int i = 0; i < playerScore.length; i++) {
28              playerScore[i] = -1;
29          }
30          bonusFilled = false;
31          fOAKFilled = false;
32      }
33  
34      public void setNewPoints(int scoreNumber, int score) {
35          if (scoreNumber > 7) {
36              scoreNumber--;
37          }
38          playerScore[scoreNumber] = score;
39      }
40  
41      public int getPoints(int scoreNumber) {
42          return playerScore[scoreNumber];
43      }
44  
45  
46      public int[] getPlayerTotal() {
47          int[] playerTotals = new int[3];
48          for (int i = 0; i < playerScore.length; i++) {
49              if (playerScore[i] != -1) {
50                  if (i < 7) {
51                      playerTotals[0] += playerScore[i];
52                  } else if (i >= 7) {
53                      playerTotals[1] += playerScore[i];
54                  }
55                  playerTotals[2] += playerScore[i];
56              }
57          }
58          return playerTotals;
59      }
60  
61      public boolean getBonusFilled() {
62          return bonusFilled;
63      }
64  
65      public void setBonusFilled(boolean bonusFilled) {
66          this.bonusFilled = bonusFilled;
67      }
68  
69      public boolean getFOAKFilled() {
70          return fOAKFilled;
71      }
72  
73      public void setFOAKFilled(boolean fOAKFilled) {
74          this.fOAKFilled = fOAKFilled;
75      }
76  
77      public int getFOAKPoints(int scoreNumber) {
78          return playerScore[scoreNumber];
79      }
80  
81      public int getGrandTotal() {
82          int grandTotal = 0;
83          for (int i = 0; i < playerScore.length; i++) {
84              if (playerScore[i] != -1) {
85                  grandTotal += playerScore[i];
86              }
87          }
88          return grandTotal;
89      }
90  
91  }