From f90ad78b2659188a0535a3cb78a2c08cbd03c9a3 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Thu, 31 Dec 2020 11:00:53 -0600 Subject: [PATCH] Fixed O-Kagachi, Vengeful Kami intervening if condition (fixes #7244) (#7318) --- .../mage/cards/o/OKagachiVengefulKami.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Mage.Sets/src/mage/cards/o/OKagachiVengefulKami.java b/Mage.Sets/src/mage/cards/o/OKagachiVengefulKami.java index 351a20aa4d..8020208b79 100644 --- a/Mage.Sets/src/mage/cards/o/OKagachiVengefulKami.java +++ b/Mage.Sets/src/mage/cards/o/OKagachiVengefulKami.java @@ -15,7 +15,6 @@ import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.events.DamagedPlayerEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.players.Player; import mage.target.TargetPermanent; import mage.watchers.Watcher; @@ -133,14 +132,23 @@ class OKagachiVengefulKamiWatcher extends Watcher { playerMap.remove(game.getActivePlayerId()); return; case ATTACKER_DECLARED: - playerMap.computeIfAbsent(event.getPlayerId(), x -> new HashSet<>()).add(event.getTargetId()); - return; + UUID attacker = event.getPlayerId(); + Set defenders = playerMap.get(attacker); + if (defenders == null) { + defenders = new HashSet<>(); + } + defenders.add(event.getTargetId()); + playerMap.put(attacker, defenders); } } boolean checkPlayer(UUID attackerId, UUID defenderId) { - return attackerId != null - && defenderId != null - && playerMap.computeIfAbsent(attackerId, x -> new HashSet<>()).contains(defenderId); + if (attackerId != null && defenderId != null) { + Set defendersLastTurn = playerMap.get(defenderId); + if (defendersLastTurn != null) { + return defendersLastTurn.contains(attackerId); + } + } + return false; } }