mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
In Breath of Fury, remember the creature enchanted by Breath of Fury when its ability triggers.
This commit is contained in:
parent
aa8554e82b
commit
ec917c7a50
1 changed files with 10 additions and 3 deletions
|
@ -38,6 +38,7 @@ import mage.constants.Outcome;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -103,9 +104,15 @@ class BreathOfFuryAbility extends TriggeredAbilityImpl {
|
||||||
if (damageEvent.isCombatDamage() &&
|
if (damageEvent.isCombatDamage() &&
|
||||||
enchantment != null &&
|
enchantment != null &&
|
||||||
enchantment.getAttachedTo().equals(event.getSourceId())) {
|
enchantment.getAttachedTo().equals(event.getSourceId())) {
|
||||||
|
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||||
|
if (creature != null) {
|
||||||
|
for (Effect effect : getEffects()) {
|
||||||
|
effect.setValue("TriggeringCreatureId", creature.getId());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +144,7 @@ class BreathOfFuryEffect extends OneShotEffect {
|
||||||
if (enchantment == null) {
|
if (enchantment == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Permanent enchantedCreature = game.getPermanent(enchantment.getAttachedTo());
|
Permanent enchantedCreature = game.getPermanent((UUID) getValue("TriggeringCreatureId"));
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature you control that could be enchanted by " + enchantment.getName());
|
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature you control that could be enchanted by " + enchantment.getName());
|
||||||
filter.add(new CanBeEnchantedByPredicate(enchantment));
|
filter.add(new CanBeEnchantedByPredicate(enchantment));
|
||||||
|
@ -147,7 +154,7 @@ class BreathOfFuryEffect extends OneShotEffect {
|
||||||
// Commanders going to the command zone and Rest in Peace style replacement effects don't make Permanent.sacrifice return false.
|
// Commanders going to the command zone and Rest in Peace style replacement effects don't make Permanent.sacrifice return false.
|
||||||
if (enchantedCreature != null && controller != null
|
if (enchantedCreature != null && controller != null
|
||||||
&& enchantedCreature.sacrifice(source.getSourceId(), game)
|
&& enchantedCreature.sacrifice(source.getSourceId(), game)
|
||||||
&& target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
|
&& target.canChoose(source.getSourceId(), controller.getId(), game)) {
|
||||||
controller.choose(outcome, target, source.getSourceId(), game);
|
controller.choose(outcome, target, source.getSourceId(), game);
|
||||||
Permanent newCreature = game.getPermanent(target.getFirstTarget());
|
Permanent newCreature = game.getPermanent(target.getFirstTarget());
|
||||||
if (newCreature != null &&
|
if (newCreature != null &&
|
||||||
|
|
Loading…
Reference in a new issue