fix Blightwing Bandit (#11282)

This commit is contained in:
xenohedron 2023-10-08 17:53:49 -04:00 committed by GitHub
parent 1a6bbfa873
commit 25e559dd9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 16 deletions

View file

@ -1,9 +1,11 @@
package mage.abilities.common;
import mage.abilities.effects.Effect;
import mage.constants.SetTargetPointer;
import mage.filter.FilterSpell;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.SpellsCastWatcher;
/**
@ -15,10 +17,14 @@ public class FirstSpellOpponentsTurnTriggeredAbility extends SpellCastController
= new FilterSpell("your first spell during each opponent's turn");
public FirstSpellOpponentsTurnTriggeredAbility(Effect effect, boolean optional) {
super(effect, defaultFilter, optional);
this(effect, optional, SetTargetPointer.NONE);
}
private FirstSpellOpponentsTurnTriggeredAbility(final FirstSpellOpponentsTurnTriggeredAbility ability) {
public FirstSpellOpponentsTurnTriggeredAbility(Effect effect, boolean optional, SetTargetPointer setTargetPointer) {
super(effect, defaultFilter, optional, setTargetPointer);
}
protected FirstSpellOpponentsTurnTriggeredAbility(final FirstSpellOpponentsTurnTriggeredAbility ability) {
super(ability);
}
@ -30,11 +36,16 @@ public class FirstSpellOpponentsTurnTriggeredAbility extends SpellCastController
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.isActivePlayer(this.getControllerId()) // ignore controller turn
|| !super.checkTrigger(event, game)
|| !game.getOpponents(this.getControllerId()).contains(game.getActivePlayerId())) {
return false;
}
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
return watcher != null && watcher.getCount(event.getPlayerId()) == 1;
if (watcher != null && (watcher.getCount(event.getPlayerId()) == 1) && super.checkTrigger(event, game)) {
if (setTargetPointer == SetTargetPointer.PLAYER) { // not handled in super class
getAllEffects().setTargetPointer(new FixedTarget(game.getActivePlayerId()));
}
return true;
}
return false;
}
}

View file

@ -83,15 +83,16 @@ public class SpellCastControllerTriggeredAbility extends TriggeredAbilityImpl {
this.getEffects().setValue("spellCast", spell);
switch (setTargetPointer) {
case NONE:
case PLAYER: // for subclasses only, needs to be handled there
break;
case SPELL:
getEffects().setTargetPointer(new FixedTarget(spell.getId(), game));
getAllEffects().setTargetPointer(new FixedTarget(spell.getId(), game));
break;
case CARD:
getEffects().setTargetPointer(new FixedTarget(spell.getCard().getId()));
getAllEffects().setTargetPointer(new FixedTarget(spell.getCard().getId()));
break;
default:
throw new UnsupportedOperationException("Unexpected setTargetPointer " + setTargetPointer);
throw new UnsupportedOperationException("Unexpected setTargetPointer in SpellCastControllerTriggeredAbility: " + setTargetPointer);
}
return true;
}
@ -114,7 +115,6 @@ public class SpellCastControllerTriggeredAbility extends TriggeredAbilityImpl {
text += " from your " + fromZone.toString().toLowerCase();
break;
}
setTriggerPhrase(text + ", ");
}
}