mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Instill Energy - Fixed that the untap enchanted creature ability did not work.
This commit is contained in:
parent
bb229156f5
commit
d818fadf52
5 changed files with 67 additions and 221 deletions
|
@ -30,16 +30,15 @@ package mage.sets.antiquities;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.LimitedTimesPerTurnActivatedAbility;
|
import mage.abilities.common.LimitedTimesPerTurnActivatedAbility;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.condition.common.IsStepCondition;
|
||||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.target.common.TargetArtifactPermanent;
|
import mage.target.common.TargetArtifactPermanent;
|
||||||
import mage.target.common.TargetControlledCreaturePermanent;
|
import mage.target.common.TargetControlledCreaturePermanent;
|
||||||
|
|
||||||
|
@ -54,7 +53,9 @@ public class GateToPhyrexia extends CardImpl {
|
||||||
this.expansionSetCode = "ATQ";
|
this.expansionSetCode = "ATQ";
|
||||||
|
|
||||||
// Sacrifice a creature: Destroy target artifact. Activate this ability only during your upkeep and only once each turn.
|
// Sacrifice a creature: Destroy target artifact. Activate this ability only during your upkeep and only once each turn.
|
||||||
Ability ability = new GateToPhyrexiaAbility(new DestroyTargetEffect(), new SacrificeTargetCost(new TargetControlledCreaturePermanent()));
|
Ability ability = new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(),
|
||||||
|
new SacrificeTargetCost(new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("a creature"))),
|
||||||
|
1, new IsStepCondition(PhaseStep.UPKEEP, true));
|
||||||
ability.addTarget(new TargetArtifactPermanent());
|
ability.addTarget(new TargetArtifactPermanent());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
@ -68,32 +69,3 @@ public class GateToPhyrexia extends CardImpl {
|
||||||
return new GateToPhyrexia(this);
|
return new GateToPhyrexia(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GateToPhyrexiaAbility extends LimitedTimesPerTurnActivatedAbility {
|
|
||||||
|
|
||||||
public GateToPhyrexiaAbility(Effect effect, Cost cost) {
|
|
||||||
super(Zone.BATTLEFIELD, effect, cost);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GateToPhyrexiaAbility(final GateToPhyrexiaAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GateToPhyrexiaAbility copy() {
|
|
||||||
return new GateToPhyrexiaAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canActivate(UUID playerId, Game game) {
|
|
||||||
if (!game.getActivePlayerId().equals(controllerId) || !PhaseStep.UPKEEP.equals(game.getStep().getType())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return super.canActivate(playerId, game);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "Sacrifice a creature: Destroy target artifact. Activate this ability only during your upkeep and only once each turn.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -28,17 +28,12 @@
|
||||||
package mage.sets.championsofkamigawa;
|
package mage.sets.championsofkamigawa;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Rarity;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.LimitedTimesPerTurnActivatedAbility;
|
import mage.abilities.common.LimitedTimesPerTurnActivatedAbility;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.common.LookLibraryControllerEffect;
|
import mage.abilities.effects.common.LookLibraryControllerEffect;
|
||||||
|
@ -49,6 +44,10 @@ import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.cards.CardsImpl;
|
import mage.cards.CardsImpl;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Rarity;
|
||||||
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
@ -67,11 +66,11 @@ public class BrutalDeceiver extends CardImpl {
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
|
|
||||||
// {1}: Look at the top card of your library.
|
// {1}: Look at the top card of your library.
|
||||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new LookLibraryControllerEffect(), new GenericManaCost(1)));
|
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new LookLibraryControllerEffect(), new GenericManaCost(1)));
|
||||||
|
|
||||||
// {2}: Reveal the top card of your library. If it's a land card, {this} gets +1/+0 and gains first strike until end of turn.
|
// {2}: Reveal the top card of your library. If it's a land card, {this} gets +1/+0 and gains first strike until end of turn.
|
||||||
Ability ability = new BrutalDeceiverAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1,0,Duration.EndOfTurn), new ManaCostsImpl("{2}"));
|
Ability ability = new BrutalDeceiverAbility(Zone.BATTLEFIELD, new BoostSourceEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl("{2}"));
|
||||||
ability.addEffect(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(),Duration.EndOfTurn));
|
ability.addEffect(new GainAbilitySourceEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn));
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,36 +86,36 @@ public class BrutalDeceiver extends CardImpl {
|
||||||
|
|
||||||
class BrutalDeceiverAbility extends LimitedTimesPerTurnActivatedAbility {
|
class BrutalDeceiverAbility extends LimitedTimesPerTurnActivatedAbility {
|
||||||
|
|
||||||
public BrutalDeceiverAbility(Zone zone, Effect effect, Cost cost) {
|
public BrutalDeceiverAbility(Zone zone, Effect effect, Cost cost) {
|
||||||
super(zone, effect, cost);
|
super(zone, effect, cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BrutalDeceiverAbility(BrutalDeceiverAbility ability) {
|
public BrutalDeceiverAbility(BrutalDeceiverAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BrutalDeceiverAbility copy() {
|
public BrutalDeceiverAbility copy() {
|
||||||
return new BrutalDeceiverAbility(this);
|
return new BrutalDeceiverAbility(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkIfClause(Game game) {
|
public boolean checkIfClause(Game game) {
|
||||||
Player player = game.getPlayer(this.getControllerId());
|
Player player = game.getPlayer(this.getControllerId());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
Card card = player.getLibrary().getFromTop(game);
|
Card card = player.getLibrary().getFromTop(game);
|
||||||
cards.add(card);
|
cards.add(card);
|
||||||
player.revealCards("Brutal Deceiver", cards, game);
|
player.revealCards("Brutal Deceiver", cards, game);
|
||||||
if (card != null && card.getCardType().contains(CardType.LAND)) {
|
if (card != null && card.getCardType().contains(CardType.LAND)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
return "{2}: Reveal the top card of your library. If it's a land card, {this} gets +1/+0 and gains first strike until end of turn. Activate this ability only once each turn.";
|
return "{2}: Reveal the top card of your library. If it's a land card, {this} gets +1/+0 and gains first strike until end of turn. Activate this ability only once each turn.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,14 +29,11 @@ package mage.sets.fifthedition;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.ActivateIfConditionActivatedAbility;
|
import mage.abilities.common.LimitedTimesPerTurnActivatedAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.condition.Condition;
|
|
||||||
import mage.abilities.condition.common.MyTurnCondition;
|
import mage.abilities.condition.common.MyTurnCondition;
|
||||||
import mage.abilities.costs.Cost;
|
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.AsThoughEffectImpl;
|
import mage.abilities.effects.AsThoughEffectImpl;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.UntapEnchantedEffect;
|
import mage.abilities.effects.common.UntapEnchantedEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||||
|
@ -53,7 +50,6 @@ import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
import mage.util.CardUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -77,8 +73,7 @@ public class InstillEnergy extends CardImpl {
|
||||||
Ability haste = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(asThough, AttachmentType.AURA, Duration.WhileOnBattlefield, "Enchanted creature can attack as though it had haste."));
|
Ability haste = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(asThough, AttachmentType.AURA, Duration.WhileOnBattlefield, "Enchanted creature can attack as though it had haste."));
|
||||||
this.addAbility(haste);
|
this.addAbility(haste);
|
||||||
// {0}: Untap enchanted creature. Activate this ability only during your turn and only once each turn.
|
// {0}: Untap enchanted creature. Activate this ability only during your turn and only once each turn.
|
||||||
Ability gainedAbility = new LimitedTimesIfConditionActivatedAbility(Zone.BATTLEFIELD, new UntapEnchantedEffect(), new GenericManaCost(0), MyTurnCondition.getInstance(), 1);
|
this.addAbility(new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new UntapEnchantedEffect(), new GenericManaCost(0), 1, MyTurnCondition.getInstance()));
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA, Duration.WhileOnBattlefield, "{0}: Untap enchanted creature. Activate this ability only during your turn and only once each turn.")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstillEnergy(final InstillEnergy card) {
|
public InstillEnergy(final InstillEnergy card) {
|
||||||
|
@ -118,104 +113,3 @@ class CanAttackAsThoughItHadHasteEnchantedEffect extends AsThoughEffectImpl {
|
||||||
return enchantment != null && enchantment.getAttachedTo() != null && enchantment.getAttachedTo().equals(objectId);
|
return enchantment != null && enchantment.getAttachedTo() != null && enchantment.getAttachedTo().equals(objectId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LimitedTimesIfConditionActivatedAbility extends ActivateIfConditionActivatedAbility {
|
|
||||||
|
|
||||||
class ActivationInfo {
|
|
||||||
|
|
||||||
public int turnNum;
|
|
||||||
public int activationCounter;
|
|
||||||
|
|
||||||
public ActivationInfo(int turnNum, int activationCounter) {
|
|
||||||
this.turnNum = turnNum;
|
|
||||||
this.activationCounter = activationCounter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int maxActivationsPerTurn;
|
|
||||||
|
|
||||||
public LimitedTimesIfConditionActivatedAbility(Zone zone, Effect effect, Cost cost, Condition condition) {
|
|
||||||
this(zone, effect, cost, condition, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LimitedTimesIfConditionActivatedAbility(Zone zone, Effect effect, Cost cost, Condition condition, int maxActivationsPerTurn) {
|
|
||||||
super(zone, effect, cost, condition);
|
|
||||||
this.maxActivationsPerTurn = maxActivationsPerTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LimitedTimesIfConditionActivatedAbility(LimitedTimesIfConditionActivatedAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
this.maxActivationsPerTurn = ability.maxActivationsPerTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canActivate(UUID playerId, Game game) {
|
|
||||||
if (super.canActivate(playerId, game)) {
|
|
||||||
ActivationInfo activationInfo = getActivationInfo(game);
|
|
||||||
return activationInfo == null || activationInfo.turnNum != game.getTurnNum() || activationInfo.activationCounter < maxActivationsPerTurn;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean activate(Game game, boolean noMana) {
|
|
||||||
if (canActivate(this.controllerId, game)) {
|
|
||||||
if (super.activate(game, noMana)) {
|
|
||||||
ActivationInfo activationInfo = getActivationInfo(game);
|
|
||||||
if (activationInfo == null) {
|
|
||||||
activationInfo = new ActivationInfo(game.getTurnNum(), 1);
|
|
||||||
} else if (activationInfo.turnNum != game.getTurnNum()) {
|
|
||||||
activationInfo.turnNum = game.getTurnNum();
|
|
||||||
activationInfo.activationCounter = 1;
|
|
||||||
} else {
|
|
||||||
activationInfo.activationCounter++;
|
|
||||||
}
|
|
||||||
setActivationInfo(activationInfo, game);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean resolve(Game game) {
|
|
||||||
return super.resolve(game);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
StringBuilder sb = new StringBuilder(super.getRule());
|
|
||||||
sb.replace(sb.length() - 1, sb.length() - 1, " and "); //suppress super()'s final period
|
|
||||||
switch (maxActivationsPerTurn) {
|
|
||||||
case 1:
|
|
||||||
sb.append("only once");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
sb.append("no more than twice");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sb.append("no more than ").append(CardUtil.numberToText(maxActivationsPerTurn)).append(" times");
|
|
||||||
}
|
|
||||||
sb.append(" each turn.");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LimitedTimesIfConditionActivatedAbility copy() {
|
|
||||||
return new LimitedTimesIfConditionActivatedAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ActivationInfo getActivationInfo(Game game) {
|
|
||||||
Integer turnNum = (Integer) game.getState().getValue(CardUtil.getCardZoneString("activationsTurn", sourceId, game));
|
|
||||||
Integer activationCount = (Integer) game.getState().getValue(CardUtil.getCardZoneString("activationsCount", sourceId, game));
|
|
||||||
if (turnNum == null || activationCount == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new ActivationInfo(turnNum, activationCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setActivationInfo(ActivationInfo activationInfo, Game game) {
|
|
||||||
game.getState().setValue(CardUtil.getCardZoneString("activationsTurn", sourceId, game), activationInfo.turnNum);
|
|
||||||
game.getState().setValue(CardUtil.getCardZoneString("activationsCount", sourceId, game), activationInfo.activationCounter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -32,9 +32,9 @@ import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||||
import mage.abilities.common.LimitedTimesPerTurnActivatedAbility;
|
import mage.abilities.common.LimitedTimesPerTurnActivatedAbility;
|
||||||
|
import mage.abilities.condition.common.IsStepCondition;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||||
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
|
import mage.abilities.effects.common.counter.RemoveCounterSourceEffect;
|
||||||
|
@ -48,6 +48,7 @@ import mage.constants.Rarity;
|
||||||
import mage.constants.TargetController;
|
import mage.constants.TargetController;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.common.TargetControlledCreaturePermanent;
|
import mage.target.common.TargetControlledCreaturePermanent;
|
||||||
|
@ -68,16 +69,16 @@ public class EbonPraetor extends CardImpl {
|
||||||
|
|
||||||
// First strike
|
// First strike
|
||||||
this.addAbility(FirstStrikeAbility.getInstance());
|
this.addAbility(FirstStrikeAbility.getInstance());
|
||||||
|
|
||||||
// Trample
|
// Trample
|
||||||
this.addAbility(TrampleAbility.getInstance());
|
this.addAbility(TrampleAbility.getInstance());
|
||||||
|
|
||||||
// At the beginning of your upkeep, put a -2/-2 counter on Ebon Praetor.
|
// At the beginning of your upkeep, put a -2/-2 counter on Ebon Praetor.
|
||||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.M2M2.createInstance()), TargetController.YOU, false));
|
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AddCountersSourceEffect(CounterType.M2M2.createInstance()), TargetController.YOU, false));
|
||||||
|
|
||||||
// Sacrifice a creature: Remove a -2/-2 counter from Ebon Praetor. If the sacrificed creature was a Thrull, put a +1/+0 counter on Ebon Praetor. Activate this ability only during your upkeep and only once each turn.
|
// Sacrifice a creature: Remove a -2/-2 counter from Ebon Praetor. If the sacrificed creature was a Thrull, put a +1/+0 counter on Ebon Praetor. Activate this ability only during your upkeep and only once each turn.
|
||||||
Ability ability = new EbonPraetorAbility(new RemoveCounterSourceEffect(CounterType.M2M2.createInstance()),
|
Ability ability = new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new RemoveCounterSourceEffect(CounterType.M2M2.createInstance()),
|
||||||
new SacrificeTargetCost(new TargetControlledCreaturePermanent()));
|
new SacrificeTargetCost(new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("a creature"))), 1, new IsStepCondition(PhaseStep.UPKEEP, true));
|
||||||
ability.addEffect(new EbonPraetorEffect());
|
ability.addEffect(new EbonPraetorEffect());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
}
|
}
|
||||||
|
@ -92,37 +93,6 @@ public class EbonPraetor extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EbonPraetorAbility extends LimitedTimesPerTurnActivatedAbility {
|
|
||||||
|
|
||||||
public EbonPraetorAbility(Effect effect, Cost cost) {
|
|
||||||
super(Zone.BATTLEFIELD, effect, cost);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EbonPraetorAbility(final EbonPraetorAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EbonPraetorAbility copy() {
|
|
||||||
return new EbonPraetorAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canActivate(UUID playerId, Game game) {
|
|
||||||
if (!game.getActivePlayerId().equals(controllerId) || !PhaseStep.UPKEEP.equals(game.getStep().getType())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return super.canActivate(playerId, game);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
StringBuilder sb = new StringBuilder("");
|
|
||||||
sb.append(super.getRule()).append(" <i>Activate this ability only during your upkeep.</i>");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class EbonPraetorEffect extends OneShotEffect {
|
class EbonPraetorEffect extends OneShotEffect {
|
||||||
|
|
||||||
public EbonPraetorEffect() {
|
public EbonPraetorEffect() {
|
||||||
|
|
|
@ -24,12 +24,12 @@
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.abilities.common;
|
package mage.abilities.common;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.ActivatedAbilityImpl;
|
import mage.abilities.ActivatedAbilityImpl;
|
||||||
|
import mage.abilities.condition.Condition;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
|
@ -54,24 +54,33 @@ public class LimitedTimesPerTurnActivatedAbility extends ActivatedAbilityImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int maxActivationsPerTurn;
|
private int maxActivationsPerTurn;
|
||||||
|
private Condition condition;
|
||||||
|
|
||||||
public LimitedTimesPerTurnActivatedAbility(Zone zone, Effect effect, Cost cost) {
|
public LimitedTimesPerTurnActivatedAbility(Zone zone, Effect effect, Cost cost) {
|
||||||
this(zone, effect, cost, 1);
|
this(zone, effect, cost, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LimitedTimesPerTurnActivatedAbility(Zone zone, Effect effect, Cost cost, int maxActivationsPerTurn) {
|
public LimitedTimesPerTurnActivatedAbility(Zone zone, Effect effect, Cost cost, int maxActivationsPerTurn) {
|
||||||
super(zone, effect, cost);
|
this(zone, effect, cost, maxActivationsPerTurn, null);
|
||||||
this.maxActivationsPerTurn = maxActivationsPerTurn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LimitedTimesPerTurnActivatedAbility(LimitedTimesPerTurnActivatedAbility ability) {
|
public LimitedTimesPerTurnActivatedAbility(Zone zone, Effect effect, Cost cost, int maxActivationsPerTurn, Condition condition) {
|
||||||
|
super(zone, effect, cost);
|
||||||
|
this.maxActivationsPerTurn = maxActivationsPerTurn;
|
||||||
|
this.condition = condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LimitedTimesPerTurnActivatedAbility(final LimitedTimesPerTurnActivatedAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
this.maxActivationsPerTurn = ability.maxActivationsPerTurn;
|
this.maxActivationsPerTurn = ability.maxActivationsPerTurn;
|
||||||
|
this.condition = ability.condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canActivate(UUID playerId, Game game) {
|
public boolean canActivate(UUID playerId, Game game) {
|
||||||
return super.canActivate(playerId, game) && hasMoreActivationsThisTurn(game);
|
return super.canActivate(playerId, game)
|
||||||
|
&& hasMoreActivationsThisTurn(game)
|
||||||
|
&& (condition == null || condition.apply(game, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasMoreActivationsThisTurn(Game game) {
|
private boolean hasMoreActivationsThisTurn(Game game) {
|
||||||
|
@ -86,13 +95,11 @@ public class LimitedTimesPerTurnActivatedAbility extends ActivatedAbilityImpl {
|
||||||
ActivationInfo activationInfo = getActivationInfo(game);
|
ActivationInfo activationInfo = getActivationInfo(game);
|
||||||
if (activationInfo == null) {
|
if (activationInfo == null) {
|
||||||
activationInfo = new ActivationInfo(game.getTurnNum(), 1);
|
activationInfo = new ActivationInfo(game.getTurnNum(), 1);
|
||||||
|
} else if (activationInfo.turnNum != game.getTurnNum()) {
|
||||||
|
activationInfo.turnNum = game.getTurnNum();
|
||||||
|
activationInfo.activationCounter = 1;
|
||||||
} else {
|
} else {
|
||||||
if (activationInfo.turnNum != game.getTurnNum()) {
|
activationInfo.activationCounter++;
|
||||||
activationInfo.turnNum = game.getTurnNum();
|
|
||||||
activationInfo.activationCounter = 1;
|
|
||||||
} else {
|
|
||||||
activationInfo.activationCounter++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setActivationInfo(activationInfo, game);
|
setActivationInfo(activationInfo, game);
|
||||||
return true;
|
return true;
|
||||||
|
@ -109,7 +116,10 @@ public class LimitedTimesPerTurnActivatedAbility extends ActivatedAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
StringBuilder sb = new StringBuilder(super.getRule()).append(" Activate this ability ");
|
StringBuilder sb = new StringBuilder(super.getRule()).append(" Activate this ability ");
|
||||||
switch(maxActivationsPerTurn) {
|
if (condition != null) {
|
||||||
|
sb.append("only ").append(condition.toString()).append(" and ");
|
||||||
|
}
|
||||||
|
switch (maxActivationsPerTurn) {
|
||||||
case 1:
|
case 1:
|
||||||
sb.append("only once");
|
sb.append("only once");
|
||||||
break;
|
break;
|
||||||
|
@ -127,6 +137,7 @@ public class LimitedTimesPerTurnActivatedAbility extends ActivatedAbilityImpl {
|
||||||
public LimitedTimesPerTurnActivatedAbility copy() {
|
public LimitedTimesPerTurnActivatedAbility copy() {
|
||||||
return new LimitedTimesPerTurnActivatedAbility(this);
|
return new LimitedTimesPerTurnActivatedAbility(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActivationInfo getActivationInfo(Game game) {
|
private ActivationInfo getActivationInfo(Game game) {
|
||||||
Integer turnNum = (Integer) game.getState().getValue(CardUtil.getCardZoneString("activationsTurn", sourceId, game));
|
Integer turnNum = (Integer) game.getState().getValue(CardUtil.getCardZoneString("activationsTurn", sourceId, game));
|
||||||
Integer activationCount = (Integer) game.getState().getValue(CardUtil.getCardZoneString("activationsCount", sourceId, game));
|
Integer activationCount = (Integer) game.getState().getValue(CardUtil.getCardZoneString("activationsCount", sourceId, game));
|
||||||
|
@ -135,7 +146,7 @@ public class LimitedTimesPerTurnActivatedAbility extends ActivatedAbilityImpl {
|
||||||
}
|
}
|
||||||
return new ActivationInfo(turnNum, activationCount);
|
return new ActivationInfo(turnNum, activationCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setActivationInfo(ActivationInfo activationInfo, Game game) {
|
private void setActivationInfo(ActivationInfo activationInfo, Game game) {
|
||||||
game.getState().setValue(CardUtil.getCardZoneString("activationsTurn", sourceId, game), activationInfo.turnNum);
|
game.getState().setValue(CardUtil.getCardZoneString("activationsTurn", sourceId, game), activationInfo.turnNum);
|
||||||
game.getState().setValue(CardUtil.getCardZoneString("activationsCount", sourceId, game), activationInfo.activationCounter);
|
game.getState().setValue(CardUtil.getCardZoneString("activationsCount", sourceId, game), activationInfo.activationCounter);
|
||||||
|
|
Loading…
Reference in a new issue