* Some more minor changes. Added test.

This commit is contained in:
LevelX2 2015-05-21 23:25:46 +02:00
parent 093b22081a
commit d7255f971c
5 changed files with 56 additions and 62 deletions

View file

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Config.xsd">
<server serverAddress="0.0.0.0" serverName="mage-server" port="17171" maxGameThreads="10" maxSecondsIdle="600"/>
<playerTypes>
<playerType name="Human" jar="mage-player-human.jar" className="mage.player.human.HumanPlayer"/>
<playerType name="Computer - minimax" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer3"/>
<playerType name="Computer - mad" jar="mage-player-ai-ma.jar" className="mage.player.ai.ComputerPlayer6"/>
<playerType name="Computer - monte carlo" jar="mage-player-aimcts.jar" className="mage.player.ai.ComputerPlayerMCTS"/>
</playerTypes>
<gameTypes>
<gameType name="Two Player Duel" jar="mage-game-twoplayerduel.jar" className="mage.game.TwoPlayerMatch" typeName="mage.game.TwoPlayerDuelType"/>
<gameType name="Free For All" jar="mage-game-freeforall.jar" className="mage.game.FreeForAllMatch" typeName="mage.game.FreeForAllType"/>
</gameTypes>
<tournamentTypes>
<tournamentType name="Elimination Booster Draft" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/>
<tournamentType name="Sealed Elimination" jar="mage-tournament-sealed.jar" className="mage.tournament.SealedEliminationTournament" typeName="mage.tournament.SealedEliminationTournamentType"/>
</tournamentTypes>
<deckTypes>
<deckType name="Constructed - Standard" jar="mage-deck-constructed.jar" className="mage.deck.Standard"/>
<deckType name="Constructed - Extended" jar="mage-deck-constructed.jar" className="mage.deck.Extended"/>
<deckType name="Constructed - Modern" jar="mage-deck-constructed.jar" className="mage.deck.Modern"/>
<deckType name="Constructed - Vintage" jar="mage-deck-constructed.jar" className="mage.deck.Vintage"/>
<deckType name="Constructed - Legacy" jar="mage-deck-constructed.jar" className="mage.deck.Legacy"/>
<deckType name="Block Constructed - Innistrad" jar="mage-deck-constructed.jar" className="mage.deck.InnistradBlock"/>
<deckType name="Block Constructed - Kamigawa" jar="mage-deck-constructed.jar" className="mage.deck.KamigawaBlock"/>
<deckType name="Block Constructed - Khans of Tarkir" jar="mage-deck-constructed.jar" className="mage.deck.KhansOfTarkirBlock"/>
<deckType name="Block Constructed - Return to Ravnica" jar="mage-deck-constructed.jar" className="mage.deck.ReturnToRavnicaBlock"/>
<deckType name="Block Constructed - Scars of Mirrodin" jar="mage-deck-constructed.jar" className="mage.deck.ScarsOfMirrodinBlock"/>
<deckType name="Block Constructed - Shadowmoore" jar="mage-deck-constructed.jar" className="mage.deck.ShadowmooreBlock"/>
<deckType name="Block Constructed - Shards of Alara" jar="mage-deck-constructed.jar" className="mage.deck.ShardsOfAlaraBlock"/>
<deckType name="Block Constructed - Zendikar" jar="mage-deck-constructed.jar" className="mage.deck.ZendikarBlock"/>
<deckType name="Variant Magic - Commander" jar="mage-deck-constructed.jar" className="mage.deck.Commander"/>
<deckType name="Limited" jar="mage-deck-limited.jar" className="mage.deck.Limited"/>
</deckTypes>
</config>

View file

@ -35,13 +35,13 @@ import mage.constants.Zone;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.events.ZoneChangeEvent; import mage.game.events.ZoneChangeEvent;
/** /**
@ -88,13 +88,12 @@ class GrafdiggersCageEffect extends ContinuousRuleModifyingEffectImpl {
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean checksEventType(GameEvent event, Game game) {
return true; return EventType.ZONE_CHANGE.equals(event.getType());
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event instanceof ZoneChangeEvent) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event; ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getToZone() == Zone.BATTLEFIELD && (zEvent.getFromZone() == Zone.GRAVEYARD || zEvent.getFromZone() == Zone.LIBRARY)) { if (zEvent.getToZone() == Zone.BATTLEFIELD && (zEvent.getFromZone() == Zone.GRAVEYARD || zEvent.getFromZone() == Zone.LIBRARY)) {
Card card = game.getCard(zEvent.getTargetId()); Card card = game.getCard(zEvent.getTargetId());
@ -102,7 +101,6 @@ class GrafdiggersCageEffect extends ContinuousRuleModifyingEffectImpl {
return true; return true;
} }
} }
}
return false; return false;
} }
@ -124,14 +122,14 @@ class GrafdiggersCageEffect2 extends ContinuousRuleModifyingEffectImpl {
return new GrafdiggersCageEffect2(this); return new GrafdiggersCageEffect2(this);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean checksEventType(GameEvent event, Game game) {
return true; return event.getType() == GameEvent.EventType.CAST_SPELL;
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL) {
Card card = game.getCard(event.getSourceId()); Card card = game.getCard(event.getSourceId());
if (card != null) { if (card != null) {
Zone zone = game.getState().getZone(card.getId()); Zone zone = game.getState().getZone(card.getId());
@ -139,7 +137,6 @@ class GrafdiggersCageEffect2 extends ContinuousRuleModifyingEffectImpl {
return true; return true;
} }
} }
}
return false; return false;
} }

View file

@ -114,8 +114,8 @@ class TargetTwoNonLandCardsWithSameNameInHand extends TargetCardInHand {
@Override @Override
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) { public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
Set<UUID> newPossibleTargets = new HashSet<UUID>(); Set<UUID> newPossibleTargets = new HashSet<>();
Set<UUID> possibleTargets = new HashSet<UUID>(); Set<UUID> possibleTargets = new HashSet<>();
Player player = game.getPlayer(sourceControllerId); Player player = game.getPlayer(sourceControllerId);
for (Card card : player.getHand().getCards(filter, game)) { for (Card card : player.getHand().getCards(filter, game)) {
possibleTargets.add(card.getId()); possibleTargets.add(card.getId());

View file

@ -12,9 +12,14 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class GrafdiggersCageTest extends CardTestPlayerBase { public class GrafdiggersCageTest extends CardTestPlayerBase {
@Test @Test
public void testCard() { public void testCard1() {
// Creature cards can't enter the battlefield from graveyards or libraries.
// Players can't cast cards in graveyards or libraries.
addCard(Zone.BATTLEFIELD, playerA, "Grafdigger's Cage"); addCard(Zone.BATTLEFIELD, playerA, "Grafdigger's Cage");
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
// Put two 1/1 white Spirit creature tokens with flying onto the battlefield.
// Flashback {1}{B}
addCard(Zone.GRAVEYARD, playerA, "Lingering Souls"); addCard(Zone.GRAVEYARD, playerA, "Lingering Souls");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Flashback {1}{B}"); activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Flashback {1}{B}");
@ -28,7 +33,7 @@ public class GrafdiggersCageTest extends CardTestPlayerBase {
} }
@Test @Test
public void testCard1() { public void testCard2() {
addCard(Zone.BATTLEFIELD, playerA, "Grafdigger's Cage"); addCard(Zone.BATTLEFIELD, playerA, "Grafdigger's Cage");
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 5); addCard(Zone.BATTLEFIELD, playerA, "Swamp", 5);
addCard(Zone.HAND, playerA, "Rise from the Grave", 1); addCard(Zone.HAND, playerA, "Rise from the Grave", 1);
@ -45,4 +50,33 @@ public class GrafdiggersCageTest extends CardTestPlayerBase {
assertGraveyardCount(playerA, "Rise from the Grave", 1); assertGraveyardCount(playerA, "Rise from the Grave", 1);
} }
/**
* With a Grafdigger's Cage in play you can still announce Cabal Therapy and pay it's flashback cost - resulting
* in a sacrificed creature (and any triggers along with that) and a Cabal Therapy still in the graveyard.
*
* Don't get me wrong, I love sacrificing 2-3 Veteran Explorer to the same Cabal Therapy, but it's just not all that fair.
*
* Same thing goes for cards like Ethersworn Canonist, assuming that the flashback isn't the first non-artifact spell for the turn.
*/
@Test
public void testCard3() {
// Creature cards can't enter the battlefield from graveyards or libraries.
// Players can't cast cards in graveyards or libraries.
addCard(Zone.BATTLEFIELD, playerA, "Grafdigger's Cage");
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 2);
// Name a nonland card. Target player reveals his or her hand and discards all cards with that name.
// Flashback-Sacrifice a creature. (You may cast this card from your graveyard for its flashback cost. Then exile it.)
addCard(Zone.GRAVEYARD, playerA, "Cabal Therapy");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Flashback");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Silvercoat Lion", 2);
assertGraveyardCount(playerA, "Cabal Therapy", 1);
}
} }

View file

@ -31,7 +31,6 @@ package mage.abilities.effects.common;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;