mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Add Deck copy constructor
- Throw exception when deserialising non-existing PaperCard
This commit is contained in:
@@ -62,6 +62,19 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
||||
getOrCreate(DeckSection.Main);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
*
|
||||
* @param other
|
||||
* the {@link Deck} to copy.
|
||||
*/
|
||||
public Deck(final Deck other) {
|
||||
super(other.getName());
|
||||
setComment(other.getComment());
|
||||
parts.putAll(other.parts);
|
||||
tags.addAll(other.getTags());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemType() {
|
||||
return "Deck";
|
||||
|
||||
@@ -211,6 +211,9 @@ public final class PaperCard implements Comparable<IPaperCard>, InventoryItemFro
|
||||
ois.defaultReadObject();
|
||||
|
||||
final IPaperCard pc = StaticData.instance().getCommonCards().getCard(name, edition, artIndex);
|
||||
if (pc == null) {
|
||||
throw new IOException(String.format("Card %s not found", name));
|
||||
}
|
||||
this.rules = pc.getRules();
|
||||
this.rarity = pc.getRarity();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user