|
@@ -1,6 +1,5 @@
|
1
|
1
|
package io.zipcoder.casino.dicegames;
|
2
|
2
|
|
3
|
|
-import io.zipcoder.casino.player.BlackJackPlayer;
|
4
|
3
|
import io.zipcoder.casino.utilities.Console;
|
5
|
4
|
import io.zipcoder.casino.utilities.interfaces.Gamble;
|
6
|
5
|
import io.zipcoder.casino.player.CrapsPlayer;
|
|
@@ -18,6 +17,7 @@ public class Craps extends DiceGame implements Gamble {
|
18
|
17
|
public Craps() {
|
19
|
18
|
announceGameChoice();
|
20
|
19
|
readyPlayers();
|
|
20
|
+ //promptBets();
|
21
|
21
|
runGame();
|
22
|
22
|
}
|
23
|
23
|
//for test purposes
|
|
@@ -40,15 +40,8 @@ public class Craps extends DiceGame implements Gamble {
|
40
|
40
|
}
|
41
|
41
|
}
|
42
|
42
|
|
43
|
|
- public void placeBet() {
|
44
|
|
- this.bet = console.integerInputSameLine("Enter your bet: ");
|
45
|
|
- }
|
46
|
|
-
|
47
|
|
- @Override
|
48
|
43
|
public void placeBet(Player player) {
|
49
|
|
- BlackJackPlayer blackJackPlayer = (BlackJackPlayer) player;
|
50
|
|
- long bet = Console.getLongInput("Please enter your bet.");
|
51
|
|
- blackJackPlayer.setBet(bet);
|
|
44
|
+ bet = console.integerInputSameLine("Enter your bet: ");
|
52
|
45
|
}
|
53
|
46
|
|
54
|
47
|
public void evaluateBet(Player player, long payout) {
|
|
@@ -56,28 +49,34 @@ public class Craps extends DiceGame implements Gamble {
|
56
|
49
|
}
|
57
|
50
|
|
58
|
51
|
public void play(CrapsPlayer currentPlayer) {
|
59
|
|
- placeBet();
|
60
|
|
-
|
61
|
|
- promptEnterKey("roll dice");
|
62
|
|
-
|
|
52
|
+ placeBet(currentPlayer);
|
63
|
53
|
int sum = rollDie(2);
|
64
|
54
|
|
|
55
|
+ promptEnterKey("roll dice");
|
65
|
56
|
console.println("Your roll sum equals: " + sum);
|
66
|
57
|
|
|
58
|
+ simulateCraps(currentPlayer, sum);
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+ private void simulateCraps(CrapsPlayer currentPlayer, int sum) {
|
67
|
62
|
if (sum == 7 || sum == 11) {
|
68
|
63
|
evalWin(currentPlayer.getP());
|
69
|
64
|
} else if (sum == 2 || sum == 3 || sum == 12) {
|
70
|
65
|
evalLoss(currentPlayer.getP());
|
71
|
66
|
} else {
|
72
|
|
- int point = sum;
|
73
|
|
- do {
|
74
|
|
- printRollAgain(point);
|
75
|
|
- sum = rollDie(2);
|
76
|
|
- evalReRoll(currentPlayer, sum , point);
|
77
|
|
- } while (sum != point && sum != 7);
|
|
67
|
+ rollForPoint(currentPlayer, sum);
|
78
|
68
|
}
|
79
|
69
|
}
|
80
|
70
|
|
|
71
|
+ private void rollForPoint(CrapsPlayer currentPlayer, int sum) {
|
|
72
|
+ int point = sum;
|
|
73
|
+ do {
|
|
74
|
+ printRollAgain(point);
|
|
75
|
+ sum = rollDie(2);
|
|
76
|
+ evalReRoll(currentPlayer, sum , point);
|
|
77
|
+ } while (sum != point && sum != 7);
|
|
78
|
+ }
|
|
79
|
+
|
81
|
80
|
public void print(){
|
82
|
81
|
for(int i = 0; i < crapsPlayers.size(); i++){
|
83
|
82
|
System.out.println(crapsPlayers.get(i).getP().getChipBalance());
|
|
@@ -85,9 +84,8 @@ public class Craps extends DiceGame implements Gamble {
|
85
|
84
|
}
|
86
|
85
|
|
87
|
86
|
public void printRollAgain(int point){
|
88
|
|
- console.println("\n--------------------");
|
89
|
|
- console.println("Point to roll for: " + point);
|
90
|
|
- console.println("--------------------");
|
|
87
|
+ console.println("\n--------------------" +
|
|
88
|
+ "\nPoint to roll for: " + point + "\n--------------------");
|
91
|
89
|
promptEnterKey("roll again");
|
92
|
90
|
}
|
93
|
91
|
|
|
@@ -120,5 +118,5 @@ public class Craps extends DiceGame implements Gamble {
|
120
|
118
|
}
|
121
|
119
|
|
122
|
120
|
@Override
|
123
|
|
- public void promptContinue(){};
|
|
121
|
+ public void promptContinue(){}
|
124
|
122
|
}
|