mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
Check CDAs from token, remove explicit parameter
This commit is contained in:
parent
ce5423bbf6
commit
9b73c8367f
6 changed files with 30 additions and 12 deletions
|
@ -38,7 +38,7 @@ public final class ChimericMass extends CardImpl {
|
|||
.withType(CardType.ARTIFACT)
|
||||
.withSubType(SubType.CONSTRUCT)
|
||||
.withAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SetBasePowerToughnessSourceEffect(new CountersSourceCount(CounterType.CHARGE)))),
|
||||
"", Duration.EndOfTurn, false, false, true).withDurationRuleAtStart(true), new GenericManaCost(1)));
|
||||
"", Duration.EndOfTurn).withDurationRuleAtStart(true), new GenericManaCost(1)));
|
||||
}
|
||||
|
||||
private ChimericMass(final ChimericMass card) {
|
||||
|
|
|
@ -47,7 +47,7 @@ public final class ChromiumTheMutable extends CardImpl {
|
|||
Ability ability = new SimpleActivatedAbility(
|
||||
new BecomesCreatureSourceEffect(
|
||||
new ChromiumTheMutableToken(), null, Duration.EndOfTurn,
|
||||
false, true, false
|
||||
false, true
|
||||
).setText("Until end of turn, {this} becomes "
|
||||
+ "a Human with base power and toughness 1/1, "
|
||||
+ "loses all abilities, and gains hexproof"),
|
||||
|
|
|
@ -103,7 +103,7 @@ class EbonyFlyEffect extends OneShotEffect {
|
|||
new CreatureToken(result, result)
|
||||
.withType(CardType.ARTIFACT)
|
||||
.withAbility(FlyingAbility.getInstance()),
|
||||
"", Duration.EndOfTurn, false, false, false
|
||||
"", Duration.EndOfTurn
|
||||
), source);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public final class MonumentToPerfection extends CardImpl {
|
|||
.withAbility(IndestructibleAbility.getInstance())
|
||||
.withAbility(new ToxicAbility(9)),
|
||||
null, Duration.Custom, true,
|
||||
true, false
|
||||
true
|
||||
), new GenericManaCost(3), MonumentToPerfectionCondition.instance
|
||||
).addHint(MonumentToPerfectionValue.getHint()));
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class SvogthosTheRestlessTomb extends CardImpl {
|
|||
this.addAbility(new ColorlessManaAbility());
|
||||
// {3}{B}{G}: Until end of turn, Svogthos, the Restless Tomb becomes a black and green Plant Zombie creature with "This creature's power and toughness are each equal to the number of creature cards in your graveyard." It's still a land.
|
||||
// set to character defining to prevent setting P/T again to 0 becuase already set by CDA of the token
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesCreatureSourceEffect(new SvogthosToken(), "land", Duration.EndOfTurn, false, false, true).withDurationRuleAtStart(true), new ManaCostsImpl<>("{3}{B}{G}"));
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesCreatureSourceEffect(new SvogthosToken(), "land", Duration.EndOfTurn).withDurationRuleAtStart(true), new ManaCostsImpl<>("{3}{B}{G}"));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ package mage.abilities.effects.common.continuous;
|
|||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -42,6 +44,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
protected DynamicValue power = null;
|
||||
protected DynamicValue toughness = null;
|
||||
protected boolean durationRuleAtStart; // put duration rule at the start of the rules text rather than the end
|
||||
protected boolean hasCDA;
|
||||
|
||||
/**
|
||||
* Becomes a creature retaining its previous types
|
||||
|
@ -50,7 +53,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
* @param duration Duration for the effect
|
||||
*/
|
||||
public BecomesCreatureSourceEffect(Token token, String theyAreStillType, Duration duration) {
|
||||
this(token, theyAreStillType, duration, false, false, false);
|
||||
this(token, theyAreStillType, duration, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +62,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
* @param duration Duration for the effect
|
||||
*/
|
||||
public BecomesCreatureSourceEffect(Token token, Duration duration) {
|
||||
this(token, "", duration, true, false, false);
|
||||
this(token, "", duration, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,17 +71,16 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
* @param duration Duration for the effect
|
||||
* @param losePreviousTypes if true, permanent loses its previous types
|
||||
* @param loseAbilities if true, permanent loses its other abilities
|
||||
* @param characterDefining if true, effect applies on layer 7a (it probably shouldn't)
|
||||
*/
|
||||
public BecomesCreatureSourceEffect(Token token, String theyAreStillType, Duration duration, boolean losePreviousTypes, boolean loseAbilities, boolean characterDefining) {
|
||||
public BecomesCreatureSourceEffect(Token token, String theyAreStillType, Duration duration, boolean losePreviousTypes, boolean loseAbilities) {
|
||||
super(duration, Outcome.BecomeCreature);
|
||||
this.characterDefining = characterDefining;
|
||||
this.token = token;
|
||||
this.theyAreStillType = theyAreStillType;
|
||||
this.losePreviousTypes = losePreviousTypes;
|
||||
this.loseAbilities = loseAbilities;
|
||||
this.durationRuleAtStart = (theyAreStillType != null && theyAreStillType.contains("planeswalker"));
|
||||
setText();
|
||||
this.hasCDA = checkTokenCDA();
|
||||
|
||||
this.addDependencyType(DependencyType.BecomeCreature);
|
||||
}
|
||||
|
@ -96,6 +98,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
this.toughness = effect.toughness.copy();
|
||||
}
|
||||
this.durationRuleAtStart = effect.durationRuleAtStart;
|
||||
this.hasCDA = effect.hasCDA;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -157,8 +160,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
break;
|
||||
|
||||
case PTChangingEffects_7:
|
||||
if ((sublayer == SubLayer.CharacteristicDefining_7a && isCharacterDefining())
|
||||
|| (sublayer == SubLayer.SetPT_7b && !isCharacterDefining())) {
|
||||
if ((sublayer == SubLayer.SetPT_7b) && !hasCDA) {
|
||||
if (power != null) {
|
||||
permanent.getPower().setModifiedBaseValue(power.calculate(game, source, this)); // check all other becomes to use calculate?
|
||||
} else if (token.getPower() != null) {
|
||||
|
@ -227,4 +229,20 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
|
|||
|| layer == Layer.TypeChangingEffects_4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the token contains a characteristic-defining ability in layer 7a.
|
||||
* If it does, then need to not overwrite P/T in layer 7b.
|
||||
* @return true if the token has a characteristic-defining ability
|
||||
*/
|
||||
private boolean checkTokenCDA() {
|
||||
for (Ability ability : token.getAbilities()) {
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
if (effect instanceof ContinuousEffect && ((ContinuousEffect) effect).getSublayer() == SubLayer.CharacteristicDefining_7a) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue