mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Implement DoubleVision
This commit is contained in:
parent
b8c1ff6e42
commit
3dcdcfc2ed
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("Mangara, the Diplomat", 27, Rarity.MYTHIC, mage.cards.m.MangaraTheDiplomat.class));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue