changed the constructor for a Watcher. Before, you had to explictly pass the name of the watcher as an argument. But most of the time this was the name of the class itself. So the watcher now determines internally its name. The method 'getBasicKey' can be overridden. Also updated some encapsulation

This commit is contained in:
Ingmar Goudt 2019-03-16 08:35:26 +01:00
parent 5c1f41f3a7
commit c4eeec1bb2
178 changed files with 313 additions and 296 deletions

View file

@ -145,7 +145,7 @@ class ExertedThisTurnWatcher extends Watcher {
private final Set<MageObjectReference> exertedThisTurnCreatures;
public ExertedThisTurnWatcher() {
super(ExertedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
exertedThisTurnCreatures = new HashSet<>();
}

View file

@ -1,10 +1,8 @@
package mage.abilities.keyword;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
@ -45,10 +43,10 @@ public class MeleeAbility extends AttacksTriggeredAbility {
class MeleeWatcher extends Watcher {
private HashMap<UUID, Set<UUID>> playersAttacked = new HashMap<>(0);
private Map<UUID, Set<UUID>> playersAttacked = new HashMap<>(0);
MeleeWatcher() {
super("MeleeWatcher", WatcherScope.GAME);
super(WatcherScope.GAME);
}
MeleeWatcher(final MeleeWatcher watcher) {

View file

@ -15,18 +15,14 @@ import mage.game.events.GameEvent;
*/
public abstract class Watcher implements Serializable {
protected String basicKey;
protected UUID controllerId;
protected UUID sourceId;
protected boolean condition;
protected final WatcherScope scope;
public Watcher(Class<? extends Watcher> watcherClass, WatcherScope scope){
this(watcherClass.getSimpleName(), scope);
}
public Watcher(String basicKey, WatcherScope scope) {
this.basicKey = basicKey;
public Watcher(WatcherScope scope) {
this.scope = scope;
}
@ -35,7 +31,6 @@ public abstract class Watcher implements Serializable {
this.controllerId = watcher.controllerId;
this.sourceId = watcher.sourceId;
this.scope = watcher.scope;
this.basicKey = watcher.basicKey;
}
public UUID getControllerId() {
@ -57,13 +52,14 @@ public abstract class Watcher implements Serializable {
public String getKey() {
switch (scope) {
case GAME:
return basicKey;
return getBasicKey();
case PLAYER:
return controllerId + basicKey;
return controllerId + getBasicKey();
case CARD:
return sourceId + basicKey;
return sourceId + getBasicKey();
default:
return getBasicKey();
}
return basicKey;
}
public boolean conditionMet() {
@ -74,6 +70,10 @@ public abstract class Watcher implements Serializable {
condition = false;
}
protected String getBasicKey(){
return getClass().getSimpleName();
}
public abstract void watch(GameEvent event, Game game);
public abstract Watcher copy();

View file

@ -21,7 +21,7 @@ public class AmountOfDamageAPlayerReceivedThisTurnWatcher extends Watcher {
private final Map<UUID, Integer> amountOfDamageReceivedThisTurn = new HashMap<>();
public AmountOfDamageAPlayerReceivedThisTurnWatcher() {
super(AmountOfDamageAPlayerReceivedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public AmountOfDamageAPlayerReceivedThisTurnWatcher(final AmountOfDamageAPlayerReceivedThisTurnWatcher watcher) {

View file

@ -24,7 +24,7 @@ public class AttackedLastTurnWatcher extends Watcher {
public final Map<UUID, Set<MageObjectReference>> attackedThisTurnCreatures = new HashMap<>(); // dummy map for beginning of turn iteration purposes
public AttackedLastTurnWatcher() {
super(AttackedLastTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public AttackedLastTurnWatcher(final AttackedLastTurnWatcher watcher) {

View file

@ -19,29 +19,29 @@ import mage.watchers.Watcher;
*/
public class AttackedOrBlockedThisCombatWatcher extends Watcher {
public final Set<MageObjectReference> attackedThisTurnCreatures = new HashSet<>();
public final Set<MageObjectReference> blockedThisTurnCreatures = new HashSet<>();
private final Set<MageObjectReference> attackedThisTurnCreatures = new HashSet<>();
private final Set<MageObjectReference> blockedThisTurnCreatures = new HashSet<>();
public AttackedOrBlockedThisCombatWatcher() {
super(AttackedOrBlockedThisCombatWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public AttackedOrBlockedThisCombatWatcher(final AttackedOrBlockedThisCombatWatcher watcher) {
super(watcher);
this.attackedThisTurnCreatures.addAll(watcher.attackedThisTurnCreatures);
this.blockedThisTurnCreatures.addAll(watcher.blockedThisTurnCreatures);
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) {
this.attackedThisTurnCreatures.clear();
this.getAttackedThisTurnCreatures().clear();
}
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) {
this.attackedThisTurnCreatures.add(new MageObjectReference(event.getSourceId(), game));
this.getAttackedThisTurnCreatures().add(new MageObjectReference(event.getSourceId(), game));
}
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) {
this.blockedThisTurnCreatures.add(new MageObjectReference(event.getSourceId(), game));
this.getBlockedThisTurnCreatures().add(new MageObjectReference(event.getSourceId(), game));
}
}

View file

@ -18,11 +18,11 @@ import java.util.Set;
*/
public class AttackedThisTurnWatcher extends Watcher {
protected final Set<MageObjectReference> attackedThisTurnCreatures = new HashSet<>();
protected final Map<MageObjectReference, Integer> attackedThisTurnCreaturesCounts = new HashMap<>();
private final Set<MageObjectReference> attackedThisTurnCreatures = new HashSet<>();
private final Map<MageObjectReference, Integer> attackedThisTurnCreaturesCounts = new HashMap<>();
public AttackedThisTurnWatcher() {
super(AttackedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public AttackedThisTurnWatcher(final AttackedThisTurnWatcher watcher) {

View file

@ -3,6 +3,7 @@ package mage.watchers.common;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import mage.MageObjectReference;
import mage.constants.WatcherScope;
@ -18,10 +19,10 @@ import mage.watchers.Watcher;
*/
public class BlockedAttackerWatcher extends Watcher {
public final HashMap<MageObjectReference, Set<MageObjectReference>> blockData = new HashMap<>();
private final Map<MageObjectReference, Set<MageObjectReference>> blockData = new HashMap<>();
public BlockedAttackerWatcher() {
super(BlockedAttackerWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public BlockedAttackerWatcher(final BlockedAttackerWatcher watcher) {

View file

@ -18,7 +18,7 @@ public class BlockedByOnlyOneCreatureThisCombatWatcher extends Watcher {
private final Map<CombatGroup, UUID> blockedByOneCreature = new HashMap<>();
public BlockedByOnlyOneCreatureThisCombatWatcher() {
super(BlockedByOnlyOneCreatureThisCombatWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public BlockedByOnlyOneCreatureThisCombatWatcher(final BlockedByOnlyOneCreatureThisCombatWatcher watcher) {

View file

@ -19,7 +19,7 @@ public class BlockedThisTurnWatcher extends Watcher {
private final Set<MageObjectReference> blockedThisTurnCreatures;
public BlockedThisTurnWatcher() {
super(BlockedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
blockedThisTurnCreatures = new HashSet<>();
}

View file

@ -16,7 +16,7 @@ import java.util.UUID;
*/
public class BloodthirstWatcher extends Watcher {
public BloodthirstWatcher(UUID controllerId) {
super(BloodthirstWatcher.class.getSimpleName(), WatcherScope.PLAYER);
super(WatcherScope.PLAYER);
this.controllerId = controllerId;
}

View file

@ -22,7 +22,7 @@ public class CardsAmountDrawnThisTurnWatcher extends Watcher {
private final Map<UUID, Integer> amountOfCardsDrawnThisTurn = new HashMap<>();
public CardsAmountDrawnThisTurnWatcher() {
super(CardsAmountDrawnThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public CardsAmountDrawnThisTurnWatcher(final CardsAmountDrawnThisTurnWatcher watcher) {

View file

@ -27,7 +27,7 @@ public class CardsCycledOrDiscardedThisTurnWatcher extends Watcher {
private final Map<UUID, Set<MageObjectReference>> numberOfCycledOrDiscardedCardsThisTurn = new HashMap<>();
public CardsCycledOrDiscardedThisTurnWatcher() {
super(CardsCycledOrDiscardedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public CardsCycledOrDiscardedThisTurnWatcher(final CardsCycledOrDiscardedThisTurnWatcher watcher) {

View file

@ -24,7 +24,7 @@ public class CardsDrawnDuringDrawStepWatcher extends Watcher {
private final Map<UUID, Integer> amountOfCardsDrawnThisTurn = new HashMap<>();
public CardsDrawnDuringDrawStepWatcher() {
super(CardsDrawnDuringDrawStepWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public CardsDrawnDuringDrawStepWatcher(final CardsDrawnDuringDrawStepWatcher watcher) {

View file

@ -29,7 +29,7 @@ public class CardsPutIntoGraveyardWatcher extends Watcher {
private final Set<MageObjectReference> cardsPutToGraveyardFromBattlefield = new HashSet<>();
public CardsPutIntoGraveyardWatcher() {
super(CardsPutIntoGraveyardWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public CardsPutIntoGraveyardWatcher(final CardsPutIntoGraveyardWatcher watcher) {

View file

@ -20,7 +20,7 @@ public class CastFromGraveyardWatcher extends Watcher {
private final Map<UUID, HashSet<Integer>> spellsCastFromGraveyard = new HashMap<>();
public CastFromGraveyardWatcher() {
super(CastFromGraveyardWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public CastFromGraveyardWatcher(final CastFromGraveyardWatcher watcher) {

View file

@ -18,7 +18,7 @@ public class CastFromHandWatcher extends Watcher {
private Step step;
public CastFromHandWatcher() {
super(CastFromHandWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public CastFromHandWatcher(final CastFromHandWatcher watcher) {

View file

@ -20,7 +20,7 @@ public class CastSpellLastTurnWatcher extends Watcher {
private final List<MageObjectReference> spellsCastThisTurnInOrder = new ArrayList<>();
public CastSpellLastTurnWatcher() {
super(CastSpellLastTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public CastSpellLastTurnWatcher(final CastSpellLastTurnWatcher watcher) {

View file

@ -19,7 +19,7 @@ public class CastSpellYourLastTurnWatcher extends Watcher {
private UUID lastActivePlayer = null;
public CastSpellYourLastTurnWatcher() {
super(CastSpellYourLastTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public CastSpellYourLastTurnWatcher(final CastSpellYourLastTurnWatcher watcher) {

View file

@ -17,7 +17,7 @@ public class ChooseBlockersRedundancyWatcher extends Watcher { // workaround for
public int copyCountApply = 0;
public ChooseBlockersRedundancyWatcher() {
super(ChooseBlockersRedundancyWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public ChooseBlockersRedundancyWatcher(final ChooseBlockersRedundancyWatcher watcher) {

View file

@ -24,11 +24,11 @@ import mage.watchers.Watcher;
*/
public class CommanderInfoWatcher extends Watcher {
public final Map<UUID, Integer> damageToPlayer = new HashMap<>();
public final boolean checkCommanderDamage;
private final Map<UUID, Integer> damageToPlayer = new HashMap<>();
private final boolean checkCommanderDamage;
public CommanderInfoWatcher(UUID commander, boolean checkCommanderDamage) {
super(CommanderInfoWatcher.class.getSimpleName(), WatcherScope.CARD);
super(WatcherScope.CARD);
this.sourceId = commander;
this.checkCommanderDamage = checkCommanderDamage;
}

View file

@ -20,7 +20,7 @@ public class CreatureAttackedWhichPlayerWatcher extends Watcher {
private final Map<UUID, UUID> getPlayerAttackedThisTurnByCreature = new HashMap<>();
public CreatureAttackedWhichPlayerWatcher() {
super(CreatureAttackedWhichPlayerWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public CreatureAttackedWhichPlayerWatcher(final CreatureAttackedWhichPlayerWatcher watcher) {

View file

@ -22,7 +22,7 @@ public class CreatureWasCastWatcher extends Watcher {
private final Set<UUID> creaturesCasted = new HashSet<>();
public CreatureWasCastWatcher() {
super(CreatureWasCastWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public CreatureWasCastWatcher(final CreatureWasCastWatcher watcher) {

View file

@ -2,6 +2,7 @@
package mage.watchers.common;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import mage.constants.WatcherScope;
import mage.game.Game;
@ -14,11 +15,11 @@ import mage.watchers.Watcher;
*/
public class CreaturesDiedWatcher extends Watcher {
private final HashMap<UUID, Integer> amountOfCreaturesThatDiedByController = new HashMap<>();
private final HashMap<UUID, Integer> amountOfCreaturesThatDiedByOwner = new HashMap<>();
private final Map<UUID, Integer> amountOfCreaturesThatDiedByController = new HashMap<>();
private final Map<UUID, Integer> amountOfCreaturesThatDiedByOwner = new HashMap<>();
public CreaturesDiedWatcher() {
super(CreaturesDiedWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public CreaturesDiedWatcher(final CreaturesDiedWatcher watcher) {

View file

@ -21,18 +21,26 @@ import java.util.UUID;
public class DamageDoneWatcher extends Watcher {
// which object did how much damage during the turn
public final Map<MageObjectReference, Integer> damagingObjects;
private final Map<MageObjectReference, Integer> damagingObjects;
public Map<MageObjectReference, Integer> getDamagingObjects() {
return damagingObjects;
}
public Map<MageObjectReference, Integer> getDamagedObjects() {
return damagedObjects;
}
// which object received how much damage during the turn
public final Map<MageObjectReference, Integer> damagedObjects;
private final Map<MageObjectReference, Integer> damagedObjects;
public DamageDoneWatcher() {
super(DamageDoneWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
this.damagingObjects = new HashMap<>();
this.damagedObjects = new HashMap<>();
}
public DamageDoneWatcher(final DamageDoneWatcher watcher) {
private DamageDoneWatcher(final DamageDoneWatcher watcher) {
super(watcher);
this.damagingObjects = new HashMap<>(watcher.damagingObjects);
this.damagedObjects = new HashMap<>(watcher.damagedObjects);

View file

@ -28,7 +28,7 @@ public class DamagedByWatcher extends Watcher {
}
public DamagedByWatcher(boolean watchPlaneswalkers) {
super(DamagedByWatcher.class.getSimpleName(), WatcherScope.CARD);
super(WatcherScope.CARD);
this.watchPlaneswalkers = watchPlaneswalkers;
}

View file

@ -26,7 +26,7 @@ public class DragonOnTheBattlefieldWhileSpellWasCastWatcher extends Watcher {
private final Set<UUID> castWithDragonOnTheBattlefield = new HashSet<>();
public DragonOnTheBattlefieldWhileSpellWasCastWatcher() {
super(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public DragonOnTheBattlefieldWhileSpellWasCastWatcher(final DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher) {

View file

@ -19,7 +19,7 @@ public class FirstSpellCastThisTurnWatcher extends Watcher {
private final Map<UUID, UUID> playerFirstCastSpell = new HashMap<>();
public FirstSpellCastThisTurnWatcher() {
super(FirstSpellCastThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public FirstSpellCastThisTurnWatcher(final FirstSpellCastThisTurnWatcher watcher) {

View file

@ -18,7 +18,7 @@ public class FirstTimeStepWatcher extends Watcher {
private final EventType eventType;
public FirstTimeStepWatcher(EventType eventType) {
super(eventType.toString() + FirstTimeStepWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
this.eventType = eventType;
}
@ -38,4 +38,9 @@ public class FirstTimeStepWatcher extends Watcher {
condition = true;
}
}
@Override
public String getBasicKey(){
return eventType.toString() + FirstTimeStepWatcher.class.getSimpleName();
}
}

View file

@ -19,7 +19,7 @@ public class GravestormWatcher extends Watcher {
private int gravestormCount = 0;
public GravestormWatcher() {
super(GravestormWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public GravestormWatcher(final GravestormWatcher watcher) {

View file

@ -15,14 +15,14 @@ import mage.watchers.Watcher;
*/
public class LandfallWatcher extends Watcher {
final Set<UUID> playerPlayedLand = new HashSet<>(); // player that had a land enter the battlefield
final Set<UUID> landEnteredBattlefield = new HashSet<>(); // land played
private final Set<UUID> playerPlayedLand = new HashSet<>(); // player that had a land enter the battlefield
private final Set<UUID> landEnteredBattlefield = new HashSet<>(); // land played
public LandfallWatcher() {
super(LandfallWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public LandfallWatcher(final LandfallWatcher watcher) {
private LandfallWatcher(final LandfallWatcher watcher) {
super(watcher);
playerPlayedLand.addAll(watcher.playerPlayedLand);
landEnteredBattlefield.addAll(watcher.landEnteredBattlefield);

View file

@ -19,7 +19,7 @@ public class LifeLossOtherFromCombatWatcher extends Watcher {
private final Set<UUID> players = new HashSet<>();
public LifeLossOtherFromCombatWatcher() {
super(LifeLossOtherFromCombatWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public LifeLossOtherFromCombatWatcher(final LifeLossOtherFromCombatWatcher watcher) {

View file

@ -17,10 +17,10 @@ import mage.watchers.Watcher;
*/
public class ManaSpentToCastWatcher extends Watcher {
Mana payment = null;
private Mana payment = null;
public ManaSpentToCastWatcher() {
super(ManaSpentToCastWatcher.class.getSimpleName(), WatcherScope.CARD);
super(WatcherScope.CARD);
}
public ManaSpentToCastWatcher(final ManaSpentToCastWatcher watcher) {

View file

@ -29,7 +29,7 @@ public class MiracleWatcher extends Watcher {
private final Map<UUID, Integer> amountOfCardsDrawnThisTurn = new HashMap<>();
public MiracleWatcher() {
super(MiracleWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public MiracleWatcher(final MiracleWatcher watcher) {

View file

@ -14,7 +14,7 @@ import mage.watchers.Watcher;
public class MorbidWatcher extends Watcher {
public MorbidWatcher() {
super(MorbidWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public MorbidWatcher(final MorbidWatcher watcher) {

View file

@ -20,7 +20,7 @@ public class NumberOfTimesPermanentTargetedATurnWatcher extends Watcher {
private final Map<MageObjectReference, Integer> permanentsTargeted = new HashMap<>();
public NumberOfTimesPermanentTargetedATurnWatcher() {
super(NumberOfTimesPermanentTargetedATurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public NumberOfTimesPermanentTargetedATurnWatcher(final NumberOfTimesPermanentTargetedATurnWatcher watcher) {

View file

@ -5,10 +5,8 @@
*/
package mage.watchers.common;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.*;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -21,11 +19,11 @@ import mage.watchers.Watcher;
*/
public class PermanentsEnteredBattlefieldWatcher extends Watcher {
private final HashMap<UUID, List<Permanent>> enteringBattlefield = new HashMap<>();
private final HashMap<UUID, List<Permanent>> enteringBattlefieldLastTurn = new HashMap<>();
private final Map<UUID, List<Permanent>> enteringBattlefield = new HashMap<>();
private final Map<UUID, List<Permanent>> enteringBattlefieldLastTurn = new HashMap<>();
public PermanentsEnteredBattlefieldWatcher() {
super(PermanentsEnteredBattlefieldWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public PermanentsEnteredBattlefieldWatcher(final PermanentsEnteredBattlefieldWatcher watcher) {

View file

@ -11,10 +11,7 @@ import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.watchers.Watcher;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
*
@ -22,12 +19,12 @@ import java.util.UUID;
*/
public class PermanentsEnteredBattlefieldYourLastTurnWatcher extends Watcher {
private final HashMap<UUID, List<Permanent>> enteringBattlefield = new HashMap<>();
private final HashMap<UUID, List<Permanent>> enteringBattlefieldLastTurn = new HashMap<>();
private final Map<UUID, List<Permanent>> enteringBattlefield = new HashMap<>();
private final Map<UUID, List<Permanent>> enteringBattlefieldLastTurn = new HashMap<>();
private UUID lastActivePlayer = null;
public PermanentsEnteredBattlefieldYourLastTurnWatcher() {
super(PermanentsEnteredBattlefieldYourLastTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public PermanentsEnteredBattlefieldYourLastTurnWatcher(final PermanentsEnteredBattlefieldYourLastTurnWatcher watcher) {

View file

@ -5,10 +5,8 @@
*/
package mage.watchers.common;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.*;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -21,10 +19,10 @@ import mage.watchers.Watcher;
*/
public class PermanentsSacrificedWatcher extends Watcher {
private final HashMap<UUID, List<Permanent>> sacrificedPermanents = new HashMap<>();
private final Map<UUID, List<Permanent>> sacrificedPermanents = new HashMap<>();
public PermanentsSacrificedWatcher() {
super(PermanentsSacrificedWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public PermanentsSacrificedWatcher(final PermanentsSacrificedWatcher watcher) {

View file

@ -21,7 +21,7 @@ public class PlanarRollWatcher extends Watcher {
private final Map<UUID, Integer> numberTimesPlanarDieRolled = new HashMap<>();
public PlanarRollWatcher() {
super(PlanarRollWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public PlanarRollWatcher(final PlanarRollWatcher watcher) {

View file

@ -14,11 +14,11 @@ import mage.watchers.Watcher;
*/
public class PlayLandWatcher extends Watcher {
final Set<UUID> playerPlayedLand = new HashSet<>(); // player that played land
final Set<UUID> landPlayed = new HashSet<>(); // land played
private final Set<UUID> playerPlayedLand = new HashSet<>(); // player that played land
private final Set<UUID> landPlayed = new HashSet<>(); // land played
public PlayLandWatcher() {
super(PlayLandWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public PlayLandWatcher(final PlayLandWatcher watcher) {

View file

@ -18,7 +18,7 @@ public class PlayerAttackedStepWatcher extends Watcher {
private final Map<UUID, Integer> playerAttacked = new HashMap<>();
public PlayerAttackedStepWatcher() {
super(PlayerAttackedStepWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public PlayerAttackedStepWatcher(final PlayerAttackedStepWatcher watcher) {

View file

@ -21,7 +21,7 @@ public class PlayerAttackedWatcher extends Watcher {
private final Map<UUID, Integer> playerAttacked = new HashMap<>();
public PlayerAttackedWatcher() {
super(PlayerAttackedWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public PlayerAttackedWatcher(final PlayerAttackedWatcher watcher) {

View file

@ -1,25 +1,25 @@
package mage.watchers.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.watchers.Watcher;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public class PlayerCastCreatureWatcher extends Watcher {
final Set<UUID> playerIds = new HashSet<>();
private final Set<UUID> playerIds = new HashSet<>();
public PlayerCastCreatureWatcher() {
super(PlayerCastCreatureWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public PlayerCastCreatureWatcher(final PlayerCastCreatureWatcher watcher) {

View file

@ -21,7 +21,7 @@ public class PlayerDamagedBySourceWatcher extends Watcher {
private final Set<String> damageSourceIds = new HashSet<>();
public PlayerDamagedBySourceWatcher(UUID playerId) {
super(PlayerDamagedBySourceWatcher.class.getSimpleName(), WatcherScope.PLAYER);
super(WatcherScope.PLAYER);
setControllerId(playerId);
}

View file

@ -21,7 +21,7 @@ public class PlayerGainedLifeWatcher extends Watcher {
private final Map<UUID, Integer> amountOfLifeGainedThisTurn = new HashMap<>();
public PlayerGainedLifeWatcher() {
super(PlayerGainedLifeWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
private PlayerGainedLifeWatcher(final PlayerGainedLifeWatcher watcher) {

View file

@ -25,7 +25,7 @@ public class PlayerLostLifeNonCombatWatcher extends Watcher {
private final Map<UUID, Integer> amountOfLifeLostLastTurn = new HashMap<>();
public PlayerLostLifeNonCombatWatcher() {
super(PlayerLostLifeNonCombatWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public PlayerLostLifeNonCombatWatcher(final PlayerLostLifeNonCombatWatcher watcher) {

View file

@ -23,7 +23,7 @@ public class PlayerLostLifeWatcher extends Watcher {
private final Map<UUID, Integer> amountOfLifeLostLastTurn = new HashMap<>();
public PlayerLostLifeWatcher() {
super(PlayerLostLifeWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public PlayerLostLifeWatcher(final PlayerLostLifeWatcher watcher) {

View file

@ -20,7 +20,7 @@ public class PlayersAttackedLastTurnWatcher extends Watcher {
private final Map<UUID, PlayerList> playersAttackedInLastTurn = new HashMap<>();
public PlayersAttackedLastTurnWatcher() {
super(PlayersAttackedLastTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public PlayersAttackedLastTurnWatcher(final PlayersAttackedLastTurnWatcher watcher) {

View file

@ -20,7 +20,7 @@ public class PlayersAttackedThisTurnWatcher extends Watcher {
private final Map<UUID, PlayerList> opponentsAttackedThisTurn = new HashMap<>();
public PlayersAttackedThisTurnWatcher() {
super(PlayersAttackedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public PlayersAttackedThisTurnWatcher(final PlayersAttackedThisTurnWatcher watcher) {

View file

@ -26,10 +26,10 @@ public class ProwlWatcher extends Watcher {
private final Set<UUID> allSubtypes = new HashSet<>();
public ProwlWatcher() {
super(ProwlWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public ProwlWatcher(final ProwlWatcher watcher) {
private ProwlWatcher(final ProwlWatcher watcher) {
super(watcher);
for (Entry<UUID, Set<SubType>> entry : watcher.damagingSubtypes.entrySet()) {
damagingSubtypes.put(entry.getKey(), entry.getValue());

View file

@ -22,7 +22,7 @@ public class RevoltWatcher extends Watcher {
private final Set<UUID> revoltActivePlayerIds = new HashSet<>(0);
public RevoltWatcher() {
super(RevoltWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public RevoltWatcher(final RevoltWatcher watcher) {

View file

@ -19,7 +19,7 @@ public class SourceDidDamageWatcher extends Watcher {
public final Set<UUID> damageSources = new HashSet<>();
public SourceDidDamageWatcher() {
super(SourceDidDamageWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public SourceDidDamageWatcher(final SourceDidDamageWatcher watcher) {

View file

@ -5,10 +5,8 @@
*/
package mage.watchers.common;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.*;
import mage.MageObject;
import mage.constants.WatcherScope;
import mage.constants.Zone;
@ -25,11 +23,11 @@ import mage.watchers.Watcher;
*/
public class SpellsCastWatcher extends Watcher {
private final HashMap<UUID, List<Spell>> spellsCast = new HashMap<>();
private final Map<UUID, List<Spell>> spellsCast = new HashMap<>();
private int nonCreatureSpells;
public SpellsCastWatcher() {
super(SpellsCastWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public SpellsCastWatcher(final SpellsCastWatcher watcher) {

View file

@ -19,11 +19,11 @@ public class WasBlockedThisTurnWatcher extends Watcher {
private final Set<MageObjectReference> wasBlockedThisTurnCreatures;
public WasBlockedThisTurnWatcher() {
super(WasBlockedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
wasBlockedThisTurnCreatures = new HashSet<>();
}
public WasBlockedThisTurnWatcher(final WasBlockedThisTurnWatcher watcher) {
private WasBlockedThisTurnWatcher(final WasBlockedThisTurnWatcher watcher) {
super(watcher);
wasBlockedThisTurnCreatures = new HashSet<>(watcher.wasBlockedThisTurnCreatures);
}

View file

@ -21,7 +21,7 @@ public class ZuberasDiedWatcher extends Watcher {
private int zuberasDiedThisTurn = 0;
public ZuberasDiedWatcher() {
super(ZuberasDiedWatcher.class.getSimpleName(), WatcherScope.GAME);
super(WatcherScope.GAME);
}
public ZuberasDiedWatcher(final ZuberasDiedWatcher watcher) {