This commit is contained in:
BetaSteward 2012-03-02 15:42:34 -05:00
parent ddf54e0139
commit 67fb349224
14 changed files with 766 additions and 20 deletions

View file

@ -0,0 +1,47 @@
package org.mage.test.ai.bugs;
import org.mage.test.cards.*;
import mage.Constants;
import mage.Constants.PhaseStep;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author BetaSteward
*/
public class TestHavengulLich extends CardTestPlayerBase {
@Test
public void testCard() {
addCard(Constants.Zone.GRAVEYARD, playerA, "Gravecrawler");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Black Cat");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Gravecrawler");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Gravecrawler", 1);
assertGraveyardCount(playerA, 0);
}
@Test
public void testCard1() {
addCard(Constants.Zone.GRAVEYARD, playerA, "Gravecrawler");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Gravecrawler");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Gravecrawler", 0);
assertGraveyardCount(playerA, 1);
}
}

View file

@ -0,0 +1,46 @@
package org.mage.test.cards;
import mage.Constants;
import mage.Constants.PhaseStep;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author BetaSteward
*/
public class TestGravecrawler extends CardTestPlayerBase {
@Test
public void testCard() {
addCard(Constants.Zone.GRAVEYARD, playerA, "Gravecrawler");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Black Cat");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Gravecrawler");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Gravecrawler", 1);
assertGraveyardCount(playerA, 0);
}
@Test
public void testCard1() {
addCard(Constants.Zone.GRAVEYARD, playerA, "Gravecrawler");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Gravecrawler");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Gravecrawler", 0);
assertGraveyardCount(playerA, 1);
}
}

View file

@ -0,0 +1,83 @@
package org.mage.test.cards;
import java.util.ArrayList;
import java.util.List;
import mage.Constants;
import mage.Constants.PhaseStep;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.target.common.TargetCreatureOrPlayer;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author BetaSteward
*/
public class TestHavengulLich extends CardTestPlayerBase {
@Test
public void testCard() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 4);
addCard(Constants.Zone.BATTLEFIELD, playerA, "Havengul Lich");
addCard(Constants.Zone.GRAVEYARD, playerA, "Prodigal Pyromancer");
activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{1}", "Prodigal Pyromancer");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Prodigal Pyromancer");
activateAbility(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "{T}", playerB);
setStopAt(1, Constants.PhaseStep.END_TURN);
execute();
assertLife(playerA, 20);
assertLife(playerB, 19);
assertPermanentCount(playerA, "Havengul Lich", 1);
assertPermanentCount(playerA, "Prodigal Pyromancer", 1);
assertTapped("Havengul Lich", true);
assertTapped("Prodigal Pyromancer", false);
assertGraveyardCount(playerA, 0);
}
@Test
public void testCard1() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp", 3);
addCard(Constants.Zone.BATTLEFIELD, playerA, "Havengul Lich");
addCard(Constants.Zone.GRAVEYARD, playerA, "Black Cat");
activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{1}", "Black Cat");
castSpell(3, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Black Cat");
setStopAt(3, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Havengul Lich", 1);
assertPermanentCount(playerA, "Black Cat", 0);
assertGraveyardCount(playerA, 1);
}
@Test
public void testCard2() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 4);
addCard(Constants.Zone.BATTLEFIELD, playerA, "Havengul Lich");
addCard(Constants.Zone.GRAVEYARD, playerA, "Prodigal Pyromancer");
activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{1}", "Prodigal Pyromancer");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Prodigal Pyromancer");
activateAbility(3, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{T}", playerB);
activateAbility(3, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{T}", playerB);
setStopAt(3, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 19);
assertPermanentCount(playerA, "Havengul Lich", 1);
assertPermanentCount(playerA, "Prodigal Pyromancer", 1);
assertTapped("Prodigal Pyromancer", true);
assertTapped("Havengul Lich", false);
assertGraveyardCount(playerA, 0);
}
}

View file

@ -0,0 +1,51 @@
package org.mage.test.cards;
import mage.Constants;
import mage.Constants.PhaseStep;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author BetaSteward
*/
public class TestImmerwolf extends CardTestPlayerBase {
@Test
public void testCard() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Afflicted Deserter");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Immerwolf");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Ornithopter");
setStopAt(2, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 17);
assertPermanentCount(playerB, "Ornithopter", 0);
assertPermanentCount(playerA, "Afflicted Deserter", 0);
assertPermanentCount(playerA, "Werewolf Ransacker", 1);
}
@Test
public void testCard1() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Afflicted Deserter");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Immerwolf");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Ornithopter");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Mountain", 2);
addCard(Constants.Zone.HAND, playerB, "Lightning Bolt", 2);
castSpell(2, Constants.PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", playerA);
castSpell(2, Constants.PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", playerA);
setStopAt(3, Constants.PhaseStep.DRAW);
execute();
assertLife(playerA, 14);
assertLife(playerB, 17);
assertPermanentCount(playerB, "Ornithopter", 0);
assertPermanentCount(playerA, "Afflicted Deserter", 0);
assertPermanentCount(playerA, "Werewolf Ransacker", 1);
}
}

View file

@ -45,5 +45,23 @@ public class TestWerewolfRansacker extends CardTestPlayerBase {
assertPermanentCount(playerA, "Blade Splicer", 1);
assertPermanentCount(playerA, "Golem", 0);
}
@Test
public void testCard2() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Afflicted Deserter");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Ornithopter");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Mountain", 2);
addCard(Constants.Zone.HAND, playerB, "Lightning Bolt", 2);
castSpell(2, Constants.PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", playerA);
castSpell(2, Constants.PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", playerA);
setStopAt(3, Constants.PhaseStep.DRAW);
execute();
assertLife(playerA, 14);
assertLife(playerB, 17);
assertPermanentCount(playerB, "Ornithopter", 0);
assertPermanentCount(playerA, "Afflicted Deserter", 1);
assertPermanentCount(playerA, "Werewolf Ransacker", 0);
}
}

View file

@ -34,8 +34,10 @@ import java.util.List;
import java.util.UUID;
import mage.Constants;
import mage.Constants.PhaseStep;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.cards.Card;
import mage.counters.Counter;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterAttackingCreature;
@ -175,17 +177,10 @@ public class TestPlayer extends ComputerPlayer<TestPlayer> {
target = group.substring(group.indexOf("target=") + 7);
String[] targets = target.split("\\^");
for (String t: targets) {
for (Permanent permanent: game.getBattlefield().getAllActivePermanents()) {
if (permanent.getName().equals(t)) {
ability.getTargets().get(0).addTarget(permanent.getId(), ability, game);
break;
}
}
Iterator<StackObject> it = game.getStack().iterator();
while (it.hasNext()) {
StackObject object = it.next();
if (object.getName().equals(t)) {
ability.getTargets().get(0).addTarget(object.getId(), ability, game);
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).addTarget(id, ability, game);
break;
}
}

View file

@ -504,7 +504,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
}
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, Player target) {
player.addAction(turnNum, step, "activate:" + ability + ";target=" + target.getName());
player.addAction(turnNum, step, "activate:" + ability + ";targetPlayer=" + target.getName());
}
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, String targetName) {