* 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.

This commit is contained in:
LevelX2 2014-08-14 14:08:41 +02:00
parent 484a4fe0f6
commit f0e8041906
3 changed files with 80 additions and 2 deletions

View file

@ -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) {

View file

@ -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());
}
}

View file

@ -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();