mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
* Fixed a problem with selecting cards from other players hand, failing because canTarget check with wrong player id. Changed/simplified canTarget method of TargetCardInHand to solve that problem. (#6532 Gruesome Discovery and Distended Mindbender and probably other changed made with 75577cdbe9
).
This commit is contained in:
parent
d8bb67cffe
commit
e1c96efa1e
2 changed files with 45 additions and 2 deletions
|
@ -120,4 +120,45 @@ public class DiscardTest extends CardTestPlayerBase {
|
|||
|
||||
assertHandCount(playerB, "Driven // Despair", 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test a discard after selecting the cards from another player
|
||||
*/
|
||||
@Test
|
||||
public void GruesomeDiscoveryTest(){
|
||||
// Target player discards two cards.
|
||||
// Morbid - If a creature died this turn, instead that player reveals their hand,
|
||||
// you choose two cards from it, then that player discards those cards.
|
||||
addCard(Zone.HAND, playerA, "Gruesome Discovery", 1); // Sorcery {2}{B}{B}
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
|
||||
addCard(Zone.HAND, playerB, "Silvercoat Lion");
|
||||
addCard(Zone.HAND, playerB, "Aluren");
|
||||
addCard(Zone.HAND, playerB, "Contagion");
|
||||
|
||||
attack(3, playerA, "Silvercoat Lion");
|
||||
block(3, playerB, "Silvercoat Lion", "Silvercoat Lion");
|
||||
castSpell(3, PhaseStep.POSTCOMBAT_MAIN, playerA, "Gruesome Discovery", playerB);
|
||||
|
||||
setChoice(playerA, "Aluren^Contagion");
|
||||
|
||||
// addTarget(playerA, "Aluren");
|
||||
// addTarget(playerA, "Contagion");
|
||||
|
||||
setStopAt(3, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Silvercoat Lion", 1);
|
||||
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
|
||||
|
||||
assertGraveyardCount(playerA, "Gruesome Discovery", 1);
|
||||
|
||||
assertGraveyardCount(playerB, "Aluren", 1);
|
||||
assertGraveyardCount(playerB, "Contagion", 1);
|
||||
assertGraveyardCount(playerB, 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,10 @@ public class TargetCardInHand extends TargetCard {
|
|||
|
||||
@Override
|
||||
public boolean canTarget(UUID playerId, UUID id, Ability source, Game game) {
|
||||
Card card = game.getPlayer(playerId).getHand().get(id, game);
|
||||
return card != null && filter.match(card, source != null ? source.getSourceId() : null, playerId, game);
|
||||
// Has to be a card in the hand of a player in range. We don't know here, from which player's hand so we have to check all possible players
|
||||
// And because a card in hand is never targeted we can omitt specific targeting related checks
|
||||
return game.getState().getZone(id) == Zone.HAND
|
||||
&& game.getState().getPlayersInRange(getTargetController() == null ? playerId : getTargetController(), game).contains(game.getOwnerId(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue