forked from External/mage
[SNC] Implemented Riveteers Ascendancy
This commit is contained in:
parent
a3b1b825c0
commit
0b50f15923
8 changed files with 179 additions and 149 deletions
|
|
@ -7,17 +7,18 @@ import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
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.Outcome;
|
||||||
|
import mage.constants.SubType;
|
||||||
|
import mage.constants.SuperType;
|
||||||
import mage.filter.FilterSpell;
|
import mage.filter.FilterSpell;
|
||||||
import mage.filter.predicate.Predicates;
|
import mage.filter.predicate.Predicates;
|
||||||
import mage.filter.predicate.mageobject.MageObjectReferencePredicate;
|
import mage.filter.predicate.mageobject.MageObjectReferencePredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.stack.Spell;
|
import mage.game.stack.Spell;
|
||||||
import mage.game.stack.StackObject;
|
import mage.game.stack.StackObject;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
import mage.util.CardUtil;
|
|
||||||
import mage.util.functions.StackObjectCopyApplier;
|
import mage.util.functions.StackObjectCopyApplier;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -27,6 +28,13 @@ import java.util.UUID;
|
||||||
*/
|
*/
|
||||||
public class DonalHeraldOfWings extends CardImpl {
|
public class DonalHeraldOfWings extends CardImpl {
|
||||||
|
|
||||||
|
private static final FilterSpell filterSpell = new FilterSpell("a nonlegendary creature spell with flying");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filterSpell.add(Predicates.not(SuperType.LEGENDARY.getPredicate()));
|
||||||
|
filterSpell.add(CardType.CREATURE.getPredicate());
|
||||||
|
}
|
||||||
|
|
||||||
public DonalHeraldOfWings(UUID ownderId, CardSetInfo setInfo) {
|
public DonalHeraldOfWings(UUID ownderId, CardSetInfo setInfo) {
|
||||||
super(ownderId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}{U}");
|
super(ownderId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}{U}");
|
||||||
|
|
||||||
|
|
@ -40,57 +48,18 @@ public class DonalHeraldOfWings extends CardImpl {
|
||||||
// Whenever you cast a nonlegendary creature spell with flying, you may copy it,
|
// Whenever you cast a nonlegendary creature spell with flying, you may copy it,
|
||||||
// except the copy is a 1/1 Spirit in addition to its other types.
|
// except the copy is a 1/1 Spirit in addition to its other types.
|
||||||
// Do this only once each turn. (The copy becomes a token.)
|
// Do this only once each turn. (The copy becomes a token.)
|
||||||
// TODO: This still triggers and asks if you wanna use it, even if you've used it once this turn.
|
this.addAbility(new SpellCastControllerTriggeredAbility(
|
||||||
this.addAbility(new DonalHeraldOfWingsTriggeredAbility());
|
new DonalHeraldOfWingsEffect(), filterSpell, true, true
|
||||||
|
).setDoOnlyOnce(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private DonalHeraldOfWings(final DonalHeraldOfWings card) { super(card); }
|
private DonalHeraldOfWings(final DonalHeraldOfWings card) {
|
||||||
|
super(card);
|
||||||
@Override
|
|
||||||
public DonalHeraldOfWings copy() { return new DonalHeraldOfWings(this); }
|
|
||||||
}
|
|
||||||
|
|
||||||
class DonalHeraldOfWingsTriggeredAbility extends SpellCastControllerTriggeredAbility {
|
|
||||||
|
|
||||||
private static final FilterSpell filterSpell = new FilterSpell("a nonlegendary creature spell with flying");
|
|
||||||
static {
|
|
||||||
filterSpell.add(Predicates.not(SuperType.LEGENDARY.getPredicate()));
|
|
||||||
filterSpell.add(CardType.CREATURE.getPredicate());
|
|
||||||
}
|
|
||||||
|
|
||||||
DonalHeraldOfWingsTriggeredAbility() {
|
|
||||||
super(new DonalHeraldOfWingsEffect(), filterSpell, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private DonalHeraldOfWingsTriggeredAbility(final DonalHeraldOfWingsTriggeredAbility ability) { super(ability); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DonalHeraldOfWingsTriggeredAbility copy() {
|
|
||||||
return new DonalHeraldOfWingsTriggeredAbility(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public DonalHeraldOfWings copy() {
|
||||||
return abilityAvailableThisTurn(game) && super.checkTrigger(event, game);
|
return new DonalHeraldOfWings(this);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean resolve(Game game) {
|
|
||||||
if (!(abilityAvailableThisTurn(game) && super.resolve(game))) { return false; }
|
|
||||||
game.getState().setValue(
|
|
||||||
CardUtil.getCardZoneString("lastTurnResolved" + originalId, sourceId, game),
|
|
||||||
game.getTurnNum()
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean abilityAvailableThisTurn(Game game) {
|
|
||||||
Integer lastTurnResolved = (Integer) game.getState().getValue(
|
|
||||||
CardUtil.getCardZoneString("lastTurnResolved" + originalId, sourceId, game)
|
|
||||||
);
|
|
||||||
// A null result is assumed to mean the this ability has not been used yet.
|
|
||||||
return lastTurnResolved == null || lastTurnResolved != game.getTurnNum();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,19 +67,24 @@ class DonalHeraldOfWingsEffect extends OneShotEffect {
|
||||||
|
|
||||||
DonalHeraldOfWingsEffect() {
|
DonalHeraldOfWingsEffect() {
|
||||||
super(Outcome.Copy);
|
super(Outcome.Copy);
|
||||||
staticText = "you may copy it, except the copy is a 1/1 Spirit in addition to its other types. " +
|
staticText = "you may copy it, except the copy is a 1/1 Spirit in addition to its other types";
|
||||||
"Do this only once each turn. <i>(The copy becomes a token.)</i>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DonalHeraldOfWingsEffect(final DonalHeraldOfWingsEffect effect) { super(effect); }
|
private DonalHeraldOfWingsEffect(final DonalHeraldOfWingsEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller == null) { return false; }
|
if (controller == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the card that was cast
|
// Get the card that was cast
|
||||||
if (this.getTargetPointer() == null) { return false; }
|
if (this.getTargetPointer() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Spell originalSpell = game.getStack().getSpell(((FixedTarget) this.getTargetPointer()).getTarget());
|
Spell originalSpell = game.getStack().getSpell(((FixedTarget) this.getTargetPointer()).getTarget());
|
||||||
|
|
||||||
// Create a token copy
|
// Create a token copy
|
||||||
|
|
@ -120,7 +94,9 @@ class DonalHeraldOfWingsEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Effect copy() { return new DonalHeraldOfWingsEffect(this); }
|
public Effect copy() {
|
||||||
|
return new DonalHeraldOfWingsEffect(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DonalHeraldOfWingsApplier implements StackObjectCopyApplier {
|
enum DonalHeraldOfWingsApplier implements StackObjectCopyApplier {
|
||||||
|
|
@ -134,5 +110,7 @@ enum DonalHeraldOfWingsApplier implements StackObjectCopyApplier {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MageObjectReferencePredicate getNextNewTargetType(int copyNumber) { return null; }
|
public MageObjectReferencePredicate getNextNewTargetType(int copyNumber) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,24 @@
|
||||||
package mage.cards.n;
|
package mage.cards.n;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.common.GainLifeControllerTriggeredAbility;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.SubType;
|
|
||||||
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.Outcome;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
|
import mage.filter.StaticFilters;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author weirddan455
|
* @author weirddan455
|
||||||
*/
|
*/
|
||||||
public final class NykthosParagon extends CardImpl {
|
public final class NykthosParagon extends CardImpl {
|
||||||
|
|
@ -35,7 +32,7 @@ public final class NykthosParagon extends CardImpl {
|
||||||
this.toughness = new MageInt(6);
|
this.toughness = new MageInt(6);
|
||||||
|
|
||||||
// Whenever you gain life, you may put that many +1/+1 counters on each creature you control. Do this only once each turn.
|
// Whenever you gain life, you may put that many +1/+1 counters on each creature you control. Do this only once each turn.
|
||||||
this.addAbility(new NykthosParagonTriggeredAbility());
|
this.addAbility(new GainLifeControllerTriggeredAbility(new NykthosParagonEffect()).setDoOnlyOnce(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private NykthosParagon(final NykthosParagon card) {
|
private NykthosParagon(final NykthosParagon card) {
|
||||||
|
|
@ -48,65 +45,11 @@ public final class NykthosParagon extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NykthosParagonTriggeredAbility extends TriggeredAbilityImpl {
|
|
||||||
|
|
||||||
public NykthosParagonTriggeredAbility() {
|
|
||||||
super(Zone.BATTLEFIELD, new NykthosParagonEffect(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private NykthosParagonTriggeredAbility(final NykthosParagonTriggeredAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NykthosParagonTriggeredAbility copy() {
|
|
||||||
return new NykthosParagonTriggeredAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.GAINED_LIFE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
if (abilityAvailableThisTurn(game) && event.getPlayerId().equals(this.getControllerId())) {
|
|
||||||
for (Effect effect : this.getEffects()) {
|
|
||||||
effect.setValue("gainedLife", event.getAmount());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean resolve(Game game) {
|
|
||||||
if (abilityAvailableThisTurn(game) && super.resolve(game)) {
|
|
||||||
game.getState().setValue(CardUtil.getCardZoneString(
|
|
||||||
"lastTurnResolved" + originalId, sourceId, game
|
|
||||||
), game.getTurnNum());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean abilityAvailableThisTurn(Game game) {
|
|
||||||
Integer lastTurnResolved = (Integer) game.getState().getValue(
|
|
||||||
CardUtil.getCardZoneString("lastTurnResolved" + originalId, sourceId, game)
|
|
||||||
);
|
|
||||||
return lastTurnResolved == null || lastTurnResolved != game.getTurnNum();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "Whenever you gain life, you may put that many +1/+1 counters on each creature you control. Do this only once each turn.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class NykthosParagonEffect extends OneShotEffect {
|
class NykthosParagonEffect extends OneShotEffect {
|
||||||
|
|
||||||
public NykthosParagonEffect() {
|
public NykthosParagonEffect() {
|
||||||
super(Outcome.BoostCreature);
|
super(Outcome.BoostCreature);
|
||||||
|
staticText = "put that many +1/+1 counters on each creature you control";
|
||||||
}
|
}
|
||||||
|
|
||||||
private NykthosParagonEffect(final NykthosParagonEffect effect) {
|
private NykthosParagonEffect(final NykthosParagonEffect effect) {
|
||||||
|
|
@ -121,20 +64,24 @@ class NykthosParagonEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
MageObject sourceObject = game.getObject(source);
|
|
||||||
Integer life = (Integer) this.getValue("gainedLife");
|
Integer life = (Integer) this.getValue("gainedLife");
|
||||||
if (controller != null && sourceObject != null && life != null) {
|
if (controller == null || life == null || life < 1) {
|
||||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
|
return false;
|
||||||
if (permanent != null && permanent.isCreature(game)) {
|
|
||||||
permanent.addCounters(CounterType.P1P1.createInstance(life), source.getControllerId(), source, game);
|
|
||||||
if (!game.isSimulation()) {
|
|
||||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts " + life
|
|
||||||
+ " +1/+1 counters on " + permanent.getLogName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(
|
||||||
|
StaticFilters.FILTER_CONTROLLED_CREATURES,
|
||||||
|
source.getControllerId(), source, game
|
||||||
|
)) {
|
||||||
|
permanent.addCounters(
|
||||||
|
CounterType.P1P1.createInstance(life),
|
||||||
|
source.getControllerId(), source, game
|
||||||
|
);
|
||||||
|
game.informPlayers(
|
||||||
|
CardUtil.getSourceLogName(game, source) + ": " +
|
||||||
|
controller.getLogName() + " puts " + life +
|
||||||
|
" +1/+1 counters on " + permanent.getLogName()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
74
Mage.Sets/src/mage/cards/r/RiveteersAscendancy.java
Normal file
74
Mage.Sets/src/mage/cards/r/RiveteersAscendancy.java
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
package mage.cards.r;
|
||||||
|
|
||||||
|
import mage.MageObject;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.SacrificePermanentTriggeredAbility;
|
||||||
|
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
|
||||||
|
import mage.cards.Card;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.filter.FilterCard;
|
||||||
|
import mage.filter.common.FilterCreatureCard;
|
||||||
|
import mage.filter.predicate.ObjectSourcePlayer;
|
||||||
|
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.target.common.TargetCardInYourGraveyard;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public final class RiveteersAscendancy extends CardImpl {
|
||||||
|
|
||||||
|
private static final FilterCard filter
|
||||||
|
= new FilterCreatureCard("creature card with lesser mana value from your graveyard ");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filter.add(RiveteersAscendancyPredicate.instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RiveteersAscendancy(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{B}{R}{G}");
|
||||||
|
|
||||||
|
// Whenever you sacrifice a creature, you may return target creature card with lesser mana value from your graveyard to the battlefield tapped. Do this only once each turn.
|
||||||
|
Ability ability = new SacrificePermanentTriggeredAbility(
|
||||||
|
new ReturnFromGraveyardToBattlefieldTargetEffect(true)
|
||||||
|
).setDoOnlyOnce(true);
|
||||||
|
ability.addTarget(new TargetCardInYourGraveyard(filter));
|
||||||
|
this.addAbility(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
private RiveteersAscendancy(final RiveteersAscendancy card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RiveteersAscendancy copy() {
|
||||||
|
return new RiveteersAscendancy(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum RiveteersAscendancyPredicate implements ObjectSourcePlayerPredicate<Card> {
|
||||||
|
instance;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(ObjectSourcePlayer<Card> input, Game game) {
|
||||||
|
return input
|
||||||
|
.getObject()
|
||||||
|
.getManaValue()
|
||||||
|
< input
|
||||||
|
.getSource()
|
||||||
|
.getEffects()
|
||||||
|
.stream()
|
||||||
|
.map(effect -> effect.getValue("sacrificedPermanent"))
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.map(Permanent.class::cast)
|
||||||
|
.mapToInt(MageObject::getManaValue)
|
||||||
|
.max()
|
||||||
|
.orElse(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -210,6 +210,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet {
|
||||||
cards.add(new SetCardInfo("Revelation of Power", 28, Rarity.COMMON, mage.cards.r.RevelationOfPower.class));
|
cards.add(new SetCardInfo("Revelation of Power", 28, Rarity.COMMON, mage.cards.r.RevelationOfPower.class));
|
||||||
cards.add(new SetCardInfo("Rhox Pummeler", 155, Rarity.COMMON, mage.cards.r.RhoxPummeler.class));
|
cards.add(new SetCardInfo("Rhox Pummeler", 155, Rarity.COMMON, mage.cards.r.RhoxPummeler.class));
|
||||||
cards.add(new SetCardInfo("Rigo, Streetwise Mentor", 215, Rarity.RARE, mage.cards.r.RigoStreetwiseMentor.class));
|
cards.add(new SetCardInfo("Rigo, Streetwise Mentor", 215, Rarity.RARE, mage.cards.r.RigoStreetwiseMentor.class));
|
||||||
|
cards.add(new SetCardInfo("Riveteers Ascendancy", 216, Rarity.RARE, mage.cards.r.RiveteersAscendancy.class));
|
||||||
cards.add(new SetCardInfo("Riveteers Charm", 217, Rarity.UNCOMMON, mage.cards.r.RiveteersCharm.class));
|
cards.add(new SetCardInfo("Riveteers Charm", 217, Rarity.UNCOMMON, mage.cards.r.RiveteersCharm.class));
|
||||||
cards.add(new SetCardInfo("Riveteers Decoy", 156, Rarity.UNCOMMON, mage.cards.r.RiveteersDecoy.class));
|
cards.add(new SetCardInfo("Riveteers Decoy", 156, Rarity.UNCOMMON, mage.cards.r.RiveteersDecoy.class));
|
||||||
cards.add(new SetCardInfo("Riveteers Initiate", 120, Rarity.COMMON, mage.cards.r.RiveteersInitiate.class));
|
cards.add(new SetCardInfo("Riveteers Initiate", 120, Rarity.COMMON, mage.cards.r.RiveteersInitiate.class));
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ability.checkTrigger(event, game) && ability.checkTriggeredAlready(game)) {
|
if (ability.checkTrigger(event, game) && ability.checkTriggeredAlready(game) && ability.checkUsedAlready(game)) {
|
||||||
NumberOfTriggersEvent numberOfTriggersEvent = new NumberOfTriggersEvent(ability, event);
|
NumberOfTriggersEvent numberOfTriggersEvent = new NumberOfTriggersEvent(ability, event);
|
||||||
if (!game.replaceEvent(numberOfTriggersEvent)) {
|
if (!game.replaceEvent(numberOfTriggersEvent)) {
|
||||||
for (int i = 0; i < numberOfTriggersEvent.getAmount(); i++) {
|
for (int i = 0; i < numberOfTriggersEvent.getAmount(); i++) {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ public interface TriggeredAbility extends Ability {
|
||||||
|
|
||||||
boolean checkTriggeredAlready(Game game);
|
boolean checkTriggeredAlready(Game game);
|
||||||
|
|
||||||
|
boolean checkUsedAlready(Game game);
|
||||||
|
|
||||||
TriggeredAbility setTriggersOnce(boolean triggersOnce);
|
TriggeredAbility setTriggersOnce(boolean triggersOnce);
|
||||||
|
|
||||||
boolean checkInterveningIfClause(Game game);
|
boolean checkInterveningIfClause(Game game);
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
||||||
protected boolean optional;
|
protected boolean optional;
|
||||||
protected boolean leavesTheBattlefieldTrigger;
|
protected boolean leavesTheBattlefieldTrigger;
|
||||||
private boolean triggersOnce = false;
|
private boolean triggersOnce = false;
|
||||||
|
private boolean doOnlyOnce = false;
|
||||||
private GameEvent triggerEvent = null;
|
private GameEvent triggerEvent = null;
|
||||||
private String triggerPhrase = null;
|
private String triggerPhrase = null;
|
||||||
|
|
||||||
|
|
@ -52,6 +53,7 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
||||||
this.optional = ability.optional;
|
this.optional = ability.optional;
|
||||||
this.leavesTheBattlefieldTrigger = ability.leavesTheBattlefieldTrigger;
|
this.leavesTheBattlefieldTrigger = ability.leavesTheBattlefieldTrigger;
|
||||||
this.triggersOnce = ability.triggersOnce;
|
this.triggersOnce = ability.triggersOnce;
|
||||||
|
this.doOnlyOnce = ability.doOnlyOnce;
|
||||||
this.triggerPhrase = ability.triggerPhrase;
|
this.triggerPhrase = ability.triggerPhrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,6 +107,23 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkUsedAlready(Game game) {
|
||||||
|
if (!doOnlyOnce) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Integer lastTurnUsed = (Integer) game.getState().getValue(
|
||||||
|
CardUtil.getCardZoneString("lastTurnUsed" + originalId, sourceId, game)
|
||||||
|
);
|
||||||
|
return lastTurnUsed == null || lastTurnUsed != game.getTurnNum();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TriggeredAbility setDoOnlyOnce(boolean doOnlyOnce) {
|
||||||
|
this.optional = true;
|
||||||
|
this.doOnlyOnce = doOnlyOnce;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkInterveningIfClause(Game game) {
|
public boolean checkInterveningIfClause(Game game) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -112,23 +131,31 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean resolve(Game game) {
|
public boolean resolve(Game game) {
|
||||||
|
if (!checkInterveningIfClause(game)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (isOptional()) {
|
if (isOptional()) {
|
||||||
MageObject object = game.getObject(getSourceId());
|
MageObject object = game.getObject(getSourceId());
|
||||||
Player player = game.getPlayer(this.getControllerId());
|
Player player = game.getPlayer(this.getControllerId());
|
||||||
if (player != null && object != null) {
|
if (player == null || object == null
|
||||||
if (!player.chooseUse(getEffects().getOutcome(this), this.getRule(object.getLogName()), this, game)) {
|
|| !player.chooseUse(
|
||||||
return false;
|
getEffects().getOutcome(this),
|
||||||
}
|
this.getRule(object.getLogName()), this, game
|
||||||
} else {
|
)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//20091005 - 603.4
|
//20091005 - 603.4
|
||||||
if (checkInterveningIfClause(game)) {
|
if (!super.resolve(game)) {
|
||||||
return super.resolve(game);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (doOnlyOnce) {
|
||||||
|
game.getState().setValue(CardUtil.getCardZoneString(
|
||||||
|
"lastTurnUsed" + originalId, sourceId, game
|
||||||
|
), game.getTurnNum());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGameLogMessage(Game game) {
|
public String getGameLogMessage(Game game) {
|
||||||
|
|
@ -182,6 +209,9 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
||||||
if (triggersOnce) {
|
if (triggersOnce) {
|
||||||
sb.append(" This ability triggers only once each turn.");
|
sb.append(" This ability triggers only once each turn.");
|
||||||
}
|
}
|
||||||
|
if (doOnlyOnce) {
|
||||||
|
sb.append(" Do this only once each turn.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String prefix;
|
String prefix;
|
||||||
if (abilityWord != null) {
|
if (abilityWord != null) {
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,8 @@ public class GainLifeControllerTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getPlayerId().equals(this.getControllerId())) {
|
if (event.getPlayerId().equals(this.getControllerId())) {
|
||||||
if (setTargetPointer) {
|
if (setTargetPointer) {
|
||||||
for (Effect effect : this.getEffects()) {
|
this.getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
|
||||||
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
|
this.getEffects().setValue("gainedLife", event.getAmount());
|
||||||
effect.setValue("gainedLife", event.getAmount());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue