|
@@ -46,27 +46,33 @@ public class Craps extends DiceGame implements Gamble {
|
46
|
46
|
|
47
|
47
|
public void play(CrapsPlayer currentPlayer) {
|
48
|
48
|
placeBet();
|
49
|
|
-
|
50
|
|
- promptEnterKey("roll dice");
|
51
|
|
-
|
52
|
49
|
int sum = rollDie(2);
|
53
|
50
|
|
|
51
|
+ promptEnterKey("roll dice");
|
54
|
52
|
console.println("Your roll sum equals: " + sum);
|
55
|
53
|
|
|
54
|
+ simulateCraps(currentPlayer, sum);
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ private void simulateCraps(CrapsPlayer currentPlayer, int sum) {
|
56
|
58
|
if (sum == 7 || sum == 11) {
|
57
|
59
|
evalWin(currentPlayer.getP());
|
58
|
60
|
} else if (sum == 2 || sum == 3 || sum == 12) {
|
59
|
61
|
evalLoss(currentPlayer.getP());
|
60
|
62
|
} else {
|
61
|
|
- int point = sum;
|
62
|
|
- do {
|
63
|
|
- printRollAgain(point);
|
64
|
|
- sum = rollDie(2);
|
65
|
|
- evalReRoll(currentPlayer, sum , point);
|
66
|
|
- } while (sum != point && sum != 7);
|
|
63
|
+ rollForPoint(currentPlayer, sum);
|
67
|
64
|
}
|
68
|
65
|
}
|
69
|
66
|
|
|
67
|
+ private void rollForPoint(CrapsPlayer currentPlayer, int sum) {
|
|
68
|
+ int point = sum;
|
|
69
|
+ do {
|
|
70
|
+ printRollAgain(point);
|
|
71
|
+ sum = rollDie(2);
|
|
72
|
+ evalReRoll(currentPlayer, sum , point);
|
|
73
|
+ } while (sum != point && sum != 7);
|
|
74
|
+ }
|
|
75
|
+
|
70
|
76
|
public void print(){
|
71
|
77
|
for(int i = 0; i < crapsPlayers.size(); i++){
|
72
|
78
|
System.out.println(crapsPlayers.get(i).getP().getChipBalance());
|
|
@@ -74,9 +80,8 @@ public class Craps extends DiceGame implements Gamble {
|
74
|
80
|
}
|
75
|
81
|
|
76
|
82
|
public void printRollAgain(int point){
|
77
|
|
- console.println("\n--------------------");
|
78
|
|
- console.println("Point to roll for: " + point);
|
79
|
|
- console.println("--------------------");
|
|
83
|
+ console.println("\n--------------------" +
|
|
84
|
+ "\nPoint to roll for: " + point + "--------------------");
|
80
|
85
|
promptEnterKey("roll again");
|
81
|
86
|
}
|
82
|
87
|
|