mirror of
https://github.com/correl/mage.git
synced 2025-01-12 03:00:13 +00:00
Merge pull request #6609 from htrajan/implement-double-vision
Implement DoubleVision
This commit is contained in:
commit
9d25cd0aa9
2 changed files with 87 additions and 0 deletions
86
Mage.Sets/src/mage/cards/d/DoubleVision.java
Normal file
86
Mage.Sets/src/mage/cards/d/DoubleVision.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.abilities.common.SpellCastControllerTriggeredAbility;
|
||||
import mage.abilities.effects.common.CopyTargetSpellEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.filter.common.FilterInstantOrSorcerySpell;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.watchers.common.SpellsCastWatcher;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author htrajan
|
||||
*/
|
||||
public final class DoubleVision extends CardImpl {
|
||||
|
||||
public DoubleVision(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}{R}");
|
||||
|
||||
// Whenever you cast your first instant or sorcery spell each turn, copy that spell. You may choose new targets for the copy.
|
||||
this.addAbility(new DoubleVisionCopyTriggeredAbility(), new SpellsCastWatcher());
|
||||
}
|
||||
|
||||
private DoubleVision(final DoubleVision card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DoubleVision copy() {
|
||||
return new DoubleVision(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DoubleVisionCopyTriggeredAbility extends SpellCastControllerTriggeredAbility {
|
||||
|
||||
DoubleVisionCopyTriggeredAbility() {
|
||||
super(new CopyTargetSpellEffect(true), new FilterInstantOrSorcerySpell(), false);
|
||||
}
|
||||
|
||||
DoubleVisionCopyTriggeredAbility(DoubleVisionCopyTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DoubleVisionCopyTriggeredAbility copy() {
|
||||
return new DoubleVisionCopyTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (super.checkTrigger(event, game)) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (isFirstInstantOrSorceryCastByPlayerOnTurn(spell, game)) {
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isFirstInstantOrSorceryCastByPlayerOnTurn(Spell spell, Game game) {
|
||||
if (spell != null) {
|
||||
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
|
||||
if (watcher != null) {
|
||||
List<Spell> eligibleSpells = watcher.getSpellsCastThisTurn(this.getControllerId())
|
||||
.stream()
|
||||
.filter(s -> s.isInstant() || s.isSorcery())
|
||||
.collect(Collectors.toList());
|
||||
return eligibleSpells.size() == 1 && eligibleSpells.get(0).getId().equals(spell.getId());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever you cast your first instant or sorcery spell each turn, copy that spell. You may choose new targets for the copy.";
|
||||
}
|
||||
}
|
|
@ -33,6 +33,7 @@ public final class CoreSet2021 extends ExpansionSet {
|
|||
this.ratioBoosterMythic = 8;
|
||||
this.maxCardNumberInBooster = 274;
|
||||
|
||||
cards.add(new SetCardInfo("Double Vision", 142, Rarity.RARE, mage.cards.d.DoubleVision.class));
|
||||
cards.add(new SetCardInfo("Azusa, Lost but Seeking", 173, Rarity.RARE, mage.cards.a.AzusaLostButSeeking.class));
|
||||
cards.add(new SetCardInfo("Baneslayer Angel", 4, Rarity.MYTHIC, mage.cards.b.BaneslayerAngel.class));
|
||||
cards.add(new SetCardInfo("Containment Priest", 314, Rarity.RARE, mage.cards.c.ContainmentPriest.class));
|
||||
|
|
Loading…
Reference in a new issue