Ver código fonte

conflicts merged

Demetrius Murray 6 anos atrás
pai
commit
01524a0e0d

BIN
.DS_Store Ver arquivo


BIN
src/.DS_Store Ver arquivo


BIN
src/main/.DS_Store Ver arquivo


BIN
src/main/java/.DS_Store Ver arquivo


BIN
src/main/java/io/.DS_Store Ver arquivo


BIN
src/main/java/io/zipcoder/.DS_Store Ver arquivo


BIN
src/main/java/io/zipcoder/casino/.DS_Store Ver arquivo


+ 6
- 0
src/main/java/io/zipcoder/casino/.idea/misc.xml Ver arquivo

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="JavaScriptSettings">
4
+    <option name="languageLevel" value="ES6" />
5
+  </component>
6
+</project>

+ 8
- 0
src/main/java/io/zipcoder/casino/.idea/modules.xml Ver arquivo

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectModuleManager">
4
+    <modules>
5
+      <module fileurl="file://$PROJECT_DIR$/.idea/casino.iml" filepath="$PROJECT_DIR$/.idea/casino.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 6
- 0
src/main/java/io/zipcoder/casino/.idea/vcs.xml Ver arquivo

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="VcsDirectoryMappings">
4
+    <mapping directory="$PROJECT_DIR$/../../../../../.." vcs="Git" />
5
+  </component>
6
+</project>

+ 137
- 0
src/main/java/io/zipcoder/casino/.idea/workspace.xml Ver arquivo

@@ -0,0 +1,137 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ChangeListManager">
4
+    <list default="true" id="845dffe2-de4a-4c4d-baff-26706b6d73ec" name="Default Changelist" comment="" />
5
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
6
+    <option name="SHOW_DIALOG" value="false" />
7
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
8
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
9
+    <option name="LAST_RESOLUTION" value="IGNORE" />
10
+  </component>
11
+  <component name="FUSProjectUsageTrigger">
12
+    <session id="-974371692">
13
+      <usages-collector id="statistics.lifecycle.project">
14
+        <counts>
15
+          <entry key="project.closed" value="1" />
16
+          <entry key="project.open.time.0" value="1" />
17
+          <entry key="project.opened" value="1" />
18
+        </counts>
19
+      </usages-collector>
20
+    </session>
21
+  </component>
22
+  <component name="Git.Settings">
23
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../../../../../.." />
24
+  </component>
25
+  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
26
+  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
27
+  <component name="JsGulpfileManager">
28
+    <detection-done>true</detection-done>
29
+    <sorting>DEFINITION_ORDER</sorting>
30
+  </component>
31
+  <component name="ProjectFrameBounds" extendedState="6">
32
+    <option name="y" value="23" />
33
+    <option name="width" value="1920" />
34
+    <option name="height" value="991" />
35
+  </component>
36
+  <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
37
+  <component name="ProjectView">
38
+    <navigator proportions="" version="1">
39
+      <foldersAlwaysOnTop value="true" />
40
+    </navigator>
41
+    <panes>
42
+      <pane id="PackagesPane" />
43
+      <pane id="ProjectPane" />
44
+      <pane id="Scope" />
45
+    </panes>
46
+  </component>
47
+  <component name="PropertiesComponent">
48
+    <property name="WebServerToolWindowFactoryState" value="false" />
49
+    <property name="aspect.path.notification.shown" value="true" />
50
+    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
51
+    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
52
+    <property name="nodejs_npm_path_reset_for_default_project" value="true" />
53
+  </component>
54
+  <component name="RunDashboard">
55
+    <option name="ruleStates">
56
+      <list>
57
+        <RuleState>
58
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
59
+        </RuleState>
60
+        <RuleState>
61
+          <option name="name" value="StatusDashboardGroupingRule" />
62
+        </RuleState>
63
+      </list>
64
+    </option>
65
+  </component>
66
+  <component name="SvnConfiguration">
67
+    <configuration />
68
+  </component>
69
+  <component name="TaskManager">
70
+    <task active="true" id="Default" summary="Default task">
71
+      <changelist id="845dffe2-de4a-4c4d-baff-26706b6d73ec" name="Default Changelist" comment="" />
72
+      <created>1541461053855</created>
73
+      <option name="number" value="Default" />
74
+      <option name="presentableId" value="Default" />
75
+      <updated>1541461053855</updated>
76
+      <workItem from="1541461055381" duration="18000" />
77
+    </task>
78
+    <servers />
79
+  </component>
80
+  <component name="TimeTrackingManager">
81
+    <option name="totallyTimeSpent" value="18000" />
82
+  </component>
83
+  <component name="ToolWindowManager">
84
+    <frame x="0" y="23" width="1280" height="712" extended-state="6" />
85
+    <layout>
86
+      <window_info id="Image Layers" />
87
+      <window_info id="Designer" />
88
+      <window_info id="UI Designer" />
89
+      <window_info id="Capture Tool" />
90
+      <window_info id="Favorites" side_tool="true" />
91
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24959612" />
92
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
93
+      <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
94
+      <window_info anchor="bottom" id="Version Control" show_stripe_button="false" />
95
+      <window_info anchor="bottom" id="Terminal" />
96
+      <window_info anchor="bottom" id="Event Log" side_tool="true" />
97
+      <window_info anchor="bottom" id="Message" order="0" />
98
+      <window_info anchor="bottom" id="Find" order="1" />
99
+      <window_info anchor="bottom" id="Run" order="2" />
100
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
101
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
102
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
103
+      <window_info anchor="bottom" id="TODO" order="6" />
104
+      <window_info anchor="right" id="Palette" />
105
+      <window_info anchor="right" id="Theme Preview" />
106
+      <window_info anchor="right" id="Capture Analysis" />
107
+      <window_info anchor="right" id="Palette&#9;" />
108
+      <window_info anchor="right" id="Database" />
109
+      <window_info anchor="right" id="Maven Projects" />
110
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
111
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
112
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
113
+    </layout>
114
+  </component>
115
+  <component name="TypeScriptGeneratedFilesManager">
116
+    <option name="version" value="1" />
117
+  </component>
118
+  <component name="VcsContentAnnotationSettings">
119
+    <option name="myLimit" value="2678400000" />
120
+  </component>
121
+  <component name="masterDetails">
122
+    <states>
123
+      <state key="ProjectJDKs.UI">
124
+        <settings>
125
+          <last-edited>1.8</last-edited>
126
+          <splitter-proportions>
127
+            <option name="proportions">
128
+              <list>
129
+                <option value="0.2" />
130
+              </list>
131
+            </option>
132
+          </splitter-proportions>
133
+        </settings>
134
+      </state>
135
+    </states>
136
+  </component>
137
+</project>

BIN
src/main/java/io/zipcoder/casino/CardGame/.DS_Store Ver arquivo


+ 85
- 10
src/main/java/io/zipcoder/casino/CardGame/BlackJack/BlackJack.java Ver arquivo

@@ -2,6 +2,7 @@ package io.zipcoder.casino.CardGame.BlackJack;
2 2
 
3 3
 import io.zipcoder.casino.CardGame.Card;
4 4
 import io.zipcoder.casino.CardGame.CardGame;
5
+import io.zipcoder.casino.CardGame.Deck;
5 6
 import io.zipcoder.casino.Interfaces.Gamble;
6 7
 import io.zipcoder.casino.Player;
7 8
 
@@ -12,13 +13,32 @@ public class BlackJack extends CardGame implements Gamble {
12 13
     private ArrayList<BlackJackPlayer> blackJackPlayers;
13 14
     private int minBet;
14 15
     private ArrayList<Card> wastepile;
15
-    private java.util.ArrayList<Card> dealerHand;
16
+    private ArrayList<Card> dealerHand;
17
+    private Deck deck;
18
+    private boolean justDealt;
19
+    private int numOfTurns;
16 20
 
17 21
     public BlackJack(Player player) {
18 22
         BlackJackPlayer blackJackPlayer = new BlackJackPlayer(player);
23
+        this.blackJackPlayers = new ArrayList<BlackJackPlayer>();
19 24
         this.blackJackPlayers.add(blackJackPlayer);
25
+        this.minBet = 100;
26
+        this.wastepile = new ArrayList<Card>();
27
+        this.dealerHand = new ArrayList<Card>();
28
+        this.deck = new Deck();
29
+        this.justDealt = false;
30
+        this.numOfTurns = 0;
20 31
     }
21 32
 
33
+//    public BlackJack(){
34
+//        this.blackJackPlayers = new ArrayList<BlackJackPlayer>();
35
+//    }
36
+
37
+//    public BlackJack(Player player) {
38
+//        BlackJackPlayer blackJackPlayer = new BlackJackPlayer(player);
39
+//        this.blackJackPlayers.add(blackJackPlayer);
40
+//    }
41
+
22 42
     // basically draw
23 43
     public Card hit() {
24 44
         return null;
@@ -33,22 +53,53 @@ public class BlackJack extends CardGame implements Gamble {
33 53
         // must be the same card value
34 54
     }
35 55
 
36
-    public void doubleDown() {
37
-        // must be right after the first daeling
56
+    public void doubleDown(BlackJackPlayer blackJackPlayer) {
57
+        if (getJustDealt() == true) {
58
+            blackJackPlayer.addToBetPot(blackJackPlayer.getInitialBet());
59
+        }
60
+        // must be right after deal, and you can only get one more card
38 61
     }
39 62
 
40 63
     public void stand() {
64
+        endTurn();
65
+        // (end turn?) what does "take a turn" actually initiate
66
+    }
67
+
68
+    public int countHand(BlackJackPlayer blackJackPlayer) {
69
+        int handSum = 0;
70
+
71
+        for (int i = 0; i < blackJackPlayer.getPlayerHand().size(); i++) {
72
+            handSum += (blackJackPlayer.getPlayerHand().get(i).getFace().getSecondaryValue());
73
+        }
74
+        return handSum;
41 75
     }
42 76
 
43
-    public int countHand() {
44
-        return 0;
77
+    public void deal(BlackJackPlayer blackJackPlayer) {
78
+        // BlackJackPlayer player1 = blackJackPlayers.get(playerIndex);
79
+        blackJackPlayers.add(blackJackPlayer);
80
+        // should we move this to start instead? we would also need to deal for each player if multiple
81
+        Card playerCard1 = deck.draw();
82
+        blackJackPlayer.addToHand(playerCard1);
83
+
84
+        Card dealerCard1 = deck.draw();
85
+        dealerHand.add(dealerCard1);
86
+
87
+        Card playerCard2 = deck.draw();
88
+        blackJackPlayer.addToHand(playerCard2);
89
+
90
+        Card dealerCard2 = deck.draw();
91
+        dealerHand.add(dealerCard2);
92
+
93
+        setJustDealt(true);
45 94
     }
46 95
 
47
-    public void deal() {
96
+    public BlackJackPlayer getPlayer(int index) {
97
+        return blackJackPlayers.get(index);
48 98
     }
49 99
 
50 100
     public void start() {
51
-
101
+        // upon starting a new game, every player places a bet? make a loop???
102
+        betAmount(50, blackJackPlayers.get(0));
52 103
     }
53 104
 
54 105
     public void end() {
@@ -59,19 +110,43 @@ public class BlackJack extends CardGame implements Gamble {
59 110
 
60 111
     }
61 112
 
62
-    public void addPlayer() {
113
+    // add to game interface?
114
+    public void endTurn() {
115
+    }
63 116
 
117
+    public void addPlayer(Player player) {
118
+        BlackJackPlayer blackJackPlayer = new BlackJackPlayer(player);
119
+        this.blackJackPlayers.add(blackJackPlayer);
64 120
     }
65 121
 
66
-    public void removePlayer() {
122
+    public void removePlayer(Player player) {
123
+        for (BlackJackPlayer blackJackPlayer : blackJackPlayers) {
124
+            if (blackJackPlayer.getPlayer() == player) {
125
+                this.blackJackPlayers.remove(blackJackPlayer);
126
+                break;
127
+            }
128
+        }
129
+
130
+    }
67 131
 
132
+    public int betAmount(int amount, BlackJackPlayer blackJackPlayer) {
133
+        blackJackPlayer.addToBetPot(amount);
134
+        return betAmount(amount, blackJackPlayer.getPlayer());
68 135
     }
69 136
 
70 137
     public int betAmount(int amount, Player player) {
71
-        return 0;
138
+        return amount;
72 139
     }
73 140
 
74 141
     public void distributePot(int amount, Player player) {
75 142
 
76 143
     }
144
+
145
+    public boolean getJustDealt() {
146
+        return this.justDealt;
147
+    }
148
+
149
+    public void setJustDealt(boolean justDealt) {
150
+        this.justDealt = justDealt;
151
+    }
77 152
 }

+ 34
- 1
src/main/java/io/zipcoder/casino/CardGame/BlackJack/BlackJackPlayer.java Ver arquivo

@@ -3,17 +3,50 @@ package io.zipcoder.casino.CardGame.BlackJack;
3 3
 import io.zipcoder.casino.CardGame.Card;
4 4
 import io.zipcoder.casino.Player;
5 5
 
6
+import java.util.ArrayList;
7
+
6 8
 public class BlackJackPlayer {
7 9
 
8 10
     private Player player;
9 11
 
10 12
     private int initialBet;
11 13
     private int handValue;
12
-    private java.util.ArrayList<Card> playerHand;
14
+    private ArrayList<Card> playerHand;
13 15
     private int betPot;
14 16
 
15 17
     public BlackJackPlayer(Player player) {
16 18
         this.player = player;
19
+        this.handValue = 0;
20
+        this.playerHand = new ArrayList<Card>();
21
+        this.betPot = 0;
22
+    }
23
+
24
+    public void addToHand(Card card){
25
+        playerHand.add(card);
26
+    }
27
+
28
+    public ArrayList<Card> getPlayerHand() {
29
+        return playerHand;
30
+    }
31
+
32
+    public Player getPlayer() {
33
+        return player;
34
+    }
35
+
36
+    public int getInitialBet() {
37
+        return initialBet;
38
+    }
39
+
40
+    public void addToBetPot(int amount) {
41
+        betPot += amount;
42
+    }
43
+
44
+    public int getBetPot() {
45
+        return betPot;
46
+    }
47
+
48
+    public void setInitialBet(int amount){
49
+        this.initialBet = amount;
17 50
     }
18 51
 
19 52
 }

+ 21
- 9
src/main/java/io/zipcoder/casino/CardGame/Face.java Ver arquivo

@@ -2,7 +2,7 @@ package io.zipcoder.casino.CardGame;
2 2
 
3 3
 public enum Face {
4 4
 
5
-    ACE(1),
5
+    ACE(1, 11),
6 6
     TWO(2),
7 7
     THREE(3),
8 8
     FOUR(4),
@@ -12,17 +12,29 @@ public enum Face {
12 12
     EIGHT(8),
13 13
     NINE(9),
14 14
     TEN(10),
15
-    JACK(11),
16
-    QUEEN(12),
17
-    KING(13);
15
+    JACK(11, 10),
16
+    QUEEN(12, 10),
17
+    KING(13, 10);
18 18
 
19
-    private int value;
19
+    private int primaryValue;
20
+    private int secondaryValue;
20 21
 
21
-    private Face(int value) {
22
-        this.value = value;
22
+    Face(int primaryValue, int secondaryValue) {
23
+        this.primaryValue = primaryValue;
24
+        this.secondaryValue = secondaryValue;
23 25
     }
24 26
 
25
-    public int getValue(){
26
-        return value;
27
+    Face(int primaryValue) {
28
+        this.primaryValue = primaryValue;
29
+        this.secondaryValue = primaryValue;     // even though they're the same, you wanna set it bc if you accdidentally call getSecondary on something w/o an initialized secondary then it'l return null
27 30
     }
31
+
32
+    public int getPrimaryValue() {
33
+        return primaryValue;
34
+    }
35
+
36
+    public int getSecondaryValue() {
37
+        return secondaryValue;
38
+    }
39
+
28 40
 }

+ 2
- 2
src/main/java/io/zipcoder/casino/CardGame/Solitaire/Solitaire.java Ver arquivo

@@ -32,11 +32,11 @@ public class Solitaire extends CardGame {
32 32
 
33 33
     }
34 34
 
35
-    public void addPlayer() {
35
+    public void addPlayer(Player player) {
36 36
 
37 37
     }
38 38
 
39
-    public void removePlayer() {
39
+    public void removePlayer(Player player) {
40 40
 
41 41
     }
42 42
 

+ 1
- 1
src/main/java/io/zipcoder/casino/CardGame/Solitaire/Tableau.java Ver arquivo

@@ -48,7 +48,7 @@ public class Tableau {
48 48
 
49 49
     //checks whether 'top' card of stack is opposite color and 1 above passed card
50 50
     private boolean canReceive(Card c) {
51
-        if ((this.stack.peek().getFace().getValue() - 1) == c.getFace().getValue()
51
+        if ((this.stack.peek().getFace().getPrimaryValue() - 1) == c.getFace().getPrimaryValue()
52 52
                 && (this.stack.peek().isBlack() != c.isBlack())) {
53 53
             return true;
54 54
         } else {

+ 2
- 2
src/main/java/io/zipcoder/casino/DiceGame/Craps/Craps.java Ver arquivo

@@ -40,11 +40,11 @@ public class Craps extends DiceGame implements Gamble {
40 40
 
41 41
     }
42 42
 
43
-    public void addPlayer() {
43
+    public void addPlayer(Player player) {
44 44
 
45 45
     }
46 46
 
47
-    public void removePlayer() {
47
+    public void removePlayer(Player player) {
48 48
 
49 49
     }
50 50
 }

+ 4
- 2
src/main/java/io/zipcoder/casino/Interfaces/Game.java Ver arquivo

@@ -1,5 +1,7 @@
1 1
 package io.zipcoder.casino.Interfaces;
2 2
 
3
+import io.zipcoder.casino.Player;
4
+
3 5
 public interface Game {
4 6
     void start();
5 7
 
@@ -7,7 +9,7 @@ public interface Game {
7 9
 
8 10
     void takeATurn();
9 11
 
10
-    void addPlayer();
12
+    void addPlayer(Player player);
11 13
 
12
-    void removePlayer();
14
+    void removePlayer(Player player);
13 15
 }

+ 58
- 0
src/test/java/io/zipcoder/casino/BlackJackTest.java Ver arquivo

@@ -1,4 +1,62 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
+import io.zipcoder.casino.CardGame.BlackJack.BlackJack;
4
+import io.zipcoder.casino.CardGame.BlackJack.BlackJackPlayer;
5
+import io.zipcoder.casino.CardGame.Card;
6
+import io.zipcoder.casino.CardGame.Deck;
7
+import org.junit.Assert;
8
+import org.junit.Before;
9
+import org.junit.Test;
10
+
11
+import java.util.ArrayList;
12
+
3 13
 public class BlackJackTest {
14
+
15
+    Deck deck = new Deck();
16
+    Player player = new Player("Jack Black");
17
+    BlackJack blackJack = new BlackJack(player);
18
+    BlackJackPlayer testPlayer = blackJack.getPlayer(0);
19
+    ArrayList<Card> testHand = testPlayer.getPlayerHand();
20
+
21
+    @Test
22
+    public void testDeal() {
23
+        blackJack.deal(testPlayer);
24
+
25
+        int expected = 2;
26
+        int actual = testHand.size();
27
+
28
+        Assert.assertEquals(expected, actual);
29
+    }
30
+
31
+    @Test
32
+    public void testCountHand() {
33
+        testPlayer.addToHand(deck.draw());
34
+        testPlayer.addToHand(deck.draw());
35
+
36
+        System.out.println(testHand);
37
+
38
+        int expected = 25;
39
+        int actual = blackJack.countHand(testPlayer);
40
+
41
+        Assert.assertEquals(expected, actual);
42
+    }
43
+
44
+    @Test
45
+    public void testJustDealt() {
46
+        blackJack.setJustDealt(false);
47
+        System.out.println(blackJack.getJustDealt());
48
+    }
49
+
50
+    @Test
51
+    public void testDoubleDown(){
52
+        blackJack.setJustDealt(true);
53
+        testPlayer.setInitialBet(blackJack.betAmount(50, testPlayer));
54
+        blackJack.doubleDown(testPlayer);
55
+
56
+        int expected = 100;
57
+        int actual = testPlayer.getBetPot();
58
+
59
+        Assert.assertEquals(expected, actual);
60
+    }
61
+
4 62
 }