Updated lose ability test and corresponding effects.

This commit is contained in:
magenoxx 2012-05-25 19:00:05 +04:00
parent 24b1b95b54
commit 1bb1df32b5
3 changed files with 8 additions and 5 deletions

View file

@ -74,7 +74,7 @@ public class LoseAbilityTest extends CardTestPlayerBase {
@Test @Test
public void testMultiGainVsLoseAbility() { public void testMultiGainVsLoseAbility() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Air Elemental"); addCard(Constants.Zone.BATTLEFIELD, playerA, "Air Elemental");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Forest", 5); addCard(Constants.Zone.BATTLEFIELD, playerA, "Forest", 10);
addCard(Constants.Zone.HAND, playerA, "Grounded"); addCard(Constants.Zone.HAND, playerA, "Grounded");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 10); addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 10);
addCard(Constants.Zone.HAND, playerA, "Drake Umbra", 2); addCard(Constants.Zone.HAND, playerA, "Drake Umbra", 2);
@ -83,7 +83,7 @@ public class LoseAbilityTest extends CardTestPlayerBase {
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Drake Umbra", "Air Elemental"); castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Drake Umbra", "Air Elemental");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Grounded", "Air Elemental"); castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Grounded", "Air Elemental");
setStopAt(2, Constants.PhaseStep.END_TURN); setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute(); execute();
assertLife(playerA, 20); assertLife(playerA, 20);
@ -92,7 +92,7 @@ public class LoseAbilityTest extends CardTestPlayerBase {
Permanent airElemental = getPermanent("Air Elemental", playerA.getId()); Permanent airElemental = getPermanent("Air Elemental", playerA.getId());
Assert.assertNotNull(airElemental); Assert.assertNotNull(airElemental);
Assert.assertTrue(airElemental.getAttachments().size() == 3); Assert.assertEquals(3, airElemental.getAttachments().size());
// should NOT have flying // should NOT have flying
Assert.assertFalse(airElemental.getAbilities().contains(FlyingAbility.getInstance())); Assert.assertFalse(airElemental.getAbilities().contains(FlyingAbility.getInstance()));
} }

View file

@ -70,8 +70,9 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl<GainAbilityA
Permanent equipment = game.getPermanent(source.getSourceId()); Permanent equipment = game.getPermanent(source.getSourceId());
if (equipment != null && equipment.getAttachedTo() != null) { if (equipment != null && equipment.getAttachedTo() != null) {
Permanent creature = game.getPermanent(equipment.getAttachedTo()); Permanent creature = game.getPermanent(equipment.getAttachedTo());
if (creature != null) if (creature != null) {
creature.addAbility(ability, game); creature.addAbility(ability, game);
}
} }
return true; return true;
} }

View file

@ -67,8 +67,10 @@ public class LoseAbilityAttachedEffect extends ContinuousEffectImpl<LoseAbilityA
if (equipment != null && equipment.getAttachedTo() != null) { if (equipment != null && equipment.getAttachedTo() != null) {
Permanent creature = game.getPermanent(equipment.getAttachedTo()); Permanent creature = game.getPermanent(equipment.getAttachedTo());
if (creature != null) { if (creature != null) {
while (creature.getAbilities().contains(ability)) {
creature.getAbilities().remove(ability); creature.getAbilities().remove(ability);
} }
}
} }
return true; return true;
} }