- Add Deck copy constructor

- Throw exception when deserialising non-existing PaperCard
This commit is contained in:
elcnesh
2015-04-02 08:43:58 +00:00
parent 6491ea51b9
commit c100b90c70
2 changed files with 16 additions and 0 deletions

View File

@@ -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";

View File

@@ -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();
}