* improved message for missing cards on the server.

This commit is contained in:
LevelX2 2014-12-14 22:55:16 +01:00
parent 424448b38f
commit 9ba6f74bf6

View file

@ -58,7 +58,7 @@ public class Deck implements Serializable {
if (card != null) { if (card != null) {
deck.cards.add(card); deck.cards.add(card);
} else if (!ignoreErrors) { } else if (!ignoreErrors) {
throw new GameException("Error loading card - " + deckCardInfo.getCardName() + " for deck - " + deck.getName()); throw createCardNotFoundGameException(deckCardInfo, deckCardLists.getName());
} }
} }
for (DeckCardInfo deckCardInfo: deckCardLists.getSideboard()) { for (DeckCardInfo deckCardInfo: deckCardLists.getSideboard()) {
@ -66,13 +66,19 @@ public class Deck implements Serializable {
if (card != null) { if (card != null) {
deck.sideboard.add(card); deck.sideboard.add(card);
} else if (!ignoreErrors) { } else if (!ignoreErrors) {
throw new GameException("Error loading card - " + deckCardInfo.getCardName() + " for deck - " + deck.getName()); throw createCardNotFoundGameException(deckCardInfo, deckCardLists.getName());
} }
} }
return deck; return deck;
} }
private static GameException createCardNotFoundGameException(DeckCardInfo deckCardInfo, String deckName) {
return new GameException("Card not found - " + deckCardInfo.getCardName() + " - " + deckCardInfo.getSetCode() + " for deck - " + deckName + "\n" +
"Possible reason is, that you use cards in your deck, that are only supported in newer versions of the server.\n" +
"So it can help to use the same card from another set, that's already supported from this server." );
}
private static Card createCard(DeckCardInfo deckCardInfo, boolean mockCards) { private static Card createCard(DeckCardInfo deckCardInfo, boolean mockCards) {
CardInfo cardInfo = CardRepository.instance.findCard(deckCardInfo.getSetCode(), deckCardInfo.getCardNum()); CardInfo cardInfo = CardRepository.instance.findCard(deckCardInfo.getSetCode(), deckCardInfo.getCardNum());
if (cardInfo == null) { if (cardInfo == null) {