mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 13:32:06 -08:00
refactor the copy functionality for no-args watchers
This commit is contained in:
parent
311532a6e7
commit
6703ba693d
52 changed files with 73 additions and 538 deletions
|
|
@ -1025,8 +1025,14 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
|
||||
public void initPlayerDefaultWatchers(UUID playerId) {
|
||||
getState().addWatcher(new PlayerDamagedBySourceWatcher(playerId));
|
||||
getState().addWatcher(new BloodthirstWatcher(playerId));
|
||||
PlayerDamagedBySourceWatcher playerDamagedBySourceWatcher = new PlayerDamagedBySourceWatcher();
|
||||
playerDamagedBySourceWatcher.setControllerId(playerId);
|
||||
|
||||
getState().addWatcher(playerDamagedBySourceWatcher);
|
||||
|
||||
BloodthirstWatcher bloodthirstWatcher = new BloodthirstWatcher();
|
||||
bloodthirstWatcher.setControllerId(playerId);
|
||||
getState().addWatcher(bloodthirstWatcher);
|
||||
}
|
||||
|
||||
protected void sendStartMessage(Player choosingPlayer, Player startingPlayer) {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,20 @@
|
|||
|
||||
package mage.watchers;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.turn.Step;
|
||||
import mage.game.events.GameEvent;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* watches for certain game events to occur and flags condition
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -26,7 +29,6 @@ public abstract class Watcher implements Serializable {
|
|||
protected final WatcherScope scope;
|
||||
|
||||
|
||||
|
||||
public Watcher(WatcherScope scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
|
@ -62,8 +64,8 @@ public abstract class Watcher implements Serializable {
|
|||
return controllerId + getBasicKey();
|
||||
case CARD:
|
||||
return sourceId + getBasicKey();
|
||||
default:
|
||||
return getBasicKey();
|
||||
default:
|
||||
return getBasicKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,18 +77,61 @@ public abstract class Watcher implements Serializable {
|
|||
condition = false;
|
||||
}
|
||||
|
||||
protected String getBasicKey(){
|
||||
protected String getBasicKey() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public abstract void watch(GameEvent event, Game game);
|
||||
|
||||
public <T extends Watcher> T copy(){
|
||||
public <T extends Watcher> T copy() {
|
||||
try {
|
||||
Constructor<? extends Watcher> constructor = this.getClass().getDeclaredConstructor(getClass());
|
||||
List<?> constructors = Arrays.asList(this.getClass().getConstructors());
|
||||
if (constructors.size() > 1) {
|
||||
logger.error(getClass().getSimpleName() + " has multiple constructors");
|
||||
return null;
|
||||
}
|
||||
|
||||
Constructor<? extends Watcher> constructor = (Constructor<? extends Watcher>) constructors.get(0);
|
||||
if (constructor.getParameterCount() > 0) {
|
||||
logger.error(getClass().getSimpleName() + " constructor has arguments, should be 0 and inject the parameters by setters");
|
||||
return null;
|
||||
}
|
||||
constructor.setAccessible(true);
|
||||
return (T) constructor.newInstance(this);
|
||||
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
|
||||
T watcher = (T) constructor.newInstance();
|
||||
List<Field> allFields = new ArrayList<>();
|
||||
allFields.addAll(Arrays.asList(getClass().getDeclaredFields()));
|
||||
allFields.addAll(Arrays.asList(getClass().getSuperclass().getDeclaredFields()));
|
||||
for (Field field : allFields) {
|
||||
field.setAccessible(true);
|
||||
if (field.getType().isPrimitive()) {
|
||||
field.set(watcher, field.get(this));
|
||||
}
|
||||
else if(field.getType() == Step.class){
|
||||
field.set(watcher, field.get(this));
|
||||
}
|
||||
else if (field.getType() == Mana.class) {
|
||||
field.set(watcher, field.get(this));
|
||||
} else if (field.getType() == UUID.class) {
|
||||
field.set(watcher, field.get(this));
|
||||
} else if (field.getType().isEnum()) {
|
||||
field.set(watcher, field.get(this));
|
||||
} else if (field.getType() == Set.class) {
|
||||
((Set) field.get(watcher)).clear();
|
||||
((Set) field.get(watcher)).addAll((Set) field.get(this));
|
||||
} else if (field.getType() == Map.class) {
|
||||
((Map) field.get(watcher)).clear();
|
||||
((Map) field.get(watcher)).putAll((Map) field.get(this));
|
||||
} else if (field.getType() == List.class) {
|
||||
((List) field.get(watcher)).clear();
|
||||
((List) field.get(watcher)).addAll((List) field.get(this));
|
||||
} else {
|
||||
if (field.getType() != Logger.class) {
|
||||
logger.error(field.getType() + " can not be copied");
|
||||
}
|
||||
}
|
||||
}
|
||||
return watcher;
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
logger.error("Can't copy watcher: " + e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -24,13 +24,6 @@ public class AmountOfDamageAPlayerReceivedThisTurnWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public AmountOfDamageAPlayerReceivedThisTurnWatcher(final AmountOfDamageAPlayerReceivedThisTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Integer> entry : watcher.amountOfDamageReceivedThisTurn.entrySet()) {
|
||||
amountOfDamageReceivedThisTurn.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
|
||||
|
|
@ -50,9 +43,4 @@ public class AmountOfDamageAPlayerReceivedThisTurnWatcher extends Watcher {
|
|||
public void reset() {
|
||||
amountOfDamageReceivedThisTurn.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AmountOfDamageAPlayerReceivedThisTurnWatcher copy() {
|
||||
return new AmountOfDamageAPlayerReceivedThisTurnWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,18 +27,6 @@ public class AttackedLastTurnWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public AttackedLastTurnWatcher(final AttackedLastTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Set<MageObjectReference>> entry : watcher.attackedLastTurnCreatures.entrySet()) {
|
||||
Set<MageObjectReference> allAttackersCopy = new HashSet<>(entry.getValue());
|
||||
attackedLastTurnCreatures.put(entry.getKey(), allAttackersCopy);
|
||||
}
|
||||
for (Entry<UUID, Set<MageObjectReference>> entry : watcher.attackedThisTurnCreatures.entrySet()) {
|
||||
Set<MageObjectReference> allAttackersCopy = new HashSet<>(entry.getValue());
|
||||
attackedThisTurnCreatures.put(entry.getKey(), allAttackersCopy);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.BEGINNING_PHASE_PRE) {
|
||||
|
|
@ -79,9 +67,4 @@ public class AttackedLastTurnWatcher extends Watcher {
|
|||
return new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttackedLastTurnWatcher copy() {
|
||||
return new AttackedLastTurnWatcher(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,12 +26,6 @@ public class AttackedOrBlockedThisCombatWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public AttackedOrBlockedThisCombatWatcher(final AttackedOrBlockedThisCombatWatcher watcher) {
|
||||
super(watcher);
|
||||
this.getAttackedThisTurnCreatures().addAll(watcher.getAttackedThisTurnCreatures());
|
||||
this.getBlockedThisTurnCreatures().addAll(watcher.getBlockedThisTurnCreatures());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.BEGIN_COMBAT_STEP_PRE) {
|
||||
|
|
@ -53,9 +47,4 @@ public class AttackedOrBlockedThisCombatWatcher extends Watcher {
|
|||
return this.blockedThisTurnCreatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttackedOrBlockedThisCombatWatcher copy() {
|
||||
return new AttackedOrBlockedThisCombatWatcher(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,12 +25,6 @@ public class AttackedThisTurnWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public AttackedThisTurnWatcher(final AttackedThisTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
this.attackedThisTurnCreatures.addAll(watcher.attackedThisTurnCreatures);
|
||||
this.attackedThisTurnCreaturesCounts.putAll(watcher.attackedThisTurnCreaturesCounts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) {
|
||||
|
|
@ -58,11 +52,6 @@ public class AttackedThisTurnWatcher extends Watcher {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttackedThisTurnWatcher copy() {
|
||||
return new AttackedThisTurnWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
|
|
|
|||
|
|
@ -25,20 +25,6 @@ public class BlockedAttackerWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public BlockedAttackerWatcher(final BlockedAttackerWatcher watcher) {
|
||||
super(watcher);
|
||||
for (MageObjectReference mageObjectReference : watcher.blockData.keySet()) {
|
||||
Set<MageObjectReference> blockedAttackers = new HashSet<>();
|
||||
blockedAttackers.addAll(watcher.blockData.get(mageObjectReference));
|
||||
blockData.put(mageObjectReference, blockedAttackers);
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public BlockedAttackerWatcher copy() {
|
||||
// return new BlockedAttackerWatcher(this);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.BLOCKER_DECLARED) {
|
||||
|
|
|
|||
|
|
@ -21,11 +21,6 @@ public class BlockedByOnlyOneCreatureThisCombatWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public BlockedByOnlyOneCreatureThisCombatWatcher(final BlockedByOnlyOneCreatureThisCombatWatcher watcher) {
|
||||
super(watcher);
|
||||
this.blockedByOneCreature.putAll(watcher.blockedByOneCreature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.BEGIN_COMBAT_STEP_PRE) {
|
||||
|
|
@ -64,8 +59,4 @@ public class BlockedByOnlyOneCreatureThisCombatWatcher extends Watcher {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockedByOnlyOneCreatureThisCombatWatcher copy() {
|
||||
return new BlockedByOnlyOneCreatureThisCombatWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,21 +16,10 @@ import java.util.Set;
|
|||
*/
|
||||
public class BlockedThisTurnWatcher extends Watcher {
|
||||
|
||||
private final Set<MageObjectReference> blockedThisTurnCreatures;
|
||||
private final Set<MageObjectReference> blockedThisTurnCreatures = new HashSet<>();
|
||||
|
||||
public BlockedThisTurnWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
blockedThisTurnCreatures = new HashSet<>();
|
||||
}
|
||||
|
||||
public BlockedThisTurnWatcher(final BlockedThisTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
blockedThisTurnCreatures = new HashSet<>(watcher.blockedThisTurnCreatures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Watcher copy() {
|
||||
return new BlockedThisTurnWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -15,14 +15,10 @@ import java.util.UUID;
|
|||
* @author Loki
|
||||
*/
|
||||
public class BloodthirstWatcher extends Watcher {
|
||||
public BloodthirstWatcher(UUID controllerId) {
|
||||
public BloodthirstWatcher() {
|
||||
super(WatcherScope.PLAYER);
|
||||
this.controllerId = controllerId;
|
||||
}
|
||||
|
||||
public BloodthirstWatcher(final BloodthirstWatcher watcher) {
|
||||
super(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
|
|
|
|||
|
|
@ -25,10 +25,6 @@ public class CardsAmountDrawnThisTurnWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public CardsAmountDrawnThisTurnWatcher(final CardsAmountDrawnThisTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
amountOfCardsDrawnThisTurn.putAll(watcher.amountOfCardsDrawnThisTurn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
|
|
@ -61,9 +57,4 @@ public class CardsAmountDrawnThisTurnWatcher extends Watcher {
|
|||
public int getAmountCardsDrawn(UUID playerId) {
|
||||
return amountOfCardsDrawnThisTurn.getOrDefault(playerId, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardsAmountDrawnThisTurnWatcher copy() {
|
||||
return new CardsAmountDrawnThisTurnWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,13 +27,6 @@ public class CardsDrawnDuringDrawStepWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public CardsDrawnDuringDrawStepWatcher(final CardsDrawnDuringDrawStepWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Integer> entry : watcher.amountOfCardsDrawnThisTurn.entrySet()) {
|
||||
amountOfCardsDrawnThisTurn.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.DREW_CARD
|
||||
|
|
@ -57,8 +50,4 @@ public class CardsDrawnDuringDrawStepWatcher extends Watcher {
|
|||
amountOfCardsDrawnThisTurn.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardsDrawnDuringDrawStepWatcher copy() {
|
||||
return new CardsDrawnDuringDrawStepWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,14 +32,6 @@ public class CardsPutIntoGraveyardWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public CardsPutIntoGraveyardWatcher(final CardsPutIntoGraveyardWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Integer> entry : watcher.amountOfCardsThisTurn.entrySet()) {
|
||||
amountOfCardsThisTurn.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
this.cardsPutToGraveyardFromBattlefield.addAll(watcher.cardsPutToGraveyardFromBattlefield);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.UNTAP_STEP_PRE) {
|
||||
|
|
@ -73,8 +65,4 @@ public class CardsPutIntoGraveyardWatcher extends Watcher {
|
|||
cardsPutToGraveyardFromBattlefield.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardsPutIntoGraveyardWatcher copy() {
|
||||
return new CardsPutIntoGraveyardWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,10 +23,6 @@ public class CastFromGraveyardWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public CastFromGraveyardWatcher(final CastFromGraveyardWatcher watcher) {
|
||||
super(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
/**
|
||||
|
|
@ -55,9 +51,4 @@ public class CastFromGraveyardWatcher extends Watcher {
|
|||
super.reset();
|
||||
spellsCastFromGraveyard.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CastFromGraveyardWatcher copy() {
|
||||
return new CastFromGraveyardWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ public class CastFromHandWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public CastFromHandWatcher(final CastFromHandWatcher watcher) {
|
||||
super(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
|
|
@ -58,8 +55,4 @@ public class CastFromHandWatcher extends Watcher {
|
|||
spellsCastFromHand.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CastFromHandWatcher copy() {
|
||||
return new CastFromHandWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,17 +23,6 @@ public class CastSpellLastTurnWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public CastSpellLastTurnWatcher(final CastSpellLastTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Integer> entry : watcher.amountOfSpellsCastOnCurrentTurn.entrySet()) {
|
||||
amountOfSpellsCastOnCurrentTurn.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
for (Entry<UUID, Integer> entry : watcher.amountOfSpellsCastOnPrevTurn.entrySet()) {
|
||||
amountOfSpellsCastOnPrevTurn.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
this.spellsCastThisTurnInOrder.addAll(watcher.spellsCastThisTurnInOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
|
|
@ -81,10 +70,4 @@ public class CastSpellLastTurnWatcher extends Watcher {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public CastSpellLastTurnWatcher copy() {
|
||||
// return new CastSpellLastTurnWatcher(this);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,16 +22,6 @@ public class CastSpellYourLastTurnWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public CastSpellYourLastTurnWatcher(final CastSpellYourLastTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Integer> entry : watcher.amountOfSpellsCastOnCurrentTurn.entrySet()) {
|
||||
amountOfSpellsCastOnCurrentTurn.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
for (Entry<UUID, Integer> entry : watcher.amountOfSpellsCastOnPrevTurn.entrySet()) {
|
||||
amountOfSpellsCastOnPrevTurn.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
lastActivePlayer = game.getActivePlayerId();
|
||||
|
|
|
|||
|
|
@ -20,23 +20,12 @@ public class ChooseBlockersRedundancyWatcher extends Watcher { // workaround for
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public ChooseBlockersRedundancyWatcher(final ChooseBlockersRedundancyWatcher watcher) {
|
||||
super(watcher);
|
||||
this.copyCount = watcher.copyCount;
|
||||
this.copyCountApply = watcher.copyCountApply;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
copyCount = 0;
|
||||
copyCountApply = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChooseBlockersRedundancyWatcher copy() {
|
||||
return new ChooseBlockersRedundancyWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,6 @@ public class CreatureAttackedWhichPlayerWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public CreatureAttackedWhichPlayerWatcher(final CreatureAttackedWhichPlayerWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, UUID> entry : watcher.getPlayerAttackedThisTurnByCreature.entrySet()) {
|
||||
getPlayerAttackedThisTurnByCreature.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) {
|
||||
|
|
@ -50,9 +43,4 @@ public class CreatureAttackedWhichPlayerWatcher extends Watcher {
|
|||
public void reset() {
|
||||
getPlayerAttackedThisTurnByCreature.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureAttackedWhichPlayerWatcher copy() {
|
||||
return new CreatureAttackedWhichPlayerWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,6 @@ public class CreatureWasCastWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public CreatureWasCastWatcher(final CreatureWasCastWatcher watcher) {
|
||||
super(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
|
|
@ -58,9 +54,4 @@ public class CreatureWasCastWatcher extends Watcher {
|
|||
super.reset();
|
||||
creaturesCasted.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreatureWasCastWatcher copy() {
|
||||
return new CreatureWasCastWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,6 @@ public class CreaturesDiedWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public CreaturesDiedWatcher(final CreaturesDiedWatcher watcher) {
|
||||
super(watcher);
|
||||
this.amountOfCreaturesThatDiedByController.putAll(watcher.amountOfCreaturesThatDiedByController);
|
||||
this.amountOfCreaturesThatDiedByOwner.putAll(watcher.amountOfCreaturesThatDiedByOwner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
|
||||
|
|
@ -57,11 +51,6 @@ public class CreaturesDiedWatcher extends Watcher {
|
|||
return amountOfCreaturesThatDiedByOwner.getOrDefault(playerId, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreaturesDiedWatcher copy() {
|
||||
return new CreaturesDiedWatcher(this);
|
||||
}
|
||||
|
||||
public int getAmountOfCreaturesDiedThisTurn() {
|
||||
return amountOfCreaturesThatDiedByController.values().stream().mapToInt(x -> x).sum();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,12 +40,6 @@ public class DamageDoneWatcher extends Watcher {
|
|||
this.damagedObjects = new HashMap<>();
|
||||
}
|
||||
|
||||
private DamageDoneWatcher(final DamageDoneWatcher watcher) {
|
||||
super(watcher);
|
||||
this.damagingObjects = new HashMap<>(watcher.damagingObjects);
|
||||
this.damagedObjects = new HashMap<>(watcher.damagedObjects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
switch (event.getType()) {
|
||||
|
|
|
|||
|
|
@ -29,11 +29,6 @@ public class DragonOnTheBattlefieldWhileSpellWasCastWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public DragonOnTheBattlefieldWhileSpellWasCastWatcher(final DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher) {
|
||||
super(watcher);
|
||||
this.castWithDragonOnTheBattlefield.addAll(watcher.castWithDragonOnTheBattlefield);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
|
|
@ -67,9 +62,4 @@ public class DragonOnTheBattlefieldWhileSpellWasCastWatcher extends Watcher {
|
|||
public boolean castWithConditionTrue(UUID spellId) {
|
||||
return castWithDragonOnTheBattlefield.contains(spellId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DragonOnTheBattlefieldWhileSpellWasCastWatcher copy() {
|
||||
return new DragonOnTheBattlefieldWhileSpellWasCastWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,6 @@ public class FirstSpellCastThisTurnWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public FirstSpellCastThisTurnWatcher(final FirstSpellCastThisTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
playerFirstSpellCast.putAll(watcher.playerFirstSpellCast);
|
||||
playerFirstCastSpell.putAll(watcher.playerFirstCastSpell);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
switch (event.getType()) {
|
||||
|
|
@ -44,11 +38,6 @@ public class FirstSpellCastThisTurnWatcher extends Watcher {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FirstSpellCastThisTurnWatcher copy() {
|
||||
return new FirstSpellCastThisTurnWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
|
|
|
|||
|
|
@ -22,11 +22,6 @@ public class GravestormWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public GravestormWatcher(final GravestormWatcher watcher) {
|
||||
super(watcher);
|
||||
this.gravestormCount = watcher.gravestormCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE) {
|
||||
|
|
@ -46,9 +41,4 @@ public class GravestormWatcher extends Watcher {
|
|||
public int getGravestormCount() {
|
||||
return this.gravestormCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GravestormWatcher copy() {
|
||||
return new GravestormWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,17 +22,6 @@ public class LandfallWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
private LandfallWatcher(final LandfallWatcher watcher) {
|
||||
super(watcher);
|
||||
playerPlayedLand.addAll(watcher.playerPlayedLand);
|
||||
landEnteredBattlefield.addAll(watcher.landEnteredBattlefield);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LandfallWatcher copy() {
|
||||
return new LandfallWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
|
||||
|
|
|
|||
|
|
@ -22,11 +22,6 @@ public class LifeLossOtherFromCombatWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public LifeLossOtherFromCombatWatcher(final LifeLossOtherFromCombatWatcher watcher) {
|
||||
super(watcher);
|
||||
this.players.addAll(watcher.players);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.LOST_LIFE && !event.getFlag()) {
|
||||
|
|
@ -52,9 +47,4 @@ public class LifeLossOtherFromCombatWatcher extends Watcher {
|
|||
super.reset();
|
||||
players.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LifeLossOtherFromCombatWatcher copy() {
|
||||
return new LifeLossOtherFromCombatWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,6 @@ public class ManaSpentToCastWatcher extends Watcher {
|
|||
super(WatcherScope.CARD);
|
||||
}
|
||||
|
||||
public ManaSpentToCastWatcher(final ManaSpentToCastWatcher watcher) {
|
||||
super(watcher);
|
||||
this.payment = watcher.payment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.HAND) {
|
||||
|
|
@ -43,11 +38,6 @@ public class ManaSpentToCastWatcher extends Watcher {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaSpentToCastWatcher copy() {
|
||||
return new ManaSpentToCastWatcher(this);
|
||||
}
|
||||
|
||||
public Mana getAndResetLastPayment() {
|
||||
Mana returnPayment = null;
|
||||
if (payment != null) {
|
||||
|
|
|
|||
|
|
@ -32,13 +32,6 @@ public class MiracleWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public MiracleWatcher(final MiracleWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Integer> entry : watcher.amountOfCardsDrawnThisTurn.entrySet()) {
|
||||
amountOfCardsDrawnThisTurn.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.UNTAP_STEP_PRE) {
|
||||
|
|
@ -82,9 +75,4 @@ public class MiracleWatcher extends Watcher {
|
|||
public void reset() {
|
||||
amountOfCardsDrawnThisTurn.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MiracleWatcher copy() {
|
||||
return new MiracleWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,6 @@ public class MorbidWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public MorbidWatcher(final MorbidWatcher watcher) {
|
||||
super(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (condition) {
|
||||
|
|
@ -32,10 +28,4 @@ public class MorbidWatcher extends Watcher {
|
|||
condition = true;
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public MorbidWatcher copy() {
|
||||
// return new MorbidWatcher(this);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,6 @@ public class NumberOfTimesPermanentTargetedATurnWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public NumberOfTimesPermanentTargetedATurnWatcher(final NumberOfTimesPermanentTargetedATurnWatcher watcher) {
|
||||
super(watcher);
|
||||
this.permanentsTargeted.putAll(watcher.permanentsTargeted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.TARGETED) {
|
||||
|
|
@ -55,9 +50,4 @@ public class NumberOfTimesPermanentTargetedATurnWatcher extends Watcher {
|
|||
super.reset();
|
||||
permanentsTargeted.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NumberOfTimesPermanentTargetedATurnWatcher copy() {
|
||||
return new NumberOfTimesPermanentTargetedATurnWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,17 +26,6 @@ public class PermanentsEnteredBattlefieldWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PermanentsEnteredBattlefieldWatcher(final PermanentsEnteredBattlefieldWatcher watcher) {
|
||||
super(watcher);
|
||||
this.enteringBattlefield.putAll(watcher.enteringBattlefield);
|
||||
this.enteringBattlefieldLastTurn.putAll(watcher.enteringBattlefieldLastTurn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermanentsEnteredBattlefieldWatcher copy() {
|
||||
return new PermanentsEnteredBattlefieldWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
|
||||
|
|
|
|||
|
|
@ -27,17 +27,6 @@ public class PermanentsEnteredBattlefieldYourLastTurnWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PermanentsEnteredBattlefieldYourLastTurnWatcher(final PermanentsEnteredBattlefieldYourLastTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
this.enteringBattlefield.putAll(watcher.enteringBattlefield);
|
||||
this.enteringBattlefieldLastTurn.putAll(watcher.enteringBattlefieldLastTurn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermanentsEnteredBattlefieldYourLastTurnWatcher copy() {
|
||||
return new PermanentsEnteredBattlefieldYourLastTurnWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
lastActivePlayer = game.getActivePlayerId();
|
||||
|
|
|
|||
|
|
@ -25,15 +25,6 @@ public class PermanentsSacrificedWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PermanentsSacrificedWatcher(final PermanentsSacrificedWatcher watcher) {
|
||||
super(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermanentsSacrificedWatcher copy() {
|
||||
return new PermanentsSacrificedWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SACRIFICED_PERMANENT) {
|
||||
|
|
|
|||
|
|
@ -24,13 +24,6 @@ public class PlanarRollWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlanarRollWatcher(final PlanarRollWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Integer> entry : watcher.numberTimesPlanarDieRolled.entrySet()) {
|
||||
numberTimesPlanarDieRolled.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.PLANAR_DIE_ROLLED) {
|
||||
|
|
|
|||
|
|
@ -21,17 +21,6 @@ public class PlayLandWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayLandWatcher(final PlayLandWatcher watcher) {
|
||||
super(watcher);
|
||||
playerPlayedLand.addAll(watcher.playerPlayedLand);
|
||||
landPlayed.addAll(watcher.landPlayed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayLandWatcher copy() {
|
||||
return new PlayLandWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.LAND_PLAYED) {
|
||||
|
|
|
|||
|
|
@ -21,18 +21,6 @@ public class PlayerAttackedStepWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayerAttackedStepWatcher(final PlayerAttackedStepWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Map.Entry<UUID, Integer> entry : watcher.playerAttacked.entrySet()) {
|
||||
this.playerAttacked.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerAttackedStepWatcher copy() {
|
||||
return new PlayerAttackedStepWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.DECLARE_ATTACKERS_STEP_POST) {
|
||||
|
|
|
|||
|
|
@ -24,19 +24,6 @@ public class PlayerAttackedWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayerAttackedWatcher(final PlayerAttackedWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Map.Entry<UUID, Integer> entry : watcher.playerAttacked.entrySet()) {
|
||||
this.playerAttacked.put(entry.getKey(), entry.getValue());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerAttackedWatcher copy() {
|
||||
return new PlayerAttackedWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) {
|
||||
|
|
|
|||
|
|
@ -22,11 +22,6 @@ public class PlayerCastCreatureWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayerCastCreatureWatcher(final PlayerCastCreatureWatcher watcher) {
|
||||
super(watcher);
|
||||
this.playerIds.addAll(watcher.playerIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
|
|
@ -37,11 +32,6 @@ public class PlayerCastCreatureWatcher extends Watcher {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerCastCreatureWatcher copy() {
|
||||
return new PlayerCastCreatureWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
|
|
|
|||
|
|
@ -20,17 +20,10 @@ public class PlayerDamagedBySourceWatcher extends Watcher {
|
|||
|
||||
private final Set<String> damageSourceIds = new HashSet<>();
|
||||
|
||||
public PlayerDamagedBySourceWatcher(UUID playerId) {
|
||||
public PlayerDamagedBySourceWatcher() {
|
||||
super(WatcherScope.PLAYER);
|
||||
setControllerId(playerId);
|
||||
}
|
||||
|
||||
public PlayerDamagedBySourceWatcher(final PlayerDamagedBySourceWatcher watcher) {
|
||||
super(watcher);
|
||||
this.damageSourceIds.addAll(watcher.damageSourceIds);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.DAMAGED_PLAYER) {
|
||||
|
|
|
|||
|
|
@ -24,12 +24,6 @@ public class PlayerGainedLifeWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
private PlayerGainedLifeWatcher(final PlayerGainedLifeWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Integer> entry : watcher.amountOfLifeGainedThisTurn.entrySet()) {
|
||||
amountOfLifeGainedThisTurn.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
|
|
@ -54,9 +48,4 @@ public class PlayerGainedLifeWatcher extends Watcher {
|
|||
super.reset();
|
||||
amountOfLifeGainedThisTurn.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerGainedLifeWatcher copy() {
|
||||
return new PlayerGainedLifeWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,6 @@ public class PlayerLostLifeNonCombatWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayerLostLifeNonCombatWatcher(final PlayerLostLifeNonCombatWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Integer> entry : watcher.amountOfLifeLostThisTurn.entrySet()) {
|
||||
amountOfLifeLostThisTurn.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.LOST_LIFE && !event.getFlag()) {
|
||||
|
|
@ -76,9 +69,4 @@ public class PlayerLostLifeNonCombatWatcher extends Watcher {
|
|||
amountOfLifeLostLastTurn.putAll(amountOfLifeLostThisTurn);
|
||||
amountOfLifeLostThisTurn.clear();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public PlayerLostLifeNonCombatWatcher copy() {
|
||||
// return new PlayerLostLifeNonCombatWatcher(this);
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,13 +26,6 @@ public class PlayerLostLifeWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayerLostLifeWatcher(final PlayerLostLifeWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Integer> entry : watcher.amountOfLifeLostThisTurn.entrySet()) {
|
||||
amountOfLifeLostThisTurn.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.LOST_LIFE) {
|
||||
|
|
@ -74,9 +67,4 @@ public class PlayerLostLifeWatcher extends Watcher {
|
|||
amountOfLifeLostLastTurn.putAll(amountOfLifeLostThisTurn);
|
||||
amountOfLifeLostThisTurn.clear();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public PlayerLostLifeWatcher copy() {
|
||||
// return new PlayerLostLifeWatcher(this);
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,18 +23,6 @@ public class PlayersAttackedLastTurnWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayersAttackedLastTurnWatcher(final PlayersAttackedLastTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Map.Entry<UUID, PlayerList> entry : watcher.playersAttackedInLastTurn.entrySet()) {
|
||||
this.playersAttackedInLastTurn.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayersAttackedLastTurnWatcher copy() {
|
||||
return new PlayersAttackedLastTurnWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.BEGINNING_PHASE_PRE) {
|
||||
|
|
|
|||
|
|
@ -23,19 +23,6 @@ public class PlayersAttackedThisTurnWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public PlayersAttackedThisTurnWatcher(final PlayersAttackedThisTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
|
||||
for (Map.Entry<UUID, PlayerList> entry : watcher.playersAttackedThisTurn.entrySet()) {
|
||||
this.playersAttackedThisTurn.putIfAbsent(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
for (Map.Entry<UUID, PlayerList> entry : watcher.opponentsAttackedThisTurn.entrySet()) {
|
||||
this.opponentsAttackedThisTurn.putIfAbsent(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.BEGINNING_PHASE_PRE) {
|
||||
|
|
|
|||
|
|
@ -29,18 +29,6 @@ public class ProwlWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
private ProwlWatcher(final ProwlWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Set<SubType>> entry : watcher.damagingSubtypes.entrySet()) {
|
||||
damagingSubtypes.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProwlWatcher copy() {
|
||||
return new ProwlWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.DAMAGED_PLAYER) {
|
||||
|
|
|
|||
|
|
@ -25,11 +25,6 @@ public class RevoltWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public RevoltWatcher(final RevoltWatcher watcher) {
|
||||
super(watcher);
|
||||
this.revoltActivePlayerIds.addAll(watcher.revoltActivePlayerIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.ZONE_CHANGE && event instanceof ZoneChangeEvent) {
|
||||
|
|
@ -51,9 +46,4 @@ public class RevoltWatcher extends Watcher {
|
|||
public void reset() {
|
||||
revoltActivePlayerIds.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevoltWatcher copy() {
|
||||
return new RevoltWatcher(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,16 +22,6 @@ public class SourceDidDamageWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public SourceDidDamageWatcher(final SourceDidDamageWatcher watcher) {
|
||||
super(watcher);
|
||||
this.damageSources.addAll(watcher.damageSources);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourceDidDamageWatcher copy() {
|
||||
return new SourceDidDamageWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.DAMAGED_CREATURE
|
||||
|
|
|
|||
|
|
@ -30,16 +30,6 @@ public class SpellsCastWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public SpellsCastWatcher(final SpellsCastWatcher watcher) {
|
||||
super(watcher);
|
||||
this.spellsCast.putAll(watcher.spellsCast);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellsCastWatcher copy() {
|
||||
return new SpellsCastWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (EventType.SPELL_CAST == event.getType()) {
|
||||
|
|
|
|||
|
|
@ -23,16 +23,6 @@ public class WasBlockedThisTurnWatcher extends Watcher {
|
|||
wasBlockedThisTurnCreatures = new HashSet<>();
|
||||
}
|
||||
|
||||
private WasBlockedThisTurnWatcher(final WasBlockedThisTurnWatcher watcher) {
|
||||
super(watcher);
|
||||
wasBlockedThisTurnCreatures = new HashSet<>(watcher.wasBlockedThisTurnCreatures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Watcher copy() {
|
||||
return new WasBlockedThisTurnWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) {
|
||||
|
|
|
|||
|
|
@ -24,16 +24,6 @@ public class ZuberasDiedWatcher extends Watcher {
|
|||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public ZuberasDiedWatcher(final ZuberasDiedWatcher watcher) {
|
||||
super(watcher);
|
||||
this.zuberasDiedThisTurn = watcher.zuberasDiedThisTurn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZuberasDiedWatcher copy() {
|
||||
return new ZuberasDiedWatcher(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue