Commit 91785b0f authored by amir's avatar amir

Some bugs detected

parent a408c34f
...@@ -16,6 +16,7 @@ public class Comp extends Player { ...@@ -16,6 +16,7 @@ public class Comp extends Player {
} }
else { else {
c = randomPunishmentCard(cards); c = randomPunishmentCard(cards);
cards.remove(c);
getPlayerCards().add(c); getPlayerCards().add(c);
if (c instanceof Colored) { if (c instanceof Colored) {
if (card instanceof Colored) { if (card instanceof Colored) {
...@@ -62,6 +63,7 @@ public class Comp extends Player { ...@@ -62,6 +63,7 @@ public class Comp extends Player {
else { else {
System.out.println("kirekhar"); System.out.println("kirekhar");
c = randomPunishmentCard(cards); c = randomPunishmentCard(cards);
cards.remove(c);
System.out.println(c.toString()); System.out.println(c.toString());
getPlayerCards().add(c); getPlayerCards().add(c);
if (c instanceof Colored) { if (c instanceof Colored) {
......
...@@ -26,6 +26,7 @@ public class Human extends Player { ...@@ -26,6 +26,7 @@ public class Human extends Player {
System.out.println("gaav!"); System.out.println("gaav!");
} }
card = getPlayerCards().get(number - 1); card = getPlayerCards().get(number - 1);
cards.remove(card);
getPlayerCards().remove(number - 1); getPlayerCards().remove(number - 1);
return card; return card;
} else { } else {
...@@ -81,6 +82,7 @@ public class Human extends Player { ...@@ -81,6 +82,7 @@ public class Human extends Player {
} }
} else { } else {
card = randomPunishmentCard(cards); card = randomPunishmentCard(cards);
cards.remove(card);
getPlayerCards().add(card); getPlayerCards().add(card);
if (card instanceof Colored) { if (card instanceof Colored) {
if (!card.cardColor.equals(Color)) { if (!card.cardColor.equals(Color)) {
......
...@@ -5,9 +5,9 @@ import java.util.Iterator; ...@@ -5,9 +5,9 @@ import java.util.Iterator;
import java.util.Random; import java.util.Random;
public class Main { public class Main {
static Card previousCard = null; static int drawCounter; static ArrayList<Card> cards = new ArrayList<>();
public static void main(String[] args) { public static void main(String[] args) {
ArrayList<Card> cards = new ArrayList<>();
String Color; String Color;
String Color1; String Color1;
for (int i = 1; i < 5; i++) { for (int i = 1; i < 5; i++) {
...@@ -150,6 +150,7 @@ public class Main { ...@@ -150,6 +150,7 @@ public class Main {
nextColor = players.get(turns).chooseColorIfBlack(card); nextColor = players.get(turns).chooseColorIfBlack(card);
if (nextColor == null) if (nextColor == null)
nextCard = card; nextCard = card;
} }
if (nextColor == null) if (nextColor == null)
System.out.println(nextCard.toString()); System.out.println(nextCard.toString());
...@@ -198,4 +199,49 @@ public class Main { ...@@ -198,4 +199,49 @@ public class Main {
System.out.println("|"); System.out.println("|");
}*/ }*/
} }
public static void switches(Card next, int turns, int move, ArrayList<Player> players){
if (previousCard instanceof Draw){
drawCounter += 2;
if (next instanceof Draw)
drawCounter += 2;
else{
for (int i = 1; i <= drawCounter; i++)
players.get(turns).getPlayerCards().add(randomCard());
turns += move;
drawCounter = 0;
}
}
if (previousCard instanceof WildDraw){
drawCounter += 4;
if (next instanceof Draw){
drawCounter += 2;
}
else{
if (next instanceof WildDraw){
drawCounter += 4;
}
else{
for (int i = 1; i <= drawCounter; i++)
players.get(turns).getPlayerCards().add(randomCard());
turns += move;
drawCounter = 0;
}
}
}
if (next instanceof Reverse)
move *= -1;
else {
if (next instanceof Skip)
turns += move;
System.out.println("Player" + (turns + 1) + "'s turns skipped");
}
previousCard = next;
}
public static Card randomCard(){
Random r = new Random();
int next = r.nextInt(cards.size());
return cards.get(next);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment