mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
* Workaround test for cards db bug.
This commit is contained in:
parent
a47480a1ce
commit
2c7d6e788d
4 changed files with 32 additions and 15 deletions
|
|
@ -38,6 +38,7 @@ import mage.cards.repository.CardInfo;
|
|||
import mage.cards.repository.CardRepository;
|
||||
import mage.game.GameException;
|
||||
import mage.util.DeckUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class Deck implements Serializable {
|
||||
|
||||
|
|
@ -89,9 +90,19 @@ public class Deck implements Serializable {
|
|||
}
|
||||
|
||||
private static GameException createCardNotFoundGameException(DeckCardInfo deckCardInfo, String deckName) {
|
||||
// Try WORKAROUND for Card DB error: Try to read a card that does exist
|
||||
CardInfo cardInfo = CardRepository.instance.findCard("Silvercoat Lion");
|
||||
if (cardInfo == null) {
|
||||
// DB seems to have a problem - try to restart the DB
|
||||
CardRepository.instance.closeDB();
|
||||
CardRepository.instance.openDB();
|
||||
cardInfo = CardRepository.instance.findCard("Silvercoat Lion");
|
||||
Logger.getLogger(Deck.class).error("Tried to restart the DB: " + (cardInfo == null ? "not successful" : "successful"));
|
||||
}
|
||||
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) {
|
||||
|
|
@ -164,7 +175,7 @@ public class Deck implements Serializable {
|
|||
public void setDeckHashCode(long deckHashCode) {
|
||||
this.deckHashCode = deckHashCode;
|
||||
}
|
||||
|
||||
|
||||
public void clearLayouts() {
|
||||
this.cardsLayout = null;
|
||||
this.sideboardLayout = null;
|
||||
|
|
|
|||
|
|
@ -75,11 +75,11 @@ public class DckDeckImporter extends DeckImporter {
|
|||
String cardName = m.group(5);
|
||||
if (cardName != null && cardName.length() > 0) {
|
||||
cardInfo = CardRepository.instance.findPreferedCoreExpansionCard(cardName, false);
|
||||
sbMessage.append("Could not find card '" + cardName + "' in set " + setCode + " of number " + cardNum + ".\n");
|
||||
sbMessage.append("Could not find card '").append(cardName).append("' in set ").append(setCode).append(" of number ").append(cardNum).append(".\n");
|
||||
if (cardInfo != null) {
|
||||
sbMessage.append("Made substitution of " + cardInfo.getCardNumber() + ", " + cardInfo.getCard().getExpansionSetCode() + " instead.\n");
|
||||
sbMessage.append("Made substitution of ").append(cardInfo.getCardNumber()).append(", ").append(cardInfo.getCard().getExpansionSetCode()).append(" instead.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cardInfo != null) {
|
||||
deckCardInfo = new DeckCardInfo(cardInfo.getName(), cardInfo.getCardNumber(), cardInfo.getSetCode());
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ public enum CardRepository {
|
|||
classNames.add(card.getClassName());
|
||||
}
|
||||
}
|
||||
return classNames.contains(className);
|
||||
return classNames.contains(className.getName());
|
||||
} catch (SQLException ex) {
|
||||
}
|
||||
return false;
|
||||
|
|
@ -464,4 +464,13 @@ public enum CardRepository {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
public void openDB() {
|
||||
try {
|
||||
ConnectionSource connectionSource = new JdbcConnectionSource(JDBC_URL);
|
||||
cardDao = DaoManager.createDao(connectionSource, CardInfo.class);
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(CardRepository.class).error("Error opening card repository - ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue