Fixed HeavyArbalest. +1 test passed.

This commit is contained in:
magenoxx 2012-05-23 22:26:58 +04:00
parent a96bb99199
commit 16c873dc2c
3 changed files with 14 additions and 5 deletions

View file

@ -41,6 +41,7 @@ import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreatureOrPlayer;
import java.util.UUID;
@ -108,7 +109,13 @@ class HeavyArbalestEffect extends ReplacementEffectImpl<HeavyArbalestEffect> {
if (game.getTurn().getStepType() == PhaseStep.UNTAP
&& event.getType() == EventType.UNTAP
&& event.getTargetId().equals(source.getSourceId())) {
return true;
Permanent p = game.getPermanent(source.getSourceId());
for (Ability ability : p.getAbilities()) {
if (ability.getRule().startsWith(staticText)) {
return true;
}
}
used = true;
}
return false;
}

View file

@ -37,17 +37,18 @@ public class HeavyArbalestTest extends CardTestPlayerBase {
}
/**
* Tests that creature with Heavy Arbalest will use it and untap later
* Tests that creature with Heavy Arbalest will use it and untap later after equip is equipped to another creature
*/
@Test
public void testUntapsLater() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 4);
addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 8);
addCard(Constants.Zone.BATTLEFIELD, playerA, "Heavy Arbalest");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Elite Vanguard");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Llanowar Elves");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Llanowar Elves");
activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Equip {4}", "Elite Vanguard");
activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: {source} deals 2 damage", playerB);
activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Equip {4}", "Llanowar Elves");
setStopAt(5, Constants.PhaseStep.BEGIN_COMBAT);
execute();
@ -56,7 +57,7 @@ public class HeavyArbalestTest extends CardTestPlayerBase {
assertLife(playerB, 18);
Permanent eliteVanguard = getPermanent("Elite Vanguard", playerA.getId());
Assert.assertTrue(eliteVanguard.getAttachments().size() > 0);
Assert.assertTrue(eliteVanguard.getAttachments().size() == 0);
Assert.assertFalse(eliteVanguard.isTapped());
}

View file

@ -230,6 +230,7 @@ public class TestPlayer extends ComputerPlayer<TestPlayer> {
for (UUID id: ability.getTargets().get(0).possibleTargets(ability.getSourceId(), ability.getControllerId(), game)) {
MageObject object = game.getObject(id);
if (object != null && object.getName().equals(t)) {
ability.getTargets().get(0).clearChosen();
ability.getTargets().get(0).addTarget(id, ability, game);
break;
}