* Morph - Fixed that static effects (eg. all your creatures gain vigilance) did not work for morphed creatures. Some more minor fixes to morph ability.

This commit is contained in:
LevelX2 2014-09-14 23:57:02 +02:00
parent 77fdd7711f
commit a407ec6fd9
3 changed files with 23 additions and 6 deletions

View file

@ -142,6 +142,7 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
super(ability); super(ability);
this.alternateCosts.addAll(ability.alternateCosts); this.alternateCosts.addAll(ability.alternateCosts);
this.zoneChangeCounter = ability.zoneChangeCounter; this.zoneChangeCounter = ability.zoneChangeCounter;
this.ruleText = ability.ruleText;
} }
private static Costs createCosts(Cost cost) { private static Costs createCosts(Cost cost) {
@ -224,6 +225,11 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
} }
} }
@Override
public String getRule(boolean all) {
return getRule();
}
@Override @Override
public String getRule() { public String getRule() {
return ruleText; return ruleText;
@ -292,8 +298,13 @@ class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implements Sour
permanent.getColor().setColor(new ObjectColor()); permanent.getColor().setColor(new ObjectColor());
break; break;
case AbilityAddingRemovingEffects_6: case AbilityAddingRemovingEffects_6:
Card card = game.getCard(permanent.getId()); //
List<Ability> abilities = new ArrayList<>(); List<Ability> abilities = new ArrayList<>();
for (Ability ability : permanent.getAbilities()) { for (Ability ability : permanent.getAbilities()) {
if (card != null && !card.getAbilities().contains(ability)) {
// gained abilities from other sources won't be removed
continue;
}
// TODO: Add flag "works also face down" to ability and use it to control ability removement instead of instanceof check // TODO: Add flag "works also face down" to ability and use it to control ability removement instead of instanceof check
if (ability.getWorksFaceDown()) { if (ability.getWorksFaceDown()) {
ability.setRuleVisible(false); ability.setRuleVisible(false);

View file

@ -213,7 +213,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
@Override @Override
public List<String> getRules() { public List<String> getRules() {
try { try {
List<String> rules = abilities.getRules(this.name); List<String> rules = abilities.getRules(this.getLogName());
if (info != null) { if (info != null) {
for (String data : info.values()) { for (String data : info.values()) {
rules.add(data); rules.add(data);

View file

@ -51,6 +51,7 @@ import mage.abilities.keyword.LifelinkAbility;
import mage.abilities.keyword.ProtectionAbility; import mage.abilities.keyword.ProtectionAbility;
import mage.abilities.keyword.ShroudAbility; import mage.abilities.keyword.ShroudAbility;
import mage.abilities.keyword.WitherAbility; import mage.abilities.keyword.WitherAbility;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.AsThoughEffectType; import mage.constants.AsThoughEffectType;
import mage.constants.CardType; import mage.constants.CardType;
@ -798,18 +799,23 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
@Override @Override
public boolean destroy(UUID sourceId, Game game, boolean noRegen) { public boolean destroy(UUID sourceId, Game game, boolean noRegen) {
//20091005 - 701.6 //20091005 - 701.6
//TODO: handle noRegen
if(abilities.containsKey(IndestructibleAbility.getInstance().getId())) { if(abilities.containsKey(IndestructibleAbility.getInstance().getId())) {
return false; return false;
} }
if (!game.replaceEvent(GameEvent.getEvent(EventType.DESTROY_PERMANENT, objectId, sourceId, controllerId, noRegen ? 1 : 0))) { if (!game.replaceEvent(GameEvent.getEvent(EventType.DESTROY_PERMANENT, objectId, sourceId, controllerId, noRegen ? 1 : 0))) {
if (moveToZone(Zone.GRAVEYARD, sourceId, game, false)) { if (moveToZone(Zone.GRAVEYARD, sourceId, game, false)) {
if (this.getCardType().contains(CardType.CREATURE)) { String logName;
game.informPlayers(new StringBuilder(this.getLogName()).append(" died").toString()); Card card = game.getCard(this.getId());
if (card != null) {
logName = card.getLogName();
} else { } else {
game.informPlayers(new StringBuilder(this.getLogName()).append(" was destroyed").toString()); logName = this.getLogName();
}
if (this.getCardType().contains(CardType.CREATURE)) {
game.informPlayers(logName +" died");
} else {
game.informPlayers(logName + " was destroyed");
} }
game.fireEvent(GameEvent.getEvent(EventType.DESTROYED_PERMANENT, objectId, sourceId, controllerId)); game.fireEvent(GameEvent.getEvent(EventType.DESTROYED_PERMANENT, objectId, sourceId, controllerId));
return true; return true;