Nick Satinover 6 years ago
parent
commit
c055f5ca80

+ 1
- 14
src/main/java/io/zipcoder/casino/CardGame.java View File

8
 public abstract class CardGame {
8
 public abstract class CardGame {
9
 
9
 
10
     private int tablePot;
10
     private int tablePot;
11
-    private int minBet;
12
-    private int maxBet;
13
     private int handSize;
11
     private int handSize;
14
     private int ante;
12
     private int ante;
15
     private CardPlayer playersTurn;
13
     private CardPlayer playersTurn;
23
         this.ante = ante;
21
         this.ante = ante;
24
     }
22
     }
25
 
23
 
26
-    //use hand size to determine dealing
27
-    // public abstract void deal();
28
-    // public abstract void deal(ArrayList<CardPlayer> players); // NEEDED FOR STUD
29
-
30
-    public void shuffle(){
31
-
32
-        //shuffle the card stack
33
-
34
-    }
35
-
36
     public Deck getDeck() {
24
     public Deck getDeck() {
37
         return deck;
25
         return deck;
38
     }
26
     }
48
         }
36
         }
49
     }
37
     }
50
 
38
 
51
-
52
     public int getAnte(){
39
     public int getAnte(){
53
         return ante;
40
         return ante;
54
     }
41
     }
85
         addPlayers(new NPC("Opponant", getAnte()));
72
         addPlayers(new NPC("Opponant", getAnte()));
86
     }
73
     }
87
 
74
 
88
-    public void chooseStatingPlayer(){
75
+    public void chooseStartingPlayer(){
89
         //loop through the players
76
         //loop through the players
90
         for(int i = 0; i < getPlayers().size(); i ++){
77
         for(int i = 0; i < getPlayers().size(); i ++){
91
             //if one is not an NPC
78
             //if one is not an NPC

+ 7
- 9
src/main/java/io/zipcoder/casino/Stud.java View File

17
         Printer.printMessage(player.getName() + " shows a " + card.getName());         //PRINT card name to CONSOLE
17
         Printer.printMessage(player.getName() + " shows a " + card.getName());         //PRINT card name to CONSOLE
18
     }
18
     }
19
 
19
 
20
-
21
     public boolean getIsDealt(){
20
     public boolean getIsDealt(){
22
         return isDealt;
21
         return isDealt;
23
     }
22
     }
24
 
23
 
25
-
26
     /**
24
     /**
27
      * Determine what player wins by looping through player array and then
25
      * Determine what player wins by looping through player array and then
28
      * passing each hand to the 'handValue' method
26
      * passing each hand to the 'handValue' method
143
     }
141
     }
144
 
142
 
145
     public void startGame() {
143
     public void startGame() {
146
-        setHandSize(3);             //SET Hand Size for game(3)
147
-        payAnte(this.getPlayers());                  //PAY ante (all players)
148
-        deal(this.getPlayers());                     //DEALS cards/ hands to each player
149
-        startRound();               //METHOD called
144
+        setHandSize(3);                 //SET Hand Size for game(3)
145
+        payAnte(this.getPlayers());     //PAY ante (all players)
146
+        deal(this.getPlayers());        //DEALS cards/ hands to each player
147
+        startRound();                   //METHOD called
150
 
148
 
151
     }
149
     }
152
 
150
 
179
      * Deal each player(and dealer) 3 face down cards in turn
177
      * Deal each player(and dealer) 3 face down cards in turn
180
      */
178
      */
181
     public void deal(ArrayList<CardPlayer> players) {
179
     public void deal(ArrayList<CardPlayer> players) {
182
-        for(int i = 0; i < getHandSize(); i ++){                        //OUTER loop - run 3 times as there are 3 cards per hand
183
-            for (int j = 0; j < players.size(); j++) {             //INNER loop through each player
184
-                players.get(j).getHand().add(getDeck().pullCard());                                 //ADD card to player hand
180
+        for(int i = 0; i < getHandSize(); i ++){
181
+            for (int j = 0; j < players.size(); j++) {
182
+                players.get(j).getHand().add(getDeck().pullCard());
185
             }
183
             }
186
         }
184
         }
187
         isDealt = true;
185
         isDealt = true;

+ 1
- 6
src/main/java/io/zipcoder/casino/War.java View File

1
 package io.zipcoder.casino;
1
 package io.zipcoder.casino;
2
 
2
 
3
 import java.util.*;
3
 import java.util.*;
4
-import java.util.concurrent.Executors;
5
-import java.util.concurrent.ScheduledExecutorService;
6
-import java.util.concurrent.TimeUnit;
7
-import java.util.regex.Pattern;
8
-import java.util.concurrent.TimeUnit;
9
 
4
 
10
 public class War extends CardGame implements Gamble, Game {
5
 public class War extends CardGame implements Gamble, Game {
11
 
6
 
116
 
111
 
117
     public void startGame(){
112
     public void startGame(){
118
         Printer.printMessage("Welcome to War!");
113
         Printer.printMessage("Welcome to War!");
119
-        super.chooseStatingPlayer();
114
+        super.chooseStartingPlayer();
120
         payAnte();
115
         payAnte();
121
         deal();
116
         deal();
122
         startRound();
117
         startRound();

+ 0
- 11
src/main/java/io/zipcoder/casino/test.java View File

1
-package io.zipcoder.casino;
2
-
3
-public class test {
4
-    public static void main(String[] args){
5
-        Player player = new Player("NickTest", 100);
6
-        Game stud = new Stud(10);
7
-        ((Stud) stud).addPlayers(player);
8
-        ((Stud) stud).addNpc();
9
-        stud.startGame();
10
-    }
11
-}

+ 1
- 0
src/test/java/io/zipcoder/casino/CardTest.java View File

17
         System.out.println(card.getName());
17
         System.out.println(card.getName());
18
         System.out.println(card1.getName());
18
         System.out.println(card1.getName());
19
     }
19
     }
20
+
20
 }
21
 }

+ 2
- 2
src/test/java/io/zipcoder/casino/WarTest.java View File

20
         War war = new War(10);
20
         War war = new War(10);
21
         Player player = new Player("Jon", 100);
21
         Player player = new Player("Jon", 100);
22
         war.addPlayers(player);
22
         war.addPlayers(player);
23
-        war.chooseStatingPlayer();
23
+        war.chooseStartingPlayer();
24
         war.deal();
24
         war.deal();
25
         war.getPlayers().get(0).setDiscard(deck);
25
         war.getPlayers().get(0).setDiscard(deck);
26
 
26
 
34
         War war = new War(10);
34
         War war = new War(10);
35
         Player player = new Player("Jon", 100);
35
         Player player = new Player("Jon", 100);
36
         war.addPlayers(player);
36
         war.addPlayers(player);
37
-        war.chooseStatingPlayer();
37
+        war.chooseStartingPlayer();
38
         war.playCard(false);
38
         war.playCard(false);
39
 
39
 
40
         Assert.assertEquals(war.getLoser(), player);
40
         Assert.assertEquals(war.getLoser(), player);