From 004d6755e36c8ec3ef2b64639ee5ae9a2c8c051e Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 6 Mar 2015 13:55:39 +0100 Subject: [PATCH] * Added magamorph handling to morph ability. --- .../abilities/common/TurnFaceUpAbility.java | 20 +++++++++--- .../BecomesFaceDownCreatureEffect.java | 6 ++-- .../mage/abilities/keyword/MorphAbility.java | 32 ++++++++++++++++--- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/Mage/src/mage/abilities/common/TurnFaceUpAbility.java b/Mage/src/mage/abilities/common/TurnFaceUpAbility.java index c61a260c63..0b6b9e0a0d 100644 --- a/Mage/src/mage/abilities/common/TurnFaceUpAbility.java +++ b/Mage/src/mage/abilities/common/TurnFaceUpAbility.java @@ -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 costs) { + this(costs, false); + } + + public TurnFaceUpAbility(Costs 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; } } diff --git a/Mage/src/mage/abilities/effects/common/continuous/BecomesFaceDownCreatureEffect.java b/Mage/src/mage/abilities/effects/common/continuous/BecomesFaceDownCreatureEffect.java index b78f87fa0d..5bb7edbdfa 100644 --- a/Mage/src/mage/abilities/effects/common/continuous/BecomesFaceDownCreatureEffect.java +++ b/Mage/src/mage/abilities/effects/common/continuous/BecomesFaceDownCreatureEffect.java @@ -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: diff --git a/Mage/src/mage/abilities/keyword/MorphAbility.java b/Mage/src/mage/abilities/keyword/MorphAbility.java index 89a465528e..6fe4083dbc 100644 --- a/Mage/src/mage/abilities/keyword/MorphAbility.java +++ b/Mage/src/mage/abilities/keyword/MorphAbility.java @@ -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 = "(You may cast this card face down as a 2/2 creature for {3}. Turn it face up any time for its morph cost.)"; + protected static final String REMINDER_TEXT_MEGA = "(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.)"; protected String ruleText; protected AlternativeCost2Impl alternateCosts = new AlternativeCost2Impl(ABILITY_KEYWORD, REMINDER_TEXT, new GenericManaCost(3)); protected Costs 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 morphCosts) { + this(card, morphCosts, false); + } + + public MorphAbility(Card card, Costs 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 createCosts(Cost cost) {