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
11
12
13
14
15
16
17
18
19
20
21
22
23
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 }