mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 05:52:06 -08:00
re-implemented O-Kagachi, Vengeful Kami (fixes #7082)
This commit is contained in:
parent
66235dc6e0
commit
44a8954edf
2 changed files with 61 additions and 113 deletions
|
|
@ -1,51 +0,0 @@
|
|||
|
||||
package mage.watchers.common;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.watchers.Watcher;
|
||||
import mage.players.PlayerList;
|
||||
|
||||
/**
|
||||
* @author spjspj
|
||||
*/
|
||||
public class PlayersAttackedLastTurnWatcher extends Watcher {
|
||||
|
||||
// Store how many players each player attacked in their last turn
|
||||
private final Map<UUID, PlayerList> playersAttackedInLastTurn = new HashMap<>();
|
||||
|
||||
public PlayersAttackedLastTurnWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.BEGINNING_PHASE_PRE) {
|
||||
playersAttackedInLastTurn.remove(event.getPlayerId());
|
||||
}
|
||||
|
||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) {
|
||||
PlayerList playersAttacked = playersAttackedInLastTurn.get(event.getPlayerId());
|
||||
if (playersAttacked == null) {
|
||||
playersAttacked = new PlayerList();
|
||||
}
|
||||
UUID defender = game.getCombat().getDefendingPlayerId(event.getSourceId(), game);
|
||||
if (defender != null) {
|
||||
playersAttacked.add(defender);
|
||||
}
|
||||
playersAttackedInLastTurn.put(event.getPlayerId(), playersAttacked);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean attackedLastTurn(UUID playerId, UUID otherPlayerId) {
|
||||
if (playersAttackedInLastTurn.get(playerId) != null) {
|
||||
return playersAttackedInLastTurn.get(playerId).contains(otherPlayerId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue