1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-02 03:18:09 -09:00

Implement AdventurePredicate.

This adds support for Edgewall Innkeeper (and similar cards) and Memory Theft.
This commit is contained in:
Patrick Hulin 2019-12-09 13:50:07 -05:00
parent 6160bc25ef
commit af5ccf6914
4 changed files with 152 additions and 52 deletions
Mage.Tests/src/test/java/org/mage/test/cards/cost/adventure
Mage/src/main/java/mage

View file

@ -0,0 +1,140 @@
package org.mage.test.cards.cost.adventure;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class AdventureCardsTest extends CardTestPlayerBase {
@Test
public void testCastTreatsToShare() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.HAND, playerA, "Curious Pair");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 0);
assertPermanentCount(playerA, "Food", 1);
assertExileCount(playerA, "Curious Pair", 1);
assertGraveyardCount(playerA,0);
assertAllCommandsUsed();
}
@Test
public void testCastCuriousPair() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.HAND, playerA, "Curious Pair");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 0);
assertPermanentCount(playerA, "Food", 0);
assertPermanentCount(playerA, "Curious Pair", 1);
assertExileCount(playerA, "Curious Pair", 0);
assertGraveyardCount(playerA,0);
assertAllCommandsUsed();
}
@Test
public void testCastTreatsToShareAndCuriousPair() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.HAND, playerA, "Curious Pair");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 0);
assertPermanentCount(playerA, "Food", 1);
assertPermanentCount(playerA, "Curious Pair", 1);
assertExileCount(playerA, "Curious Pair", 0);
assertGraveyardCount(playerA, 0);
assertAllCommandsUsed();
}
@Test
public void testCastTreatsToShareWithEdgewallInnkeeper() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Edgewall Innkeeper");
addCard(Zone.HAND, playerA, "Curious Pair");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 0);
assertPermanentCount(playerA, "Food", 1);
assertPermanentCount(playerA, "Curious Pair", 0);
assertExileCount(playerA, "Curious Pair", 1);
assertGraveyardCount(playerA, 0);
assertAllCommandsUsed();
}
@Test
public void testCastCuriousPairWithEdgewallInnkeeper() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Edgewall Innkeeper");
addCard(Zone.HAND, playerA, "Curious Pair");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 1);
assertPermanentCount(playerA, "Food", 0);
assertPermanentCount(playerA, "Curious Pair", 1);
assertExileCount(playerA, "Curious Pair", 0);
assertGraveyardCount(playerA,0);
assertAllCommandsUsed();
}
@Test
public void testCastTreatsToShareAndCuriousPairWithEdgewallInnkeeper() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Edgewall Innkeeper");
addCard(Zone.HAND, playerA, "Curious Pair");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 1);
assertPermanentCount(playerA, "Food", 1);
assertPermanentCount(playerA, "Curious Pair", 1);
assertExileCount(playerA, "Curious Pair", 0);
assertGraveyardCount(playerA, 0);
assertAllCommandsUsed();
}
@Test
public void testCastMemoryTheft() {
setStrictChooseMode(true);
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.HAND, playerA, "Curious Pair");
addCard(Zone.HAND, playerA, "Opt");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
addCard(Zone.BATTLEFIELD, playerB, "Swamp");
addCard(Zone.BATTLEFIELD, playerB, "Swamp");
addCard(Zone.BATTLEFIELD, playerB, "Swamp");
addCard(Zone.HAND, playerB, "Memory Theft");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Memory Theft", playerA);
playerB.addChoice("Opt");
playerB.addChoice("Curious Pair");
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 0);
assertExileCount(playerA, "Curious Pair", 0);
assertGraveyardCount(playerA, 2);
assertAllCommandsUsed();
}
}

View file

@ -1,50 +0,0 @@
package org.mage.test.cards.cost.adventure;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class CastAdventureCardsTest extends CardTestPlayerBase {
@Test
public void testCastTreatsToShare() {
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.HAND, playerA, "Curious Pair");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Food", 1);
assertExileCount(playerA, "Curious Pair", 1);
assertGraveyardCount(playerA,0);
}
@Test
public void testCastCuriousPair() {
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.HAND, playerA, "Curious Pair");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Food", 0);
assertPermanentCount(playerA, "Curious Pair", 1);
assertExileCount(playerA, "Curious Pair", 0);
assertGraveyardCount(playerA,0);
}
@Test
public void testCastTreatsToShareAndCuriousPair() {
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.BATTLEFIELD, playerA, "Forest");
addCard(Zone.HAND, playerA, "Curious Pair");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Food", 1);
assertPermanentCount(playerA, "Curious Pair", 1);
assertExileCount(playerA, "Curious Pair", 0);
assertGraveyardCount(playerA, 0);
}
}

View file

@ -7,6 +7,7 @@ package mage.cards;
import mage.constants.CardType;
import mage.constants.SpellAbilityType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
@ -23,6 +24,7 @@ public class AdventureCardSpellImpl extends CardImpl implements AdventureCardSpe
public AdventureCardSpellImpl(UUID ownerId, CardSetInfo setInfo, CardType[] cardTypes, String costs, AdventureCard adventureCardParent) {
super(ownerId, setInfo, cardTypes, costs, SpellAbilityType.ADVENTURE_SPELL);
this.subtype.add(SubType.ADVENTURE);
this.adventureCardParent = adventureCardParent;
}

View file

@ -1,19 +1,27 @@
package mage.filter.predicate.mageobject;
import mage.MageObject;
import mage.cards.AdventureCard;
import mage.cards.Card;
import mage.filter.predicate.Predicate;
import mage.game.Game;
import mage.game.stack.Spell;
/**
* @author TheElk801
* TODO: make this actually work
*/
public enum AdventurePredicate implements Predicate<MageObject> {
instance;
@Override
public boolean apply(MageObject input, Game game) {
return false;
if (input instanceof Spell) {
return ((Spell) input).getCard() instanceof AdventureCard;
} else if (input instanceof Card) {
return input instanceof AdventureCard;
} else {
return false;
}
}
@Override