refactor: use same code style in library's methods

This commit is contained in:
Oleg Agafonov 2023-08-31 19:38:37 +04:00
parent c5deb3d3ba
commit e3229d7eab

View file

@ -103,6 +103,7 @@ public class Library implements Serializable {
public void putOnTop(Card card, Game game) {
if (card.isOwnedBy(playerId)) {
card.setZone(Zone.LIBRARY, game);
library.remove(card.getId());
library.addFirst(card.getId());
} else {
game.getPlayer(card.getOwnerId()).getLibrary().putOnTop(card, game);
@ -146,13 +147,6 @@ public class Library implements Serializable {
return library.size();
}
public void set(Library newLibrary) {
library.clear();
for (UUID card : newLibrary.getCardList()) {
library.add(card);
}
}
public List<UUID> getCardList() {
return new ArrayList<>(library);
}
@ -202,8 +196,10 @@ public class Library implements Serializable {
}
public void addAll(Set<Card> cards, Game game) {
// put on bottom
for (Card card : cards) {
card.setZone(Zone.LIBRARY, game);
library.remove(card.getId());
library.add(card.getId());
}
}