mirror of
https://github.com/correl/mage.git
synced 2024-11-16 03:00:12 +00:00
watcher now saves info for all players. Rule modifying effect does the check
This commit is contained in:
parent
7ce878a315
commit
c3e8903105
1 changed files with 12 additions and 9 deletions
|
@ -78,17 +78,17 @@ public class LeovoldEmissaryOfTrest extends CardImpl {
|
||||||
|
|
||||||
class LeovoldEmissaryOfTrestWatcher extends Watcher {
|
class LeovoldEmissaryOfTrestWatcher extends Watcher {
|
||||||
|
|
||||||
private final HashSet<UUID> opponentsThatDrewCard;
|
private final HashSet<UUID> playersThatDrewCard;
|
||||||
|
|
||||||
public LeovoldEmissaryOfTrestWatcher() {
|
public LeovoldEmissaryOfTrestWatcher() {
|
||||||
super("DrewCard", WatcherScope.GAME);
|
super("DrewCard", WatcherScope.GAME);
|
||||||
this.opponentsThatDrewCard = new HashSet<>();
|
this.playersThatDrewCard = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LeovoldEmissaryOfTrestWatcher(final LeovoldEmissaryOfTrestWatcher watcher) {
|
public LeovoldEmissaryOfTrestWatcher(final LeovoldEmissaryOfTrestWatcher watcher) {
|
||||||
super(watcher);
|
super(watcher);
|
||||||
this.opponentsThatDrewCard = new HashSet<>();
|
this.playersThatDrewCard = new HashSet<>();
|
||||||
opponentsThatDrewCard.addAll(watcher.opponentsThatDrewCard);
|
playersThatDrewCard.addAll(watcher.playersThatDrewCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,8 +99,8 @@ class LeovoldEmissaryOfTrestWatcher extends Watcher {
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.DREW_CARD ) {
|
if (event.getType() == GameEvent.EventType.DREW_CARD ) {
|
||||||
if (!event.getPlayerId().equals(this.getControllerId()) && !opponentsThatDrewCard.contains(event.getPlayerId())) {
|
if (!playersThatDrewCard.contains(event.getPlayerId())) {
|
||||||
opponentsThatDrewCard.add(event.getPlayerId());
|
playersThatDrewCard.add(event.getPlayerId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,11 +108,11 @@ class LeovoldEmissaryOfTrestWatcher extends Watcher {
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
super.reset();
|
super.reset();
|
||||||
opponentsThatDrewCard.clear();
|
playersThatDrewCard.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPlayerDrewCardThisTurn(UUID playerId) {
|
public boolean hasPlayerDrewCardThisTurn(UUID playerId) {
|
||||||
return opponentsThatDrewCard.contains(playerId);
|
return playersThatDrewCard.contains(playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,10 @@ class LeovoldEmissaryOfTrestEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
LeovoldEmissaryOfTrestWatcher watcher = (LeovoldEmissaryOfTrestWatcher) game.getState().getWatchers().get("DrewCard");
|
LeovoldEmissaryOfTrestWatcher watcher = (LeovoldEmissaryOfTrestWatcher) game.getState().getWatchers().get("DrewCard");
|
||||||
return watcher != null && watcher.hasPlayerDrewCardThisTurn(event.getPlayerId());
|
|
||||||
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
|
return watcher != null && controller != null && watcher.hasPlayerDrewCardThisTurn(event.getPlayerId())
|
||||||
|
&& game.isOpponent(controller, event.getPlayerId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue