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

@ -5,7 +5,7 @@ import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.constants.SubType;
import mage.constants.*;
import mage.game.Game;
import mage.players.ManaPoolItem;
import mage.players.Player;
@ -23,11 +23,6 @@ import mage.abilities.keyword.DeathtouchAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.ManaType;
import mage.constants.Outcome;
/**
*
@ -50,7 +45,7 @@ public final class BlightwingBandit extends CardImpl {
this.addAbility(DeathtouchAbility.getInstance());
// Whenever you cast your first spell during each opponent's turn, look at the top card of that player's library, then exile it face down. You may play that card for as long as it remains exiled, and mana of any type can be spent to cast it.
this.addAbility(new FirstSpellOpponentsTurnTriggeredAbility(new BlightwingBanditEffect(), false));
this.addAbility(new FirstSpellOpponentsTurnTriggeredAbility(new BlightwingBanditEffect(), false, SetTargetPointer.PLAYER));
}
private BlightwingBandit(final BlightwingBandit card) {
@ -221,4 +216,4 @@ class BlightwingBanditSpendAnyManaEffect extends AsThoughEffectImpl implements A
public ManaType getAsThoughManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) {
return mana.getFirstAvailable();
}
}
}

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 + ", ");
}
}