mirror of
https://github.com/correl/mage.git
synced 2024-11-16 03:00:12 +00: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:
parent
bb9dd1600e
commit
ee6aa7a1e2
2 changed files with 26 additions and 29 deletions
|
@ -637,11 +637,9 @@ public abstract class AbilityImpl implements Ability {
|
|||
public void setSourceId(UUID sourceId) {
|
||||
if (this.sourceId == null) {
|
||||
this.sourceId = sourceId;
|
||||
} else {
|
||||
if (!(this instanceof MageSingleton)) {
|
||||
} else if (!(this instanceof MageSingleton)) {
|
||||
this.sourceId = sourceId;
|
||||
}
|
||||
}
|
||||
if (subAbilities != null) {
|
||||
for (Ability subAbility : subAbilities) {
|
||||
subAbility.setSourceId(sourceId);
|
||||
|
@ -970,10 +968,13 @@ public abstract class AbilityImpl implements Ability {
|
|||
object = game.getObject(getSourceId());
|
||||
}
|
||||
}
|
||||
if (object != null && !object.getAbilities().contains(this)) {
|
||||
if (object != null) {
|
||||
if (object instanceof Permanent) {
|
||||
if (!((Permanent) object).getAbilities(game).contains(this)) {
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
return ((Permanent) object).isPhasedIn();
|
||||
} else if (!object.getAbilities().contains(this)) {
|
||||
// check if it's an ability that is temporary gained to a card
|
||||
Abilities<Ability> otherAbilities = game.getState().getAllOtherAbilities(this.getSourceId());
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1060,8 +1058,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
} else {
|
||||
sb.append(GameLog.getColoredObjectIdName(object));
|
||||
}
|
||||
} else {
|
||||
if (object instanceof Spell) {
|
||||
} else if (object instanceof Spell) {
|
||||
Spell spell = (Spell) object;
|
||||
String castText = spell.getSpellCastText(game);
|
||||
sb.append((castText.startsWith("Cast ") ? castText.substring(5) : castText));
|
||||
|
@ -1072,7 +1069,6 @@ public abstract class AbilityImpl implements Ability {
|
|||
} else {
|
||||
sb.append(GameLog.getColoredObjectIdName(object));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sb.append("unknown");
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ public class PutIntoGraveFromBattlefieldSourceTriggeredAbility extends Triggered
|
|||
|
||||
public PutIntoGraveFromBattlefieldSourceTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.ALL, effect, optional);
|
||||
setLeavesTheBattlefieldTrigger(true);
|
||||
}
|
||||
|
||||
PutIntoGraveFromBattlefieldSourceTriggeredAbility(PutIntoGraveFromBattlefieldSourceTriggeredAbility ability) {
|
||||
|
@ -37,15 +38,15 @@ public class PutIntoGraveFromBattlefieldSourceTriggeredAbility extends Triggered
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getTargetId().equals(getSourceId())) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
Permanent permanent = zEvent.getTarget();
|
||||
|
||||
if (permanent != null &&
|
||||
zEvent.getToZone() == Zone.GRAVEYARD &&
|
||||
zEvent.getFromZone() == Zone.BATTLEFIELD &&
|
||||
permanent.getId().equals(this.getSourceId())) {
|
||||
if (permanent != null
|
||||
&& zEvent.getToZone() == Zone.GRAVEYARD
|
||||
&& zEvent.getFromZone() == Zone.BATTLEFIELD) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue