first batch of watcher naming

This commit is contained in:
igoudt 2017-04-29 08:33:10 +02:00
parent 20a881a374
commit efae1251f9
111 changed files with 177 additions and 179 deletions

View file

@ -31,6 +31,7 @@ import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
import mage.watchers.Watcher;
import mage.watchers.common.MorbidWatcher;
/**
* @author nantuko
@ -41,7 +42,7 @@ public enum MorbidCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Watcher watcher = game.getState().getWatchers().get("Morbid");
Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName());
return watcher.conditionMet();
}

View file

@ -49,7 +49,7 @@ public enum NoSpellsWereCastLastTurnCondition implements Condition {
return false;
}
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName());
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
// if any player cast spell, return false
for (Integer count : watcher.getAmountOfSpellsCastOnPrevTurn().values()) {
if (count > 0) {

View file

@ -41,7 +41,7 @@ public enum TwoOrMoreSpellsWereCastLastTurnCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName());
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
// if any player cast more than two spells, return true
for (Integer count : watcher.getAmountOfSpellsCastOnPrevTurn().values()) {
if (count >= 2) {

View file

@ -100,7 +100,7 @@ class StormEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
MageObjectReference spellRef = (MageObjectReference) this.getValue("StormSpellRef");
if (spellRef != null) {
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName());
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
int stormCount = watcher.getSpellOrder(spellRef, game) - 1;
if (stormCount > 0) {
Spell spell = (Spell) this.getValue("StormSpell");

View file

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

View file

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

View file

@ -43,7 +43,7 @@ public class AttackedThisTurnWatcher extends Watcher {
public final Set<MageObjectReference> attackedThisTurnCreatures = new HashSet<>();
public AttackedThisTurnWatcher() {
super(AttackedThisTurnWatcher.class.getName(), WatcherScope.GAME);
super(AttackedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public AttackedThisTurnWatcher(final AttackedThisTurnWatcher watcher) {

View file

@ -47,7 +47,7 @@ public class BlockedAttackerWatcher extends Watcher {
public final HashMap<MageObjectReference, Set<MageObjectReference>> blockData = new HashMap<>();
public BlockedAttackerWatcher() {
super("BlockedAttackerWatcher", WatcherScope.GAME);
super(BlockedAttackerWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public BlockedAttackerWatcher(final BlockedAttackerWatcher watcher) {

View file

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

View file

@ -37,11 +37,12 @@ import java.util.UUID;
/**
* Must be installed to player for proper Bloodthirst work
*
* @author Loki
*/
public class BloodthirstWatcher extends Watcher {
public BloodthirstWatcher(UUID controllerId) {
super("DamagedOpponents", WatcherScope.PLAYER);
super(BloodthirstWatcher.class.getSimpleName(), WatcherScope.PLAYER);
this.controllerId = controllerId;
}
@ -55,7 +56,7 @@ public class BloodthirstWatcher extends Watcher {
return;
}
if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
if (game.getPlayer(this.getControllerId()).hasOpponent(damageEvent.getPlayerId(), game)) {
condition = true;
}

View file

@ -44,12 +44,11 @@ import java.util.UUID;
*/
public class CardsAmountDrawnThisTurnWatcher extends Watcher {
public final static String BASIC_KEY = "CardsAmountDrawnThisTurnWatcher";
private final Map<UUID, Integer> amountOfCardsDrawnThisTurn = new HashMap<>();
public CardsAmountDrawnThisTurnWatcher() {
super(BASIC_KEY, WatcherScope.GAME);
super(CardsAmountDrawnThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public CardsAmountDrawnThisTurnWatcher(final CardsAmountDrawnThisTurnWatcher watcher) {

View file

@ -49,7 +49,7 @@ public class CardsCycledOrDiscardedThisTurnWatcher extends Watcher {
private final Map<UUID, Cards> cycledOrDiscardedCardsThisTurn = new HashMap<>();
public CardsCycledOrDiscardedThisTurnWatcher() {
super(CardsCycledOrDiscardedThisTurnWatcher.class.getName(), WatcherScope.GAME);
super(CardsCycledOrDiscardedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public CardsCycledOrDiscardedThisTurnWatcher(final CardsCycledOrDiscardedThisTurnWatcher watcher) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -54,7 +54,7 @@ public class CommanderInfoWatcher extends Watcher {
public final boolean checkCommanderDamage;
public CommanderInfoWatcher(UUID commander, boolean checkCommanderDamage) {
super("CommanderCombatDamageWatcher", WatcherScope.CARD);
super(CommanderInfoWatcher.class.getSimpleName(), WatcherScope.CARD);
this.sourceId = commander;
this.checkCommanderDamage = checkCommanderDamage;
}

View file

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

View file

@ -45,7 +45,7 @@ public class CreaturesDiedWatcher extends Watcher {
private final HashMap<UUID, Integer> amountOfCreaturesThatDiedByController = new HashMap<>();
public CreaturesDiedWatcher() {
super("CreaturesDiedWatcher", WatcherScope.GAME);
super(CreaturesDiedWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public CreaturesDiedWatcher(final CreaturesDiedWatcher watcher) {

View file

@ -27,7 +27,7 @@ public class DamageDoneWatcher extends Watcher {
public final Map<MageObjectReference, Integer> damagedObjects;
public DamageDoneWatcher() {
super("DamageDone", WatcherScope.GAME);
super(DamageDoneWatcher.class.getSimpleName(), WatcherScope.GAME);
this.damagingObjects = new HashMap<>();
this.damagedObjects = new HashMap<>();
}

View file

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

View file

@ -51,7 +51,7 @@ public class DragonOnTheBattlefieldWhileSpellWasCastWatcher extends Watcher {
private final Set<UUID> castWithDragonOnTheBattlefield = new HashSet<>();
public DragonOnTheBattlefieldWhileSpellWasCastWatcher() {
super("DragonOnTheBattlefieldWhileSpellWasCastWatcher", WatcherScope.GAME);
super(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName(), 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("FirstSpellCastThisTurn", WatcherScope.GAME);
super(FirstSpellCastThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public FirstSpellCastThisTurnWatcher(final FirstSpellCastThisTurnWatcher watcher) {

View file

@ -44,7 +44,7 @@ public class FirstTimeStepWatcher extends Watcher {
private final EventType eventType;
public FirstTimeStepWatcher(EventType eventType) {
super(eventType.toString() + FirstTimeStepWatcher.class.getName(), WatcherScope.GAME);
super(eventType.toString() + FirstTimeStepWatcher.class.getSimpleName(), WatcherScope.GAME);
this.eventType = eventType;
}

View file

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

View file

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

View file

@ -45,7 +45,7 @@ public class LifeLossOtherFromCombatWatcher extends Watcher {
private final Set<UUID> players = new HashSet<>();
public LifeLossOtherFromCombatWatcher() {
super(LifeLossOtherFromCombatWatcher.class.getName(), WatcherScope.GAME);
super(LifeLossOtherFromCombatWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public LifeLossOtherFromCombatWatcher(final LifeLossOtherFromCombatWatcher watcher) {
@ -66,7 +66,7 @@ public class LifeLossOtherFromCombatWatcher extends Watcher {
public boolean opponentLostLifeOtherFromCombat(UUID playerId, Game game) {
Player player = game.getPlayer(playerId);
if (player != null) {
if (players.stream().anyMatch((damagedPlayerId) -> (player.hasOpponent(damagedPlayerId, game)))) {
if (players.stream().anyMatch(damagedPlayerId -> player.hasOpponent(damagedPlayerId, game))) {
return true;
}
}

View file

@ -46,7 +46,7 @@ public class ManaSpentToCastWatcher extends Watcher {
Mana payment = null;
public ManaSpentToCastWatcher() {
super("ManaSpentToCast", WatcherScope.CARD);
super(ManaSpentToCastWatcher.class.getSimpleName(), WatcherScope.CARD);
}
public ManaSpentToCastWatcher(final ManaSpentToCastWatcher watcher) {

View file

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

View file

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

View file

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

View file

@ -25,7 +25,7 @@ public class PermanentsEnteredBattlefieldWatcher extends Watcher {
private final HashMap<UUID, List<Permanent>> enteringBattlefieldLastTurn = new HashMap<>();
public PermanentsEnteredBattlefieldWatcher() {
super(PermanentsEnteredBattlefieldWatcher.class.getName(), WatcherScope.GAME);
super(PermanentsEnteredBattlefieldWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public PermanentsEnteredBattlefieldWatcher(final PermanentsEnteredBattlefieldWatcher watcher) {

View file

@ -24,7 +24,7 @@ public class PermanentsSacrificedWatcher extends Watcher {
private final HashMap<UUID, List<Permanent>> sacrificedPermanents = new HashMap<>();
public PermanentsSacrificedWatcher() {
super(PermanentsSacrificedWatcher.class.getName(), WatcherScope.GAME);
super(PermanentsSacrificedWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public PermanentsSacrificedWatcher(final PermanentsSacrificedWatcher watcher) {

View file

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

View file

@ -46,7 +46,7 @@ public class PlayerCastCreatureWatcher extends Watcher {
final Set<UUID> playerIds = new HashSet<>();
public PlayerCastCreatureWatcher() {
super("PlayerCastCreature", WatcherScope.GAME);
super(PlayerCastCreatureWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public PlayerCastCreatureWatcher(final PlayerCastCreatureWatcher watcher) {

View file

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

View file

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

View file

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

View file

@ -55,7 +55,7 @@ public class ProwlWatcher extends Watcher {
private final Set<UUID> allSubtypes = new HashSet<>();
public ProwlWatcher() {
super("Prowl", WatcherScope.GAME);
super(ProwlWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public ProwlWatcher(final ProwlWatcher watcher) {

View file

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

View file

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

View file

@ -27,7 +27,7 @@ public class SpellsCastWatcher extends Watcher {
private final HashMap<UUID, List<Spell>> spellsCast = new HashMap<>();
public SpellsCastWatcher() {
super(SpellsCastWatcher.class.getName(), WatcherScope.GAME);
super(SpellsCastWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public SpellsCastWatcher(final SpellsCastWatcher watcher) {

View file

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