Most obvious bugs ironed out. Ready for PR.

This commit is contained in:
Mark Langen 2016-08-31 23:37:31 -06:00
parent d5415d2d04
commit d33f8a636e
19 changed files with 415 additions and 101 deletions

View file

@ -38,6 +38,7 @@ import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.keyword.ChangelingAbility;
import mage.abilities.mana.ManaAbility;
import mage.constants.CardType;
import mage.game.Game;
import mage.util.CardUtil;
@ -176,7 +177,48 @@ public abstract class MageObjectImpl implements MageObject {
@Override
public ObjectColor getFrameColor(Game game) {
return frameColor;
// For lands, add any colors of mana the land can produce to
// its frame colors.
if (getCardType().contains(CardType.LAND)) {
ObjectColor cl = frameColor.copy();
for (Ability ab: getAbilities()) {
if (ab instanceof ManaAbility) {
ManaAbility mana = (ManaAbility)ab;
try {
List<Mana> manaAdded = mana.getNetMana(game);
for (Mana m: manaAdded) {
if (m.getAny() > 0) {
return new ObjectColor("WUBRG");
}
if (m.getWhite() > 0) {
cl.setWhite(true);
}
if (m.getBlue() > 0) {
cl.setBlue(true);
}
if (m.getBlack() > 0) {
cl.setBlack(true);
}
if (m.getRed() > 0) {
cl.setRed(true);
}
if (m.getGreen() > 0) {
cl.setGreen(true);
}
}
} catch (NullPointerException e) {
// Ability depends on game
// but no game passed
// All such abilities are 5-color ones
return new ObjectColor("WUBRG");
}
}
}
return cl;
} else {
// For everything else, just return the frame colors
return frameColor;
}
}
@Override

View file

@ -50,7 +50,7 @@ public class MockCard extends CardImpl {
if (this.cardType.contains(CardType.PLANESWALKER)) {
String startingLoyaltyString = card.getStartingLoyalty();
if (startingLoyaltyString.isEmpty()) {
Logger.getLogger(MockCard.class).warn("Planeswalker `" + this.name + "` has empty starting loyalty.");
//Logger.getLogger(MockCard.class).warn("Planeswalker `" + this.name + "` has empty starting loyalty.");
} else {
try {
this.startingLoyalty = Integer.parseInt(startingLoyaltyString);

View file

@ -42,7 +42,6 @@ import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
import mage.abilities.effects.PlaneswalkerRedirectionEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.mock.MockCard;
@ -190,7 +189,7 @@ public class CardInfo {
}
}
if (this.startingLoyalty == null) {
Logger.getLogger(CardInfo.class).warn("Planeswalker `" + card.getName() + "` missing starting loyalty");
//Logger.getLogger(CardInfo.class).warn("Planeswalker `" + card.getName() + "` missing starting loyalty");
this.startingLoyalty = "";
}
} else {

View file

@ -61,9 +61,9 @@ public enum CardRepository {
private static final String JDBC_URL = "jdbc:h2:file:./db/cards.h2;AUTO_SERVER=TRUE";
private static final String VERSION_ENTITY_NAME = "card";
// raise this if db structure was changed
private static final long CARD_DB_VERSION = 44;
private static final long CARD_DB_VERSION = 46;
// raise this if new cards were added to the server
private static final long CARD_CONTENT_VERSION = 55;
private static final long CARD_CONTENT_VERSION = 57;
private final Random random = new Random();
private Dao<CardInfo, Object> cardDao;

View file

@ -118,6 +118,7 @@ public class PermanentCard extends PermanentImpl {
this.cardType.clear();
this.cardType.addAll(card.getCardType());
this.color = card.getColor(null).copy();
this.frameColor = card.getFrameColor(null).copy();
this.manaCost = card.getManaCost().copy();
if (card instanceof PermanentCard) {
this.maxLevelCounters = ((PermanentCard) card).maxLevelCounters;

View file

@ -82,6 +82,7 @@ public class PermanentToken extends PermanentImpl {
}
this.cardType = token.getCardType();
this.color = token.getColor(game).copy();
this.frameColor = token.getFrameColor(game);
this.power.modifyBaseValue(token.getPower().getBaseValueModified());
this.toughness.modifyBaseValue(token.getToughness().getBaseValueModified());
this.supertype = token.getSupertype();