Parcourir la source

pseudo code for startround in war

Jonathan Hinds il y a 6 ans
Parent
révision
f393813214

+ 7
- 0
src/main/java/io/zipcoder/casino/CardGame.java Voir le fichier

@@ -46,4 +46,11 @@ public abstract class CardGame {
46 46
         return players;
47 47
     }
48 48
 
49
+    public void setDeck(ArrayList<Card> deck) {
50
+        this.deck = deck;
51
+    }
52
+
53
+    public int getAnte(){
54
+        return ante;
55
+    }
49 56
 }

+ 4
- 0
src/main/java/io/zipcoder/casino/CardPlayer.java Voir le fichier

@@ -10,4 +10,8 @@ public class CardPlayer {
10 10
     public ArrayList<Card> getHand(){
11 11
         return hand;
12 12
     }
13
+
14
+    public Player getPlayer() {
15
+        return player;
16
+    }
13 17
 }

+ 4
- 1
src/main/java/io/zipcoder/casino/Deck.java Voir le fichier

@@ -11,6 +11,10 @@ public class Deck {
11 11
      * Then, they are shuffled
12 12
      */
13 13
     public Deck(){
14
+        createDeck();
15
+    }
16
+
17
+    public void createDeck(){
14 18
         this.deck = new ArrayList<>();
15 19
 
16 20
         for (int i = 0; i < 13; i++){
@@ -21,7 +25,6 @@ public class Deck {
21 25
                 this.deck.add(card);
22 26
             }
23 27
         }
24
-
25 28
         Collections.shuffle(deck);
26 29
     }
27 30
 

+ 0
- 1
src/main/java/io/zipcoder/casino/Gamble.java Voir le fichier

@@ -3,5 +3,4 @@ package io.zipcoder.casino;
3 3
 public interface Gamble {
4 4
      void Bet(int betAmount);
5 5
      int Payout(int payoutAmount);
6
-     void Ante(int anteAmount);
7 6
 }

+ 19
- 4
src/main/java/io/zipcoder/casino/War.java Voir le fichier

@@ -41,8 +41,12 @@ public class War extends CardGame implements Gamble, Game {
41 41
         return 0;
42 42
     }
43 43
 
44
-    public void Ante(int anteAmount) {
45
-
44
+    public void payAnte() {
45
+        for(int i = 0; i < super.getPlayers().size(); i ++)
46
+        {
47
+            CardPlayer player = super.getPlayers().get(i);
48
+            player.getPlayer().changeBalance(-super.getAnte());
49
+        }
46 50
     }
47 51
 
48 52
     /**
@@ -54,11 +58,22 @@ public class War extends CardGame implements Gamble, Game {
54 58
     }
55 59
 
56 60
     public void StartGame() {
57
-
61
+        Deck deck = new Deck();
62
+        payAnte();
63
+        Deal();
58 64
     }
59 65
 
60 66
     public void StartRound() {
61
-
67
+        //player plays a card faceup
68
+        //remove cards from player hand
69
+        //pc plays a card faceup
70
+        //remove cards from npc hand
71
+        //determinewinner
72
+        //add all table cards to winners discard facedown
73
+
74
+        //when player is out of cards
75
+        //shuffle players discard
76
+        //insert discard into hand facedown
62 77
     }
63 78
 
64 79
     public void Deal() {