Procházet zdrojové kódy

Merge branch 'master' of christiansheridan/Casino into master

JenniferChao4 před 6 roky
rodič
revize
e67f2adc00

+ 70
- 6
src/main/java/io/zipcoder/casino/DiceGame/Craps/Craps.java Zobrazit soubor

@@ -1,27 +1,81 @@
1 1
 package io.zipcoder.casino.DiceGame.Craps;
2 2
 
3
+import io.zipcoder.casino.CardGame.Solitaire.Tableau;
4
+import io.zipcoder.casino.DiceGame.Dice;
3 5
 import io.zipcoder.casino.DiceGame.DiceGame;
4 6
 import io.zipcoder.casino.Interfaces.Gamble;
5 7
 import io.zipcoder.casino.Player;
6 8
 
9
+import java.lang.reflect.Array;
10
+import java.util.ArrayList;
7 11
 import java.util.Map;
8 12
 
9 13
 public class Craps extends DiceGame implements Gamble {
10 14
 
15
+
16
+    public int[] betOptions = {2, 3, 4, 5, 6, 8, 9, 10, 11, 12};
17
+    int rollNumber = 0;
18
+    private ArrayList<CrapsPlayers> crapsPlayers;
19
+    private int minBet;
11 20
     private Player player;
12
-    private int hold;
13 21
     private Map<Integer, Integer> betPots;
22
+    private Dice dice;
23
+    private int pointer;
24
+
25
+    public int getPointer() {
26
+        return pointer;
27
+    }
28
+
29
+    public void setPointer(int pointer) {
30
+        this.pointer = pointer;
31
+    }
32
+
14 33
 
15 34
     public Craps(Player player) {
16
-        this.player = player;
35
+        CrapsPlayers crappyPlayer = new CrapsPlayers(player);
36
+        ArrayList<Integer> betOptions = new ArrayList<>(10);
37
+        this.crapsPlayers = new ArrayList<>();
38
+        this.minBet = 10;
39
+        this.dice = new Dice();
17 40
     }
18 41
 
19 42
     public int rollDice() {
20
-        return 0;
43
+        int sum = rollDice(2);
44
+        System.out.println("Total = " + sum);
45
+        rollNumber++;
46
+        return sum;
47
+    }
48
+
49
+    public void firstRoll() {
50
+        rollDice();
51
+        if (rollDice() == 7 || rollDice() == 11) {
52
+            //player wins!!
53
+        } else if (rollDice() == 2 || rollDice() == 3 || rollDice() == 12) {
54
+            //player loses :(
55
+        } else {
56
+            pointer = rollDice();
57
+        }
58
+    }
59
+
60
+    public void remainingRolls() {
61
+        rollDice();
62
+        if (rollDice() == pointer) {
63
+            //player wins pot
64
+        } else if (rollDice() == 7) {
65
+            //player loses all money in pot
66
+        } else {
67
+            //if betOptions == rollDice()
68
+            //casino adds money to the pot - matching whatever bet the player made
69
+        }
21 70
     }
22 71
 
23 72
     public int betAmount(int amount, Player player) {
24
-        return 0;
73
+        return amount;
74
+    }
75
+
76
+    public void bet() {
77
+
78
+
25 79
     }
26 80
 
27 81
     public void distributePot(int amount, Player player) {
@@ -29,6 +83,8 @@ public class Craps extends DiceGame implements Gamble {
29 83
     }
30 84
 
31 85
     public void start() {
86
+        //when starting a game passLine bet or dontPassLine bet is made
87
+
32 88
 
33 89
     }
34 90
 
@@ -41,10 +97,18 @@ public class Craps extends DiceGame implements Gamble {
41 97
     }
42 98
 
43 99
     public void addPlayer(Player player) {
44
-
100
+        CrapsPlayers crappyPlayer = new CrapsPlayers(player);
101
+        this.crapsPlayers.add(crappyPlayer);
45 102
     }
46 103
 
47 104
     public void removePlayer(Player player) {
105
+        for (CrapsPlayers crappyPlayer : crapsPlayers) {
106
+            if (crappyPlayer.getPlayer() == player) {
107
+                this.crapsPlayers.remove(crappyPlayer);
108
+                break;
109
+            }
110
+
111
+        }
48 112
 
49 113
     }
50
-}
114
+}

+ 40
- 0
src/main/java/io/zipcoder/casino/DiceGame/Craps/CrapsPlayers.java Zobrazit soubor

@@ -0,0 +1,40 @@
1
+package io.zipcoder.casino.DiceGame.Craps;
2
+
3
+import io.zipcoder.casino.Player;
4
+
5
+public class CrapsPlayers {
6
+
7
+        private Player player;
8
+
9
+        private int initialBet;
10
+        private int rollValue;
11
+        private int betPot;
12
+
13
+        public CrapsPlayers(Player player) {
14
+            this.player = player;
15
+            this.initialBet = 0;
16
+            this.rollValue = 0;
17
+            this.betPot = 0;
18
+        }
19
+
20
+        public Player getPlayer() {
21
+            return player;
22
+        }
23
+
24
+        public int getInitialBet() {
25
+            return initialBet;
26
+        }
27
+
28
+        public void addToBetPot(int amount) {
29
+            betPot += amount;
30
+        }
31
+
32
+        public int getBetPot() {
33
+            return betPot;
34
+        }
35
+
36
+        public void setInitialBet(int amount){
37
+            this.initialBet = amount;
38
+        }
39
+
40
+    }

+ 1
- 1
src/main/java/io/zipcoder/casino/DiceGame/DiceGame.java Zobrazit soubor

@@ -13,8 +13,8 @@ public abstract class DiceGame implements Game {
13 13
         for (int i = 0; i < numOfDice; i++) {
14 14
             die[i] = (int) Math.floor((Math.random() * 6) + 1);
15 15
             sum += die[i];
16
+            System.out.println("Die #" + (i+1) + " = " + die[i]);
16 17
         }
17
-
18 18
         return sum;
19 19
     }
20 20
 

+ 15
- 0
src/test/java/io/zipcoder/casino/CrapsTest.java Zobrazit soubor

@@ -1,4 +1,19 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
+import io.zipcoder.casino.DiceGame.Craps.Craps;
4
+import io.zipcoder.casino.DiceGame.DiceGame;
5
+import org.junit.Assert;
6
+import org.junit.Test;
7
+
3 8
 public class CrapsTest {
9
+
10
+    Player Crappy = new Player("Crappy");
11
+    Craps game1 = new Craps(Crappy);
12
+
13
+    @Test
14
+    public void rollDiceTest(){
15
+        int actual = game1.rollDice();
16
+        Assert.assertTrue((2 < actual) && (actual < 12));
17
+    }
18
+
4 19
 }

+ 1
- 0
src/test/java/io/zipcoder/casino/PlayerTest.java Zobrazit soubor

@@ -1,4 +1,5 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 public class PlayerTest {
4
+
4 5
 }