Fixed few bugs with transform effect. +4 tests pass. Some transform cards should be refactored.

This commit is contained in:
magenoxx 2012-06-01 21:08:29 +04:00
parent 47cf770318
commit 04379e7c99
9 changed files with 141 additions and 22 deletions

View file

@ -27,17 +27,13 @@
*/
package mage.sets.innistrad;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.TargetController;
import mage.Constants.Zone;
import mage.Constants.*;
import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.TransformedCondition;
import mage.abilities.condition.common.TwoOrMoreSpellsWereCastLastTurnCondition;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.effects.common.CreateTokenEffect;
@ -49,12 +45,16 @@ import mage.filter.Filter.ComparisonScope;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.permanent.token.WolfToken;
import java.util.UUID;
/**
*
* @author North
* @author North, noxx
*/
public class HowlpackAlpha extends CardImpl<HowlpackAlpha> {
private static final String ruleText = "At the beginning of your end step, put a 2/2 green Wolf creature token onto the battlefield";
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Werewolf and Wolf creatures");
static {
@ -79,7 +79,8 @@ public class HowlpackAlpha extends CardImpl<HowlpackAlpha> {
// Other Werewolf and Wolf creatures you control get +1/+1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter, true)));
// At the beginning of your end step, put a 2/2 green Wolf creature token onto the battlefield.
this.addAbility(new BeginningOfYourEndStepTriggeredAbility(new CreateTokenEffect(new WolfToken()), false));
this.addAbility(new ConditionalTriggeredAbility(new BeginningOfYourEndStepTriggeredAbility(new CreateTokenEffect(new WolfToken()), false), new TransformedCondition(), ruleText));
// At the beginning of each upkeep, if a player cast two or more spells last turn, transform Howlpack Alpha.
TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(new TransformSourceEffect(false), TargetController.ANY, false);
this.addAbility(new ConditionalTriggeredAbility(ability, TwoOrMoreSpellsWereCastLastTurnCondition.getInstance(), TransformAbility.TWO_OR_MORE_SPELLS_TRANSFORM_RULE));

View file

@ -27,18 +27,17 @@
*/
package mage.sets.innistrad;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.TargetController;
import mage.Constants.Zone;
import mage.Constants.*;
import mage.MageInt;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.InvertCondition;
import mage.abilities.condition.common.NoSpellsWereCastLastTurnCondition;
import mage.abilities.condition.common.TransformedCondition;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.TransformSourceEffect;
import mage.abilities.effects.common.continious.BoostControlledEffect;
import mage.abilities.keyword.TransformAbility;
@ -46,12 +45,16 @@ import mage.cards.CardImpl;
import mage.filter.Filter.ComparisonScope;
import mage.filter.common.FilterCreaturePermanent;
import java.util.UUID;
/**
*
* @author North
* @author North, noxx
*/
public class MayorOfAvabruck extends CardImpl<MayorOfAvabruck> {
private static final String ruleText = "Other Human creatures you control get +1/+1";
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Human creatures");
static {
@ -74,7 +77,9 @@ public class MayorOfAvabruck extends CardImpl<MayorOfAvabruck> {
this.toughness = new MageInt(1);
// Other Human creatures you control get +1/+1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter, true)));
Effect effect = new ConditionalContinousEffect(new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter, true), new InvertCondition(new TransformedCondition()), ruleText);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
// At the beginning of each upkeep, if no spells were cast last turn, transform Mayor of Avabruck.
this.addAbility(new TransformAbility());
TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(new TransformSourceEffect(true), TargetController.ANY, false);

View file

@ -78,7 +78,7 @@ public class TwoFacedCardEffectsTest extends CardTestPlayerBase {
execute();
assertHandCount(playerA, 2);
assertHandCount(playerB, 1);
assertHandCount(playerB, 2);
// should transform - original
assertPermanentCount(playerA, "Howlpack Alpha", 1);

View file

@ -0,0 +1,59 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
/**
* A simple {@link mage.abilities.condition.Condition} to invert a decorated conditions
* {@link mage.abilities.condition.Condition#apply(mage.game.Game, mage.abilities.Ability) apply(mage.game.Game, mage.abilities.Ability)}
* method invocation.
*
* The copy for {@link UnlessCondition}.
*
* @author noxx
*/
public class InvertCondition implements Condition {
private Condition condition;
public InvertCondition(Condition condition) {
this.condition = condition;
}
/*
* {@inheritDoc}
*/
@Override
public boolean apply(Game game, Ability source) {
return !condition.apply(game, source);
}
}

View file

@ -0,0 +1,47 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
/**
*
* @author noxx
*/
public class TransformedCondition implements Condition {
public TransformedCondition() {
}
@Override
public boolean apply(Game game, Ability source) {
return game.getPermanent(source.getSourceId()).isTransformed();
}
}

View file

@ -28,11 +28,7 @@
package mage.abilities.effects.common;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Layer;
import mage.Constants.Outcome;
import mage.Constants.SubLayer;
import mage.Constants.*;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
@ -94,6 +90,10 @@ public class CopyEffect extends ContinuousEffectImpl<CopyEffect> {
}
permanent.getPower().setValue(target.getPower().getValue());
permanent.getToughness().setValue(target.getToughness().getValue());
if (target instanceof Permanent) {
permanent.setTransformed(((Permanent)target).isTransformed());
permanent.setSecondCardFace(((Permanent) target).getSecondCardFace());
}
return true;
}

View file

@ -62,6 +62,7 @@ public interface Card extends MageObject {
public boolean canTransform();
public Card getSecondCardFace();
public void setSecondCardFace(Card card);
public boolean isNightCard();
public void assignNewId();

View file

@ -410,6 +410,11 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
return this.secondSideCard;
}
@Override
public void setSecondCardFace(Card card) {
this.secondSideCard = card;
}
@Override
public boolean isNightCard() {
return this.nightCard;

View file

@ -738,6 +738,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
@Override
public void copyPermanent(Permanent copyFromPermanent, Permanent copyToPermanent, Ability source, ApplyToPermanent applier) {
Permanent permanent = copyFromPermanent.copy();
//getState().addCard(permanent);
permanent.reset(this);
permanent.assignNewId();