need to discard black cards so reshuffling actually works

This commit is contained in:
Andy Janata 2012-11-10 20:00:52 -08:00
parent 482361fa46
commit 891d2a36a1
1 changed files with 18 additions and 14 deletions

View File

@ -602,22 +602,26 @@ public class Game {
playedCards.clear();
synchronized (blackCardLock) {
blackCard = getNextBlackCard();
BlackCard newBlackCard;
if (blackCard.getDraw() > 0) {
synchronized (players) {
for (final Player player : players) {
if (getJudge() == player) {
continue;
}
final List<WhiteCard> cards = new ArrayList<WhiteCard>(blackCard.getDraw());
for (int i = 0; i < blackCard.getDraw(); i++) {
cards.add(getNextWhiteCard());
}
player.getHand().addAll(cards);
sendCardsToPlayer(player, cards);
synchronized (blackCardLock) {
if (blackCard != null) {
blackDeck.discard(blackCard);
}
newBlackCard = blackCard = getNextBlackCard();
}
if (newBlackCard.getDraw() > 0) {
synchronized (players) {
for (final Player player : players) {
if (getJudge() == player) {
continue;
}
final List<WhiteCard> cards = new ArrayList<WhiteCard>(newBlackCard.getDraw());
for (int i = 0; i < newBlackCard.getDraw(); i++) {
cards.add(getNextWhiteCard());
}
player.getHand().addAll(cards);
sendCardsToPlayer(player, cards);
}
}
}