Connor Dunnigan пре 6 година
родитељ
комит
35657bf58f

+ 17
- 12
src/main/java/io/zipcoder/casino/dicegames/Craps.java Прегледај датотеку

46
 
46
 
47
     public void play(CrapsPlayer currentPlayer) {
47
     public void play(CrapsPlayer currentPlayer) {
48
         placeBet();
48
         placeBet();
49
-
50
-        promptEnterKey("roll dice");
51
-
52
         int sum = rollDie(2);
49
         int sum = rollDie(2);
53
 
50
 
51
+        promptEnterKey("roll dice");
54
         console.println("Your roll sum equals: " + sum);
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
         if (sum == 7 || sum == 11) {
58
         if (sum == 7 || sum == 11) {
57
             evalWin(currentPlayer.getP());
59
             evalWin(currentPlayer.getP());
58
         } else if (sum == 2 || sum == 3 || sum == 12) {
60
         } else if (sum == 2 || sum == 3 || sum == 12) {
59
             evalLoss(currentPlayer.getP());
61
             evalLoss(currentPlayer.getP());
60
         } else {
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
     public void print(){
76
     public void print(){
71
         for(int i = 0; i < crapsPlayers.size(); i++){
77
         for(int i = 0; i < crapsPlayers.size(); i++){
72
             System.out.println(crapsPlayers.get(i).getP().getChipBalance());
78
             System.out.println(crapsPlayers.get(i).getP().getChipBalance());
74
     }
80
     }
75
 
81
 
76
     public void printRollAgain(int point){
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
         promptEnterKey("roll again");
85
         promptEnterKey("roll again");
81
     }
86
     }
82
 
87
 

+ 1
- 1
src/main/java/io/zipcoder/casino/utilities/Console.java Прегледај датотеку

102
 
102
 
103
     public static void printWcarrot(String output){
103
     public static void printWcarrot(String output){
104
         System.out.println(output);
104
         System.out.println(output);
105
-        System.out.print(">");
105
+        System.out.print("> ");
106
     }
106
     }
107
 
107
 
108
 
108