mirror of
https://github.com/correl/mage.git
synced 2024-11-14 19:19:32 +00:00
* Fixed problems with win / lose restrictions in relation to empty draw condition (fixes #1681 #6553).
This commit is contained in:
parent
37f7389c17
commit
3aefbfb360
13 changed files with 107 additions and 34 deletions
|
@ -90,14 +90,14 @@ class JaceWielderOfMysteriesContinuousEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.EMPTY_DRAW;
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getPlayerId().equals(source.getControllerId())) {
|
||||
Player player = game.getPlayer(event.getPlayerId());
|
||||
if (player != null && !player.hasLost() && player.isEmptyDraw()) {
|
||||
if (player != null && !player.hasLost() && !player.getLibrary().hasCards()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,14 +79,14 @@ class LaboratoryManiacEffect extends ReplacementEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.EMPTY_DRAW;
|
||||
return event.getType() == EventType.DRAW_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getPlayerId().equals(source.getControllerId())) {
|
||||
Player player = game.getPlayer(event.getPlayerId());
|
||||
if (player != null && !player.hasLost() && player.isEmptyDraw()) {
|
||||
if (player != null && !player.hasLost() && !player.getLibrary().hasCards()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,8 +63,7 @@ class TreasureKeeperEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Boolean cardWasCast = false;
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null
|
||||
&& !controller.getLibrary().isEmptyDraw()) {
|
||||
if (controller != null && controller.getLibrary().hasCards()) {
|
||||
CardsImpl toReveal = new CardsImpl();
|
||||
Card nonLandCard = null;
|
||||
for (Card card : controller.getLibrary().getCards(game)) {
|
||||
|
|
|
@ -38,6 +38,10 @@ public class PlayerWinsTest extends CardTestMultiPlayerBase {
|
|||
/**
|
||||
* Tests multiplayer effects Player order: A -> D -> C -> B
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test that players out of range do not lose the game if effect from Approach of the Seconnd Sun takes effect.
|
||||
*/
|
||||
@Test
|
||||
public void ApproachOfTheSecondSunTest() {
|
||||
|
||||
|
@ -54,11 +58,103 @@ public class PlayerWinsTest extends CardTestMultiPlayerBase {
|
|||
|
||||
assertLife(playerA, 47);
|
||||
assertLife(playerC, 40);
|
||||
Assert.assertTrue("Player D has lost the game", !playerD.isInGame());
|
||||
Assert.assertTrue("Player B has lost the game", !playerB.isInGame());
|
||||
Assert.assertTrue("Player D still alive but should have lost the game", !playerD.isInGame());
|
||||
Assert.assertTrue("Player B still alive but should have lost the game", !playerB.isInGame());
|
||||
Assert.assertTrue("Player C is in the game", playerC.isInGame());
|
||||
Assert.assertTrue("Player A is in the game", playerA.isInGame());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that players out of range do not lose the game if effect from Laboratory Maniac takes effect.
|
||||
*/
|
||||
@Test
|
||||
public void LaboratoryManiacWinsTest() {
|
||||
// If you would draw a card while your library has no cards in it, you win the game instead.
|
||||
addCard(Zone.HAND, playerA, "Laboratory Maniac", 1); // Creature {2}{U}
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Laboratory Maniac");
|
||||
removeAllCardsFromLibrary(playerA);
|
||||
addCard(Zone.LIBRARY, playerA, "Mountain");
|
||||
|
||||
setStopAt(5, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Laboratory Maniac", 1);
|
||||
assertHandCount(playerA, "Mountain", 1);
|
||||
assertLibraryCount(playerA, 0);
|
||||
Assert.assertTrue("Player D still alive but should have lost the game", !playerD.isInGame());
|
||||
Assert.assertTrue("Player B still alive but should have lost the game", !playerB.isInGame());
|
||||
Assert.assertTrue("Player C should be in the game but has lost", playerC.isInGame());
|
||||
Assert.assertTrue("Player A should be in the game but has lost", playerA.isInGame());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that player can't win while Platinium Angel ist in range.
|
||||
*/
|
||||
@Test
|
||||
public void LaboratoryManiacAndPlatinumAngelInRangeTest() {
|
||||
// If you would draw a card while your library has no cards in it, you win the game instead.
|
||||
addCard(Zone.HAND, playerA, "Laboratory Maniac", 1); // Creature {2}{U}
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
|
||||
removeAllCardsFromLibrary(playerA);
|
||||
|
||||
// You can't lose the game and your opponents can't win the game.
|
||||
addCard(Zone.HAND, playerD, "Platinum Angel", 1); // Creature {2}{U}
|
||||
addCard(Zone.BATTLEFIELD, playerD, "Island", 7);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Laboratory Maniac");
|
||||
addCard(Zone.LIBRARY, playerA, "Mountain");
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerD, "Platinum Angel");
|
||||
|
||||
setStopAt(9, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Laboratory Maniac", 1);
|
||||
assertHandCount(playerA, "Mountain", 1);
|
||||
assertLibraryCount(playerA, 0);
|
||||
|
||||
assertPermanentCount(playerD, "Platinum Angel", 1);
|
||||
|
||||
Assert.assertTrue("Player D should be in the game but has lost", playerD.isInGame());
|
||||
Assert.assertTrue("Player B should be in the game but has lost", playerB.isInGame());
|
||||
Assert.assertTrue("Player C should be in the game but has lost", playerC.isInGame());
|
||||
Assert.assertTrue("Player A should be in the game but has lost", playerA.isInGame());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that player can't win while Platinium Angel ist in range.
|
||||
*/
|
||||
@Test
|
||||
public void LaboratoryManiacAndPlatinumAngelFirstOutOfRangeTest() {
|
||||
// If you would draw a card while your library has no cards in it, you win the game instead.
|
||||
addCard(Zone.HAND, playerA, "Laboratory Maniac", 1); // Creature {2}{U}
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
|
||||
removeAllCardsFromLibrary(playerA);
|
||||
|
||||
// You can't lose the game and your opponents can't win the game.
|
||||
addCard(Zone.HAND, playerC, "Platinum Angel", 1); // Creature {2}{U}
|
||||
addCard(Zone.BATTLEFIELD, playerC, "Island", 7);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Laboratory Maniac");
|
||||
addCard(Zone.LIBRARY, playerA, "Mountain");
|
||||
|
||||
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerC, "Platinum Angel");
|
||||
|
||||
setStopAt(9, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Laboratory Maniac", 1);
|
||||
assertHandCount(playerA, "Mountain", 1);
|
||||
assertLibraryCount(playerA, 0);
|
||||
|
||||
assertPermanentCount(playerC, "Platinum Angel", 1);
|
||||
|
||||
Assert.assertTrue("Player D still alive but should have lost the gamet", !playerD.isInGame());
|
||||
Assert.assertTrue("Player B still alive but should have lost the game", !playerB.isInGame());
|
||||
Assert.assertTrue("Player C should be in the game but has lost", playerC.isInGame());
|
||||
Assert.assertTrue("Player A should be in the game but has lost", playerA.isInGame());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2952,11 +2952,6 @@ public class TestPlayer implements Player {
|
|||
computerPlayer.pass(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmptyDraw() {
|
||||
return computerPlayer.isEmptyDraw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPassed() {
|
||||
computerPlayer.resetPassed();
|
||||
|
|
|
@ -288,11 +288,6 @@ public class PlayerStub implements Player {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmptyDraw() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pass(Game game) {
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public class LookLibraryMayPutToBottomEffect extends OneShotEffect {
|
|||
if (sourceObject == null || controller == null) {
|
||||
return false;
|
||||
}
|
||||
if (!controller.getLibrary().isEmptyDraw()) {
|
||||
if (controller.getLibrary().hasCards()) {
|
||||
Card card = controller.getLibrary().getFromTop(game);
|
||||
if (card == null) {
|
||||
return false;
|
||||
|
|
|
@ -61,12 +61,6 @@ public class MageDrawAction extends MageAction {
|
|||
if (!player.isTopCardRevealed() && numDrawn > 0) {
|
||||
game.fireInformEvent(player.getLogName() + " draws " + CardUtil.numberToText(numDrawn, "a") + " card" + (numDrawn > 1 ? "s" : ""));
|
||||
}
|
||||
if (player.isEmptyDraw()) {
|
||||
event = GameEvent.getEvent(GameEvent.EventType.EMPTY_DRAW, player.getId(), player.getId());
|
||||
if (!game.replaceEvent(event)) {
|
||||
game.doAction(new MageLoseGameAction(player, MageLoseGameAction.DRAW_REASON), sourceId);
|
||||
}
|
||||
}
|
||||
|
||||
setScore(player, score);
|
||||
game.setStateCheckRequired();
|
||||
|
|
|
@ -1848,7 +1848,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
for (Player player : state.getPlayers().values()) {
|
||||
if (!player.hasLost()
|
||||
&& ((player.getLife() <= 0 && player.canLoseByZeroOrLessLife())
|
||||
|| player.isEmptyDraw()
|
||||
|| player.getLibrary().isEmptyDraw()
|
||||
|| player.getCounters().getCount(CounterType.POISON) >= 10)) {
|
||||
player.lost(this);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ public class GameEvent implements Serializable {
|
|||
*/
|
||||
ZONE_CHANGE,
|
||||
ZONE_CHANGE_GROUP,
|
||||
EMPTY_DRAW,
|
||||
DRAW_CARDS, // applies to an instruction to draw more than one card before any replacement effects apply to individual cards drawn
|
||||
DRAW_CARD, DREW_CARD,
|
||||
EXPLORED,
|
||||
|
|
|
@ -239,6 +239,8 @@ public class Library implements Serializable {
|
|||
|
||||
/**
|
||||
* Tests only -- find card position in library
|
||||
* @param cardId
|
||||
* @return
|
||||
*/
|
||||
public int getCardPosition(UUID cardId) {
|
||||
UUID[] list = library.toArray(new UUID[0]);
|
||||
|
|
|
@ -152,8 +152,6 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
boolean isPassed();
|
||||
|
||||
boolean isEmptyDraw();
|
||||
|
||||
void pass(Game game);
|
||||
|
||||
void resetPassed();
|
||||
|
|
|
@ -2338,11 +2338,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
resetStoredBookmark(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmptyDraw() {
|
||||
return library.isEmptyDraw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPassed() {
|
||||
this.passed = this.loses || this.hasLeft();
|
||||
|
|
Loading…
Reference in a new issue