forked from Westfield-Codes/Yahtzee
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoresheet.java
More file actions
134 lines (121 loc) · 3.91 KB
/
Scoresheet.java
File metadata and controls
134 lines (121 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package main.functions;
public class Scoresheet {
private Player currentPlayer;
private Dicecup cup;
private int[] hand;
private int[] board;
private String[] categories;
private ArrayList<String> unusedCategories;
public Scoresheet(Player currentPlayer, Dicecup cup) {
this.currentPlayer = currentPlayer;
this.cup = cup;
this.hand = cup.getHand();
this.board = new int[14];
this.categories = {"ones","twos","threes","fours","fives","sixes","upper section bonus","three of a kind","four of a kind","full house","small straight","large straight","chance","yahtzee"};
this.unusedCategories = new ArrayList<String>();
unusedCategories.add("ones");
unusedCategories.add("twos");
unusedCategories.add("threes");
unusedCategories.add("fours");
unusedCategories.add("fives");
unusedCategories.add("upper section bonus");
unusedCategories.add("three of a kind");
unusedCategories.add("four of a kind");
unusedCategories.add("full house");
unusedCategories.add("small straight");
unusedCategories.add("large straight");
unusedCategories.add("chance");
unusedCategories.add("yahtzee");
}
public String getName() {
return currentPlayer.getName();
}
public int[] getHand() {
return cup.getHand();
}
public boolean validCategory(String category) {
for (int i = 0; i < this.categories.length; i++) {
if (categories[i].compareTo(category) == 0) {
return unused(category);
}
}
return false;
}
public booleaan unused(String category) {
for (int i = 0; i < this.unusedCategories.size(); i++) {
if (unusedCategories.get(i).contains(category)) {
}
}
// public int scoreHand(String category) {
// int score = 0;
// int[] hand = cup.getHand();
// if (this.board.hasCategory(category)) {
// return -1;
// }
// else if (indexOf(category) < 6) {
// int counting = indexOf(category) + 1;
// for (Die die = 0; die < 6; die++) {
// if (hand(die) == counting) {
// score += counting;
// }
// }
// } else {
// if (category.equals("three of a kind")) {
// for (int die = 0; die < 6; die++) {
// score += hand[die];
// }
// }
// if (category.equals("four of a kind")) {
// for (int die = 0; die < 6; die++) {
// score += hand[die];
// }
// }
// if (category.equals("full house")) {
// score += 25;
// }
// if (category.equals("small straight")) {
// score += 30;
// }
// if (category.equals("large straight")) {
// score += 40;
// }
// if (category.equals("yahtzee")) {
// score += 50;
// }
// if (category.equals("chance")) {
// for (int die = 0; die < 6; die++) {
// score += hand[die];
// }
// }
// }
// int newScore = {indexOf(category), score};
// this.board.add(newScore);
// int latest = this.board.length - 1;
// System.out.println("Scored: " + this.board[latest].toString());
// return score;
// }
public int scoreHand(String category) {
int score = 0;
int[] hand = cup.getHand();
if (!this.board.hasCategory(category)) {
for(int i = 0; i < categories)
if(indexOf(category) < 6) {
scoreSimple(indexOf(category));
} else {
scoreComplex(indexOf(category));
}
}
}
public int scoreSimple(int categoryIndex) {
int total = 0;
for(int value : hand) {
if(value == categoryIndex + 1) {
total += value;
}
}
return total;
}
public int scoreComplex(int categoryIndex) {
if(categoryIndex == )
}
}