mirror of
https://github.com/correl/mage.git
synced 2024-12-28 11:14:13 +00:00
deduplicated code with CastSecondSpellTriggeredAbility
This commit is contained in:
parent
5ba97c089d
commit
9cdcc6b35d
4 changed files with 35 additions and 184 deletions
|
@ -1,25 +1,24 @@
|
||||||
package mage.cards.h;
|
package mage.cards.h;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
|
||||||
import mage.abilities.common.BeginningOfCombatTriggeredAbility;
|
import mage.abilities.common.BeginningOfCombatTriggeredAbility;
|
||||||
|
import mage.abilities.common.CastSecondSpellTriggeredAbility;
|
||||||
import mage.abilities.effects.common.CreateTokenEffect;
|
import mage.abilities.effects.common.CreateTokenEffect;
|
||||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.SubType;
|
||||||
|
import mage.constants.TargetController;
|
||||||
import mage.filter.common.FilterControlledPermanent;
|
import mage.filter.common.FilterControlledPermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
import mage.filter.predicate.Predicates;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.permanent.token.WolfToken;
|
import mage.game.permanent.token.WolfToken;
|
||||||
import mage.target.common.TargetControlledPermanent;
|
import mage.target.common.TargetControlledPermanent;
|
||||||
import mage.watchers.common.CastSpellLastTurnWatcher;
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author weirddan455
|
* @author weirddan455
|
||||||
*/
|
*/
|
||||||
public final class HowlingMoon extends CardImpl {
|
public final class HowlingMoon extends CardImpl {
|
||||||
|
@ -42,7 +41,9 @@ public final class HowlingMoon extends CardImpl {
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// Whenever an opponent casts their second spell each turn, create a 2/2 green Wolf creature token.
|
// Whenever an opponent casts their second spell each turn, create a 2/2 green Wolf creature token.
|
||||||
this.addAbility(new HowlingMoonTriggeredAbility(), new CastSpellLastTurnWatcher());
|
this.addAbility(new CastSecondSpellTriggeredAbility(
|
||||||
|
new CreateTokenEffect(new WolfToken()), TargetController.OPPONENT
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private HowlingMoon(final HowlingMoon card) {
|
private HowlingMoon(final HowlingMoon card) {
|
||||||
|
@ -54,38 +55,3 @@ public final class HowlingMoon extends CardImpl {
|
||||||
return new HowlingMoon(this);
|
return new HowlingMoon(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HowlingMoonTriggeredAbility extends TriggeredAbilityImpl {
|
|
||||||
// TODO: replace this and others like it with CastSecondSpellTriggeredAbility
|
|
||||||
public HowlingMoonTriggeredAbility() {
|
|
||||||
super(Zone.BATTLEFIELD, new CreateTokenEffect(new WolfToken()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private HowlingMoonTriggeredAbility(final HowlingMoonTriggeredAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HowlingMoonTriggeredAbility copy() {
|
|
||||||
return new HowlingMoonTriggeredAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.SPELL_CAST;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
if (game.getOpponents(controllerId).contains(event.getPlayerId())) {
|
|
||||||
CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class);
|
|
||||||
return watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTriggerPhrase() {
|
|
||||||
return "Whenever an opponent casts their second spell each turn, ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
|
|
||||||
package mage.cards.k;
|
package mage.cards.k;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.common.CastSecondSpellTriggeredAbility;
|
||||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.abilities.keyword.HasteAbility;
|
import mage.abilities.keyword.HasteAbility;
|
||||||
|
@ -13,14 +11,11 @@ import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.constants.SuperType;
|
import mage.constants.SuperType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.TargetController;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
import java.util.UUID;
|
||||||
import mage.game.events.GameEvent.EventType;
|
|
||||||
import mage.watchers.common.CastSpellLastTurnWatcher;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Styxo
|
* @author Styxo
|
||||||
*/
|
*/
|
||||||
public final class KraumLudevicsOpus extends CardImpl {
|
public final class KraumLudevicsOpus extends CardImpl {
|
||||||
|
@ -40,11 +35,12 @@ public final class KraumLudevicsOpus extends CardImpl {
|
||||||
this.addAbility(HasteAbility.getInstance());
|
this.addAbility(HasteAbility.getInstance());
|
||||||
|
|
||||||
// Whenever an opponent casts their second spell each turn, draw a card.
|
// Whenever an opponent casts their second spell each turn, draw a card.
|
||||||
this.addAbility(new KraumLudevicsOpusTriggeredAbility(), new CastSpellLastTurnWatcher());
|
this.addAbility(new CastSecondSpellTriggeredAbility(
|
||||||
|
new DrawCardSourceControllerEffect(1), TargetController.OPPONENT
|
||||||
|
));
|
||||||
|
|
||||||
// Partner
|
// Partner
|
||||||
this.addAbility(PartnerAbility.getInstance());
|
this.addAbility(PartnerAbility.getInstance());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private KraumLudevicsOpus(final KraumLudevicsOpus card) {
|
private KraumLudevicsOpus(final KraumLudevicsOpus card) {
|
||||||
|
@ -56,40 +52,3 @@ public final class KraumLudevicsOpus extends CardImpl {
|
||||||
return new KraumLudevicsOpus(this);
|
return new KraumLudevicsOpus(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class KraumLudevicsOpusTriggeredAbility extends TriggeredAbilityImpl {
|
|
||||||
|
|
||||||
public KraumLudevicsOpusTriggeredAbility() {
|
|
||||||
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public KraumLudevicsOpusTriggeredAbility(final KraumLudevicsOpusTriggeredAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KraumLudevicsOpusTriggeredAbility copy() {
|
|
||||||
return new KraumLudevicsOpusTriggeredAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.SPELL_CAST;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
if (game.getOpponents(controllerId).contains(event.getPlayerId())) {
|
|
||||||
CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class);
|
|
||||||
if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "Whenever an opponent casts their second spell each turn, draw a card.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,18 +2,15 @@ package mage.cards.m;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
|
import mage.abilities.common.CastSecondSpellTriggeredAbility;
|
||||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||||
import mage.abilities.keyword.LifelinkAbility;
|
import mage.abilities.keyword.LifelinkAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.SuperType;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.watchers.common.CastSpellLastTurnWatcher;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -35,10 +32,12 @@ public final class MangaraTheDiplomat extends CardImpl {
|
||||||
this.addAbility(LifelinkAbility.getInstance());
|
this.addAbility(LifelinkAbility.getInstance());
|
||||||
|
|
||||||
// Whenever an opponent attacks with creatures, if two or more of those creatures are attacking you and/or a planeswalker you control, draw a card.
|
// Whenever an opponent attacks with creatures, if two or more of those creatures are attacking you and/or a planeswalker you control, draw a card.
|
||||||
this.addAbility(new MangaraTheDiplomatAttackTriggeredAbility());
|
this.addAbility(new MangaraTheDiplomatTriggeredAbility());
|
||||||
|
|
||||||
// Whenever an opponent casts their second spell each turn, draw a card.
|
// Whenever an opponent casts their second spell each turn, draw a card.
|
||||||
this.addAbility(new MangaraTheDiplomatCastTriggeredAbility());
|
this.addAbility(new CastSecondSpellTriggeredAbility(
|
||||||
|
new DrawCardSourceControllerEffect(1), TargetController.OPPONENT
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private MangaraTheDiplomat(final MangaraTheDiplomat card) {
|
private MangaraTheDiplomat(final MangaraTheDiplomat card) {
|
||||||
|
@ -51,13 +50,13 @@ public final class MangaraTheDiplomat extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MangaraTheDiplomatAttackTriggeredAbility extends TriggeredAbilityImpl {
|
class MangaraTheDiplomatTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
MangaraTheDiplomatAttackTriggeredAbility() {
|
MangaraTheDiplomatTriggeredAbility() {
|
||||||
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1));
|
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private MangaraTheDiplomatAttackTriggeredAbility(final MangaraTheDiplomatAttackTriggeredAbility ability) {
|
private MangaraTheDiplomatTriggeredAbility(final MangaraTheDiplomatTriggeredAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,8 +80,8 @@ class MangaraTheDiplomatAttackTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MangaraTheDiplomatAttackTriggeredAbility copy() {
|
public MangaraTheDiplomatTriggeredAbility copy() {
|
||||||
return new MangaraTheDiplomatAttackTriggeredAbility(this);
|
return new MangaraTheDiplomatTriggeredAbility(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,40 +91,3 @@ class MangaraTheDiplomatAttackTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
"and/or planeswalkers you control, draw a card.";
|
"and/or planeswalkers you control, draw a card.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MangaraTheDiplomatCastTriggeredAbility extends TriggeredAbilityImpl {
|
|
||||||
|
|
||||||
MangaraTheDiplomatCastTriggeredAbility() {
|
|
||||||
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
private MangaraTheDiplomatCastTriggeredAbility(final MangaraTheDiplomatCastTriggeredAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.SPELL_CAST;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
Player player = game.getPlayer(getControllerId());
|
|
||||||
CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class);
|
|
||||||
return player != null
|
|
||||||
&& watcher != null
|
|
||||||
&& player.hasOpponent(event.getPlayerId(), game)
|
|
||||||
&& watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MangaraTheDiplomatCastTriggeredAbility copy() {
|
|
||||||
return new MangaraTheDiplomatCastTriggeredAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "Whenever an opponent casts their second spell each turn, draw a card.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
package mage.cards.m;
|
package mage.cards.m;
|
||||||
|
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.common.CastSecondSpellTriggeredAbility;
|
||||||
import mage.abilities.effects.common.CreateTokenEffect;
|
import mage.abilities.effects.common.CreateTokenEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.TargetController;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.permanent.token.TreasureToken;
|
import mage.game.permanent.token.TreasureToken;
|
||||||
import mage.players.Player;
|
|
||||||
import mage.watchers.common.CastSpellLastTurnWatcher;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -23,7 +19,11 @@ public final class MonologueTax extends CardImpl {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
|
||||||
|
|
||||||
// Whenever an opponent casts their second spell each turn, you create a Treasure token.
|
// Whenever an opponent casts their second spell each turn, you create a Treasure token.
|
||||||
this.addAbility(new MonologueTaxTriggeredAbility());
|
this.addAbility(new CastSecondSpellTriggeredAbility(
|
||||||
|
new CreateTokenEffect(new TreasureToken())
|
||||||
|
.setText("you create a Treasure token"),
|
||||||
|
TargetController.OPPONENT
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private MonologueTax(final MonologueTax card) {
|
private MonologueTax(final MonologueTax card) {
|
||||||
|
@ -35,39 +35,3 @@ public final class MonologueTax extends CardImpl {
|
||||||
return new MonologueTax(this);
|
return new MonologueTax(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MonologueTaxTriggeredAbility extends TriggeredAbilityImpl {
|
|
||||||
|
|
||||||
MonologueTaxTriggeredAbility() {
|
|
||||||
super(Zone.BATTLEFIELD, new CreateTokenEffect(new TreasureToken()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private MonologueTaxTriggeredAbility(final MonologueTaxTriggeredAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.SPELL_CAST;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
Player player = game.getPlayer(getControllerId());
|
|
||||||
CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class);
|
|
||||||
return player != null
|
|
||||||
&& watcher != null
|
|
||||||
&& player.hasOpponent(event.getPlayerId(), game)
|
|
||||||
&& watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MonologueTaxTriggeredAbility copy() {
|
|
||||||
return new MonologueTaxTriggeredAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "Whenever an opponent casts their second spell each turn, you create a Treasure token.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue