Just returning to avoid errors

master
sgoudham 4 years ago
parent 8cff1aba79
commit 4be46e184a
No known key found for this signature in database
GPG Key ID: EF51A29A50FB754C

@ -44,7 +44,7 @@ public class Sevens extends Deck {
String[] splitCard = userCard.split(" "); String[] splitCard = userCard.split(" ");
if (splitCard.length != 2) if (splitCard.length != 2)
askPlayer(playerCounter, player, tableHand, in); return new String[0];
return splitCard; return splitCard;
} }
@ -63,39 +63,38 @@ public class Sevens extends Deck {
} }
Hand userSuitHand = tableHand.getSevensTableHand().get(userSuitInTableHand); Hand userSuitHand = tableHand.getSevensTableHand().get(userSuitInTableHand);
canBePlayed(cardToBePlayed, userSuitHand, userSuitInTableHand, tableHand, player); canBePlayed(cardToBePlayed, userSuitHand, userSuitInTableHand, tableHand, player);
playACard(userSuitHand, cardToBePlayed, tableHand, userSuitInTableHand, player);
} }
public void canBePlayed(Card cardToBePlayed, Hand userSuitHand, Suits userSuitInTableHand, TableHand tableHand, public void canBePlayed(Card cardToBePlayed, Hand userSuitHand, Suits userSuitInTableHand, TableHand tableHand,
Player player) { Player player) {
int minimumValueInUserSuitHand = userSuitHand.getListOfCards().get(0).getFace();
int sizeOfUserSuitHand = userSuitHand.getListOfCards().size();
int maximumValueInUserSuitHand = userSuitHand.getListOfCards().get(sizeOfUserSuitHand - 1).getFace();
if (userSuitHand.getListOfCards().size() == 0) { if (userSuitHand.getListOfCards().size() == 0) {
if (cardToBePlayed.getFace() == 7) { if (cardToBePlayed.getFace() == 7) {
playACard(userSuitHand, cardToBePlayed, tableHand, userSuitInTableHand, player); playACard(userSuitHand, cardToBePlayed, 0, tableHand, userSuitInTableHand, player);
} else { } else {
System.out.println("Card Played Was Not A Face of 7 in Empty Suit! Try again!"); System.out.println("Card Played Was Not A Face of 7 in Empty Suit! Try again!");
return; return;
} }
} else { } else {
if (cardToBePlayed.getFace() == (minimumValueInUserSuitHand - 1)) { int minimumValueInUserSuitHand = userSuitHand.getListOfCards().get(0).getFace();
int sizeOfUserSuitHand = userSuitHand.getListOfCards().size();
int maximumValueInUserSuitHand = userSuitHand.getListOfCards().get(sizeOfUserSuitHand - 1).getFace();
if (cardToBePlayed.getFace() == (minimumValueInUserSuitHand - 1)) {
playACard(userSuitHand, cardToBePlayed, 0, tableHand, userSuitInTableHand, player);
} else if (cardToBePlayed.getFace() == (maximumValueInUserSuitHand + 1)) {
playACard(userSuitHand, cardToBePlayed, sizeOfUserSuitHand, tableHand, userSuitInTableHand, player);
} }
} }
} }
public void playACard(Hand userSuitHand, Card playingCard, TableHand tableHand, Suits userSuitInTableHand, public void playACard(Hand userSuitHand, Card playingCard, int indexToInsertCard, TableHand tableHand,
Player player) { Suits userSuitInTableHand, Player player) {
userSuitHand.addCard(indexToInsertCard, playingCard);
userSuitHand.addCard(playingCard);
tableHand.getSevensTableHand().put(userSuitInTableHand, userSuitHand);
player.getHand().removeCard(playingCard); player.getHand().removeCard(playingCard);
} }
} }

Loading…
Cancel
Save