EffectEffect: now does treat emblems different than Effects, also does try to guess the ImageKey from Name for Emblems

shows the PlaneswalkerType for the Emblem but thats only cosmetic.
This commit is contained in:
Hanmac
2016-07-01 17:41:19 +00:00
parent a2facc6e39
commit 5dcee79d54
4 changed files with 26 additions and 6 deletions

View File

@@ -81,7 +81,7 @@ public class AbilityUtils {
c = sa.getRootAbility().getOriginalHost(); c = sa.getRootAbility().getOriginalHost();
} }
else if (defined.equals("EffectSource")) { else if (defined.equals("EffectSource")) {
if (hostCard.getType().hasSubtype("Effect")) { if (hostCard.isEmblem() || hostCard.getType().hasSubtype("Effect")) {
c = AbilityUtils.findEffectRoot(hostCard); c = AbilityUtils.findEffectRoot(hostCard);
} }
} }
@@ -296,7 +296,7 @@ public class AbilityUtils {
private static Card findEffectRoot(Card startCard) { private static Card findEffectRoot(Card startCard) {
Card cc = startCard.getEffectSource(); Card cc = startCard.getEffectSource();
if (cc != null) { if (cc != null) {
if (cc.getType().hasSubtype("Effect")) { if (cc.isEmblem() || cc.getType().hasSubtype("Effect")) {
return findEffectRoot(cc); return findEffectRoot(cc);
} }
return cc; return cc;

View File

@@ -2,6 +2,7 @@ package forge.game.ability.effects;
import forge.GameCommand; import forge.GameCommand;
import forge.ImageKeys; import forge.ImageKeys;
import forge.card.CardType;
import forge.game.Game; import forge.game.Game;
import forge.game.ability.AbilityFactory; import forge.game.ability.AbilityFactory;
import forge.game.ability.AbilityUtils; import forge.game.ability.AbilityUtils;
@@ -109,10 +110,29 @@ public class EffectEffect extends SpellAbilityEffect {
final Player controller = sa.hasParam("EffectOwner") ? ownerEff : sa.getActivatingPlayer(); final Player controller = sa.hasParam("EffectOwner") ? ownerEff : sa.getActivatingPlayer();
final Card eff = new Card(game.nextCardId(), game); final Card eff = new Card(game.nextCardId(), game);
eff.setName(name); eff.setName(name);
eff.addType("Effect"); // Or Emblem // if name includes emplem then it should be one
eff.addType(name.endsWith("emblem") ? "Emblem" : "Effect");
// add Planeswalker types into Emblem for fun
if (name.endsWith("emblem") && hostCard.isPlaneswalker()) {
for (final String type : hostCard.getType().getSubtypes()) {
if (CardType.isAPlaneswalkerType(type)) {
eff.addType(type);
}
}
}
eff.setToken(true); // Set token to true, so when leaving play it gets nuked eff.setToken(true); // Set token to true, so when leaving play it gets nuked
eff.setOwner(controller); eff.setOwner(controller);
eff.setImageKey(sa.hasParam("Image") ? ImageKeys.getTokenKey(sa.getParam("Image")) : hostCard.getImageKey());
String image;
if (sa.hasParam("Image")) {
image = ImageKeys.getTokenKey(sa.getParam("Image"));
} else if (name.endsWith("emblem")) { // try to get the image from name
image = ImageKeys.getTokenKey(name.replace(",", "").replace(" ", "_").toLowerCase());
} else { // use host image
image = hostCard.getImageKey();
}
eff.setImageKey(image);
eff.setColor(hostCard.determineColor().getColor()); eff.setColor(hostCard.determineColor().getColor());
eff.setImmutable(true); eff.setImmutable(true);
eff.setEffectSource(hostCard); eff.setEffectSource(hostCard);

View File

@@ -253,7 +253,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
final CardStateView state = getCard().getCurrentState(); final CardStateView state = getCard().getCurrentState();
final CardEdition ed = FModel.getMagicDb().getEditions().get(state.getSetCode()); final CardEdition ed = FModel.getMagicDb().getEditions().get(state.getSetCode());
boolean colorIsSet = false; boolean colorIsSet = false;
if (state.getType().hasStringType("Effect")) { if (state.getType().isEmblem() || state.getType().hasStringType("Effect")) {
// Effects are drawn with orange border // Effects are drawn with orange border
g2d.setColor(Color.ORANGE); g2d.setColor(Color.ORANGE);
colorIsSet = true; colorIsSet = true;

View File

@@ -205,7 +205,7 @@ public class CardDetailUtil {
String curColors = ""; String curColors = "";
// do not show current colors for temp effect cards, emblems and the like // do not show current colors for temp effect cards, emblems and the like
if (state.getType().hasSubtype("Effect")) { if (state.getType().isEmblem() || state.getType().hasSubtype("Effect")) {
return ""; return "";
} }