|
@@ -1,31 +1,19 @@
|
1
|
1
|
package io.zipcoder.casino.cardgames;
|
2
|
2
|
|
3
|
|
-import io.zipcoder.casino.utilities.abstracts.CardGame;
|
4
|
|
-import io.zipcoder.casino.utilities.containers.Deck;
|
5
|
3
|
import io.zipcoder.casino.player.GoFishPlayer;
|
6
|
4
|
import io.zipcoder.casino.player.Player;
|
7
|
5
|
import io.zipcoder.casino.player.Players;
|
|
6
|
+import io.zipcoder.casino.utilities.Card;
|
|
7
|
+import io.zipcoder.casino.utilities.Console;
|
|
8
|
+import io.zipcoder.casino.utilities.abstracts.CardGame;
|
|
9
|
+import io.zipcoder.casino.utilities.containers.Deck;
|
8
|
10
|
|
9
|
11
|
import java.util.ArrayList;
|
10
|
12
|
|
11
|
13
|
public class GoFish extends CardGame {
|
12
|
14
|
private static Deck drawPile = new Deck();
|
13
|
|
- // Change Deck to deque;
|
14
|
15
|
private ArrayList<GoFishPlayer> goFishPlayers = new ArrayList<>();
|
15
|
|
-
|
16
|
|
- public static void main(String[] args) {
|
17
|
|
- System.out.println();
|
18
|
|
- }
|
19
|
|
-
|
20
|
|
- public GoFish() {
|
21
|
|
- readyPlayers();
|
22
|
|
- runGame();
|
23
|
|
- }
|
24
|
|
-
|
25
|
|
- @Override
|
26
|
|
- public void runGame(){
|
27
|
|
-
|
28
|
|
- }
|
|
16
|
+// private int numberOfCards;
|
29
|
17
|
|
30
|
18
|
public void readyPlayers() {
|
31
|
19
|
for (Player player : Players.getInstance().getPlayers()) {
|
|
@@ -33,11 +21,20 @@ public class GoFish extends CardGame {
|
33
|
21
|
}
|
34
|
22
|
}
|
35
|
23
|
|
36
|
|
- public int getNumberOfCards() { //generate numberOfCards param for below based on number of players
|
|
24
|
+ @Override
|
|
25
|
+ public void runGame() { // run the game as long as the drawPile is more than 0 cards
|
|
26
|
+ while (drawPile.size() >= 0) {
|
|
27
|
+ for (int j = 0; j < goFishPlayers.size(); j++) {
|
|
28
|
+ playGoFish();
|
|
29
|
+ }
|
|
30
|
+ }
|
|
31
|
+ }
|
|
32
|
+
|
|
33
|
+ public int getStartingCards() { //generate numberOfCards param for below based on number of players
|
37
|
34
|
int numberOfCards;
|
38
|
|
- if (goFishPlayers.size() <= 3) { //RULES: For 3 players or less, deal each player 7 cards;
|
|
35
|
+ if (goFishPlayers.size() <= 3) { //RULES: For 3 players or less, deal each player 7 cards;
|
39
|
36
|
numberOfCards = 7;
|
40
|
|
- } else { //RULES contd: if more than three players, deal 5 cards each.
|
|
37
|
+ } else { //RULES contd: if more than three players, deal 5 cards each.
|
41
|
38
|
numberOfCards = 5;
|
42
|
39
|
}
|
43
|
40
|
return numberOfCards;
|
|
@@ -45,56 +42,107 @@ public class GoFish extends CardGame {
|
45
|
42
|
|
46
|
43
|
@Override
|
47
|
44
|
public void dealCards(Player player, int numberOfCards) {
|
48
|
|
- // dealPile = dealPile - numberOfCards;
|
|
45
|
+// numberOfCards = getStartingCards();
|
|
46
|
+// GoFishPlayer fishie = (GoFishPlayer) player; // depending on how many players
|
|
47
|
+// for (int i = 0; i < numberOfCards; i++) {
|
|
48
|
+// Card card = drawPile.removeFirst();
|
|
49
|
+// fishie.getHand().add(card);
|
|
50
|
+// }
|
49
|
51
|
}
|
50
|
52
|
|
51
|
53
|
@Override
|
52
|
54
|
public void dealCards(int numberOfCards) {
|
|
55
|
+ numberOfCards = getStartingCards();
|
|
56
|
+ for (GoFishPlayer p : goFishPlayers) {
|
|
57
|
+ for (int i = 0; i < numberOfCards; i++) {
|
|
58
|
+ Card card = drawPile.removeFirst();
|
|
59
|
+ p.getHand().add(card);
|
|
60
|
+ }
|
|
61
|
+ }
|
|
62
|
+ }
|
53
|
63
|
|
|
64
|
+ public GoFish() {
|
|
65
|
+ readyPlayers();
|
|
66
|
+ dealCards(getStartingCards());
|
|
67
|
+ runGame();
|
54
|
68
|
}
|
55
|
69
|
|
56
|
70
|
@Override
|
57
|
|
- public void promptContinue(){};
|
58
|
|
- //
|
59
|
|
- public void updateDrawPile() {
|
60
|
|
-
|
61
|
|
-// public void play() {
|
62
|
|
-// for (int i = 0; i }
|
63
|
|
-
|
64
|
|
-// int setsCount;
|
65
|
|
-
|
66
|
|
-
|
67
|
|
- //while (drawPile > 0) {
|
68
|
|
- //public void questionPlayer(String cardRank, Player player) {
|
69
|
|
- //start w/ player
|
70
|
|
- //for (deck.size aka (52 cards - numOfCards per player))
|
71
|
|
- //askPlayerQuestion(); Prompt w/ question of who to ask [console output?]
|
72
|
|
- //take userInput [console input?]
|
73
|
|
- //askPlayerCard(); Prompt w/question of what card (rank) to look for [console output?]
|
74
|
|
- //take userInput[console input?]
|
75
|
|
- //for cardHand(chosen player)
|
76
|
|
- //evalCards(userInput): If userInput.equals(card[i].cardGetValue)
|
77
|
|
- //swap();
|
78
|
|
- //repeat until userInput != cardGetValue
|
79
|
|
- //else
|
80
|
|
- //goFish(); draw a card from Deck - (deck - 1)
|
81
|
|
- //move to next player;
|
82
|
|
- //checkSets: run through each cardHand and looks for 4 of a kind;
|
83
|
|
- //if found, setsCount++;
|
84
|
|
-
|
85
|
|
-
|
86
|
|
-// public void evalCards() {
|
87
|
|
-// //for cards in dealerHand:
|
88
|
|
-//// swap cards or go fish
|
89
|
|
-// }
|
90
|
|
-//
|
91
|
|
-// public void goFish() {
|
92
|
|
-// //pull from top of deck
|
93
|
|
-// }
|
94
|
|
-//
|
95
|
|
-// public void checkSets() {
|
96
|
|
-// // check if 4 in dealerHand have same value
|
97
|
|
-// }
|
|
71
|
+ public void promptContinue() {
|
|
72
|
+ } //WHAT??
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+ public void playGoFish() {
|
|
76
|
+ askForOpponent();
|
|
77
|
+ searchCard();
|
|
78
|
+ checkCards();
|
|
79
|
+ checkSets();
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+ public String askForOpponent() {
|
|
83
|
+ String opponent = Console.getStringInput("Which player would you like to question?");
|
|
84
|
+ return opponent;
|
|
85
|
+ }
|
|
86
|
+
|
|
87
|
+ public Integer searchCard() {
|
|
88
|
+ Integer wantedCard = Console.getIntegerInput("Which card would you like to request?");
|
|
89
|
+ return wantedCard;
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+ public void checkCards() {
|
|
93
|
+ String opponent = askForOpponent();
|
|
94
|
+ GoFishPlayer fishie = new GoFishPlayer();
|
|
95
|
+ for (int i = 0; i < goFishPlayers.size(); i++) {
|
|
96
|
+ if (opponent.equals(goFishPlayers.get(i).getName())) {
|
|
97
|
+ Console.println(fishie.getName() + " has " + fishie.getHand().display()); //hopefully this prints out
|
|
98
|
+ for (int j = 0; j < goFishPlayers.get(i).getHand().size(); j++) {
|
|
99
|
+ while (searchCard().equals(goFishPlayers.get(i).getHand().get(j).getCardValue())) {
|
|
100
|
+ Console.println("Nice job!");
|
|
101
|
+ fishie.getHand().add(goFishPlayers.get(i).getHand().get(j));
|
|
102
|
+ goFishPlayers.get(i).getHand().remove(j);
|
|
103
|
+ askForOpponent(); //need this?
|
|
104
|
+ searchCard(); //need this?
|
|
105
|
+ }
|
|
106
|
+ fish();
|
|
107
|
+ }
|
|
108
|
+ }
|
|
109
|
+ }
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+ public void fish() {
|
|
114
|
+ GoFishPlayer player = new GoFishPlayer();
|
|
115
|
+ player.getHand().add(drawPile.removeFirst());
|
|
116
|
+ Console.println("Lame. Go Fish loser \"\\uD83D\\uDC1F\"");
|
|
117
|
+ }
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+ public void checkSets() { // help. lost. trying to set aside the sets
|
|
121
|
+// GoFishPlayer player = new GoFishPlayer();
|
|
122
|
+ for (int i = 0; i < goFishPlayers.size(); i++) {
|
|
123
|
+ GoFishPlayer currentPlayer = goFishPlayers.get(i);
|
|
124
|
+ for (int j = 0; j < currentPlayer.getHand().size(); j++) {
|
|
125
|
+ int set = 0;
|
|
126
|
+ for (int k = 1; k < currentPlayer.getHand().size(); k++) {
|
|
127
|
+ if (currentPlayer.getHand().get(j).getCardValue() == currentPlayer.getHand().get(k).getCardValue()) {
|
|
128
|
+ set++;
|
|
129
|
+ }
|
|
130
|
+ }
|
|
131
|
+ if (set>=4) {
|
|
132
|
+ int setCount = currentPlayer.getSetCount();
|
|
133
|
+ int newSetCount = setCount += 1;
|
|
134
|
+ currentPlayer.setSetCount(newSetCount);
|
|
135
|
+ }
|
|
136
|
+// setCount.put();
|
|
137
|
+// }
|
|
138
|
+// goFishPlayers.get(i).getHand();
|
|
139
|
+// if (setCount.containsKey(goFishPlayers.get(i).getHand().get().getCardValue())))
|
|
140
|
+ }
|
|
141
|
+ {
|
|
142
|
+
|
|
143
|
+ }
|
|
144
|
+ }
|
|
145
|
+
|
98
|
146
|
|
99
|
147
|
}
|
100
|
|
-}
|
|
148
|
+}
|