mirror of
https://github.com/correl/mage.git
synced 2025-01-12 03:00:13 +00: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
|
@ -25,13 +25,10 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -41,6 +38,7 @@ import mage.cards.CardsImpl;
|
|||
import mage.cards.repository.CardRepository;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
|
@ -48,16 +46,14 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Loki
|
||||
*/
|
||||
public class Mindblaze extends CardImpl {
|
||||
|
||||
public Mindblaze (UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{5}{R}");
|
||||
|
||||
public Mindblaze(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{5}{R}");
|
||||
|
||||
// Name a nonland card and choose a number greater than 0. Target player reveals his or her library.
|
||||
// If that library contains exactly the chosen number of the named card,
|
||||
|
@ -67,7 +63,7 @@ public class Mindblaze extends CardImpl {
|
|||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
}
|
||||
|
||||
public Mindblaze (final Mindblaze card) {
|
||||
public Mindblaze(final Mindblaze card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
|
@ -79,6 +75,7 @@ public class Mindblaze extends CardImpl {
|
|||
}
|
||||
|
||||
class MindblazeEffect extends OneShotEffect {
|
||||
|
||||
MindblazeEffect() {
|
||||
super(Outcome.Damage);
|
||||
staticText = "Name a nonland card and choose a number greater than 0. Target player reveals his or her library. If that library contains exactly the chosen number of the named card, {this} deals 8 damage to that player. Then that player shuffles his or her library";
|
||||
|
@ -98,7 +95,7 @@ class MindblazeEffect extends OneShotEffect {
|
|||
cardChoice.clearChoice();
|
||||
Choice numberChoice = new ChoiceImpl();
|
||||
numberChoice.setMessage("Choose a number greater than 0");
|
||||
HashSet<String> numbers = new HashSet<String>();
|
||||
HashSet<String> numbers = new HashSet<>();
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
numbers.add(Integer.toString(i));
|
||||
}
|
||||
|
@ -138,4 +135,4 @@ class MindblazeEffect extends OneShotEffect {
|
|||
return new MindblazeEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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…
Reference in a new issue