From c8eb9f00a92feef05778c142d8c64d94182d1a94 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 21 Jan 2015 23:41:11 +0100 Subject: [PATCH] * 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. --- Mage.Client/serverlist.txt | 8 ++++---- .../mage/sets/innistrad/LaboratoryManiac.java | 7 ++++++- .../mage/sets/shardsofalara/LichsMirror.java | 7 ++++++- .../src/mage/sets/tenth/PlatinumAngel.java | 10 +++------- .../src/mage/sets/timespiral/AngelsGrace.java | 19 ++++++++++--------- .../sets/worldwake/AbyssalPersecutor.java | 2 +- Mage/src/mage/players/PlayerImpl.java | 17 ++++++++++++++--- 7 files changed, 44 insertions(+), 26 deletions(-) diff --git a/Mage.Client/serverlist.txt b/Mage.Client/serverlist.txt index e48b45d95f..5bda14f524 100644 --- a/Mage.Client/serverlist.txt +++ b/Mage.Client/serverlist.txt @@ -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 diff --git a/Mage.Sets/src/mage/sets/innistrad/LaboratoryManiac.java b/Mage.Sets/src/mage/sets/innistrad/LaboratoryManiac.java index 829af586a7..2ff2661bd0 100644 --- a/Mage.Sets/src/mage/sets/innistrad/LaboratoryManiac.java +++ b/Mage.Sets/src/mage/sets/innistrad/LaboratoryManiac.java @@ -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()) diff --git a/Mage.Sets/src/mage/sets/shardsofalara/LichsMirror.java b/Mage.Sets/src/mage/sets/shardsofalara/LichsMirror.java index cb21f97848..fd93901578 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/LichsMirror.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/LichsMirror.java @@ -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; diff --git a/Mage.Sets/src/mage/sets/tenth/PlatinumAngel.java b/Mage.Sets/src/mage/sets/tenth/PlatinumAngel.java index 698be26788..4802714da7 100644 --- a/Mage.Sets/src/mage/sets/tenth/PlatinumAngel.java +++ b/Mage.Sets/src/mage/sets/tenth/PlatinumAngel.java @@ -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())) || diff --git a/Mage.Sets/src/mage/sets/timespiral/AngelsGrace.java b/Mage.Sets/src/mage/sets/timespiral/AngelsGrace.java index 9bc2a66e2e..cff3e09861 100644 --- a/Mage.Sets/src/mage/sets/timespiral/AngelsGrace.java +++ b/Mage.Sets/src/mage/sets/timespiral/AngelsGrace.java @@ -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 ) { diff --git a/Mage.Sets/src/mage/sets/worldwake/AbyssalPersecutor.java b/Mage.Sets/src/mage/sets/worldwake/AbyssalPersecutor.java index 1986ee19cf..90c1ed0f69 100644 --- a/Mage.Sets/src/mage/sets/worldwake/AbyssalPersecutor.java +++ b/Mage.Sets/src/mage/sets/worldwake/AbyssalPersecutor.java @@ -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"; } diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index 6663eecc51..3ee92c04d7 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -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