Fixed O-Kagachi, Vengeful Kami intervening if condition (fixes #7244) (#7318)

This commit is contained in:
Daniel Bomar 2020-12-31 11:00:53 -06:00 committed by GitHub
parent 3965f31860
commit f90ad78b26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,7 +15,6 @@ import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.events.DamagedPlayerEvent; import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.watchers.Watcher; import mage.watchers.Watcher;
@ -133,14 +132,23 @@ class OKagachiVengefulKamiWatcher extends Watcher {
playerMap.remove(game.getActivePlayerId()); playerMap.remove(game.getActivePlayerId());
return; return;
case ATTACKER_DECLARED: case ATTACKER_DECLARED:
playerMap.computeIfAbsent(event.getPlayerId(), x -> new HashSet<>()).add(event.getTargetId()); UUID attacker = event.getPlayerId();
return; Set<UUID> defenders = playerMap.get(attacker);
if (defenders == null) {
defenders = new HashSet<>();
}
defenders.add(event.getTargetId());
playerMap.put(attacker, defenders);
} }
} }
boolean checkPlayer(UUID attackerId, UUID defenderId) { boolean checkPlayer(UUID attackerId, UUID defenderId) {
return attackerId != null if (attackerId != null && defenderId != null) {
&& defenderId != null Set<UUID> defendersLastTurn = playerMap.get(defenderId);
&& playerMap.computeIfAbsent(attackerId, x -> new HashSet<>()).contains(defenderId); if (defendersLastTurn != null) {
return defendersLastTurn.contains(attackerId);
}
}
return false;
} }
} }