diff --git a/src/magic/model/MagicCard.java b/src/magic/model/MagicCard.java index 81a6df554a..90719a4a1d 100644 --- a/src/magic/model/MagicCard.java +++ b/src/magic/model/MagicCard.java @@ -9,6 +9,7 @@ import java.util.Collections; public class MagicCard implements MagicSource,MagicTarget,Comparable { public static final int TOKEN_ID=-1; + public static final MagicCard NONE = new MagicCard(); private MagicCardDefinition cardDefinition; private MagicPlayer owner; @@ -46,17 +47,18 @@ public class MagicCard implements MagicSource,MagicTarget,Comparable final MagicPlayer mappedOwner=(MagicPlayer)owner.map(game); MagicCard card = mappedOwner.getHand().getCard(id); - if (card == null) { + if (card == MagicCard.NONE) { card = mappedOwner.getGraveyard().getCard(id); } - if (card == null) { + if (card == MagicCard.NONE) { card = mappedOwner.getExile().getCard(id); } - if (card == null) { + if (card == MagicCard.NONE) { card = mappedOwner.getLibrary().getCard(id); } - - assert card != null: "ERROR! Mapping card failed, card " + id + " not found"; + if (card == MagicCard.NONE) { + throw new RuntimeException("Mapping card failed, card " + getName() + " " + id + " not found"); + } return card; } diff --git a/src/magic/model/MagicCardList.java b/src/magic/model/MagicCardList.java index 1a5cad4aef..417caf57a1 100644 --- a/src/magic/model/MagicCardList.java +++ b/src/magic/model/MagicCardList.java @@ -73,14 +73,14 @@ public class MagicCardList extends ArrayList { } return index; } - + public MagicCard getCard(final long id) { for (final MagicCard card : this) { if (card.getId()==id) { return card; } } - return null; + return MagicCard.NONE; } public MagicCard getRandomCard() {