mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Added magamorph handling to morph ability.
This commit is contained in:
parent
21187ef818
commit
004d6755e3
3 changed files with 46 additions and 12 deletions
|
@ -38,6 +38,7 @@ import mage.cards.Card;
|
|||
import mage.constants.AbilityType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
@ -50,8 +51,12 @@ import mage.players.Player;
|
|||
public class TurnFaceUpAbility extends SpecialAction {
|
||||
|
||||
public TurnFaceUpAbility(Costs<Cost> costs) {
|
||||
this(costs, false);
|
||||
}
|
||||
|
||||
public TurnFaceUpAbility(Costs<Cost> costs, boolean megamorph) {
|
||||
super(Zone.BATTLEFIELD);
|
||||
this.addEffect(new TurnFaceUpEffect());
|
||||
this.addEffect(new TurnFaceUpEffect(megamorph));
|
||||
this.addCost(costs);
|
||||
this.usesStack = false;
|
||||
this.abilityType = AbilityType.SPECIAL_ACTION;
|
||||
|
@ -70,13 +75,17 @@ public class TurnFaceUpAbility extends SpecialAction {
|
|||
|
||||
class TurnFaceUpEffect extends OneShotEffect {
|
||||
|
||||
public TurnFaceUpEffect() {
|
||||
private final boolean megamorph;
|
||||
|
||||
public TurnFaceUpEffect(boolean megamorph) {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Turn this face-down permanent face up";
|
||||
this.staticText = "Turn this face-down permanent face up" +(megamorph ? " and put a +1/+1 counter on it":"");
|
||||
this.megamorph = megamorph;
|
||||
}
|
||||
|
||||
public TurnFaceUpEffect(final TurnFaceUpEffect effect) {
|
||||
super(effect);
|
||||
this.megamorph = effect.megamorph;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,8 +101,9 @@ class TurnFaceUpEffect extends OneShotEffect {
|
|||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
if (sourcePermanent.turnFaceUp(game, source.getControllerId())) {
|
||||
game.informPlayers(controller.getName() + " pays the costs of " + card.getLogName() + " to turn it face up");
|
||||
|
||||
if (megamorph) {
|
||||
sourcePermanent.addCounters(CounterType.P1P1.createInstance(), game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
|||
|
||||
public enum FaceDownType {
|
||||
MORPHED,
|
||||
MEGAMORPHED,
|
||||
MANIFESTED
|
||||
}
|
||||
|
||||
|
@ -89,7 +90,7 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
|||
this.objectReference = objectReference;
|
||||
this.zoneChangeCounter = Integer.MIN_VALUE;
|
||||
if (turnFaceUpCosts != null) {
|
||||
this.turnFaceUpAbility = new TurnFaceUpAbility(turnFaceUpCosts);
|
||||
this.turnFaceUpAbility = new TurnFaceUpAbility(turnFaceUpCosts, faceDownType.equals(FaceDownType.MEGAMORPHED));
|
||||
}
|
||||
staticText = "{this} becomes a 2/2 face-down creature, with no text, no name, no subtypes, and no mana cost";
|
||||
foundPermanent = false;
|
||||
|
@ -139,6 +140,7 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
|||
permanent.setManifested(true);
|
||||
break;
|
||||
case MORPHED:
|
||||
case MEGAMORPHED:
|
||||
permanent.setMorphed(true);
|
||||
break;
|
||||
}
|
||||
|
@ -176,7 +178,7 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
|||
}
|
||||
permanent.getAbilities().removeAll(abilities);
|
||||
if (turnFaceUpAbility != null) {
|
||||
permanent.addAbility(turnFaceUpAbility, game);
|
||||
permanent.addAbility(turnFaceUpAbility, source.getSourceId(), game);
|
||||
}
|
||||
break;
|
||||
case PTChangingEffects_7:
|
||||
|
|
|
@ -96,25 +96,41 @@ import mage.players.Player;
|
|||
public class MorphAbility extends StaticAbility implements AlternativeSourceCosts {
|
||||
|
||||
protected static final String ABILITY_KEYWORD = "Morph";
|
||||
protected static final String ABILITY_KEYWORD_MEGA = "Megamorph";
|
||||
protected static final String REMINDER_TEXT = "<i>(You may cast this card face down as a 2/2 creature for {3}. Turn it face up any time for its morph cost.)</i>";
|
||||
protected static final String REMINDER_TEXT_MEGA = "<i>(You may cast this card face down as a 2/2 creature for {3}. Turn it face up at any time for its megamorph cost and put a +1/+1 counter on it.)</i>";
|
||||
protected String ruleText;
|
||||
protected AlternativeCost2Impl alternateCosts = new AlternativeCost2Impl(ABILITY_KEYWORD, REMINDER_TEXT, new GenericManaCost(3));
|
||||
protected Costs<Cost> morphCosts;
|
||||
// needed to check activation status, if card changes zone after casting it
|
||||
private int zoneChangeCounter = 0;
|
||||
|
||||
private boolean megamorph;
|
||||
|
||||
public MorphAbility(Card card, Cost morphCost) {
|
||||
this(card, createCosts(morphCost));
|
||||
}
|
||||
|
||||
public MorphAbility(Card card, Cost morphCost, boolean megamorph) {
|
||||
this(card, createCosts(morphCost), megamorph);
|
||||
}
|
||||
|
||||
public MorphAbility(Card card, Costs<Cost> morphCosts) {
|
||||
this(card, morphCosts, false);
|
||||
}
|
||||
|
||||
public MorphAbility(Card card, Costs<Cost> morphCosts, boolean megamorph) {
|
||||
super(Zone.HAND, null);
|
||||
this.morphCosts = morphCosts;
|
||||
this.megamorph = megamorph;
|
||||
card.setMorphCard(true);
|
||||
this.setWorksFaceDown(true);
|
||||
name = ABILITY_KEYWORD;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(ABILITY_KEYWORD).append(" ");
|
||||
if (megamorph) {
|
||||
sb.append(ABILITY_KEYWORD_MEGA).append(" ");
|
||||
} else {
|
||||
sb.append(ABILITY_KEYWORD).append(" ");
|
||||
}
|
||||
name = ABILITY_KEYWORD;
|
||||
for (Cost cost :morphCosts) {
|
||||
if (!(cost instanceof ManaCosts)) {
|
||||
sb.append("- ");
|
||||
|
@ -122,10 +138,15 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
|
|||
}
|
||||
}
|
||||
sb.append(morphCosts.getText()).append(" ");
|
||||
sb.append(REMINDER_TEXT);
|
||||
if (megamorph) {
|
||||
sb.append(REMINDER_TEXT_MEGA);
|
||||
} else {
|
||||
sb.append(REMINDER_TEXT);
|
||||
}
|
||||
|
||||
ruleText = sb.toString();
|
||||
|
||||
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesFaceDownCreatureEffect(morphCosts, FaceDownType.MORPHED));
|
||||
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesFaceDownCreatureEffect(morphCosts, (megamorph ? FaceDownType.MEGAMORPHED :FaceDownType.MORPHED)));
|
||||
ability.setWorksFaceDown(true);
|
||||
ability.setRuleVisible(false);
|
||||
card.addAbility(ability);
|
||||
|
@ -138,6 +159,7 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
|
|||
this.ruleText = ability.ruleText;
|
||||
this.alternateCosts = ability.alternateCosts.copy();
|
||||
this.morphCosts = ability.morphCosts; // can't be changed
|
||||
this.megamorph = ability.megamorph;
|
||||
}
|
||||
|
||||
private static Costs<Cost> createCosts(Cost cost) {
|
||||
|
|
Loading…
Reference in a new issue