1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-02 11:25:59 -09:00

* Fixed a bug were abilities could trigger when a permanent was moved to graveyard but the triggering ability from the moved permanent were removed at that time.

This commit is contained in:
LevelX2 2016-01-30 01:15:34 +01:00
parent bb9dd1600e
commit ee6aa7a1e2
2 changed files with 26 additions and 29 deletions

View file

@ -637,10 +637,8 @@ public abstract class AbilityImpl implements Ability {
public void setSourceId(UUID sourceId) { public void setSourceId(UUID sourceId) {
if (this.sourceId == null) { if (this.sourceId == null) {
this.sourceId = sourceId; this.sourceId = sourceId;
} else { } else if (!(this instanceof MageSingleton)) {
if (!(this instanceof MageSingleton)) { this.sourceId = sourceId;
this.sourceId = sourceId;
}
} }
if (subAbilities != null) { if (subAbilities != null) {
for (Ability subAbility : subAbilities) { for (Ability subAbility : subAbilities) {
@ -970,10 +968,13 @@ public abstract class AbilityImpl implements Ability {
object = game.getObject(getSourceId()); object = game.getObject(getSourceId());
} }
} }
if (object != null && !object.getAbilities().contains(this)) { if (object != null) {
if (object instanceof Permanent) { if (object instanceof Permanent) {
return false; if (!((Permanent) object).getAbilities(game).contains(this)) {
} else { return false;
}
return ((Permanent) object).isPhasedIn();
} else if (!object.getAbilities().contains(this)) {
// check if it's an ability that is temporary gained to a card // check if it's an ability that is temporary gained to a card
Abilities<Ability> otherAbilities = game.getState().getAllOtherAbilities(this.getSourceId()); Abilities<Ability> otherAbilities = game.getState().getAllOtherAbilities(this.getSourceId());
if (otherAbilities == null || !otherAbilities.contains(this)) { if (otherAbilities == null || !otherAbilities.contains(this)) {
@ -981,9 +982,6 @@ public abstract class AbilityImpl implements Ability {
} }
} }
} }
if (object instanceof Permanent) {
return ((Permanent) object).isPhasedIn();
}
return true; return true;
} }
@ -1060,18 +1058,16 @@ public abstract class AbilityImpl implements Ability {
} else { } else {
sb.append(GameLog.getColoredObjectIdName(object)); sb.append(GameLog.getColoredObjectIdName(object));
} }
} else { } else if (object instanceof Spell) {
if (object instanceof Spell) { Spell spell = (Spell) object;
Spell spell = (Spell) object; String castText = spell.getSpellCastText(game);
String castText = spell.getSpellCastText(game); sb.append((castText.startsWith("Cast ") ? castText.substring(5) : castText));
sb.append((castText.startsWith("Cast ") ? castText.substring(5) : castText)); if (spell.getFromZone() == Zone.GRAVEYARD) {
if (spell.getFromZone() == Zone.GRAVEYARD) { sb.append(" from graveyard");
sb.append(" from graveyard");
}
sb.append(getOptionalTextSuffix(game, spell));
} else {
sb.append(GameLog.getColoredObjectIdName(object));
} }
sb.append(getOptionalTextSuffix(game, spell));
} else {
sb.append(GameLog.getColoredObjectIdName(object));
} }
} else { } else {
sb.append("unknown"); sb.append("unknown");

View file

@ -19,6 +19,7 @@ public class PutIntoGraveFromBattlefieldSourceTriggeredAbility extends Triggered
public PutIntoGraveFromBattlefieldSourceTriggeredAbility(Effect effect, boolean optional) { public PutIntoGraveFromBattlefieldSourceTriggeredAbility(Effect effect, boolean optional) {
super(Zone.ALL, effect, optional); super(Zone.ALL, effect, optional);
setLeavesTheBattlefieldTrigger(true);
} }
PutIntoGraveFromBattlefieldSourceTriggeredAbility(PutIntoGraveFromBattlefieldSourceTriggeredAbility ability) { PutIntoGraveFromBattlefieldSourceTriggeredAbility(PutIntoGraveFromBattlefieldSourceTriggeredAbility ability) {
@ -37,14 +38,14 @@ public class PutIntoGraveFromBattlefieldSourceTriggeredAbility extends Triggered
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event; if (event.getTargetId().equals(getSourceId())) {
Permanent permanent = zEvent.getTarget(); ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Permanent permanent = zEvent.getTarget();
if (permanent != null && if (permanent != null
zEvent.getToZone() == Zone.GRAVEYARD && && zEvent.getToZone() == Zone.GRAVEYARD
zEvent.getFromZone() == Zone.BATTLEFIELD && && zEvent.getFromZone() == Zone.BATTLEFIELD) {
permanent.getId().equals(this.getSourceId())) { return true;
return true; }
} }
return false; return false;
} }