mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Extract UnlessPaysDelayedEffect from Quenchable Fire into its own file and implement cards that use it: Glass Asp, Nafs Asp, and Sabertooth Cobra
This commit is contained in:
parent
f7df5201c3
commit
8feb31405b
6 changed files with 462 additions and 128 deletions
69
Mage.Sets/src/mage/sets/arabiannights/NafsAsp.java
Normal file
69
Mage.Sets/src/mage/sets/arabiannights/NafsAsp.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.sets.arabiannights;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.DealsDamageToAPlayerTriggeredAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.LoseLifeTargetEffect;
|
||||
import mage.abilities.effects.common.UnlessPaysDelayedEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class NafsAsp extends CardImpl {
|
||||
|
||||
public NafsAsp(UUID ownerId) {
|
||||
super(ownerId, 36, "Nafs Asp", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{G}");
|
||||
this.expansionSetCode = "ARN";
|
||||
this.subtype.add("Snake");
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// Whenever Nafs Asp deals damage to a player, that player loses 1 life at the beginning of his or her next draw step unless he or she pays {1} before that draw step.
|
||||
this.addAbility(new DealsDamageToAPlayerTriggeredAbility(new UnlessPaysDelayedEffect(
|
||||
new ManaCostsImpl("{1}"), new LoseLifeTargetEffect(1), PhaseStep.DRAW, true,
|
||||
"that player loses 1 life at the beginning of his or her next draw step unless he or she pays {1} before that draw step."),
|
||||
false, true));
|
||||
}
|
||||
|
||||
public NafsAsp(final NafsAsp card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NafsAsp copy() {
|
||||
return new NafsAsp(this);
|
||||
}
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
@ -20,7 +20,7 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
|
@ -29,23 +29,13 @@
|
|||
package mage.sets.conflux;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.SpecialAction;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.RemoveDelayedTriggeredAbilityEffect;
|
||||
import mage.abilities.effects.common.RemoveSpecialActionEffect;
|
||||
import mage.abilities.effects.common.UnlessPaysDelayedEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
/**
|
||||
|
@ -59,10 +49,12 @@ public class QuenchableFire extends CardImpl {
|
|||
this.expansionSetCode = "CON";
|
||||
|
||||
// Quenchable Fire deals 3 damage to target player.
|
||||
// It deals an additional 3 damage to that player at the beginning of your next upkeep step unless he or she pays {U} before that step.
|
||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
this.getSpellAbility().addEffect(new DamageTargetEffect(3));
|
||||
this.getSpellAbility().addEffect(new QuenchableFireEffect());
|
||||
// It deals an additional 3 damage to that player at the beginning of your next upkeep step unless he or she pays {U} before that step.
|
||||
this.getSpellAbility().addEffect(new UnlessPaysDelayedEffect(new ManaCostsImpl("{U}"),
|
||||
new DamageTargetEffect(3, true, "that player"), PhaseStep.UPKEEP, false,
|
||||
"It deals an additional 3 damage to that player at the beginning of your next upkeep step unless he or she pays {U} before that step."));
|
||||
}
|
||||
|
||||
public QuenchableFire(final QuenchableFire card) {
|
||||
|
@ -74,112 +66,3 @@ public class QuenchableFire extends CardImpl {
|
|||
return new QuenchableFire(this);
|
||||
}
|
||||
}
|
||||
|
||||
class QuenchableFireEffect extends OneShotEffect {
|
||||
|
||||
public QuenchableFireEffect() {
|
||||
super(Outcome.Damage);
|
||||
staticText = "{this} deals an additional 3 damage to that player at the beginning of your next upkeep step unless he or she pays {U} before that step."
|
||||
+ "<br><i>Use the Special button to pay the {U} with a special action before the beginning of your next upkeep step.</i>";
|
||||
}
|
||||
|
||||
public QuenchableFireEffect(final QuenchableFireEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuenchableFireEffect copy() {
|
||||
return new QuenchableFireEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (sourceObject != null) {
|
||||
|
||||
//create special action
|
||||
QuenchableFireSpecialAction newAction = new QuenchableFireSpecialAction();
|
||||
|
||||
//create delayed triggered ability
|
||||
QuenchableFireDelayedTriggeredAbility delayedAbility = new QuenchableFireDelayedTriggeredAbility();
|
||||
delayedAbility.setSourceId(source.getSourceId());
|
||||
delayedAbility.setControllerId(source.getControllerId());
|
||||
delayedAbility.setSourceObject(sourceObject, game);
|
||||
delayedAbility.getTargets().addAll(source.getTargets());
|
||||
delayedAbility.setSpecialActionId(newAction.getId());
|
||||
UUID delayedAbilityId = game.addDelayedTriggeredAbility(delayedAbility);
|
||||
|
||||
// update special action
|
||||
newAction.addCost(new ManaCostsImpl("{U}"));
|
||||
Effect effect = new RemoveDelayedTriggeredAbilityEffect(delayedAbilityId);
|
||||
newAction.addEffect(effect);
|
||||
effect.setText(sourceObject.getIdName() + " - Pay {U} to remove the triggered ability that deals 3 damage to you at the beginning of your next upkeep step");
|
||||
newAction.addEffect(new RemoveSpecialActionEffect(newAction.getId()));
|
||||
newAction.setSourceId(source.getSourceId());
|
||||
newAction.setControllerId(source.getFirstTarget());
|
||||
newAction.getTargets().addAll(source.getTargets());
|
||||
game.getState().getSpecialActions().add(newAction);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class QuenchableFireDelayedTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
||||
private UUID specialActionId;
|
||||
|
||||
public QuenchableFireDelayedTriggeredAbility() {
|
||||
super(new DamageTargetEffect(3));
|
||||
}
|
||||
|
||||
public void setSpecialActionId(UUID specialActionId) {
|
||||
this.specialActionId = specialActionId;
|
||||
}
|
||||
|
||||
public QuenchableFireDelayedTriggeredAbility(final QuenchableFireDelayedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuenchableFireDelayedTriggeredAbility copy() {
|
||||
return new QuenchableFireDelayedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.UPKEEP_STEP_PRE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getPlayerId().equals(this.controllerId)) {
|
||||
for (SpecialAction action: game.getState().getSpecialActions()) {
|
||||
if (action.getId().equals(specialActionId)) {
|
||||
game.getState().getSpecialActions().remove(action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class QuenchableFireSpecialAction extends SpecialAction {
|
||||
|
||||
public QuenchableFireSpecialAction() {
|
||||
super();
|
||||
}
|
||||
|
||||
public QuenchableFireSpecialAction(final QuenchableFireSpecialAction ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuenchableFireSpecialAction copy() {
|
||||
return new QuenchableFireSpecialAction(this);
|
||||
}
|
||||
}
|
52
Mage.Sets/src/mage/sets/fourthedition/NafsAsp.java
Normal file
52
Mage.Sets/src/mage/sets/fourthedition/NafsAsp.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.sets.fourthedition;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class NafsAsp extends mage.sets.arabiannights.NafsAsp {
|
||||
|
||||
public NafsAsp(UUID ownerId) {
|
||||
super(ownerId);
|
||||
this.cardNumber = 148;
|
||||
this.expansionSetCode = "4ED";
|
||||
}
|
||||
|
||||
public NafsAsp(final NafsAsp card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NafsAsp copy() {
|
||||
return new NafsAsp(this);
|
||||
}
|
||||
}
|
75
Mage.Sets/src/mage/sets/mirage/SabertoothCobra.java
Normal file
75
Mage.Sets/src/mage/sets/mirage/SabertoothCobra.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.sets.mirage;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DealsDamageToAPlayerTriggeredAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.UnlessPaysDelayedEffect;
|
||||
import mage.abilities.effects.common.counter.AddPoisonCounterTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class SabertoothCobra extends CardImpl {
|
||||
|
||||
public SabertoothCobra(UUID ownerId) {
|
||||
super(ownerId, 136, "Sabertooth Cobra", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{2}{G}");
|
||||
this.expansionSetCode = "MIR";
|
||||
this.subtype.add("Snake");
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(2);
|
||||
|
||||
// Whenever Sabertooth Cobra deals damage to a player, he or she gets a poison counter. That player gets another poison counter at the beginning of his or her next upkeep unless he or she pays {2} before that turn.
|
||||
Effect effect = new AddPoisonCounterTargetEffect(1);
|
||||
effect.setText("that player gets a poison counter");
|
||||
Ability ability = new DealsDamageToAPlayerTriggeredAbility(effect, false, true);
|
||||
effect = new AddPoisonCounterTargetEffect(1);
|
||||
effect.setText("That player gets another poison counter.");
|
||||
ability.addEffect(new UnlessPaysDelayedEffect(new ManaCostsImpl("{2}"), effect, PhaseStep.UPKEEP, true,
|
||||
"That player gets another poison counter at the beginning of his or her next upkeep unless he or she pays {2} before that turn."));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
public SabertoothCobra(final SabertoothCobra card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SabertoothCobra copy() {
|
||||
return new SabertoothCobra(this);
|
||||
}
|
||||
}
|
69
Mage.Sets/src/mage/sets/timespiral/GlassAsp.java
Normal file
69
Mage.Sets/src/mage/sets/timespiral/GlassAsp.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.sets.timespiral;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.common.DealsDamageToAPlayerTriggeredAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.LoseLifeTargetEffect;
|
||||
import mage.abilities.effects.common.UnlessPaysDelayedEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Rarity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class GlassAsp extends CardImpl {
|
||||
|
||||
public GlassAsp(UUID ownerId) {
|
||||
super(ownerId, 197, "Glass Asp", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{G}{G}");
|
||||
this.expansionSetCode = "TSP";
|
||||
this.subtype.add("Snake");
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// Whenever Glass Asp deals combat damage to a player, that player loses 2 life at the beginning of his or her next draw step unless he or she pays {2} before that step.
|
||||
this.addAbility(new DealsDamageToAPlayerTriggeredAbility(new UnlessPaysDelayedEffect(
|
||||
new ManaCostsImpl("{2}"), new LoseLifeTargetEffect(2), PhaseStep.DRAW, true,
|
||||
"that player loses 2 life at the beginning of his or her next draw step unless he or she pays {2} before that draw step."),
|
||||
false, true));
|
||||
}
|
||||
|
||||
public GlassAsp(final GlassAsp card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GlassAsp copy() {
|
||||
return new GlassAsp(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.SpecialAction;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.RemoveDelayedTriggeredAbilityEffect;
|
||||
import mage.abilities.effects.common.RemoveSpecialActionEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox (based on Quenchable Fire code by BetaSteward_at_googlemail.com)
|
||||
*/
|
||||
|
||||
public class UnlessPaysDelayedEffect extends OneShotEffect {
|
||||
|
||||
private final Cost cost;
|
||||
private final Effect effect;
|
||||
private final PhaseStep step;
|
||||
private final boolean affectedPlayersTurn;
|
||||
|
||||
public UnlessPaysDelayedEffect(Cost cost, Effect effect, PhaseStep step, boolean affectedPlayersTurn, String text) {
|
||||
super(Outcome.Detriment);
|
||||
this.cost = cost;
|
||||
this.effect = effect;
|
||||
this.step = step;
|
||||
this.affectedPlayersTurn = affectedPlayersTurn;
|
||||
staticText = text + "<br><i>Use the Special button to pay the " + cost.getText()
|
||||
+ " with a special action before that step.</i>";
|
||||
}
|
||||
|
||||
public UnlessPaysDelayedEffect(final UnlessPaysDelayedEffect effect) {
|
||||
super(effect);
|
||||
this.cost = effect.cost.copy();
|
||||
this.effect = effect.effect.copy();
|
||||
this.step = effect.step;
|
||||
this.affectedPlayersTurn = effect.affectedPlayersTurn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnlessPaysDelayedEffect copy() {
|
||||
return new UnlessPaysDelayedEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (sourceObject != null) {
|
||||
|
||||
//create special action
|
||||
UnlessPaysDelayedEffectAction newAction = new UnlessPaysDelayedEffectAction();
|
||||
|
||||
//create delayed triggered ability
|
||||
UUID turnPlayer = affectedPlayersTurn ? getTargetPointer().getFirst(game, source) : source.getControllerId();
|
||||
effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source)));
|
||||
UnlessPaysDelayedEffectTriggeredAbility delayedAbility = new UnlessPaysDelayedEffectTriggeredAbility(turnPlayer, step, effect);
|
||||
delayedAbility.setSourceId(source.getSourceId());
|
||||
delayedAbility.setControllerId(source.getControllerId());
|
||||
delayedAbility.setSourceObject(sourceObject, game);
|
||||
delayedAbility.setSpecialActionId(newAction.getId());
|
||||
UUID delayedAbilityId = game.addDelayedTriggeredAbility(delayedAbility);
|
||||
|
||||
// update special action
|
||||
newAction.addCost(cost);
|
||||
Effect removeEffect = new RemoveDelayedTriggeredAbilityEffect(delayedAbilityId);
|
||||
newAction.addEffect(removeEffect);
|
||||
newAction.addEffect(new RemoveSpecialActionEffect(newAction.getId()));
|
||||
newAction.setSourceId(source.getSourceId());
|
||||
newAction.setControllerId(getTargetPointer().getFirst(game, source));
|
||||
removeEffect.setText(sourceObject.getIdName() + " - Pay " + cost.getText() + " to remove the triggered ability.");
|
||||
game.getState().getSpecialActions().add(newAction);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UnlessPaysDelayedEffectTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
||||
private UUID specialActionId;
|
||||
private final UUID turnPlayer;
|
||||
private final PhaseStep step;
|
||||
|
||||
public UnlessPaysDelayedEffectTriggeredAbility(UUID turnPlayer, PhaseStep step, Effect effect) {
|
||||
super(effect);
|
||||
this.turnPlayer = turnPlayer;
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public void setSpecialActionId(UUID specialActionId) {
|
||||
this.specialActionId = specialActionId;
|
||||
}
|
||||
|
||||
public UnlessPaysDelayedEffectTriggeredAbility(final UnlessPaysDelayedEffectTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.turnPlayer = ability.turnPlayer;
|
||||
this.step = ability.step;
|
||||
this.specialActionId = ability.specialActionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnlessPaysDelayedEffectTriggeredAbility copy() {
|
||||
return new UnlessPaysDelayedEffectTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
switch(step) {
|
||||
case UPKEEP:
|
||||
return event.getType() == EventType.UPKEEP_STEP_PRE;
|
||||
case DRAW:
|
||||
return event.getType() == EventType.DRAW_STEP_PRE;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getPlayerId().equals(turnPlayer)) {
|
||||
for (SpecialAction action: game.getState().getSpecialActions()) {
|
||||
if (action.getId().equals(specialActionId)) {
|
||||
game.getState().getSpecialActions().remove(action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UnlessPaysDelayedEffectAction extends SpecialAction {
|
||||
|
||||
public UnlessPaysDelayedEffectAction() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UnlessPaysDelayedEffectAction(final UnlessPaysDelayedEffectAction ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnlessPaysDelayedEffectAction copy() {
|
||||
return new UnlessPaysDelayedEffectAction(this);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue