mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
refactor: use same code style in library's methods
This commit is contained in:
parent
c5deb3d3ba
commit
e3229d7eab
1 changed files with 3 additions and 7 deletions
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue