foul-magics/Mage/src/main/java/mage/actions/MageLoseGameAction.java
Evan Kranzler 378dfbf89a
Updated implementation of Unpredictable Cyclone (#6423)
* updated implementation of Unpredictable Cyclone, refactored drawCard method

* fixed another small implementation error

* added test for Unpredictable Cyclone

* updated Unpredictable Cyclone test
2020-04-16 08:04:21 -04:00

46 lines
No EOL
1.3 KiB
Java

package mage.actions;
import mage.actions.impl.MageAction;
import mage.actions.score.ArtificialScoringSystem;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
* Lose game action.
*
* @author ayratn
*/
public class MageLoseGameAction extends MageAction {
public static final String LIFE_REASON = "{L} You lose the game.";
public static final String POISON_REASON = "{L} You are poisoned. You lose the game.";
public static final String DRAW_REASON = "{L} You attempt to draw from an empty library. You lose the game.";
private final Player player;
private final String reason;
private Player oldLosingPlayer;
public MageLoseGameAction(final Player player, final String reason) {
this.player = player;
this.reason = reason;
}
@Override
public int doAction(UUID sourceId, final Game game) {
oldLosingPlayer = game.getLosingPlayer();
if (oldLosingPlayer == null && player.canLose(game)) {
setScore(player, ArtificialScoringSystem.inst.getLoseGameScore(game));
game.setLosingPlayer(player);
if (!game.isSimulation())
game.informPlayer(player, reason);
}
return 0;
}
@Override
public void undoAction(final Game game) {
game.setLosingPlayer(oldLosingPlayer);
}
}