|
@@ -13,12 +13,7 @@ import java.util.ArrayList;
|
13
|
13
|
public class GoFish extends CardGame {
|
14
|
14
|
private static Deck drawPile = new Deck();
|
15
|
15
|
private ArrayList<GoFishPlayer> goFishPlayers = new ArrayList<>();
|
16
|
|
-
|
17
|
|
- public void goFish() {
|
18
|
|
- readyPlayers();
|
19
|
|
- dealCards(getNumberOfCards());
|
20
|
|
- runGame();
|
21
|
|
- }
|
|
16
|
+// private int numberOfCards;
|
22
|
17
|
|
23
|
18
|
public void readyPlayers() {
|
24
|
19
|
for (Player player : Players.getInstance().getPlayers()) {
|
|
@@ -27,13 +22,15 @@ public class GoFish extends CardGame {
|
27
|
22
|
}
|
28
|
23
|
|
29
|
24
|
@Override
|
30
|
|
- public void runGame() { // run the game as longa s the drawPile is more than 0 cards
|
31
|
|
- for (int i = drawPile.size(); i > 0; i++) {
|
32
|
|
- playGoFish();
|
|
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
|
+ }
|
33
|
30
|
}
|
34
|
31
|
}
|
35
|
32
|
|
36
|
|
- public int getNumberOfCards() { //generate numberOfCards param for below based on number of players
|
|
33
|
+ public int getStartingCards() { //generate numberOfCards param for below based on number of players
|
37
|
34
|
int numberOfCards;
|
38
|
35
|
if (goFishPlayers.size() <= 3) { //RULES: For 3 players or less, deal each player 7 cards;
|
39
|
36
|
numberOfCards = 7;
|
|
@@ -44,16 +41,18 @@ public class GoFish extends CardGame {
|
44
|
41
|
}
|
45
|
42
|
|
46
|
43
|
@Override
|
47
|
|
- public void dealCards(Player player, int numberOfCards) { //populate the cardHand of players
|
48
|
|
- GoFishPlayer fishie = (GoFishPlayer) player; // depending on how many players
|
49
|
|
- for (int i = 0; i < numberOfCards; i++) {
|
50
|
|
- Card card = drawPile.removeFirst();
|
51
|
|
- fishie.getHand().add(card);
|
52
|
|
- }
|
|
44
|
+ public void dealCards(Player player, int 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
|
+// }
|
53
|
51
|
}
|
54
|
52
|
|
55
|
53
|
@Override
|
56
|
54
|
public void dealCards(int numberOfCards) {
|
|
55
|
+ numberOfCards = getStartingCards();
|
57
|
56
|
for (GoFishPlayer p : goFishPlayers) {
|
58
|
57
|
for (int i = 0; i < numberOfCards; i++) {
|
59
|
58
|
Card card = drawPile.removeFirst();
|
|
@@ -62,17 +61,22 @@ public class GoFish extends CardGame {
|
62
|
61
|
}
|
63
|
62
|
}
|
64
|
63
|
|
|
64
|
+ public GoFish() {
|
|
65
|
+ readyPlayers();
|
|
66
|
+ dealCards(getStartingCards());
|
|
67
|
+ runGame();
|
|
68
|
+ }
|
|
69
|
+
|
65
|
70
|
@Override
|
66
|
71
|
public void promptContinue() {
|
67
|
|
- } //WHAT?
|
|
72
|
+ } //WHAT??
|
68
|
73
|
|
69
|
74
|
|
70
|
75
|
public void playGoFish() {
|
71
|
|
- for (int i = 0; i < goFishPlayers.size(); i++) {
|
72
|
|
- askForOpponent();
|
73
|
|
- searchCard();
|
74
|
|
- //matchCards();
|
75
|
|
- }
|
|
76
|
+ askForOpponent();
|
|
77
|
+ searchCard();
|
|
78
|
+ checkCards();
|
|
79
|
+ checkSets();
|
76
|
80
|
}
|
77
|
81
|
|
78
|
82
|
public String askForOpponent() {
|
|
@@ -85,51 +89,60 @@ public class GoFish extends CardGame {
|
85
|
89
|
return wantedCard;
|
86
|
90
|
}
|
87
|
91
|
|
88
|
|
- public void matchCards(GoFishPlayer opponent, Integer wantedCard) {
|
|
92
|
+ public void checkCards() {
|
|
93
|
+ String opponent = askForOpponent();
|
89
|
94
|
GoFishPlayer fishie = new GoFishPlayer();
|
90
|
95
|
for (int i = 0; i < goFishPlayers.size(); i++) {
|
91
|
96
|
if (opponent.equals(goFishPlayers.get(i).getName())) {
|
92
|
|
- for (int j = 0; j < opponent.getHand().size(); j++) {
|
93
|
|
- if (wantedCard.equals(opponent.getHand().get(i).getCardValue())) {
|
94
|
|
- fishie.getHand().add(opponent.getHand().get(i));
|
95
|
|
- opponent.getHand().remove(i);
|
96
|
|
- } else fishie.getHand().add(drawPile.removeFirst());
|
|
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();
|
97
|
107
|
}
|
98
|
108
|
}
|
99
|
109
|
}
|
100
|
110
|
}
|
101
|
111
|
|
102
|
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\"");
|
103
|
117
|
}
|
104
|
118
|
|
105
|
|
- //take userInput [console input?]
|
106
|
|
- //askPlayerCard(); Prompt w/question of what card (rank) to look for [console output?]
|
107
|
|
- //take userInput[console input?]
|
108
|
|
- //for cardHand(chosen player)
|
109
|
|
- //evalCards(userInput): If userInput.equals(card[i].cardGetValue)
|
110
|
|
- //swap();
|
111
|
|
- //repeat until userInput != cardGetValue
|
112
|
|
-
|
113
|
|
-
|
114
|
|
- //else
|
115
|
|
- //goFish(); draw a card from Deck - (deck - 1)
|
116
|
|
- //move to next player;
|
117
|
|
- //checkSets: run through each cardHand and looks for 4 of a kind;
|
118
|
|
- //if found, setsCount++;
|
119
|
|
-
|
120
|
|
-
|
121
|
|
-// public void evalCards() {
|
122
|
|
-// // if for cards in dealerHand:
|
123
|
|
-//// swap cards or go fish
|
124
|
|
-// }
|
125
|
|
-//
|
126
|
|
-// public void goFish() {
|
127
|
|
-// //pull from top of deck
|
128
|
|
-// }
|
129
|
|
-//
|
130
|
|
-// public void checkSets() {
|
131
|
|
-// // check if 4 in dealerHand have same value
|
132
|
|
-// }
|
133
|
|
-}
|
|
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
|
+ }
|
134
|
145
|
|
135
|
146
|
|
|
147
|
+ }
|
|
148
|
+}
|