Added Storm of Saruman card (#10433)

* Added Storm of Saruman card

Some classes have been added/adjusted for code reusability:
- CastSecondSpellTriggeredAbility has been modified to set a target pointer to either the caster or the spell (used here to set a target pointer to the spell for the copy effect)
- CopyTargetSpellEffect has been modified to allow specifying a copy applier (used here to apply the legenedary-stripping effect)
- RemoveTypeCopyApplier has been added as a generic copy applier for any cards which read "except it isn't <type>"

* Fixed verify failure - Remove ward hint on Storm of Saruman

* Fixed a typo - ammount -> amount

* Modified Double Major to use new CopyTargetSpellEffect

* Re-added ability text for Double Major
This commit is contained in:
Alexander Novotny 2023-06-08 13:58:28 -07:00 committed by GitHub
parent 49075d6893
commit 0b2f582d84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 217 additions and 57 deletions

View file

@ -6,10 +6,12 @@ import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.constants.SetTargetPointer;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.CastSpellLastTurnWatcher;
/**
@ -19,6 +21,7 @@ public class CastSecondSpellTriggeredAbility extends TriggeredAbilityImpl {
private static final Hint hint = new ValueHint("Spells you cast this turn", SpellCastValue.instance);
private final TargetController targetController;
private final SetTargetPointer setTargetPointer;
public CastSecondSpellTriggeredAbility(Effect effect) {
this(effect, TargetController.YOU);
@ -29,18 +32,33 @@ public class CastSecondSpellTriggeredAbility extends TriggeredAbilityImpl {
}
public CastSecondSpellTriggeredAbility(Zone zone, Effect effect, TargetController targetController, boolean optional) {
this(zone, effect, targetController, optional, SetTargetPointer.NONE);
}
/**
*
* @param zone What zone the ability can trigger from (see {@link mage.abilities.Ability#getZone})
* @param effect What effect will happen when this ability triggers (see {@link mage.abilities.Ability#getEffects})
* @param targetController Which player(s) to pay attention to
* @param optional Whether the effect is optional (see {@link mage.abilities.TriggeredAbility#isOptional})
* @param setTargetPointer Who to set the target pointer of the effects to. Only accepts NONE, PLAYER (the player who cast the spell), and SPELL (the spell which was cast)
*/
public CastSecondSpellTriggeredAbility(Zone zone, Effect effect, TargetController targetController,
boolean optional, SetTargetPointer setTargetPointer) {
super(zone, effect, optional);
this.addWatcher(new CastSpellLastTurnWatcher());
if (targetController == TargetController.YOU) {
this.addHint(hint);
}
this.targetController = targetController;
this.setTargetPointer = setTargetPointer;
setTriggerPhrase(generateTriggerPhrase());
}
private CastSecondSpellTriggeredAbility(final CastSecondSpellTriggeredAbility ability) {
super(ability);
this.targetController = ability.targetController;
this.setTargetPointer = ability.setTargetPointer;
}
@Override
@ -73,6 +91,18 @@ public class CastSecondSpellTriggeredAbility extends TriggeredAbilityImpl {
CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class);
if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2) {
this.getEffects().setValue("spellCast", game.getSpell(event.getTargetId()));
switch (this.setTargetPointer) {
case PLAYER:
this.getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
break;
case SPELL:
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
break;
case NONE:
break;
default:
throw new IllegalArgumentException("SetTargetPointer " + this.setTargetPointer + " not supported");
}
return true;
}
return false;