Act of Heroism fixes (#3608)

* Adding test case for Act of Heroism

* Fixing Act of Heroism mana cost

* Adding can block additional creature effect that applies to spell/ability target rather than source

* Updating Act of Heroism to use new effect

* Removing redundant assertion, adding some comments
This commit is contained in:
Matthew Zulch 2017-07-07 17:53:06 -07:00 committed by Jeff Wadsworth
parent af79f02ac0
commit 51595dbedf
3 changed files with 136 additions and 9 deletions

View file

@ -27,20 +27,18 @@
*/
package mage.cards.a;
import java.util.UUID;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.UntapTargetEffect;
import mage.abilities.effects.common.combat.CanBlockAdditionalCreatureEffect;
import mage.abilities.effects.common.combat.CanBlockAdditionalCreatureTargetEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author Archer262
@ -48,19 +46,21 @@ import mage.target.common.TargetCreaturePermanent;
public class ActOfHeroism extends CardImpl {
public ActOfHeroism(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}");
// Untap target creature.
Effect effect = new UntapTargetEffect();
effect.setText("Untap target creature");
this.getSpellAbility().addEffect(effect);
// It gets +2/+2 and can block an additional creature this turn.
// It gets +2/+2 until end of turn
effect = new BoostTargetEffect(2, 2, Duration.EndOfTurn);
effect.setText("It gets +2/+2");
this.getSpellAbility().addEffect(effect);
effect = new GainAbilityTargetEffect(new SimpleStaticAbility(Zone.BATTLEFIELD, new CanBlockAdditionalCreatureEffect()), Duration.EndOfTurn);
effect.setText("and can block an additional creature this turn");
// and can block an additional creature this turn
effect = new CanBlockAdditionalCreatureTargetEffect();
effect.setText("and can block an additional creature this turn.");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent());

View file

@ -0,0 +1,43 @@
package org.mage.test.cards.continuous;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author mzulch
*/
public class ActOfHeroismTest extends CardTestPlayerBase {
// Test that loss of abilities doesn't remove Act of Heroism's "block an additional creature" effect
@Test
public void testCanBlockMultiple() {
// 0/4 Creature - Camel
addCard(Zone.BATTLEFIELD, playerA, "Tasseled Dromedary");
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.HAND, playerA, "Act of Heroism");
addCard(Zone.BATTLEFIELD, playerB, "Unwavering Initiate");
addCard(Zone.BATTLEFIELD, playerB, "Sacred Cat");
addCard(Zone.BATTLEFIELD, playerB, "Plains", 8);
addCard(Zone.HAND, playerB, "Overwhelming Splendor");
// Untap target creature. It gets +2/+2 until end of turn and can block an additional creature this turn
castSpell(2, PhaseStep.UPKEEP, playerA, "Act of Heroism", "Tasseled Dromedary");
// Creatures enchanted player controls loses all abilities and have base power and toughness 1/1
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Overwhelming Splendor", playerA);
attack(2, playerB, "Unwavering Initiate");
attack(2, playerB, "Sacred Cat");
block(2, playerA, "Tasseled Dromedary", "Unwavering Initiate");
block(2, playerA, "Tasseled Dromedary", "Sacred Cat");
setStopAt(2, PhaseStep.COMBAT_DAMAGE);
// Fails if A's creature is unable to block both attackers
execute();
}
}

View file

@ -0,0 +1,84 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.util.CardUtil;
/**
* @author mzulch
*/
public class CanBlockAdditionalCreatureTargetEffect extends ContinuousEffectImpl {
protected int amount;
public CanBlockAdditionalCreatureTargetEffect() {
this(Duration.EndOfTurn, 1);
}
public CanBlockAdditionalCreatureTargetEffect(Duration duration, int amount) {
super(duration, Outcome.Benefit);
this.amount = amount;
staticText = setText();
}
public CanBlockAdditionalCreatureTargetEffect(final CanBlockAdditionalCreatureTargetEffect effect) {
super(effect);
this.amount = effect.amount;
}
@Override
public CanBlockAdditionalCreatureTargetEffect copy() {
return new CanBlockAdditionalCreatureTargetEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent target = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (target == null) {
return false;
}
// maxBlocks = 0 equals to "can block any number of creatures"
if (amount > 0) {
target.setMaxBlocks(target.getMaxBlocks() + amount);
} else {
target.setMaxBlocks(0);
}
return true;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
private String setText() {
String text = "target can block ";
switch (amount) {
case 0:
text += "any number of creatures";
break;
default:
text += CardUtil.numberToText(amount, "an") + " additional creature" + (amount > 1 ? "s" : "");
}
if (duration == Duration.EndOfTurn) {
text += " this turn";
}
if (duration == Duration.WhileOnBattlefield) {
text += " each combat";
}
return text;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.RulesEffects;
}
}