* Fixed that lose restricting effects could not be replaced (e.g. by Abysal Persecutor's ability) if the player has conceded or left the match. Fixed that "can't win" or "can't lose" messages where repeated send to the players if such an effect activly prevents a player from losing or winning.

This commit is contained in:
LevelX2 2015-01-21 23:41:11 +01:00
parent 1340ebff49
commit c8eb9f00a9
7 changed files with 44 additions and 26 deletions

View file

@ -1,5 +1,5 @@
woogerworks :xmage.woogerworks.com:17171
XMage.info 1 :176.31.186.181:17171
XMage.info 2 :176.31.186.181:17000
Seedds Server (inactive?) :115.29.203.80:17171
woogerworks (North America):xmage.woogerworks.com:17171
XMage.info 1 (Europe) :176.31.186.181:17171
XMage.info 2 (Europe):176.31.186.181:17000
Seedds Server (Asia) :115.29.203.80:17171
localhost -> connect to your local server (must be started):localhost:17171

View file

@ -105,9 +105,14 @@ class LaboratoryManiacEffect extends ReplacementEffectImpl {
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.LOSES;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.LOSES && event.getPlayerId().equals(source.getControllerId())) {
if (event.getPlayerId().equals(source.getControllerId())) {
Player player = game.getPlayer(event.getPlayerId());
if (!player.hasLost() && (
(player.getLife() > 0 || !player.canLoseByZeroOrLessLife())

View file

@ -119,9 +119,14 @@ class LichsMirrorEffect extends ReplacementEffectImpl {
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.LOSES;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.LOSES && event.getPlayerId().equals(source.getControllerId())) {
if (event.getPlayerId().equals(source.getControllerId())) {
return true;
}
return false;

View file

@ -37,6 +37,7 @@ import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
@ -70,10 +71,10 @@ public class PlatinumAngel extends CardImpl {
return new PlatinumAngel(this);
}
class PlatinumAngelEffect extends ReplacementEffectImpl {
class PlatinumAngelEffect extends ContinuousRuleModifiyingEffectImpl {
public PlatinumAngelEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
super(Duration.WhileOnBattlefield, Outcome.Benefit, false, false);
staticText = "You can't lose the game and your opponents can't win the game";
}
@ -91,11 +92,6 @@ public class PlatinumAngel extends CardImpl {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if ((event.getType() == EventType.WINS && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) ||

View file

@ -29,6 +29,7 @@ package mage.sets.timespiral;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.SplitSecondAbility;
import mage.cards.CardImpl;
@ -71,10 +72,10 @@ public class AngelsGrace extends CardImpl {
}
}
class AngelsGraceEffect extends ReplacementEffectImpl {
class AngelsGraceEffect extends ContinuousRuleModifiyingEffectImpl {
public AngelsGraceEffect() {
super(Duration.EndOfTurn, Outcome.Benefit);
super(Duration.EndOfTurn, Outcome.Benefit, false, false);
staticText = "You can't lose the game this turn and your opponents can't win the game this turn";
}
@ -92,11 +93,6 @@ class AngelsGraceEffect extends ReplacementEffectImpl {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if ((event.getType() == EventType.WINS && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) ||
@ -124,10 +120,15 @@ class AngelsGraceReplacementEffect extends ReplacementEffectImpl {
return new AngelsGraceReplacementEffect(this);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType().equals(GameEvent.EventType.DAMAGE_CAUSES_LIFE_LOSS);
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType().equals(GameEvent.EventType.DAMAGE_CAUSES_LIFE_LOSS)
&& event.getPlayerId().equals(source.getControllerId())) {
if (event.getPlayerId().equals(source.getControllerId())) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null
&& (controller.getLife() - event.getAmount()) < 1 ) {

View file

@ -79,7 +79,7 @@ public class AbyssalPersecutor extends CardImpl {
class AbyssalPersecutorCannotWinEffect extends ContinuousRuleModifiyingEffectImpl {
AbyssalPersecutorCannotWinEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
super(Duration.WhileOnBattlefield, Outcome.Detriment, false, false);
staticText = "You can't win the game and your opponents can't lose the game";
}

View file

@ -1896,12 +1896,23 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override
public boolean canLose(Game game) {
return !game.replaceEvent(new GameEvent(GameEvent.EventType.LOSES, null, null, playerId));
return hasLeft() // If a player concedes or has left the match he loses also if effect would say otherwise
|| !game.replaceEvent(new GameEvent(GameEvent.EventType.LOSES, null, null, playerId));
}
@Override
public void won(Game game) {
if (!game.replaceEvent(new GameEvent(GameEvent.EventType.WINS, null, null, playerId))) {
public void won(Game game) {
boolean opponentInGame = false;
for (UUID opponentId: game.getOpponents(playerId)) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null && opponent.isInGame()) {
opponentInGame = true;
break;
}
}
if (!opponentInGame || // if no more opponent is in game the wins event may no longer be replaced
!game.replaceEvent(new GameEvent(GameEvent.EventType.WINS, null, null, playerId))) {
logger.debug("player won -> start: " + this.getName());
if (!this.loses) {
//20130501 - 800.7, 801.16