mirror of
https://github.com/correl/mage.git
synced 2025-01-13 19:11:33 +00:00
This commit is contained in:
parent
3965f31860
commit
f90ad78b26
1 changed files with 14 additions and 6 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue