Added handling to make it possible that a transformable card can enter the battlefield transformed.

This commit is contained in:
LevelX2 2015-06-16 17:01:15 +02:00
parent d8df53dde7
commit 27929cccba
3 changed files with 17 additions and 0 deletions

View file

@ -18,6 +18,12 @@ public class TwoFacedCardEffectsTest extends CardTestPlayerBase {
*/
@Test
public void testEffectTurnedOffOnTransform() {
// Other Human creatures you control get +1/+1.
// At the beginning of each upkeep, if no spells were cast last turn, transform Mayor of Avabruck.
// Howlpack Alpha (transformed side) ----------------
// Each other creature you control that's a Werewolf or a Wolf gets +1/+1.
// At the beginning of your end step, put a 2/2 green Wolf creature token onto the battlefield.
// At the beginning of each upkeep, if a player cast two or more spells last turn, transform Howlpack Alpha.
addCard(Zone.BATTLEFIELD, playerA, "Mayor of Avabruck");
addCard(Zone.BATTLEFIELD, playerA, "Wolfir Avenger");
addCard(Zone.BATTLEFIELD, playerA, "Elite Inquisitor");

View file

@ -44,6 +44,9 @@ public class TransformAbility extends SimpleStaticAbility {
public static final String NO_SPELLS_TRANSFORM_RULE = "At the beginning of each upkeep, if no spells were cast last turn, transform {this}.";
public static final String TWO_OR_MORE_SPELLS_TRANSFORM_RULE = "At the beginning of each upkeep, if a player cast two or more spells last turn, transform {this}.";
// this state value controlls if a permanent enters the battlefield already transformed
public static final String VALUE_KEY_ENTER_TRANSFORMED = "EnterTransformed";
public TransformAbility() {
super(Zone.BATTLEFIELD, new TransformEffect());
}

View file

@ -33,6 +33,7 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.keyword.TransformAbility;
import mage.cards.Card;
import mage.cards.LevelerCard;
import mage.constants.Zone;
@ -65,6 +66,13 @@ public class PermanentCard extends PermanentImpl {
if (card instanceof LevelerCard) {
maxLevelCounters = ((LevelerCard) card).getMaxLevelCounters();
}
if (canTransform()) {
if (game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + getId()) != null) {
game.getState().setValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + getId(), null);
setTransformed(true);
TransformAbility.transform(this, getSecondCardFace(), game);
}
}
}
public PermanentCard(final PermanentCard permanent) {