* Fixed some card movement (fixes #4910).

This commit is contained in:
LevelX2 2018-05-08 18:01:15 +02:00
parent 7b4ca412b8
commit df987049c0
43 changed files with 481 additions and 548 deletions

View file

@ -136,24 +136,26 @@ public class Library implements Serializable {
}
public void putCardThirdFromTheTop(Card card, Game game) {
if (card != null && card.getOwnerId().equals(playerId)) {
Card cardTop = null;
Card cardSecond = null;
if (hasCards()) {
cardTop = removeFromTop(game);
if (card != null) {
if (card.getOwnerId().equals(playerId)) {
Card cardTop = null;
Card cardSecond = null;
if (hasCards()) {
cardTop = removeFromTop(game);
}
if (hasCards()) {
cardSecond = removeFromTop(game);
}
putOnTop(card, game);
if (cardSecond != null) {
putOnTop(cardSecond, game);
}
if (cardTop != null) {
putOnTop(cardTop, game);
}
} else {
game.getPlayer(card.getOwnerId()).getLibrary().putCardThirdFromTheTop(card, game);
}
if (hasCards()) {
cardSecond = removeFromTop(game);
}
putOnTop(card, game);
if (cardSecond != null) {
putOnTop(cardSecond, game);
}
if (cardTop != null) {
putOnTop(cardTop, game);
}
} else {
game.getPlayer(card.getOwnerId()).getLibrary().putCardThirdFromTheTop(card, game);
}
}
@ -190,6 +192,12 @@ public class Library implements Serializable {
return new ArrayList<>(library);
}
/**
* Returns the cards of the library in a list ordered from top to buttom
*
* @param game
* @return
*/
public List<Card> getCards(Game game) {
return library.stream().map(game::getCard).collect(Collectors.toList());
}