From 9416c6140acc6e7180d8ec9e13e0a370a94f499e Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sat, 6 Feb 2021 13:04:20 +0400 Subject: [PATCH] [KHM] fixed Reidane, God of the Worthy - rollback error on some events check without sourceId; --- Mage.Sets/src/mage/cards/r/ReidaneGodOfTheWorthy.java | 11 ++++++----- Mage/src/main/java/mage/game/Game.java | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Mage.Sets/src/mage/cards/r/ReidaneGodOfTheWorthy.java b/Mage.Sets/src/mage/cards/r/ReidaneGodOfTheWorthy.java index 76a8df0836..4b71765918 100644 --- a/Mage.Sets/src/mage/cards/r/ReidaneGodOfTheWorthy.java +++ b/Mage.Sets/src/mage/cards/r/ReidaneGodOfTheWorthy.java @@ -169,17 +169,18 @@ class ValkmiraProtectorsShieldPreventionEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (!game.getOpponents(game.getControllerId(event.getSourceId())).contains(source.getControllerId())) { - return false; - } switch (event.getType()) { case DAMAGE_PLAYER: - return source.isControlledBy(event.getTargetId()) + boolean isOpponent = game.getOpponents(game.getControllerId(event.getSourceId())).contains(source.getControllerId()); + return isOpponent + && source.isControlledBy(event.getTargetId()) && super.applies(event, source, game); case DAMAGE_CREATURE: case DAMAGE_PLANESWALKER: + isOpponent = game.getOpponents(game.getControllerId(event.getSourceId())).contains(source.getControllerId()); Permanent permanent = game.getPermanent(event.getTargetId()); - return permanent != null + return isOpponent + && permanent != null && permanent.isControlledBy(source.getControllerId()) && super.applies(event, source, game); } diff --git a/Mage/src/main/java/mage/game/Game.java b/Mage/src/main/java/mage/game/Game.java index 49e804efa2..9b132ee3de 100644 --- a/Mage/src/main/java/mage/game/Game.java +++ b/Mage/src/main/java/mage/game/Game.java @@ -135,6 +135,10 @@ public interface Game extends MageItem, Serializable { */ default Set getOpponents(UUID playerId) { Player player = getPlayer(playerId); + if (player == null) { + return new HashSet<>(); + } + return player.getInRange().stream() .filter(opponentId -> !opponentId.equals(playerId)) .collect(Collectors.toSet());