mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 22:42:03 -08:00
Fix effects where the source's controller sacrifices it (#12583)
* Fix effects where the source's controller sacrifices it. Added test. Fixes #12582 * Update Evoke rules text
This commit is contained in:
parent
3eb7ffa4cd
commit
96b08ee6bf
4 changed files with 49 additions and 8 deletions
|
|
@ -8,7 +8,6 @@ import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
|||
import mage.abilities.effects.common.SacrificeSourceEffect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
|
|
@ -18,7 +17,7 @@ import mage.game.stack.Spell;
|
|||
public class SacrificeIfCastAtInstantTimeTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public SacrificeIfCastAtInstantTimeTriggeredAbility() {
|
||||
super(Zone.STACK, new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextCleanupDelayedTriggeredAbility(new SacrificeSourceEffect())));
|
||||
super(Zone.STACK, new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextCleanupDelayedTriggeredAbility(new SacrificeSourceEffect(true))));
|
||||
}
|
||||
|
||||
protected SacrificeIfCastAtInstantTimeTriggeredAbility(final SacrificeIfCastAtInstantTimeTriggeredAbility ability) {
|
||||
|
|
|
|||
|
|
@ -13,13 +13,21 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class SacrificeSourceEffect extends OneShotEffect {
|
||||
|
||||
private final boolean controllerSacrifices;
|
||||
|
||||
public SacrificeSourceEffect() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
public SacrificeSourceEffect(boolean controllerSacrifices) {
|
||||
super(Outcome.Sacrifice);
|
||||
staticText = "sacrifice {this}";
|
||||
this.controllerSacrifices = controllerSacrifices;
|
||||
staticText = (controllerSacrifices ? "{this}'s controller sacrifices it" : "sacrifice {this}");
|
||||
}
|
||||
|
||||
protected SacrificeSourceEffect(final SacrificeSourceEffect effect) {
|
||||
super(effect);
|
||||
controllerSacrifices = effect.controllerSacrifices;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -40,7 +48,7 @@ public class SacrificeSourceEffect extends OneShotEffect {
|
|||
if (sourceObject instanceof Permanent) {
|
||||
Permanent permanent = (Permanent) sourceObject;
|
||||
// you can only sacrifice a permanent you control
|
||||
if (source.isControlledBy(permanent.getControllerId())) {
|
||||
if (controllerSacrifices || source.isControlledBy(permanent.getControllerId())) {
|
||||
return permanent.sacrifice(source, game);
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ public class EvokeAbility extends AlternativeSourceCostsImpl {
|
|||
public EvokeAbility(Cost cost) {
|
||||
super(EVOKE_KEYWORD, REMINDER_TEXT, cost);
|
||||
Ability ability = new ConditionalInterveningIfTriggeredAbility(
|
||||
new EntersBattlefieldTriggeredAbility(new SacrificeSourceEffect()),
|
||||
EvokedCondition.instance, "Sacrifice {this} when it enters the battlefield and was evoked.");
|
||||
new EntersBattlefieldTriggeredAbility(new SacrificeSourceEffect(true)),
|
||||
EvokedCondition.instance, "When this permanent enters the battlefield, if its evoke cost was paid, its controller sacrifices it.");
|
||||
ability.setRuleVisible(false);
|
||||
addSubAbility(ability);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue