From f0e8041906d2edc05fb1939766c13d2ddfcdc8fa Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 14 Aug 2014 14:08:41 +0200 Subject: [PATCH] * Fixed a bug that winning with alternate win condition (e.g. Biovisionary) did not set game end date. That leads to a NPE in client. --- .../src/mage/sets/gatecrash/Biovisionary.java | 6 +- .../test/cards/triggers/BiovisionaryTest.java | 74 +++++++++++++++++++ Mage/src/mage/game/GameImpl.java | 2 +- 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/triggers/BiovisionaryTest.java diff --git a/Mage.Sets/src/mage/sets/gatecrash/Biovisionary.java b/Mage.Sets/src/mage/sets/gatecrash/Biovisionary.java index 66e170738b..c9f05343b9 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/Biovisionary.java +++ b/Mage.Sets/src/mage/sets/gatecrash/Biovisionary.java @@ -66,7 +66,11 @@ public class Biovisionary extends CardImpl { this.toughness = new MageInt(3); //At the beginning of the end step, if you control four or more creatures named Biovisionary, you win the game. - this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new WinGameSourceControllerEffect(), TargetController.ANY, new ControlsPermanentCondition(filter, ControlsPermanentCondition.CountType.MORE_THAN, 3), false)); + this.addAbility(new BeginningOfEndStepTriggeredAbility( + Zone.BATTLEFIELD, new WinGameSourceControllerEffect(), + TargetController.ANY, + new ControlsPermanentCondition(filter, ControlsPermanentCondition.CountType.MORE_THAN, 3), + false)); } public Biovisionary(final Biovisionary card) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/BiovisionaryTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/BiovisionaryTest.java new file mode 100644 index 0000000000..89e7a0caff --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/BiovisionaryTest.java @@ -0,0 +1,74 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package org.mage.test.cards.triggers; + +import junit.framework.Assert; +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + * + */ +public class BiovisionaryTest extends CardTestPlayerBase { + /** + * Biovisionary {1}{G}{U} + * Creature 2/3 + * At the beginning of the end step, if you control four or more creatures named Biovisionary, you win the game. + * + */ + + @Test + public void testFourWin() { + + addCard(Zone.BATTLEFIELD, playerA, "Biovisionary", 4); + + setStopAt(2, PhaseStep.UNTAP); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + assertPermanentCount(playerA, "Biovisionary", 4); + + Assert.assertTrue("Player B loses",playerB.hasLost()); + Assert.assertTrue("Player A wins with four Biovisionary",playerA.hasWon()); + + } + + @Test + public void testFourWithThreeClonesWin() { + addCard(Zone.BATTLEFIELD, playerA, "Island", 12); + addCard(Zone.BATTLEFIELD, playerA, "Biovisionary", 1); + + addCard(Zone.HAND, playerA, "Clone", 3); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Clone"); + setChoice(playerA, "Yes"); + setChoice(playerA, "Biovisionary"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Clone"); + setChoice(playerA, "Yes"); + setChoice(playerA, "Biovisionary"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Clone"); + setChoice(playerA, "Yes"); + setChoice(playerA, "Biovisionary"); + + setStopAt(2, PhaseStep.UNTAP); + execute(); + + assertLife(playerA, 20); + assertLife(playerB, 20); + + assertPermanentCount(playerA, "Biovisionary", 4); + Assert.assertTrue("Player B loses",playerB.hasLost()); + Assert.assertTrue("Player A wins with four Biovisionary",playerA.hasWon()); + + } +} diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index 899d897297..aeb08d6b3c 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -459,7 +459,6 @@ public abstract class GameImpl implements Game, Serializable { player.won(this); } } - endTime = new Date(); return true; } return false; @@ -869,6 +868,7 @@ public abstract class GameImpl implements Game, Serializable { @Override public void end() { if (!state.isGameOver()) { + endTime = new Date(); state.endGame(); for (Player player: state.getPlayers().values()) { player.abort();