From 9a310732d82965c2413e792e46457526e40f75c5 Mon Sep 17 00:00:00 2001 From: Ingmar Goudt Date: Sun, 6 Jan 2019 20:58:51 +0100 Subject: [PATCH] rewrite watchers to GameState.getWatcher(), rather than getWatchers().get(). This hides away the implementation of the watchers. Accepts the class rather than the name. Always returns the specific subclass, so there is no more casting needed. Only 1 line in the common library remains, that is still using the old 'deprecated' method. Needs a new version release to do that. --- .../mage/cards/a/AbandonedSarcophagus.java | 2 +- .../src/mage/cards/a/AdmiralBeckettBrass.java | 2 +- .../src/mage/cards/a/AetherfluxReservoir.java | 2 +- Mage.Sets/src/mage/cards/a/Aggravate.java | 2 +- .../src/mage/cards/a/AlhammarretsArchive.java | 2 +- .../src/mage/cards/a/AngelicArbiter.java | 4 +- Mage.Sets/src/mage/cards/a/AngelsTrumpet.java | 2 +- Mage.Sets/src/mage/cards/a/Antagonism.java | 2 +- .../mage/cards/a/ApproachOfTheSecondSun.java | 2 +- Mage.Sets/src/mage/cards/a/Arboria.java | 4 +- .../src/mage/cards/a/ArchfiendOfDespair.java | 2 +- Mage.Sets/src/mage/cards/a/ArchiveTrap.java | 2 +- .../src/mage/cards/a/ArchmageAscension.java | 6 +-- .../src/mage/cards/a/ArclightPhoenix.java | 6 +-- Mage.Sets/src/mage/cards/a/AsForetold.java | 7 ++- .../src/mage/cards/a/AsmiraHolyAvenger.java | 2 +- Mage.Sets/src/mage/cards/a/AureliasFury.java | 2 +- Mage.Sets/src/mage/cards/a/AvengingArrow.java | 4 +- .../src/mage/cards/b/BalduvianWarlord.java | 2 +- .../src/mage/cards/b/BalothCageTrap.java | 2 +- Mage.Sets/src/mage/cards/b/Berserk.java | 16 +++--- .../src/mage/cards/b/BloodcrazedGoblin.java | 2 +- .../src/mage/cards/b/BontuTheGlorified.java | 2 +- .../mage/cards/b/BoseijuWhoSheltersAll.java | 4 +- .../src/mage/cards/b/BriarbridgePatrol.java | 2 +- .../src/mage/cards/b/BrimstoneVolley.java | 2 +- .../src/mage/cards/b/BrutalHordechief.java | 4 +- .../BurningCinderFuryOfCrimsonChaosFire.java | 2 +- .../src/mage/cards/c/CallerOfTheClaw.java | 2 +- .../src/mage/cards/c/CathedralMembrane.java | 2 +- Mage.Sets/src/mage/cards/c/CavernOfSouls.java | 2 +- .../src/mage/cards/c/CerebralVortex.java | 2 +- .../mage/cards/c/ChainsOfMephistopheles.java | 2 +- .../src/mage/cards/c/ChargingCinderhorn.java | 2 +- .../src/mage/cards/c/ChildrenOfKorlis.java | 2 +- .../src/mage/cards/c/CivilizedScholar.java | 27 +--------- Mage.Sets/src/mage/cards/c/CobraTrap.java | 2 +- Mage.Sets/src/mage/cards/c/ConduitOfRuin.java | 2 +- .../src/mage/cards/c/ContainmentPriest.java | 2 +- Mage.Sets/src/mage/cards/c/CorrosiveOoze.java | 20 ++++---- .../src/mage/cards/c/CryOfTheCarnarium.java | 2 +- .../src/mage/cards/c/CurseOfExhaustion.java | 2 +- .../src/mage/cards/c/CustodiSoulcaller.java | 2 +- Mage.Sets/src/mage/cards/c/CyclopeanTomb.java | 9 ++-- Mage.Sets/src/mage/cards/d/DampingSphere.java | 2 +- .../src/mage/cards/d/DarkbladeAgent.java | 27 ++++------ Mage.Sets/src/mage/cards/d/Desolation.java | 2 +- Mage.Sets/src/mage/cards/d/DraconicRoar.java | 2 +- Mage.Sets/src/mage/cards/d/DreamSalvage.java | 4 +- Mage.Sets/src/mage/cards/d/DreamThief.java | 2 +- .../src/mage/cards/d/DuelingGrounds.java | 4 +- .../src/mage/cards/e/EpharaGodOfThePolis.java | 2 +- .../mage/cards/e/ErayoSoratamiAscendant.java | 4 +- .../src/mage/cards/e/ErdwalIlluminator.java | 2 +- Mage.Sets/src/mage/cards/e/ErgRaiders.java | 2 +- .../src/mage/cards/e/EtherswornCanonist.java | 2 +- .../src/mage/cards/e/ExecutionersSwing.java | 6 +-- .../mage/cards/f/FairgroundsTrumpeter.java | 2 +- Mage.Sets/src/mage/cards/f/FaithsReward.java | 4 +- Mage.Sets/src/mage/cards/f/FalseOrders.java | 2 +- .../src/mage/cards/f/FeastOnTheFallen.java | 2 +- Mage.Sets/src/mage/cards/f/FellShepherd.java | 4 +- .../src/mage/cards/f/FinalPunishment.java | 2 +- .../src/mage/cards/f/FireAndBrimstone.java | 2 +- Mage.Sets/src/mage/cards/f/Flamebreak.java | 2 +- Mage.Sets/src/mage/cards/f/FleshAllergy.java | 4 +- .../mage/cards/f/FoulTongueInvocation.java | 2 +- Mage.Sets/src/mage/cards/f/FrayingSanity.java | 2 +- .../src/mage/cards/f/FreeRangeChicken.java | 4 +- Mage.Sets/src/mage/cards/f/FreshMeat.java | 2 +- Mage.Sets/src/mage/cards/f/FyndhornDruid.java | 2 +- .../src/mage/cards/g/GarnaTheBloodflame.java | 2 +- .../src/mage/cards/g/GazeOfTheGorgon.java | 2 +- .../src/mage/cards/g/GeneratorServant.java | 4 +- Mage.Sets/src/mage/cards/g/GiantTurtle.java | 2 +- .../src/mage/cards/g/GiltspireAvenger.java | 6 +-- Mage.Sets/src/mage/cards/g/GisaAndGeralf.java | 2 +- Mage.Sets/src/mage/cards/g/Gleancrawler.java | 2 +- Mage.Sets/src/mage/cards/g/GlyphKeeper.java | 2 +- Mage.Sets/src/mage/cards/g/GlyphOfDoom.java | 2 +- Mage.Sets/src/mage/cards/g/GoblinCohort.java | 2 +- .../src/mage/cards/g/GoblinRockSled.java | 2 +- Mage.Sets/src/mage/cards/g/Gomazoa.java | 2 +- .../src/mage/cards/g/GontisMachinations.java | 4 +- .../src/mage/cards/g/GrandWarlordRadha.java | 4 +- Mage.Sets/src/mage/cards/g/GrimReminder.java | 4 +- Mage.Sets/src/mage/cards/g/GrimReturn.java | 2 +- .../mage/cards/g/GrothamaAllDevouring.java | 4 +- Mage.Sets/src/mage/cards/g/Gutterbones.java | 2 +- .../src/mage/cards/h/HallowedMoonlight.java | 2 +- Mage.Sets/src/mage/cards/h/HallsOfMist.java | 2 +- .../src/mage/cards/h/HardenedBerserker.java | 4 +- .../src/mage/cards/h/HarnessTheStorm.java | 2 +- Mage.Sets/src/mage/cards/h/HeatStroke.java | 4 +- Mage.Sets/src/mage/cards/h/HollowOne.java | 2 +- .../src/mage/cards/h/HomicidalBrute.java | 5 +- .../mage/cards/h/HomicidalBruteWatcher.java | 32 ++++++++++++ .../src/mage/cards/h/HopeOfGhirapur.java | 2 +- .../src/mage/cards/h/HotheadedGiant.java | 2 +- Mage.Sets/src/mage/cards/h/HuntDown.java | 2 +- .../src/mage/cards/i/ImpactResonance.java | 4 +- Mage.Sets/src/mage/cards/i/Impatience.java | 2 +- Mage.Sets/src/mage/cards/i/Imprison.java | 2 +- Mage.Sets/src/mage/cards/i/Incinerate.java | 2 +- .../src/mage/cards/i/IncursionSpecialist.java | 2 +- .../src/mage/cards/i/InfernoHellion.java | 4 +- Mage.Sets/src/mage/cards/i/InfernoTrap.java | 4 +- .../src/mage/cards/i/InsatiableRakghoul.java | 4 +- Mage.Sets/src/mage/cards/i/Insist.java | 6 +-- Mage.Sets/src/mage/cards/j/JandorsRing.java | 6 +-- .../src/mage/cards/j/JayaBallardTaskMage.java | 2 +- .../mage/cards/j/JelevaNephaliasScourge.java | 4 +- .../src/mage/cards/j/JoriEnRuinDiver.java | 2 +- Mage.Sets/src/mage/cards/j/JovensFerrets.java | 2 +- .../mage/cards/k/KaradorGhostChieftain.java | 4 +- .../src/mage/cards/k/KeldonTwilight.java | 2 +- .../src/mage/cards/k/KeranosGodOfStorms.java | 2 +- .../src/mage/cards/k/KessDissidentMage.java | 6 +-- .../mage/cards/k/KiraGreatGlassSpinner.java | 2 +- .../mage/cards/k/KnightsOfTheBlackRose.java | 4 +- .../src/mage/cards/k/KnollspineDragon.java | 2 +- .../src/mage/cards/k/KraumLudevicsOpus.java | 2 +- .../src/mage/cards/k/KrovikanVampire.java | 8 +-- .../src/mage/cards/k/KumanosBlessing.java | 4 +- .../src/mage/cards/k/KuonOgreAscendant.java | 2 +- .../mage/cards/k/KydeleChosenOfKruphix.java | 4 +- .../src/mage/cards/k/KytheonHeroOfAkros.java | 2 +- Mage.Sets/src/mage/cards/l/LavaballTrap.java | 2 +- Mage.Sets/src/mage/cards/l/Leapfrog.java | 4 +- .../mage/cards/l/LeovoldEmissaryOfTrest.java | 2 +- .../mage/cards/l/LiciaSanguineTribune.java | 4 +- .../mage/cards/l/LudevicNecroAlchemist.java | 2 +- .../src/mage/cards/l/LuminarchAscension.java | 2 +- Mage.Sets/src/mage/cards/l/LureOfPrey.java | 2 +- Mage.Sets/src/mage/cards/m/MadDog.java | 4 +- Mage.Sets/src/mage/cards/m/MaddeningImp.java | 2 +- .../src/mage/cards/m/MaelstromNexus.java | 2 +- .../src/mage/cards/m/MagusOfTheMind.java | 2 +- Mage.Sets/src/mage/cards/m/ManaMaze.java | 4 +- .../src/mage/cards/m/MasterWarcraft.java | 8 +-- Mage.Sets/src/mage/cards/m/Melee.java | 4 +- .../src/mage/cards/m/MercadianAtlas.java | 2 +- .../mage/cards/m/MetzaliTowerOfTriumph.java | 2 +- Mage.Sets/src/mage/cards/m/MindbreakTrap.java | 2 +- Mage.Sets/src/mage/cards/m/MindsDilation.java | 2 +- .../src/mage/cards/m/MindstormCrown.java | 4 +- Mage.Sets/src/mage/cards/m/Mistcaller.java | 2 +- .../src/mage/cards/m/MoggConscripts.java | 2 +- Mage.Sets/src/mage/cards/m/MoltenPsyche.java | 2 +- .../mage/cards/m/MuldrothaTheGravetide.java | 4 +- .../src/mage/cards/m/MultanisPresence.java | 2 +- Mage.Sets/src/mage/cards/n/NeedleDrop.java | 2 +- .../src/mage/cards/n/NeedlebiteTrap.java | 4 +- .../src/mage/cards/n/NoRestForTheWicked.java | 4 +- Mage.Sets/src/mage/cards/n/NotionThief.java | 2 +- .../src/mage/cards/n/NotoriousThrong.java | 2 +- .../src/mage/cards/n/NullstoneGargoyle.java | 2 +- .../mage/cards/o/OKagachiVengefulKami.java | 2 +- Mage.Sets/src/mage/cards/o/OathOfChandra.java | 4 +- Mage.Sets/src/mage/cards/o/OathOfLiliana.java | 4 +- .../mage/cards/o/OdricMasterTactician.java | 4 +- Mage.Sets/src/mage/cards/o/OpalPalace.java | 4 +- Mage.Sets/src/mage/cards/o/OracleEnVec.java | 2 +- .../src/mage/cards/o/OratorOfOjutai.java | 4 +- Mage.Sets/src/mage/cards/o/Overmaster.java | 6 +-- .../mage/cards/p/PalladiaMorsTheRuiner.java | 4 +- Mage.Sets/src/mage/cards/p/ParadoxHaze.java | 2 +- .../src/mage/cards/p/PatriciansScorn.java | 4 +- .../src/mage/cards/p/PermafrostTrap.java | 2 +- .../src/mage/cards/p/PetrifiedWoodKin.java | 2 +- .../src/mage/cards/p/PistonFistCyclops.java | 4 +- .../mage/cards/p/PlaneswalkersMischief.java | 2 +- Mage.Sets/src/mage/cards/p/PowerSurge.java | 4 +- .../src/mage/cards/p/PredatoryAdvantage.java | 4 +- .../src/mage/cards/p/PrematureBurial.java | 6 +-- Mage.Sets/src/mage/cards/p/PrizedAmalgam.java | 2 +- Mage.Sets/src/mage/cards/p/PsychicTheft.java | 2 +- .../src/mage/cards/p/PyromancersAssault.java | 2 +- Mage.Sets/src/mage/cards/q/Quicken.java | 4 +- .../mage/cards/r/RashmiEternitiesCrafter.java | 2 +- .../src/mage/cards/r/RasputinDreamweaver.java | 4 +- Mage.Sets/src/mage/cards/r/RavenousTrap.java | 2 +- .../src/mage/cards/r/ReaperFromTheAbyss.java | 2 +- Mage.Sets/src/mage/cards/r/Reciprocate.java | 6 +-- .../src/mage/cards/r/RefractionTrap.java | 2 +- .../src/mage/cards/r/RegnaTheRedeemer.java | 4 +- Mage.Sets/src/mage/cards/r/RelicRunner.java | 2 +- .../src/mage/cards/r/RestoreThePeace.java | 2 +- Mage.Sets/src/mage/cards/r/Revenge.java | 2 +- .../src/mage/cards/r/ReversePolarity.java | 2 +- Mage.Sets/src/mage/cards/r/RicochetTrap.java | 2 +- .../src/mage/cards/r/RimehornAurochs.java | 2 +- .../src/mage/cards/r/RixMaadiGuildmage.java | 2 +- .../src/mage/cards/r/RocketLauncher.java | 4 +- Mage.Sets/src/mage/cards/r/RuneflareTrap.java | 2 +- Mage.Sets/src/mage/cards/r/Runesword.java | 2 +- .../src/mage/cards/s/SaheeliTheGifted.java | 4 +- .../src/mage/cards/s/SavageSummoning.java | 8 +-- .../src/mage/cards/s/ScaleguardSentinels.java | 2 +- Mage.Sets/src/mage/cards/s/ScoutsWarning.java | 2 +- Mage.Sets/src/mage/cards/s/SeaTroll.java | 2 +- Mage.Sets/src/mage/cards/s/SearingBlaze.java | 2 +- .../src/mage/cards/s/SeasonOfTheWitch.java | 6 +-- Mage.Sets/src/mage/cards/s/SecondGuess.java | 2 +- Mage.Sets/src/mage/cards/s/SecondSunrise.java | 4 +- Mage.Sets/src/mage/cards/s/Seedtime.java | 2 +- .../src/mage/cards/s/SeekerOfInsight.java | 2 +- Mage.Sets/src/mage/cards/s/SentinelTower.java | 4 +- .../src/mage/cards/s/ShadowOfTheGrave.java | 2 +- .../src/mage/cards/s/ShapeOfTheWiitigo.java | 4 +- .../src/mage/cards/s/SiftThroughSands.java | 4 +- .../src/mage/cards/s/SilburlindSnapper.java | 2 +- .../src/mage/cards/s/SilentChantZubera.java | 4 +- .../src/mage/cards/s/SilumgarsScorn.java | 2 +- Mage.Sets/src/mage/cards/s/Simulacrum.java | 2 +- Mage.Sets/src/mage/cards/s/SirensCall.java | 2 +- .../src/mage/cards/s/SkarrganFirebird.java | 2 +- Mage.Sets/src/mage/cards/s/Skeletonize.java | 2 +- Mage.Sets/src/mage/cards/s/SoulReap.java | 4 +- .../src/mage/cards/s/SpinerockKnoll.java | 2 +- Mage.Sets/src/mage/cards/s/SpinyStarfish.java | 8 +-- .../mage/cards/s/SpiritOfTheLabyrinth.java | 2 +- Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java | 4 +- Mage.Sets/src/mage/cards/s/SteelHellkite.java | 4 +- Mage.Sets/src/mage/cards/s/StormEntity.java | 2 +- Mage.Sets/src/mage/cards/s/SummoningTrap.java | 4 +- .../src/mage/cards/s/SupremeLeaderSnoke.java | 2 +- Mage.Sets/src/mage/cards/s/SylvanLibrary.java | 4 +- Mage.Sets/src/mage/cards/t/TaintedSigil.java | 2 +- .../src/mage/cards/t/TalarasBattalion.java | 4 +- Mage.Sets/src/mage/cards/t/TangleKelp.java | 2 +- .../src/mage/cards/t/TapestryOfTheAges.java | 4 +- .../src/mage/cards/t/TerritorialHellkite.java | 4 +- Mage.Sets/src/mage/cards/t/TheChainVeil.java | 2 +- Mage.Sets/src/mage/cards/t/TheFallen.java | 4 +- Mage.Sets/src/mage/cards/t/ThirstingAxe.java | 2 +- .../src/mage/cards/t/ThousandYearStorm.java | 2 +- .../src/mage/cards/t/ThrillingEncore.java | 2 +- Mage.Sets/src/mage/cards/t/TimeToReflect.java | 4 +- Mage.Sets/src/mage/cards/t/TotalWar.java | 2 +- Mage.Sets/src/mage/cards/t/TunnelIgnus.java | 4 +- .../src/mage/cards/t/TuvasaTheSunlit.java | 6 +-- .../src/mage/cards/t/TwilightShepherd.java | 2 +- Mage.Sets/src/mage/cards/t/TwinningGlass.java | 2 +- .../src/mage/cards/t/TymnaTheWeaver.java | 4 +- Mage.Sets/src/mage/cards/u/UbaMask.java | 6 +-- Mage.Sets/src/mage/cards/u/UphillBattle.java | 6 +-- Mage.Sets/src/mage/cards/u/UrborgJustice.java | 2 +- Mage.Sets/src/mage/cards/u/UrzasMiter.java | 4 +- .../mage/cards/v/VancesBlastingCannons.java | 2 +- .../src/mage/cards/v/VeneratedLoxodon.java | 4 +- Mage.Sets/src/mage/cards/v/Vengevine.java | 4 +- .../src/mage/cards/v/VenomousBreath.java | 2 +- .../mage/cards/v/VialSmasherTheFierce.java | 2 +- Mage.Sets/src/mage/cards/v/VileRedeemer.java | 2 +- .../src/mage/cards/v/VizierOfDeferment.java | 4 +- .../src/mage/cards/v/VizierOfManyFaces.java | 4 +- .../src/mage/cards/v/VodalianWarMachine.java | 4 +- Mage.Sets/src/mage/cards/w/WarElemental.java | 2 +- Mage.Sets/src/mage/cards/w/WhiplashTrap.java | 2 +- .../src/mage/cards/w/WhisperingSnitch.java | 4 +- Mage.Sets/src/mage/cards/w/WickedAkuba.java | 2 +- Mage.Sets/src/mage/cards/w/WildPair.java | 2 +- .../src/mage/cards/w/WindbriskHeights.java | 2 +- Mage.Sets/src/mage/cards/w/WorldAtWar.java | 2 +- .../src/mage/cards/w/WoundReflection.java | 2 +- Mage.Sets/src/mage/cards/y/YdwenEfreet.java | 2 +- .../AttacksFirstTimeTriggeredAbility.java | 2 +- ...kedOrBlockedThisCombatSourceCondition.java | 2 +- .../common/AttackedThisStepCondition.java | 2 +- .../common/AttackedThisTurnCondition.java | 2 +- .../AttackedThisTurnSourceCondition.java | 2 +- .../BlockedThisTurnSourceCondition.java | 2 +- .../common/CastFromHandSourceCondition.java | 2 +- .../ControllerAttackedThisTurnCondition.java | 2 +- .../common/DealtDamageToAnOpponent.java | 2 +- .../condition/common/HateCondition.java | 2 +- .../condition/common/LandfallCondition.java | 2 +- .../common/LiveLostLastTurnCondition.java | 2 +- .../common/ManaWasSpentCondition.java | 4 +- .../condition/common/MorbidCondition.java | 2 +- .../NoSpellsWereCastLastTurnCondition.java | 2 +- .../common/OpponentLostLifeCondition.java | 2 +- .../condition/common/PlayLandCondition.java | 2 +- .../condition/common/RaidCondition.java | 2 +- .../condition/common/RevoltCondition.java | 2 +- .../common/SourceDealtDamageCondition.java | 2 +- .../TargetAttackedThisTurnCondition.java | 2 +- ...OrMoreSpellsWereCastLastTurnCondition.java | 2 +- .../condition/common/WatcherCondition.java | 51 ------------------- .../common/YouGainedLifeCondition.java | 4 +- .../AttackedThisTurnOpponentsCount.java | 2 +- .../common/ControllerGotLifeCount.java | 4 +- .../common/CreaturesDiedThisTurnCount.java | 2 +- .../common/OpponentsLostLifeCount.java | 2 +- .../common/ZuberasDiedDynamicValue.java | 4 +- .../common/UntapAllThatAttackedEffect.java | 6 +-- .../common/combat/AttacksIfAbleAllEffect.java | 2 +- .../combat/AttacksIfAbleSourceEffect.java | 2 +- .../MustBeBlockedByAllTargetEffect.java | 8 +-- .../MustBeBlockedByTargetSourceEffect.java | 2 +- .../CantCastMoreThanOneSpellEffect.java | 2 +- .../DealtDamageToCreatureBySourceDies.java | 2 +- ...stOnlyIfYouHaveCastAnotherSpellEffect.java | 2 +- .../abilities/keyword/BloodthirstAbility.java | 4 +- .../mage/abilities/keyword/ExertAbility.java | 2 +- .../abilities/keyword/GravestormAbility.java | 2 +- .../mage/abilities/keyword/MeleeAbility.java | 2 +- .../mage/abilities/keyword/ProwlAbility.java | 4 +- .../abilities/keyword/SpectacleAbility.java | 2 +- .../mage/abilities/keyword/StormAbility.java | 2 +- .../mage/abilities/keyword/SurgeAbility.java | 2 +- .../permanent/BlockedByIdPredicate.java | 2 +- .../DamagedPlayerThisTurnPredicate.java | 8 +-- .../java/mage/game/GameCommanderImpl.java | 4 +- Mage/src/main/java/mage/game/GameImpl.java | 27 +++++----- Mage/src/main/java/mage/game/GameState.java | 17 +++++++ .../emblems/JaceUnravelerOfSecretsEmblem.java | 2 +- .../command/emblems/JayaBallardEmblem.java | 2 +- .../mage/game/command/planes/BantPlane.java | 2 +- Mage/src/main/java/mage/watchers/Watcher.java | 4 ++ .../src/main/java/mage/watchers/Watchers.java | 27 +++++++--- .../common/PlayerGainedLifeWatcher.java | 4 +- .../watchers/common/ZuberasDiedWatcher.java | 6 ++- 324 files changed, 573 insertions(+), 586 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/h/HomicidalBruteWatcher.java delete mode 100644 Mage/src/main/java/mage/abilities/condition/common/WatcherCondition.java diff --git a/Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java b/Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java index cb7291c0d8..263dd0d8ab 100644 --- a/Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java +++ b/Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java @@ -106,7 +106,7 @@ class AbandonedSarcophagusReplacementEffect extends ReplacementEffectImpl { return false; } Player controller = game.getPlayer(source.getControllerId()); - AbandonedSarcophagusWatcher watcher = (AbandonedSarcophagusWatcher) game.getState().getWatchers().get(AbandonedSarcophagusWatcher.class.getSimpleName()); + AbandonedSarcophagusWatcher watcher = game.getState().getWatcher(AbandonedSarcophagusWatcher.class); Card card = game.getCard(event.getTargetId()); if (card == null || controller == null diff --git a/Mage.Sets/src/mage/cards/a/AdmiralBeckettBrass.java b/Mage.Sets/src/mage/cards/a/AdmiralBeckettBrass.java index f03302bd76..18448c3cd8 100644 --- a/Mage.Sets/src/mage/cards/a/AdmiralBeckettBrass.java +++ b/Mage.Sets/src/mage/cards/a/AdmiralBeckettBrass.java @@ -124,7 +124,7 @@ class ControllerDealtDamageByPiratesPredicate implements Predicate { @Override public boolean apply(Permanent input, Game game) { - DamagedByPiratesWatcher watcher = (DamagedByPiratesWatcher) game.getState().getWatchers().get(DamagedByPiratesWatcher.class.getSimpleName()); + DamagedByPiratesWatcher watcher = game.getState().getWatcher(DamagedByPiratesWatcher.class); if (watcher != null) { return watcher.damagedByEnoughPirates(input.getControllerId(), game); } diff --git a/Mage.Sets/src/mage/cards/a/AetherfluxReservoir.java b/Mage.Sets/src/mage/cards/a/AetherfluxReservoir.java index f835909a00..871b4d90ac 100644 --- a/Mage.Sets/src/mage/cards/a/AetherfluxReservoir.java +++ b/Mage.Sets/src/mage/cards/a/AetherfluxReservoir.java @@ -50,7 +50,7 @@ class AetherfluxReservoirDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); if(watcher != null) { return watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(sourceAbility.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/a/Aggravate.java b/Mage.Sets/src/mage/cards/a/Aggravate.java index 6110f09d52..21d9585854 100644 --- a/Mage.Sets/src/mage/cards/a/Aggravate.java +++ b/Mage.Sets/src/mage/cards/a/Aggravate.java @@ -61,7 +61,7 @@ class AggravateRequirementEffect extends RequirementEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), source.getSourceId()); + DamagedByWatcher watcher = game.getState().getWatcher(DamagedByWatcher.class, source.getSourceId()); if (watcher != null) { return watcher.wasDamaged(permanent, game); } diff --git a/Mage.Sets/src/mage/cards/a/AlhammarretsArchive.java b/Mage.Sets/src/mage/cards/a/AlhammarretsArchive.java index 02b087e0ab..7934c8b858 100644 --- a/Mage.Sets/src/mage/cards/a/AlhammarretsArchive.java +++ b/Mage.Sets/src/mage/cards/a/AlhammarretsArchive.java @@ -113,7 +113,7 @@ class AlhammarretsArchiveReplacementEffect extends ReplacementEffectImpl { if (event.getPlayerId().equals(source.getControllerId())) { if (game.isActivePlayer(event.getPlayerId()) && game.getPhase().getStep().getType() == PhaseStep.DRAW) { - CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get(CardsDrawnDuringDrawStepWatcher.class.getSimpleName()); + CardsDrawnDuringDrawStepWatcher watcher = game.getState().getWatcher(CardsDrawnDuringDrawStepWatcher.class); if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) { return true; } diff --git a/Mage.Sets/src/mage/cards/a/AngelicArbiter.java b/Mage.Sets/src/mage/cards/a/AngelicArbiter.java index 75693f80c0..4acf0a2b1b 100644 --- a/Mage.Sets/src/mage/cards/a/AngelicArbiter.java +++ b/Mage.Sets/src/mage/cards/a/AngelicArbiter.java @@ -66,7 +66,7 @@ class AngelicArbiterCantAttackTargetEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (game.isActivePlayer(permanent.getControllerId()) && game.getOpponents(source.getControllerId()).contains(permanent.getControllerId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(permanent.getControllerId()) > 0) { return true; } @@ -114,7 +114,7 @@ class AngelicArbiterEffect2 extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (game.isActivePlayer(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { - PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get(PlayerAttackedWatcher.class.getSimpleName()); + PlayerAttackedWatcher watcher = game.getState().getWatcher(PlayerAttackedWatcher.class); if (watcher != null && watcher.getNumberOfAttackersCurrentTurn(event.getPlayerId()) > 0) { return true; } diff --git a/Mage.Sets/src/mage/cards/a/AngelsTrumpet.java b/Mage.Sets/src/mage/cards/a/AngelsTrumpet.java index 2a05d869ff..5de5f29b03 100644 --- a/Mage.Sets/src/mage/cards/a/AngelsTrumpet.java +++ b/Mage.Sets/src/mage/cards/a/AngelsTrumpet.java @@ -72,7 +72,7 @@ class AngelsTrumpetTapEffect extends OneShotEffect { continue; } // Creatures that attacked are safe. - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); if (watcher != null && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(creature, game))) { continue; } diff --git a/Mage.Sets/src/mage/cards/a/Antagonism.java b/Mage.Sets/src/mage/cards/a/Antagonism.java index 2bde3ac7b2..818a31125e 100644 --- a/Mage.Sets/src/mage/cards/a/Antagonism.java +++ b/Mage.Sets/src/mage/cards/a/Antagonism.java @@ -49,7 +49,7 @@ class OpponentWasNotDealtDamageCondition implements Condition { public boolean apply(Game game, Ability source) { UUID activePlayer = game.getState().getActivePlayerId(); if (activePlayer != null) { - BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), activePlayer); + BloodthirstWatcher watcher = game.getState().getWatcher(BloodthirstWatcher.class, activePlayer); if (watcher != null) { return !watcher.conditionMet(); } diff --git a/Mage.Sets/src/mage/cards/a/ApproachOfTheSecondSun.java b/Mage.Sets/src/mage/cards/a/ApproachOfTheSecondSun.java index 574c2ce7b7..235118e8b3 100644 --- a/Mage.Sets/src/mage/cards/a/ApproachOfTheSecondSun.java +++ b/Mage.Sets/src/mage/cards/a/ApproachOfTheSecondSun.java @@ -65,7 +65,7 @@ class ApproachOfTheSecondSunEffect extends OneShotEffect { Spell spell = game.getStack().getSpell(source.getSourceId()); if (controller != null && spell != null) { ApproachOfTheSecondSunWatcher watcher - = (ApproachOfTheSecondSunWatcher) game.getState().getWatchers().get(ApproachOfTheSecondSunWatcher.class.getSimpleName()); + = game.getState().getWatcher(ApproachOfTheSecondSunWatcher.class); if (watcher != null && !spell.isCopy() && watcher.getApproachesCast(controller.getId()) > 1 diff --git a/Mage.Sets/src/mage/cards/a/Arboria.java b/Mage.Sets/src/mage/cards/a/Arboria.java index 0cb05c3628..6fa2572c54 100644 --- a/Mage.Sets/src/mage/cards/a/Arboria.java +++ b/Mage.Sets/src/mage/cards/a/Arboria.java @@ -60,13 +60,13 @@ class ArboriaEffect extends RestrictionEffect { @Override public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) { - CastSpellYourLastTurnWatcher watcher = (CastSpellYourLastTurnWatcher) game.getState().getWatchers().get(CastSpellYourLastTurnWatcher.class.getSimpleName()); + CastSpellYourLastTurnWatcher watcher = game.getState().getWatcher(CastSpellYourLastTurnWatcher.class); if (watcher != null && watcher.getAmountOfSpellsCastOnPlayersTurn(defenderId) > 0) { return true; } PermanentsEnteredBattlefieldYourLastTurnWatcher watcher2 - = (PermanentsEnteredBattlefieldYourLastTurnWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldYourLastTurnWatcher.class.getSimpleName()); + = game.getState().getWatcher(PermanentsEnteredBattlefieldYourLastTurnWatcher.class); if (watcher2 != null && watcher2.getPermanentsEnteringOnPlayersLastTurn(game, defenderId) != null) { for (Permanent permanent : watcher2.getPermanentsEnteringOnPlayersLastTurn(game, defenderId)) { diff --git a/Mage.Sets/src/mage/cards/a/ArchfiendOfDespair.java b/Mage.Sets/src/mage/cards/a/ArchfiendOfDespair.java index c7c5a5ed6f..e7f41f723f 100644 --- a/Mage.Sets/src/mage/cards/a/ArchfiendOfDespair.java +++ b/Mage.Sets/src/mage/cards/a/ArchfiendOfDespair.java @@ -79,7 +79,7 @@ class ArchfiendOfDespairEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); if (controller != null && watcher != null) { for (UUID playerId : game.getOpponents(controller.getId())) { Player opponent = game.getPlayer(playerId); diff --git a/Mage.Sets/src/mage/cards/a/ArchiveTrap.java b/Mage.Sets/src/mage/cards/a/ArchiveTrap.java index d0c3c88c15..4320b92011 100644 --- a/Mage.Sets/src/mage/cards/a/ArchiveTrap.java +++ b/Mage.Sets/src/mage/cards/a/ArchiveTrap.java @@ -92,7 +92,7 @@ enum OpponentSearchesLibCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - ArchiveTrapWatcher watcher = (ArchiveTrapWatcher) game.getState().getWatchers().get(ArchiveTrapWatcher.class.getSimpleName()); + ArchiveTrapWatcher watcher = game.getState().getWatcher(ArchiveTrapWatcher.class); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && watcher != null) { for (UUID playerId : watcher.getPlayersSearchedLibrary()) { diff --git a/Mage.Sets/src/mage/cards/a/ArchmageAscension.java b/Mage.Sets/src/mage/cards/a/ArchmageAscension.java index 71f9e08a5d..efbcafce29 100644 --- a/Mage.Sets/src/mage/cards/a/ArchmageAscension.java +++ b/Mage.Sets/src/mage/cards/a/ArchmageAscension.java @@ -1,7 +1,6 @@ package mage.cards.a; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.SimpleStaticAbility; @@ -22,8 +21,9 @@ import mage.players.Player; import mage.target.common.TargetCardInLibrary; import mage.watchers.common.CardsAmountDrawnThisTurnWatcher; +import java.util.UUID; + /** - * * @author jeffwadsworth */ public final class ArchmageAscension extends CardImpl { @@ -74,7 +74,7 @@ class ArchmageAscensionTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { Permanent archmage = game.getPermanent(super.getSourceId()); CardsAmountDrawnThisTurnWatcher watcher - = (CardsAmountDrawnThisTurnWatcher) game.getState().getWatchers().get(CardsAmountDrawnThisTurnWatcher.class.getSimpleName()); + = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class); return archmage != null && watcher != null && watcher.getAmountCardsDrawn(this.getControllerId()) >= 2; } diff --git a/Mage.Sets/src/mage/cards/a/ArclightPhoenix.java b/Mage.Sets/src/mage/cards/a/ArclightPhoenix.java index 89fe19f8ee..8301cc88c2 100644 --- a/Mage.Sets/src/mage/cards/a/ArclightPhoenix.java +++ b/Mage.Sets/src/mage/cards/a/ArclightPhoenix.java @@ -72,8 +72,8 @@ enum ArclightPhoenixCondition implements Condition { @Override public boolean apply(Game game, Ability source) { ArclightPhoenixWatcher watcher - = (ArclightPhoenixWatcher) game.getState().getWatchers().get( - ArclightPhoenixWatcher.class.getSimpleName() + = game.getState().getWatcher( + ArclightPhoenixWatcher.class ); return watcher != null && watcher.getInstantSorceryCount(source.getControllerId()) > 2; } @@ -81,7 +81,7 @@ enum ArclightPhoenixCondition implements Condition { class ArclightPhoenixWatcher extends Watcher { - private final Map instantSorceryCount = new HashMap(); + private final Map instantSorceryCount = new HashMap<>(); public ArclightPhoenixWatcher() { super(ArclightPhoenixWatcher.class.getSimpleName(), WatcherScope.GAME); diff --git a/Mage.Sets/src/mage/cards/a/AsForetold.java b/Mage.Sets/src/mage/cards/a/AsForetold.java index b4da2d9dce..01dc7cb567 100644 --- a/Mage.Sets/src/mage/cards/a/AsForetold.java +++ b/Mage.Sets/src/mage/cards/a/AsForetold.java @@ -120,8 +120,7 @@ class AsForetoldAlternativeCost extends AlternativeCostSourceAbility { if (wasActivated) { // Get the watcher AsForetoldAltCostUsedWatcher asForetoldAltCostUsedWatcher - = (AsForetoldAltCostUsedWatcher) game.getState().getWatchers() - .get("asForetoldAltCostUsedWatcher", sourceAsForetold); + = game.getState().getWatcher(AsForetoldAltCostUsedWatcher.class, sourceAsForetold); // Mark as used asForetoldAltCostUsedWatcher.markUsedThisTurn(); @@ -161,8 +160,8 @@ class AsForetoldAddAltCostEffect extends ContinuousEffectImpl { if (sourcePermanent != null) { // Get the watcher AsForetoldAltCostUsedWatcher asForetoldAltCostUsedWatcher - = (AsForetoldAltCostUsedWatcher) game.getState().getWatchers() - .get("asForetoldAltCostUsedWatcher", sourcePermanent.getId()); + = game.getState().getWatcher( + AsForetoldAltCostUsedWatcher.class, sourcePermanent.getId()); // If we haven't used it yet this turn, give the option of using the zero alternative cost if (!asForetoldAltCostUsedWatcher.hasBeenUsedThisTurn()) { diff --git a/Mage.Sets/src/mage/cards/a/AsmiraHolyAvenger.java b/Mage.Sets/src/mage/cards/a/AsmiraHolyAvenger.java index 60cb57bd4f..7fa11e1473 100644 --- a/Mage.Sets/src/mage/cards/a/AsmiraHolyAvenger.java +++ b/Mage.Sets/src/mage/cards/a/AsmiraHolyAvenger.java @@ -95,7 +95,7 @@ class AsmiraHolyAvengerDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - AsmiraHolyAvengerWatcher watcher = (AsmiraHolyAvengerWatcher) game.getState().getWatchers().get(AsmiraHolyAvengerWatcher.class.getSimpleName(), sourceAbility.getControllerId()); + AsmiraHolyAvengerWatcher watcher = game.getState().getWatcher(AsmiraHolyAvengerWatcher.class, sourceAbility.getControllerId()); if (watcher != null) { return watcher.getCreaturesCount(); } diff --git a/Mage.Sets/src/mage/cards/a/AureliasFury.java b/Mage.Sets/src/mage/cards/a/AureliasFury.java index 3660c4cfb2..0f42f5d652 100644 --- a/Mage.Sets/src/mage/cards/a/AureliasFury.java +++ b/Mage.Sets/src/mage/cards/a/AureliasFury.java @@ -98,7 +98,7 @@ class AureliasFuryEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - AureliasFuryDamagedByWatcher watcher = (AureliasFuryDamagedByWatcher) game.getState().getWatchers().get(AureliasFuryDamagedByWatcher.class.getSimpleName(), source.getSourceId()); + AureliasFuryDamagedByWatcher watcher = game.getState().getWatcher(AureliasFuryDamagedByWatcher.class, source.getSourceId()); if (watcher != null) { for (UUID creatureId : watcher.getDamagedCreatures()) { Permanent permanent = game.getPermanent(creatureId); diff --git a/Mage.Sets/src/mage/cards/a/AvengingArrow.java b/Mage.Sets/src/mage/cards/a/AvengingArrow.java index eb277e62ce..e04ff459b6 100644 --- a/Mage.Sets/src/mage/cards/a/AvengingArrow.java +++ b/Mage.Sets/src/mage/cards/a/AvengingArrow.java @@ -53,7 +53,7 @@ class AvengingArrowTarget extends TargetPermanent { @Override public boolean canTarget(UUID id, Ability source, Game game) { - SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName()); + SourceDidDamageWatcher watcher = game.getState().getWatcher(SourceDidDamageWatcher.class); if (watcher != null) { if (watcher.damageSources.contains(id)) { return super.canTarget(id, source, game); @@ -66,7 +66,7 @@ class AvengingArrowTarget extends TargetPermanent { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); Set possibleTargets = new HashSet<>(); - SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName()); + SourceDidDamageWatcher watcher = game.getState().getWatcher(SourceDidDamageWatcher.class); if (watcher != null) { for (UUID targetId : availablePossibleTargets) { Permanent permanent = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/b/BalduvianWarlord.java b/Mage.Sets/src/mage/cards/b/BalduvianWarlord.java index 1adf661c5c..4a18b913d8 100644 --- a/Mage.Sets/src/mage/cards/b/BalduvianWarlord.java +++ b/Mage.Sets/src/mage/cards/b/BalduvianWarlord.java @@ -89,7 +89,7 @@ class BalduvianWarlordUnblockEffect extends OneShotEffect { effect.apply(game, source); // Make blocked creatures unblocked - BlockedByOnlyOneCreatureThisCombatWatcher watcher = (BlockedByOnlyOneCreatureThisCombatWatcher) game.getState().getWatchers().get(BlockedByOnlyOneCreatureThisCombatWatcher.class.getSimpleName()); + BlockedByOnlyOneCreatureThisCombatWatcher watcher = game.getState().getWatcher(BlockedByOnlyOneCreatureThisCombatWatcher.class); if (watcher != null) { Set combatGroups = watcher.getBlockedOnlyByCreature(permanent.getId()); if (combatGroups != null) { diff --git a/Mage.Sets/src/mage/cards/b/BalothCageTrap.java b/Mage.Sets/src/mage/cards/b/BalothCageTrap.java index 9d419b7921..4c86becb5b 100644 --- a/Mage.Sets/src/mage/cards/b/BalothCageTrap.java +++ b/Mage.Sets/src/mage/cards/b/BalothCageTrap.java @@ -50,7 +50,7 @@ enum BalothCageTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getSimpleName()); + PermanentsEnteredBattlefieldWatcher watcher = game.getState().getWatcher(PermanentsEnteredBattlefieldWatcher.class); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { List permanents = watcher.getThisTurnEnteringPermanents(opponentId); diff --git a/Mage.Sets/src/mage/cards/b/Berserk.java b/Mage.Sets/src/mage/cards/b/Berserk.java index 3d38da94d8..dc4065a0c8 100644 --- a/Mage.Sets/src/mage/cards/b/Berserk.java +++ b/Mage.Sets/src/mage/cards/b/Berserk.java @@ -1,7 +1,6 @@ package mage.cards.b; -import java.util.UUID; import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; @@ -26,8 +25,9 @@ import mage.target.targetpointer.FixedTarget; import mage.watchers.Watcher; import mage.watchers.common.AttackedThisTurnWatcher; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class Berserk extends CardImpl { @@ -76,7 +76,7 @@ class BerserkReplacementEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == GameEvent.EventType.CAST_SPELL && event.getSourceId().equals(source.getSourceId())) { - CombatDamageStepStartedWatcher watcher = (CombatDamageStepStartedWatcher) game.getState().getWatchers().get(CombatDamageStepStartedWatcher.class.getSimpleName()); + CombatDamageStepStartedWatcher watcher = game.getState().getWatcher(CombatDamageStepStartedWatcher.class); return watcher == null || watcher.conditionMet(); } return false; @@ -96,7 +96,7 @@ class BerserkReplacementEffect extends ContinuousRuleModifyingEffectImpl { class CombatDamageStepStartedWatcher extends Watcher { public CombatDamageStepStartedWatcher() { - super(CombatDamageStepStartedWatcher.class.getSimpleName(), WatcherScope.GAME); + super(CombatDamageStepStartedWatcher.class, WatcherScope.GAME); } public CombatDamageStepStartedWatcher(final CombatDamageStepStartedWatcher watcher) { @@ -170,11 +170,9 @@ class BerserkDelayedDestroyEffect extends OneShotEffect { if (controller != null) { Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (permanent != null) { - Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); - if (watcher instanceof AttackedThisTurnWatcher) { - if (((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) { - return permanent.destroy(source.getSourceId(), game, false); - } + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); + if (watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) { + return permanent.destroy(source.getSourceId(), game, false); } } } diff --git a/Mage.Sets/src/mage/cards/b/BloodcrazedGoblin.java b/Mage.Sets/src/mage/cards/b/BloodcrazedGoblin.java index fbc0a3c769..ab1708edb1 100644 --- a/Mage.Sets/src/mage/cards/b/BloodcrazedGoblin.java +++ b/Mage.Sets/src/mage/cards/b/BloodcrazedGoblin.java @@ -69,7 +69,7 @@ class BloodcrazedGoblinEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { - BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); // BloodthirstWatcher + BloodthirstWatcher watcher = game.getState().getWatcher(BloodthirstWatcher.class, source.getControllerId()); // BloodthirstWatcher return watcher != null && !watcher.conditionMet(); } return false; diff --git a/Mage.Sets/src/mage/cards/b/BontuTheGlorified.java b/Mage.Sets/src/mage/cards/b/BontuTheGlorified.java index 57662b4c40..7ea8bac0b4 100644 --- a/Mage.Sets/src/mage/cards/b/BontuTheGlorified.java +++ b/Mage.Sets/src/mage/cards/b/BontuTheGlorified.java @@ -98,7 +98,7 @@ class BontuTheGlorifiedRestrictionEffect extends RestrictionEffect { public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { Player controller = game.getPlayer(source.getControllerId()); - CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatchers().get(CreaturesDiedWatcher.class.getSimpleName()); + CreaturesDiedWatcher watcher = game.getState().getWatcher(CreaturesDiedWatcher.class); if (controller != null && watcher != null) { return (watcher.getAmountOfCreaturesDiedThisTurnByController(controller.getId()) == 0); diff --git a/Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java b/Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java index 9e19d3430a..15c1b4f486 100644 --- a/Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java +++ b/Mage.Sets/src/mage/cards/b/BoseijuWhoSheltersAll.java @@ -62,7 +62,7 @@ class BoseijuWhoSheltersAllWatcher extends Watcher { private final String originalId; public BoseijuWhoSheltersAllWatcher(UUID originalId) { - super(BoseijuWhoSheltersAllWatcher.class.getSimpleName(), WatcherScope.CARD); + super(BoseijuWhoSheltersAllWatcher.class, WatcherScope.CARD); this.originalId = originalId.toString(); } @@ -137,7 +137,7 @@ class BoseijuWhoSheltersAllCantCounterEffect extends ContinuousRuleModifyingEffe @Override public boolean applies(GameEvent event, Ability source, Game game) { - BoseijuWhoSheltersAllWatcher watcher = (BoseijuWhoSheltersAllWatcher) game.getState().getWatchers().get(BoseijuWhoSheltersAllWatcher.class.getSimpleName(), source.getSourceId()); + BoseijuWhoSheltersAllWatcher watcher = game.getState().getWatcher(BoseijuWhoSheltersAllWatcher.class, source.getSourceId()); Spell spell = game.getStack().getSpell(event.getTargetId()); return spell != null && watcher != null && watcher.spellCantBeCountered(spell.getId()); } diff --git a/Mage.Sets/src/mage/cards/b/BriarbridgePatrol.java b/Mage.Sets/src/mage/cards/b/BriarbridgePatrol.java index 9995cf93e4..594613056f 100644 --- a/Mage.Sets/src/mage/cards/b/BriarbridgePatrol.java +++ b/Mage.Sets/src/mage/cards/b/BriarbridgePatrol.java @@ -56,7 +56,7 @@ enum BriarbridgePatrolCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PermanentsSacrificedWatcher watcher = (PermanentsSacrificedWatcher) game.getState().getWatchers().get(PermanentsSacrificedWatcher.class.getSimpleName()); + PermanentsSacrificedWatcher watcher = game.getState().getWatcher(PermanentsSacrificedWatcher.class); if (watcher != null) { List sacrificedPermanents = watcher.getThisTurnSacrificedPermanents(source.getControllerId()); if (sacrificedPermanents != null && !sacrificedPermanents.isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/b/BrimstoneVolley.java b/Mage.Sets/src/mage/cards/b/BrimstoneVolley.java index 168cdae234..d0fca03525 100644 --- a/Mage.Sets/src/mage/cards/b/BrimstoneVolley.java +++ b/Mage.Sets/src/mage/cards/b/BrimstoneVolley.java @@ -53,7 +53,7 @@ class BrimstoneVolleyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int damage = 3; - Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName()); + MorbidWatcher watcher = game.getState().getWatcher(MorbidWatcher.class); if (watcher != null && watcher.conditionMet()) { damage = 5; } diff --git a/Mage.Sets/src/mage/cards/b/BrutalHordechief.java b/Mage.Sets/src/mage/cards/b/BrutalHordechief.java index 0565345b7d..c6e43f6dc7 100644 --- a/Mage.Sets/src/mage/cards/b/BrutalHordechief.java +++ b/Mage.Sets/src/mage/cards/b/BrutalHordechief.java @@ -74,7 +74,7 @@ public final class BrutalHordechief extends CardImpl { @Override public boolean apply(Game game, Ability source) { - ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); + ChooseBlockersRedundancyWatcher watcher = game.getState().getWatcher(ChooseBlockersRedundancyWatcher.class); if (watcher != null) { watcher.increment(); return true; @@ -155,7 +155,7 @@ class BrutalHordechiefChooseBlockersEffect extends ContinuousRuleModifyingEffect @Override public boolean applies(GameEvent event, Ability source, Game game) { - ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); + ChooseBlockersRedundancyWatcher watcher = game.getState().getWatcher(ChooseBlockersRedundancyWatcher.class); if(watcher == null){ return false; } diff --git a/Mage.Sets/src/mage/cards/b/BurningCinderFuryOfCrimsonChaosFire.java b/Mage.Sets/src/mage/cards/b/BurningCinderFuryOfCrimsonChaosFire.java index 1585222ed7..ec620a455e 100644 --- a/Mage.Sets/src/mage/cards/b/BurningCinderFuryOfCrimsonChaosFire.java +++ b/Mage.Sets/src/mage/cards/b/BurningCinderFuryOfCrimsonChaosFire.java @@ -184,7 +184,7 @@ class BurningCinderFuryOfCrimsonChaosFireCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - BurningCinderFuryOfCrimsonChaosFireWatcher watcher = (BurningCinderFuryOfCrimsonChaosFireWatcher) game.getState().getWatchers().get(BurningCinderFuryOfCrimsonChaosFireWatcher.class.getSimpleName()); + BurningCinderFuryOfCrimsonChaosFireWatcher watcher = game.getState().getWatcher(BurningCinderFuryOfCrimsonChaosFireWatcher.class); if (watcher != null) { return !watcher.tappedNonlandThisTurn(game.getActivePlayerId()); } diff --git a/Mage.Sets/src/mage/cards/c/CallerOfTheClaw.java b/Mage.Sets/src/mage/cards/c/CallerOfTheClaw.java index e5607074fe..1a36673626 100644 --- a/Mage.Sets/src/mage/cards/c/CallerOfTheClaw.java +++ b/Mage.Sets/src/mage/cards/c/CallerOfTheClaw.java @@ -114,7 +114,7 @@ class CallerOfTheClawDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - CallerOfTheClawWatcher watcher = (CallerOfTheClawWatcher) game.getState().getWatchers().get(CallerOfTheClawWatcher.class.getSimpleName(), sourceAbility.getControllerId()); + CallerOfTheClawWatcher watcher = game.getState().getWatcher(CallerOfTheClawWatcher.class, sourceAbility.getControllerId()); if (watcher != null) { return watcher.getCreaturesCount(); } diff --git a/Mage.Sets/src/mage/cards/c/CathedralMembrane.java b/Mage.Sets/src/mage/cards/c/CathedralMembrane.java index 5c41e0029f..c68b249095 100644 --- a/Mage.Sets/src/mage/cards/c/CathedralMembrane.java +++ b/Mage.Sets/src/mage/cards/c/CathedralMembrane.java @@ -93,7 +93,7 @@ class CathedralMembraneEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - CathedralMembraneWatcher watcher = (CathedralMembraneWatcher) game.getState().getWatchers().get(CathedralMembraneWatcher.class.getSimpleName(), source.getSourceId()); + CathedralMembraneWatcher watcher = game.getState().getWatcher(CathedralMembraneWatcher.class, source.getSourceId()); if (watcher != null) { for (UUID uuid : watcher.getBlockedCreatures()) { Permanent permanent = game.getPermanent(uuid); diff --git a/Mage.Sets/src/mage/cards/c/CavernOfSouls.java b/Mage.Sets/src/mage/cards/c/CavernOfSouls.java index 87e9f839eb..57d0c4482e 100644 --- a/Mage.Sets/src/mage/cards/c/CavernOfSouls.java +++ b/Mage.Sets/src/mage/cards/c/CavernOfSouls.java @@ -197,7 +197,7 @@ class CavernOfSoulsCantCounterEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - CavernOfSoulsWatcher watcher = (CavernOfSoulsWatcher) game.getState().getWatchers().get(CavernOfSoulsWatcher.class.getSimpleName(), source.getSourceId()); + CavernOfSoulsWatcher watcher = game.getState().getWatcher(CavernOfSoulsWatcher.class, source.getSourceId()); Spell spell = game.getStack().getSpell(event.getTargetId()); return spell != null && watcher != null && watcher.spellCantBeCountered(spell.getId()); } diff --git a/Mage.Sets/src/mage/cards/c/CerebralVortex.java b/Mage.Sets/src/mage/cards/c/CerebralVortex.java index 8421720254..eca4f82e04 100644 --- a/Mage.Sets/src/mage/cards/c/CerebralVortex.java +++ b/Mage.Sets/src/mage/cards/c/CerebralVortex.java @@ -66,7 +66,7 @@ class CerebralVortexEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (targetPlayer != null) { - CerebralVortexWatcher watcher = (CerebralVortexWatcher) game.getState().getWatchers().get(CerebralVortexWatcher.class.getSimpleName()); + CerebralVortexWatcher watcher = game.getState().getWatcher(CerebralVortexWatcher.class); if (watcher != null) { targetPlayer.damage(watcher.getDraws(targetPlayer.getId()), source.getSourceId(), game, false, true); return true; diff --git a/Mage.Sets/src/mage/cards/c/ChainsOfMephistopheles.java b/Mage.Sets/src/mage/cards/c/ChainsOfMephistopheles.java index 04f12fe4cf..4cba73bcdc 100644 --- a/Mage.Sets/src/mage/cards/c/ChainsOfMephistopheles.java +++ b/Mage.Sets/src/mage/cards/c/ChainsOfMephistopheles.java @@ -86,7 +86,7 @@ class ChainsOfMephistophelesReplacementEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (game.isActivePlayer(event.getPlayerId()) && game.getPhase().getStep().getType() == PhaseStep.DRAW) { - CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get(CardsDrawnDuringDrawStepWatcher.class.getSimpleName()); + CardsDrawnDuringDrawStepWatcher watcher = game.getState().getWatcher(CardsDrawnDuringDrawStepWatcher.class); if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) { return true; } diff --git a/Mage.Sets/src/mage/cards/c/ChargingCinderhorn.java b/Mage.Sets/src/mage/cards/c/ChargingCinderhorn.java index 52d71ff766..28603c5d0f 100644 --- a/Mage.Sets/src/mage/cards/c/ChargingCinderhorn.java +++ b/Mage.Sets/src/mage/cards/c/ChargingCinderhorn.java @@ -62,7 +62,7 @@ class ChargingCinderhornCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); if (watcher != null) { return watcher.getAttackedThisTurnCreatures().isEmpty(); } diff --git a/Mage.Sets/src/mage/cards/c/ChildrenOfKorlis.java b/Mage.Sets/src/mage/cards/c/ChildrenOfKorlis.java index d6165cffc5..6275d1f0f3 100644 --- a/Mage.Sets/src/mage/cards/c/ChildrenOfKorlis.java +++ b/Mage.Sets/src/mage/cards/c/ChildrenOfKorlis.java @@ -52,7 +52,7 @@ class SourceControllerLostLifeCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); if (watcher != null) { return watcher.getLifeLost(sourceAbility.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/c/CivilizedScholar.java b/Mage.Sets/src/mage/cards/c/CivilizedScholar.java index 775632b928..0f3f1eb7d2 100644 --- a/Mage.Sets/src/mage/cards/c/CivilizedScholar.java +++ b/Mage.Sets/src/mage/cards/c/CivilizedScholar.java @@ -12,6 +12,7 @@ import mage.abilities.keyword.TransformAbility; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.cards.h.HomicidalBruteWatcher; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Outcome; @@ -54,31 +55,7 @@ public final class CivilizedScholar extends CardImpl { } } -class HomicidalBruteWatcher extends Watcher { - public HomicidalBruteWatcher() { - super(HomicidalBruteWatcher.class.getSimpleName(), WatcherScope.CARD); - } - - public HomicidalBruteWatcher(final HomicidalBruteWatcher watcher) { - super(watcher); - } - - @Override - public HomicidalBruteWatcher copy() { - return new HomicidalBruteWatcher(this); - } - - @Override - public void watch(GameEvent event, Game game) { - if (condition == true) { - return; - } - if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(sourceId)) { - condition = true; - } - } -} class CivilizedScholarEffect extends OneShotEffect { @@ -87,7 +64,7 @@ class CivilizedScholarEffect extends OneShotEffect { staticText = "Draw a card, then discard a card. If a creature card is discarded this way, untap {this}, then transform it"; } - public CivilizedScholarEffect(final CivilizedScholarEffect effect) { + private CivilizedScholarEffect(final CivilizedScholarEffect effect) { super(effect); } diff --git a/Mage.Sets/src/mage/cards/c/CobraTrap.java b/Mage.Sets/src/mage/cards/c/CobraTrap.java index a84de7815d..3d74db53a4 100644 --- a/Mage.Sets/src/mage/cards/c/CobraTrap.java +++ b/Mage.Sets/src/mage/cards/c/CobraTrap.java @@ -55,7 +55,7 @@ enum CobraTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - CobraTrapWatcher watcher = (CobraTrapWatcher) game.getState().getWatchers().get(CobraTrapWatcher.class.getSimpleName()); + CobraTrapWatcher watcher = game.getState().getWatcher(CobraTrapWatcher.class); return watcher != null && watcher.conditionMet(source.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/c/ConduitOfRuin.java b/Mage.Sets/src/mage/cards/c/ConduitOfRuin.java index 3dc843647f..137a3b091d 100644 --- a/Mage.Sets/src/mage/cards/c/ConduitOfRuin.java +++ b/Mage.Sets/src/mage/cards/c/ConduitOfRuin.java @@ -117,7 +117,7 @@ class FirstCastCreatureSpellPredicate implements ObjectPlayerPredicate input, Game game) { if (input.getObject() instanceof Spell && ((Spell) input.getObject()).isCreature()) { - ConduitOfRuinWatcher watcher = (ConduitOfRuinWatcher) game.getState().getWatchers().get(ConduitOfRuinWatcher.class.getSimpleName()); + ConduitOfRuinWatcher watcher = game.getState().getWatcher(ConduitOfRuinWatcher.class); return watcher != null && watcher.creatureSpellsCastThisTurn(input.getPlayerId()) == 0; } return false; diff --git a/Mage.Sets/src/mage/cards/c/ContainmentPriest.java b/Mage.Sets/src/mage/cards/c/ContainmentPriest.java index a571b315d3..701eb3aa4a 100644 --- a/Mage.Sets/src/mage/cards/c/ContainmentPriest.java +++ b/Mage.Sets/src/mage/cards/c/ContainmentPriest.java @@ -96,7 +96,7 @@ class ContainmentPriestReplacementEffect extends ReplacementEffectImpl { card = card.getSecondCardFace(); } if (card != null && card.isCreature()) { // TODO: Bestow Card cast as Enchantment probably not handled correctly - CreatureWasCastWatcher watcher = (CreatureWasCastWatcher) game.getState().getWatchers().get(CreatureWasCastWatcher.class.getSimpleName()); + CreatureWasCastWatcher watcher = game.getState().getWatcher(CreatureWasCastWatcher.class); return watcher != null && !watcher.wasCreatureCastThisTurn(event.getTargetId()); } } diff --git a/Mage.Sets/src/mage/cards/c/CorrosiveOoze.java b/Mage.Sets/src/mage/cards/c/CorrosiveOoze.java index b135e5b7e7..fe7dbf077b 100644 --- a/Mage.Sets/src/mage/cards/c/CorrosiveOoze.java +++ b/Mage.Sets/src/mage/cards/c/CorrosiveOoze.java @@ -76,7 +76,7 @@ class CorrosiveOozeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - CorrosiveOozeCombatWatcher watcher = (CorrosiveOozeCombatWatcher) game.getState().getWatchers().get(CorrosiveOozeCombatWatcher.class.getSimpleName()); + CorrosiveOozeCombatWatcher watcher = game.getState().getWatcher(CorrosiveOozeCombatWatcher.class); if (controller != null && watcher != null) { MageObjectReference sourceMor = new MageObjectReference(source.getSourceObject(game), game); // get equipmentsToDestroy of creatres already left the battlefield @@ -118,8 +118,8 @@ class CorrosiveOozeEffect extends OneShotEffect { class CorrosiveOozeCombatWatcher extends Watcher { - public final HashMap> oozeBlocksOrBlocked = new HashMap<>(); - public final HashMap> oozeEquipmentsToDestroy = new HashMap<>(); + private final Map> oozeBlocksOrBlocked = new HashMap<>(); + private final Map> oozeEquipmentsToDestroy = new HashMap<>(); public CorrosiveOozeCombatWatcher() { super(CorrosiveOozeCombatWatcher.class.getSimpleName(), WatcherScope.GAME); @@ -127,11 +127,11 @@ class CorrosiveOozeCombatWatcher extends Watcher { public CorrosiveOozeCombatWatcher(final CorrosiveOozeCombatWatcher watcher) { super(watcher); - for (Map.Entry> entry : watcher.oozeBlocksOrBlocked.entrySet()) { - HashSet newSet = new HashSet<>(entry.getValue()); + for (Map.Entry> entry : watcher.oozeBlocksOrBlocked.entrySet()) { + Set newSet = new HashSet<>(entry.getValue()); oozeBlocksOrBlocked.put(entry.getKey(), newSet); } - for (Map.Entry> entry : watcher.oozeEquipmentsToDestroy.entrySet()) { + for (Map.Entry> entry : watcher.oozeEquipmentsToDestroy.entrySet()) { HashSet newSet = new HashSet<>(entry.getValue()); oozeEquipmentsToDestroy.put(entry.getKey(), newSet); } @@ -148,7 +148,7 @@ class CorrosiveOozeCombatWatcher extends Watcher { if (attacker != null && CardUtil.haveSameNames(attacker.getName(), "Corrosive Ooze")) { // To check for name is not working if Ooze is copied but name changed if (blocker != null && hasAttachedEquipment(game, blocker)) { MageObjectReference oozeMor = new MageObjectReference(attacker, game); - HashSet relatedCreatures = oozeBlocksOrBlocked.getOrDefault(oozeMor, new HashSet<>()); + Set relatedCreatures = oozeBlocksOrBlocked.getOrDefault(oozeMor, new HashSet<>()); relatedCreatures.add(new MageObjectReference(event.getSourceId(), game)); oozeBlocksOrBlocked.put(oozeMor, relatedCreatures); } @@ -156,7 +156,7 @@ class CorrosiveOozeCombatWatcher extends Watcher { if (blocker != null && CardUtil.haveSameNames(blocker.getName(), "Corrosive Ooze")) { if (attacker != null && hasAttachedEquipment(game, attacker)) { MageObjectReference oozeMor = new MageObjectReference(blocker, game); - HashSet relatedCreatures = oozeBlocksOrBlocked.getOrDefault(oozeMor, new HashSet<>()); + Set relatedCreatures = oozeBlocksOrBlocked.getOrDefault(oozeMor, new HashSet<>()); relatedCreatures.add(new MageObjectReference(event.getTargetId(), game)); oozeBlocksOrBlocked.put(oozeMor, relatedCreatures); } @@ -167,14 +167,14 @@ class CorrosiveOozeCombatWatcher extends Watcher { if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) { if (game.getTurn() != null && TurnPhase.COMBAT == game.getTurn().getPhaseType()) { // Check if a previous blocked or blocked by creatures is leaving the battlefield - for (Map.Entry> entry : oozeBlocksOrBlocked.entrySet()) { + for (Map.Entry> entry : oozeBlocksOrBlocked.entrySet()) { for (MageObjectReference mor : entry.getValue()) { if (mor.refersTo(((ZoneChangeEvent) event).getTarget(), game)) { // check for equipments and remember for (UUID attachmentId : ((ZoneChangeEvent) event).getTarget().getAttachments()) { Permanent attachment = game.getPermanent(attachmentId); if (attachment != null && attachment.hasSubtype(SubType.EQUIPMENT, game)) { - HashSet toDestroy = oozeEquipmentsToDestroy.getOrDefault(entry.getKey(), new HashSet<>()); + Set toDestroy = oozeEquipmentsToDestroy.getOrDefault(entry.getKey(), new HashSet<>()); toDestroy.add(new MageObjectReference(attachment, game)); oozeEquipmentsToDestroy.put(entry.getKey(), toDestroy); } diff --git a/Mage.Sets/src/mage/cards/c/CryOfTheCarnarium.java b/Mage.Sets/src/mage/cards/c/CryOfTheCarnarium.java index e99cde2d8d..3e074e93b7 100644 --- a/Mage.Sets/src/mage/cards/c/CryOfTheCarnarium.java +++ b/Mage.Sets/src/mage/cards/c/CryOfTheCarnarium.java @@ -63,7 +63,7 @@ class CryOfTheCarnariumExileEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get(CardsPutIntoGraveyardWatcher.class.getSimpleName()); + CardsPutIntoGraveyardWatcher watcher = game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class); if (player == null || watcher == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/c/CurseOfExhaustion.java b/Mage.Sets/src/mage/cards/c/CurseOfExhaustion.java index d08a2bb66f..ea636fef2a 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfExhaustion.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfExhaustion.java @@ -77,7 +77,7 @@ class CurseOfExhaustionEffect extends ContinuousRuleModifyingEffectImpl { if (enchantment != null && enchantment.getAttachedTo() != null) { Player player = game.getPlayer(enchantment.getAttachedTo()); if (player != null && event.getPlayerId().equals(player.getId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) > 0) { return true; } diff --git a/Mage.Sets/src/mage/cards/c/CustodiSoulcaller.java b/Mage.Sets/src/mage/cards/c/CustodiSoulcaller.java index ae27d4bdda..65b6340f1d 100644 --- a/Mage.Sets/src/mage/cards/c/CustodiSoulcaller.java +++ b/Mage.Sets/src/mage/cards/c/CustodiSoulcaller.java @@ -52,7 +52,7 @@ public final class CustodiSoulcaller extends CardImpl { public void adjustTargets(Ability ability, Game game) { if (ability.getClass().equals(AttacksTriggeredAbility.class)) { ability.getTargets().clear(); - CustodiSoulcallerWatcher watcher = (CustodiSoulcallerWatcher) game.getState().getWatchers().get(CustodiSoulcallerWatcher.class.getSimpleName()); + CustodiSoulcallerWatcher watcher = game.getState().getWatcher(CustodiSoulcallerWatcher.class); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(ability.getSourceId()); if (watcher != null && watcher.playersAttacked != null) { int xValue = watcher.getNumberOfAttackedPlayers(sourcePermanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/c/CyclopeanTomb.java b/Mage.Sets/src/mage/cards/c/CyclopeanTomb.java index 1e8379f450..ef91a62b11 100644 --- a/Mage.Sets/src/mage/cards/c/CyclopeanTomb.java +++ b/Mage.Sets/src/mage/cards/c/CyclopeanTomb.java @@ -30,10 +30,7 @@ import mage.target.common.TargetLandPermanent; import mage.target.targetpointer.FixedTarget; import mage.watchers.Watcher; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; +import java.util.*; /** * @author MTGfan @@ -151,7 +148,7 @@ class CyclopeanTombEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObjectReference mor = new MageObjectReference(source.getSourceId(), source.getSourceObjectZoneChangeCounter(), game); - CyclopeanTombCounterWatcher watcher = (CyclopeanTombCounterWatcher) game.getState().getWatchers().get(CyclopeanTombCounterWatcher.class.getSimpleName()); + CyclopeanTombCounterWatcher watcher = game.getState().getWatcher(CyclopeanTombCounterWatcher.class); if (controller != null && watcher != null) { Set landRef = watcher.landMiredByCyclopeanTombInstance(mor, game); @@ -190,7 +187,7 @@ class CyclopeanTombEffect extends OneShotEffect { class CyclopeanTombCounterWatcher extends Watcher { - private final HashMap> counterData = new HashMap<>(); + private final Map> counterData = new HashMap<>(); CyclopeanTombCounterWatcher() { super(CyclopeanTombCounterWatcher.class.getSimpleName(), WatcherScope.GAME); diff --git a/Mage.Sets/src/mage/cards/d/DampingSphere.java b/Mage.Sets/src/mage/cards/d/DampingSphere.java index 8447bc0aed..b4780d80d7 100644 --- a/Mage.Sets/src/mage/cards/d/DampingSphere.java +++ b/Mage.Sets/src/mage/cards/d/DampingSphere.java @@ -103,7 +103,7 @@ class DampingSphereIncreasementAllEffect extends SpellsCostIncreasementAllEffect @Override public boolean apply(Game game, Ability source, Ability abilityToModify) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null) { int additionalCost = watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(abilityToModify.getControllerId()); CardUtil.increaseCost(abilityToModify, additionalCost); diff --git a/Mage.Sets/src/mage/cards/d/DarkbladeAgent.java b/Mage.Sets/src/mage/cards/d/DarkbladeAgent.java index 85a91830aa..f87221674b 100644 --- a/Mage.Sets/src/mage/cards/d/DarkbladeAgent.java +++ b/Mage.Sets/src/mage/cards/d/DarkbladeAgent.java @@ -1,8 +1,5 @@ package mage.cards.d; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; @@ -12,19 +9,18 @@ import mage.abilities.decorator.ConditionalContinuousEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; import mage.abilities.keyword.DeathtouchAbility; -import mage.constants.SubType; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.WatcherScope; -import mage.constants.Zone; +import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; import mage.watchers.Watcher; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class DarkbladeAgent extends CardImpl { @@ -46,7 +42,7 @@ public final class DarkbladeAgent extends CardImpl { Duration.WhileOnBattlefield ), DarkbladeAgentCondition.instance, "As long as you've surveilled this turn, " - + "{this} has deathtouch" + + "{this} has deathtouch" ) ); ability.addEffect(new ConditionalContinuousEffect( @@ -56,7 +52,7 @@ public final class DarkbladeAgent extends CardImpl { ), Duration.WhileOnBattlefield ), DarkbladeAgentCondition.instance, "and \"Whenever this creature deals " - + "combat damage to a player, draw a card.\"" + + "combat damage to a player, draw a card.\"" )); this.addAbility(ability, new DarkbladeAgentWatcher()); } @@ -77,9 +73,8 @@ enum DarkbladeAgentCondition implements Condition { @Override public boolean apply(Game game, Ability source) { DarkbladeAgentWatcher watcher - = (DarkbladeAgentWatcher) game.getState().getWatchers().get( - DarkbladeAgentWatcher.class.getSimpleName() - ); + = game.getState().getWatcher( + DarkbladeAgentWatcher.class); return watcher != null && watcher.getSurveiledThisTurn(source.getControllerId()); } @@ -87,10 +82,10 @@ enum DarkbladeAgentCondition implements Condition { class DarkbladeAgentWatcher extends Watcher { - private final Set surveiledThisTurn = new HashSet(); + private final Set surveiledThisTurn = new HashSet<>(); public DarkbladeAgentWatcher() { - super(DarkbladeAgentWatcher.class.getSimpleName(), WatcherScope.GAME); + super(DarkbladeAgentWatcher.class, WatcherScope.GAME); } public DarkbladeAgentWatcher(final DarkbladeAgentWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/d/Desolation.java b/Mage.Sets/src/mage/cards/d/Desolation.java index bed641377a..89418192ea 100644 --- a/Mage.Sets/src/mage/cards/d/Desolation.java +++ b/Mage.Sets/src/mage/cards/d/Desolation.java @@ -69,7 +69,7 @@ class DesolationEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - DesolationWatcher watcher = (DesolationWatcher) game.getState().getWatchers().get(DesolationWatcher.class.getSimpleName()); + DesolationWatcher watcher = game.getState().getWatcher(DesolationWatcher.class); if (watcher != null) { for (UUID playerId : watcher.getPlayersTappedForMana()) { Player player = game.getPlayer(playerId); diff --git a/Mage.Sets/src/mage/cards/d/DraconicRoar.java b/Mage.Sets/src/mage/cards/d/DraconicRoar.java index 2eb1d61e95..f65e60f704 100644 --- a/Mage.Sets/src/mage/cards/d/DraconicRoar.java +++ b/Mage.Sets/src/mage/cards/d/DraconicRoar.java @@ -90,7 +90,7 @@ class DraconicRoarEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName()); + DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class); if (watcher != null && watcher.castWithConditionTrue(source.getId())) { Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/d/DreamSalvage.java b/Mage.Sets/src/mage/cards/d/DreamSalvage.java index fcd535a32d..6d8ad465fc 100644 --- a/Mage.Sets/src/mage/cards/d/DreamSalvage.java +++ b/Mage.Sets/src/mage/cards/d/DreamSalvage.java @@ -49,7 +49,7 @@ class CardsDiscardedThisTurnWatcher extends Watcher { private final Map amountOfCardsDiscardedThisTurn = new HashMap<>(); public CardsDiscardedThisTurnWatcher() { - super(CardsDiscardedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); + super(CardsDiscardedThisTurnWatcher.class, WatcherScope.GAME); } public CardsDiscardedThisTurnWatcher(final CardsDiscardedThisTurnWatcher watcher) { @@ -102,7 +102,7 @@ class DreamSalvageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - CardsDiscardedThisTurnWatcher watcher = (CardsDiscardedThisTurnWatcher) game.getState().getWatchers().get(CardsDiscardedThisTurnWatcher.class.getSimpleName()); + CardsDiscardedThisTurnWatcher watcher = game.getState().getWatcher(CardsDiscardedThisTurnWatcher.class); Player targetOpponent = game.getPlayer(source.getFirstTarget()); Player controller = game.getPlayer(source.getControllerId()); if (targetOpponent != null diff --git a/Mage.Sets/src/mage/cards/d/DreamThief.java b/Mage.Sets/src/mage/cards/d/DreamThief.java index 1be3f20e76..4777110118 100644 --- a/Mage.Sets/src/mage/cards/d/DreamThief.java +++ b/Mage.Sets/src/mage/cards/d/DreamThief.java @@ -57,7 +57,7 @@ class CastBlueSpellThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class); if (watcher != null) { List spells = watcher.getSpellsCastThisTurn(source.getControllerId()); if (spells != null) { diff --git a/Mage.Sets/src/mage/cards/d/DuelingGrounds.java b/Mage.Sets/src/mage/cards/d/DuelingGrounds.java index fbab09bf33..25418a7d7c 100644 --- a/Mage.Sets/src/mage/cards/d/DuelingGrounds.java +++ b/Mage.Sets/src/mage/cards/d/DuelingGrounds.java @@ -74,7 +74,7 @@ class NoMoreThanOneCreatureCanAttackEachTurnEffect extends RestrictionEffect { if (!game.getCombat().getAttackers().isEmpty()) { return false; } - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); if(watcher == null){ return false; } @@ -111,7 +111,7 @@ class NoMoreThanOneCreatureCanBlockEachTurnEffect extends RestrictionEffect { if (!game.getCombat().getBlockers().isEmpty()) { return false; } - BlockedThisTurnWatcher watcher = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName()); + BlockedThisTurnWatcher watcher = game.getState().getWatcher(BlockedThisTurnWatcher.class); if(watcher == null){ return false; } diff --git a/Mage.Sets/src/mage/cards/e/EpharaGodOfThePolis.java b/Mage.Sets/src/mage/cards/e/EpharaGodOfThePolis.java index 8f149ba496..c3ae62a97a 100644 --- a/Mage.Sets/src/mage/cards/e/EpharaGodOfThePolis.java +++ b/Mage.Sets/src/mage/cards/e/EpharaGodOfThePolis.java @@ -70,7 +70,7 @@ enum HadAnotherCreatureEnterTheBattlefieldCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); - PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getSimpleName()); + PermanentsEnteredBattlefieldWatcher watcher = game.getState().getWatcher(PermanentsEnteredBattlefieldWatcher.class); return sourcePermanent != null && watcher != null && watcher.anotherCreatureEnteredBattlefieldUnderPlayersControlLastTurn(sourcePermanent, game); diff --git a/Mage.Sets/src/mage/cards/e/ErayoSoratamiAscendant.java b/Mage.Sets/src/mage/cards/e/ErayoSoratamiAscendant.java index 6f50051ae6..6841c7760f 100644 --- a/Mage.Sets/src/mage/cards/e/ErayoSoratamiAscendant.java +++ b/Mage.Sets/src/mage/cards/e/ErayoSoratamiAscendant.java @@ -78,7 +78,7 @@ class ErayoSoratamiAscendantTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); return watcher != null && watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn() == 4; } @@ -134,7 +134,7 @@ class ErayosEssenceTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (game.getOpponents(getControllerId()).contains(event.getPlayerId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 1) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(event.getTargetId())); diff --git a/Mage.Sets/src/mage/cards/e/ErdwalIlluminator.java b/Mage.Sets/src/mage/cards/e/ErdwalIlluminator.java index c5e6480f44..c303a87b82 100644 --- a/Mage.Sets/src/mage/cards/e/ErdwalIlluminator.java +++ b/Mage.Sets/src/mage/cards/e/ErdwalIlluminator.java @@ -66,7 +66,7 @@ class ErdwalIlluminatorTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - InvestigatedWatcher watcher = (InvestigatedWatcher) game.getState().getWatchers().get(InvestigatedWatcher.class.getSimpleName()); + InvestigatedWatcher watcher = game.getState().getWatcher(InvestigatedWatcher.class); return watcher != null && watcher.getTimesInvestigated(getControllerId()) == 1; } diff --git a/Mage.Sets/src/mage/cards/e/ErgRaiders.java b/Mage.Sets/src/mage/cards/e/ErgRaiders.java index 3ad0a59eef..01899e227c 100644 --- a/Mage.Sets/src/mage/cards/e/ErgRaiders.java +++ b/Mage.Sets/src/mage/cards/e/ErgRaiders.java @@ -55,7 +55,7 @@ class ErgRaidersCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Permanent raiders = game.getPermanentOrLKIBattlefield(source.getSourceId()); - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); // wasControlledFromStartOfControllerTurn should be checked during resolution I guess, but shouldn't be relevant return raiders != null &&raiders.wasControlledFromStartOfControllerTurn() && watcher != null && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(raiders, game)); } diff --git a/Mage.Sets/src/mage/cards/e/EtherswornCanonist.java b/Mage.Sets/src/mage/cards/e/EtherswornCanonist.java index 8c0fa6561f..754304f2e4 100644 --- a/Mage.Sets/src/mage/cards/e/EtherswornCanonist.java +++ b/Mage.Sets/src/mage/cards/e/EtherswornCanonist.java @@ -116,7 +116,7 @@ class EtherswornCanonistReplacementEffect extends ContinuousRuleModifyingEffectI public boolean applies(GameEvent event, Ability source, Game game) { Card card = game.getCard(event.getSourceId()); if (card != null && !card.isArtifact()) { - EtherswornCanonistWatcher watcher = (EtherswornCanonistWatcher) game.getState().getWatchers().get(EtherswornCanonistWatcher.class.getSimpleName()); + EtherswornCanonistWatcher watcher = game.getState().getWatcher(EtherswornCanonistWatcher.class); return watcher != null && watcher.castNonArtifactSpell(event.getPlayerId()); } return false; diff --git a/Mage.Sets/src/mage/cards/e/ExecutionersSwing.java b/Mage.Sets/src/mage/cards/e/ExecutionersSwing.java index 668225ef53..dbcf5fd062 100644 --- a/Mage.Sets/src/mage/cards/e/ExecutionersSwing.java +++ b/Mage.Sets/src/mage/cards/e/ExecutionersSwing.java @@ -56,7 +56,7 @@ class TargetCreaturePermanentThatDealtDamageThisTurn extends TargetPermanent { @Override public boolean canTarget(UUID id, Ability source, Game game) { - SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName()); + SourceDidDamageWatcher watcher = game.getState().getWatcher(SourceDidDamageWatcher.class); if (watcher != null) { if (watcher.damageSources.contains(id)) { return super.canTarget(id, source, game); @@ -73,7 +73,7 @@ class TargetCreaturePermanentThatDealtDamageThisTurn extends TargetPermanent { } int count = 0; MageObject targetSource = game.getObject(sourceId); - SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName()); + SourceDidDamageWatcher watcher = game.getState().getWatcher(SourceDidDamageWatcher.class); if (watcher != null && targetSource != null) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { if (!targets.containsKey(permanent.getId()) && watcher.damageSources.contains(permanent.getId())) { @@ -93,7 +93,7 @@ class TargetCreaturePermanentThatDealtDamageThisTurn extends TargetPermanent { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); Set possibleTargets = new HashSet<>(); - SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName()); + SourceDidDamageWatcher watcher = game.getState().getWatcher(SourceDidDamageWatcher.class); if (watcher != null) { for (UUID targetId : availablePossibleTargets) { Permanent permanent = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/f/FairgroundsTrumpeter.java b/Mage.Sets/src/mage/cards/f/FairgroundsTrumpeter.java index 8a4959443b..da246d4624 100644 --- a/Mage.Sets/src/mage/cards/f/FairgroundsTrumpeter.java +++ b/Mage.Sets/src/mage/cards/f/FairgroundsTrumpeter.java @@ -57,7 +57,7 @@ enum FairgroundsTrumpeterCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - FairgroundsTrumpeterWatcher watcher = (FairgroundsTrumpeterWatcher) game.getState().getWatchers().get(FairgroundsTrumpeterWatcher.class.getSimpleName()); + FairgroundsTrumpeterWatcher watcher = game.getState().getWatcher(FairgroundsTrumpeterWatcher.class); return watcher != null && watcher.p1p1AddedToPermanent(source.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/f/FaithsReward.java b/Mage.Sets/src/mage/cards/f/FaithsReward.java index cf44963565..1987daeffb 100644 --- a/Mage.Sets/src/mage/cards/f/FaithsReward.java +++ b/Mage.Sets/src/mage/cards/f/FaithsReward.java @@ -57,7 +57,7 @@ class FaithsRewardEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - FaithsRewardWatcher watcher = (FaithsRewardWatcher) game.getState().getWatchers().get(FaithsRewardWatcher.class.getSimpleName()); + FaithsRewardWatcher watcher = game.getState().getWatcher(FaithsRewardWatcher.class); if (watcher != null) { for (UUID id : watcher.cards) { Card c = game.getCard(id); @@ -80,7 +80,7 @@ class FaithsRewardWatcher extends Watcher { List cards = new ArrayList<>(); public FaithsRewardWatcher() { - super(FaithsRewardWatcher.class.getSimpleName(), WatcherScope.GAME); + super(FaithsRewardWatcher.class, WatcherScope.GAME); } public FaithsRewardWatcher(final FaithsRewardWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/f/FalseOrders.java b/Mage.Sets/src/mage/cards/f/FalseOrders.java index f4c8066db6..7a3279720b 100644 --- a/Mage.Sets/src/mage/cards/f/FalseOrders.java +++ b/Mage.Sets/src/mage/cards/f/FalseOrders.java @@ -104,7 +104,7 @@ class FalseOrdersUnblockEffect extends OneShotEffect { effect.apply(game, source); // Make blocked creatures unblocked - BlockedByOnlyOneCreatureThisCombatWatcher watcher = (BlockedByOnlyOneCreatureThisCombatWatcher) game.getState().getWatchers().get(BlockedByOnlyOneCreatureThisCombatWatcher.class.getSimpleName()); + BlockedByOnlyOneCreatureThisCombatWatcher watcher = game.getState().getWatcher(BlockedByOnlyOneCreatureThisCombatWatcher.class); if (watcher != null) { Set combatGroups = watcher.getBlockedOnlyByCreature(permanent.getId()); if (combatGroups != null) { diff --git a/Mage.Sets/src/mage/cards/f/FeastOnTheFallen.java b/Mage.Sets/src/mage/cards/f/FeastOnTheFallen.java index 7d37092fff..78c8edfd69 100644 --- a/Mage.Sets/src/mage/cards/f/FeastOnTheFallen.java +++ b/Mage.Sets/src/mage/cards/f/FeastOnTheFallen.java @@ -54,7 +54,7 @@ enum FeastOnTheFallenCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { if (watcher.getLifeLostLastTurn(opponentId) > 0) { diff --git a/Mage.Sets/src/mage/cards/f/FellShepherd.java b/Mage.Sets/src/mage/cards/f/FellShepherd.java index 626237217f..44f9007fe6 100644 --- a/Mage.Sets/src/mage/cards/f/FellShepherd.java +++ b/Mage.Sets/src/mage/cards/f/FellShepherd.java @@ -65,7 +65,7 @@ class FellShepherdWatcher extends Watcher { private Set creatureIds = new HashSet<>(); public FellShepherdWatcher() { - super(FellShepherdWatcher.class.getSimpleName(), WatcherScope.PLAYER); + super(FellShepherdWatcher.class, WatcherScope.PLAYER); condition = true; } @@ -118,7 +118,7 @@ class FellShepherdEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - FellShepherdWatcher watcher = (FellShepherdWatcher) game.getState().getWatchers().get(FellShepherdWatcher.class.getSimpleName(), source.getControllerId()); + FellShepherdWatcher watcher = game.getState().getWatcher(FellShepherdWatcher.class, source.getControllerId()); if (watcher != null) { StringBuilder sb = new StringBuilder(); for (UUID creatureId : watcher.getCreaturesIds()) { diff --git a/Mage.Sets/src/mage/cards/f/FinalPunishment.java b/Mage.Sets/src/mage/cards/f/FinalPunishment.java index f4dc817ccc..abf048a636 100644 --- a/Mage.Sets/src/mage/cards/f/FinalPunishment.java +++ b/Mage.Sets/src/mage/cards/f/FinalPunishment.java @@ -45,7 +45,7 @@ class FinalPunishmentAmount implements DynamicValue { @Override public int calculate(Game game, Ability source, Effect effect) { AmountOfDamageAPlayerReceivedThisTurnWatcher watcher - = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatchers().get(AmountOfDamageAPlayerReceivedThisTurnWatcher.class.getSimpleName()); + = game.getState().getWatcher(AmountOfDamageAPlayerReceivedThisTurnWatcher.class); if(watcher != null) { return watcher.getAmountOfDamageReceivedThisTurn(source.getFirstTarget()); } diff --git a/Mage.Sets/src/mage/cards/f/FireAndBrimstone.java b/Mage.Sets/src/mage/cards/f/FireAndBrimstone.java index 72ce9e2c9d..92e9f2cf2a 100644 --- a/Mage.Sets/src/mage/cards/f/FireAndBrimstone.java +++ b/Mage.Sets/src/mage/cards/f/FireAndBrimstone.java @@ -59,7 +59,7 @@ class FireAndBrimstonePredicate extends PlayerPredicate { if (player == null || playerId == null) { return false; } - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); if (watcher != null) { if (!watcher.getAttackedThisTurnCreatures().isEmpty()) { return player.getId().equals(game.getActivePlayerId()); diff --git a/Mage.Sets/src/mage/cards/f/Flamebreak.java b/Mage.Sets/src/mage/cards/f/Flamebreak.java index f80450b3a6..1e834bd05a 100644 --- a/Mage.Sets/src/mage/cards/f/Flamebreak.java +++ b/Mage.Sets/src/mage/cards/f/Flamebreak.java @@ -76,7 +76,7 @@ class FlamebreakCantRegenerateEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == EventType.REGENERATE) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), source.getSourceId()); + DamagedByWatcher watcher = game.getState().getWatcher(DamagedByWatcher.class, source.getSourceId()); if (watcher != null) { return watcher.wasDamaged(event.getTargetId(), game); } diff --git a/Mage.Sets/src/mage/cards/f/FleshAllergy.java b/Mage.Sets/src/mage/cards/f/FleshAllergy.java index fb92c9a5c1..6206824743 100644 --- a/Mage.Sets/src/mage/cards/f/FleshAllergy.java +++ b/Mage.Sets/src/mage/cards/f/FleshAllergy.java @@ -57,7 +57,7 @@ class FleshAllergyWatcher extends Watcher { public int creaturesDiedThisTurn = 0; public FleshAllergyWatcher() { - super(FleshAllergyWatcher.class.getSimpleName(), WatcherScope.GAME); + super(FleshAllergyWatcher.class, WatcherScope.GAME); } public FleshAllergyWatcher(final FleshAllergyWatcher watcher) { @@ -105,7 +105,7 @@ class FleshAllergyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - FleshAllergyWatcher watcher = (FleshAllergyWatcher) game.getState().getWatchers().get(FleshAllergyWatcher.class.getSimpleName()); + FleshAllergyWatcher watcher = game.getState().getWatcher(FleshAllergyWatcher.class); Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); if (permanent != null && watcher != null) { Player player = game.getPlayer(permanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/f/FoulTongueInvocation.java b/Mage.Sets/src/mage/cards/f/FoulTongueInvocation.java index 629c797974..e2069077fd 100644 --- a/Mage.Sets/src/mage/cards/f/FoulTongueInvocation.java +++ b/Mage.Sets/src/mage/cards/f/FoulTongueInvocation.java @@ -89,7 +89,7 @@ class FoulTongueInvocationEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName()); + DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class); if (watcher != null && watcher.castWithConditionTrue(source.getId())) { controller.gainLife(4, game, source); } diff --git a/Mage.Sets/src/mage/cards/f/FrayingSanity.java b/Mage.Sets/src/mage/cards/f/FrayingSanity.java index c53c85c054..501a6e021f 100644 --- a/Mage.Sets/src/mage/cards/f/FrayingSanity.java +++ b/Mage.Sets/src/mage/cards/f/FrayingSanity.java @@ -113,7 +113,7 @@ class FrayingSanityEffect extends OneShotEffect { } Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo()); if (enchantedPlayer != null) { - CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get(CardsPutIntoGraveyardWatcher.class.getSimpleName()); + CardsPutIntoGraveyardWatcher watcher = game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class); if (watcher != null) { xAmount = watcher.getAmountCardsPutToGraveyard(enchantedPlayer.getId()); } diff --git a/Mage.Sets/src/mage/cards/f/FreeRangeChicken.java b/Mage.Sets/src/mage/cards/f/FreeRangeChicken.java index 47310ccc4b..2bc8ed23a3 100644 --- a/Mage.Sets/src/mage/cards/f/FreeRangeChicken.java +++ b/Mage.Sets/src/mage/cards/f/FreeRangeChicken.java @@ -75,7 +75,7 @@ class FreeRangeChickenEffect extends OneShotEffect { if (firstRoll == secondRoll) { game.addEffect(new BoostSourceEffect(firstRoll, firstRoll, Duration.EndOfTurn), source); } - FreeRangeChickenWatcher watcher = (FreeRangeChickenWatcher) game.getState().getWatchers().get(FreeRangeChickenWatcher.class.getSimpleName()); + FreeRangeChickenWatcher watcher = game.getState().getWatcher(FreeRangeChickenWatcher.class); if (watcher != null) { int totalRoll = firstRoll + secondRoll; Permanent sourcePermanent = game.getPermanent(source.getSourceId()); @@ -98,7 +98,7 @@ class FreeRangeChickenWatcher extends Watcher { private final Map totalRolls = new HashMap<>(); public FreeRangeChickenWatcher() { - super(FreeRangeChickenWatcher.class.getSimpleName(), WatcherScope.GAME); + super(FreeRangeChickenWatcher.class, WatcherScope.GAME); } public FreeRangeChickenWatcher(final FreeRangeChickenWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/f/FreshMeat.java b/Mage.Sets/src/mage/cards/f/FreshMeat.java index 886d76becd..9938654926 100644 --- a/Mage.Sets/src/mage/cards/f/FreshMeat.java +++ b/Mage.Sets/src/mage/cards/f/FreshMeat.java @@ -41,7 +41,7 @@ class FreshMeatDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatchers().get(CreaturesDiedWatcher.class.getSimpleName()); + CreaturesDiedWatcher watcher = game.getState().getWatcher(CreaturesDiedWatcher.class); if (watcher != null) { return watcher.getAmountOfCreaturesDiedThisTurnByController(sourceAbility.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/f/FyndhornDruid.java b/Mage.Sets/src/mage/cards/f/FyndhornDruid.java index b1b49136b1..a1b1fb15af 100644 --- a/Mage.Sets/src/mage/cards/f/FyndhornDruid.java +++ b/Mage.Sets/src/mage/cards/f/FyndhornDruid.java @@ -50,7 +50,7 @@ class SourceWasBlockedThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); - WasBlockedThisTurnWatcher watcher = (WasBlockedThisTurnWatcher) game.getState().getWatchers().get(WasBlockedThisTurnWatcher.class.getSimpleName()); + WasBlockedThisTurnWatcher watcher = game.getState().getWatcher(WasBlockedThisTurnWatcher.class); return sourcePermanent != null && watcher != null && watcher.getWasBlockedThisTurnCreatures().contains(new MageObjectReference(sourcePermanent, game)); } } diff --git a/Mage.Sets/src/mage/cards/g/GarnaTheBloodflame.java b/Mage.Sets/src/mage/cards/g/GarnaTheBloodflame.java index 74585b1ffe..379d0b3c0d 100644 --- a/Mage.Sets/src/mage/cards/g/GarnaTheBloodflame.java +++ b/Mage.Sets/src/mage/cards/g/GarnaTheBloodflame.java @@ -80,7 +80,7 @@ class GarnaTheBloodflameEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - GarnaTheBloodflameWatcher watcher = (GarnaTheBloodflameWatcher) game.getState().getWatchers().get(GarnaTheBloodflameWatcher.class.getSimpleName()); + GarnaTheBloodflameWatcher watcher = (GarnaTheBloodflameWatcher) game.getState().getWatcher(GarnaTheBloodflameWatcher.class); if (watcher != null) { Set toHand = new HashSet<>(); for (UUID cardId : watcher.getCardsPutToGraveyardThisTurn()) { diff --git a/Mage.Sets/src/mage/cards/g/GazeOfTheGorgon.java b/Mage.Sets/src/mage/cards/g/GazeOfTheGorgon.java index ecdd1863e5..189093c8a0 100644 --- a/Mage.Sets/src/mage/cards/g/GazeOfTheGorgon.java +++ b/Mage.Sets/src/mage/cards/g/GazeOfTheGorgon.java @@ -98,7 +98,7 @@ class GazeOfTheGorgonEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null && targetCreature != null) { - BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); + BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatcher(BlockedAttackerWatcher.class); if (watcher != null) { List toDestroy = new ArrayList<>(); for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { diff --git a/Mage.Sets/src/mage/cards/g/GeneratorServant.java b/Mage.Sets/src/mage/cards/g/GeneratorServant.java index 567c43884d..7e5c6b7e33 100644 --- a/Mage.Sets/src/mage/cards/g/GeneratorServant.java +++ b/Mage.Sets/src/mage/cards/g/GeneratorServant.java @@ -63,7 +63,7 @@ class GeneratorServantWatcher extends Watcher { public List creatures = new ArrayList<>(); public GeneratorServantWatcher() { - super(GeneratorServantWatcher.class.getSimpleName(), WatcherScope.CARD); + super(GeneratorServantWatcher.class, WatcherScope.CARD); } public GeneratorServantWatcher(final GeneratorServantWatcher watcher) { @@ -114,7 +114,7 @@ class GeneratorServantHasteEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - GeneratorServantWatcher watcher = (GeneratorServantWatcher) game.getState().getWatchers().get(GeneratorServantWatcher.class.getSimpleName(), source.getSourceId()); + GeneratorServantWatcher watcher = (GeneratorServantWatcher) game.getState().getWatcher(GeneratorServantWatcher.class, source.getSourceId()); if (watcher != null) { for (Permanent perm : game.getBattlefield().getAllActivePermanents()) { if (watcher.creatures.contains(perm.getId())) { diff --git a/Mage.Sets/src/mage/cards/g/GiantTurtle.java b/Mage.Sets/src/mage/cards/g/GiantTurtle.java index 6d0e100c75..b4a6decf72 100644 --- a/Mage.Sets/src/mage/cards/g/GiantTurtle.java +++ b/Mage.Sets/src/mage/cards/g/GiantTurtle.java @@ -63,7 +63,7 @@ class CantAttackIfAttackedLastTurnEffect extends RestrictionEffect { @Override public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) { - AttackedLastTurnWatcher watcher = (AttackedLastTurnWatcher) game.getState().getWatchers().get(AttackedLastTurnWatcher.class.getSimpleName()); + AttackedLastTurnWatcher watcher = (AttackedLastTurnWatcher) game.getState().getWatcher(AttackedLastTurnWatcher.class); if (watcher != null) { Set attackingCreatures = watcher.getAttackedLastTurnCreatures(attacker.getControllerId()); MageObjectReference mor = new MageObjectReference(attacker, game); diff --git a/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java b/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java index 82ac97ef3c..ae40261d9f 100644 --- a/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java +++ b/Mage.Sets/src/mage/cards/g/GiltspireAvenger.java @@ -68,7 +68,7 @@ class GiltspireAvengerTarget extends TargetPermanent { @Override public boolean canTarget(UUID id, Ability source, Game game) { - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), source.getControllerId()); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, source.getControllerId()); if (watcher != null && watcher.hasSourceDoneDamage(id, game)) { return super.canTarget(id, source, game); } @@ -79,7 +79,7 @@ class GiltspireAvengerTarget extends TargetPermanent { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); Set possibleTargets = new HashSet<>(); - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, sourceControllerId); for (UUID targetId : availablePossibleTargets) { Permanent permanent = game.getPermanent(targetId); if (permanent != null && watcher != null && watcher.hasSourceDoneDamage(targetId, game)) { @@ -97,7 +97,7 @@ class GiltspireAvengerTarget extends TargetPermanent { } int count = 0; MageObject targetSource = game.getObject(sourceId); - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, sourceControllerId); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && watcher != null && watcher.hasSourceDoneDamage(permanent.getId(), game)) { diff --git a/Mage.Sets/src/mage/cards/g/GisaAndGeralf.java b/Mage.Sets/src/mage/cards/g/GisaAndGeralf.java index ab9e185c8d..621003fabd 100644 --- a/Mage.Sets/src/mage/cards/g/GisaAndGeralf.java +++ b/Mage.Sets/src/mage/cards/g/GisaAndGeralf.java @@ -120,7 +120,7 @@ class GisaAndGeralfCastFromGraveyardEffect extends AsThoughEffectImpl { public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { if (objectId.equals(getTargetPointer().getFirst(game, source))) { if (affectedControllerId.equals(source.getControllerId())) { - GisaAndGeralfWatcher watcher = (GisaAndGeralfWatcher) game.getState().getWatchers().get(GisaAndGeralfWatcher.class.getSimpleName(), source.getSourceId()); + GisaAndGeralfWatcher watcher = (GisaAndGeralfWatcher) game.getState().getWatcher(GisaAndGeralfWatcher.class, source.getSourceId()); return watcher != null && !watcher.isAbilityUsed(); } } diff --git a/Mage.Sets/src/mage/cards/g/Gleancrawler.java b/Mage.Sets/src/mage/cards/g/Gleancrawler.java index 9b183e132c..3ebace8d90 100644 --- a/Mage.Sets/src/mage/cards/g/Gleancrawler.java +++ b/Mage.Sets/src/mage/cards/g/Gleancrawler.java @@ -73,7 +73,7 @@ class GleancrawlerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get(CardsPutIntoGraveyardWatcher.class.getSimpleName()); + CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && watcher != null) { Set cardsToGraveyardThisTurn = watcher.getCardsPutToGraveyardFromBattlefield(); diff --git a/Mage.Sets/src/mage/cards/g/GlyphKeeper.java b/Mage.Sets/src/mage/cards/g/GlyphKeeper.java index 697acf4696..5510194ec8 100644 --- a/Mage.Sets/src/mage/cards/g/GlyphKeeper.java +++ b/Mage.Sets/src/mage/cards/g/GlyphKeeper.java @@ -79,7 +79,7 @@ class GlyphKeeperAbility extends TriggeredAbilityImpl { if (event.getTargetId().equals(this.getSourceId())) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.isCreature()) { - NumberOfTimesPermanentTargetedATurnWatcher watcher = (NumberOfTimesPermanentTargetedATurnWatcher) game.getState().getWatchers().get(NumberOfTimesPermanentTargetedATurnWatcher.class.getSimpleName()); + NumberOfTimesPermanentTargetedATurnWatcher watcher = (NumberOfTimesPermanentTargetedATurnWatcher) game.getState().getWatcher(NumberOfTimesPermanentTargetedATurnWatcher.class); if (watcher != null && watcher.notMoreThanOnceTargetedThisTurn(permanent, game)) { for (Effect effect : getEffects()) { diff --git a/Mage.Sets/src/mage/cards/g/GlyphOfDoom.java b/Mage.Sets/src/mage/cards/g/GlyphOfDoom.java index ea23f5b02b..c473614c44 100644 --- a/Mage.Sets/src/mage/cards/g/GlyphOfDoom.java +++ b/Mage.Sets/src/mage/cards/g/GlyphOfDoom.java @@ -106,7 +106,7 @@ class GlyphOfDoomEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null && targetCreature != null) { - BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); + BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatcher(BlockedAttackerWatcher.class); if (watcher != null) { List toDestroy = new ArrayList<>(); for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { diff --git a/Mage.Sets/src/mage/cards/g/GoblinCohort.java b/Mage.Sets/src/mage/cards/g/GoblinCohort.java index 592c7e6759..c7e84adbab 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinCohort.java +++ b/Mage.Sets/src/mage/cards/g/GoblinCohort.java @@ -69,7 +69,7 @@ class GoblinCohortEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { - PlayerCastCreatureWatcher watcher = (PlayerCastCreatureWatcher) game.getState().getWatchers().get(PlayerCastCreatureWatcher.class.getSimpleName()); + PlayerCastCreatureWatcher watcher = (PlayerCastCreatureWatcher) game.getState().getWatcher(PlayerCastCreatureWatcher.class); if (watcher != null && !watcher.playerDidCastCreatureThisTurn(source.getControllerId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/g/GoblinRockSled.java b/Mage.Sets/src/mage/cards/g/GoblinRockSled.java index fa2d9fd378..d6f255ce70 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinRockSled.java +++ b/Mage.Sets/src/mage/cards/g/GoblinRockSled.java @@ -96,7 +96,7 @@ class DontUntapIfAttackedLastTurnSourceEffect extends ContinuousRuleModifyingEff && event.getTargetId().equals(source.getSourceId())) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null && permanent.isControlledBy(game.getActivePlayerId())) { - AttackedLastTurnWatcher watcher = (AttackedLastTurnWatcher) game.getState().getWatchers().get(AttackedLastTurnWatcher.class.getSimpleName()); + AttackedLastTurnWatcher watcher = (AttackedLastTurnWatcher) game.getState().getWatcher(AttackedLastTurnWatcher.class); if (watcher != null) { Set attackingCreatures = watcher.getAttackedLastTurnCreatures(permanent.getControllerId()); MageObjectReference mor = new MageObjectReference(permanent, game); diff --git a/Mage.Sets/src/mage/cards/g/Gomazoa.java b/Mage.Sets/src/mage/cards/g/Gomazoa.java index f609015e0f..9547e3ad48 100644 --- a/Mage.Sets/src/mage/cards/g/Gomazoa.java +++ b/Mage.Sets/src/mage/cards/g/Gomazoa.java @@ -86,7 +86,7 @@ class GomazoaEffect extends OneShotEffect { players.add(gomazoa.getOwnerId()); } - BlockedByWatcher watcher = (BlockedByWatcher) game.getState().getWatchers().get(BlockedByWatcher.class.getSimpleName(), source.getSourceId()); + BlockedByWatcher watcher = (BlockedByWatcher) game.getState().getWatcher(BlockedByWatcher.class, source.getSourceId()); creaturesBlocked = watcher.blockedByWatcher; for (UUID blockedById : creaturesBlocked) { diff --git a/Mage.Sets/src/mage/cards/g/GontisMachinations.java b/Mage.Sets/src/mage/cards/g/GontisMachinations.java index 513d886712..baf4c07630 100644 --- a/Mage.Sets/src/mage/cards/g/GontisMachinations.java +++ b/Mage.Sets/src/mage/cards/g/GontisMachinations.java @@ -68,7 +68,7 @@ class GontisMachinationsTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(getControllerId())) { GontisMachinationsFirstLostLifeThisTurnWatcher watcher - = (GontisMachinationsFirstLostLifeThisTurnWatcher) game.getState().getWatchers().get(GontisMachinationsFirstLostLifeThisTurnWatcher.class.getSimpleName()); + = (GontisMachinationsFirstLostLifeThisTurnWatcher) game.getState().getWatcher(GontisMachinationsFirstLostLifeThisTurnWatcher.class); if (watcher != null && watcher.timesLostLifeThisTurn(event.getTargetId()) < 2) { return true; } @@ -92,7 +92,7 @@ class GontisMachinationsFirstLostLifeThisTurnWatcher extends Watcher { private final Map playersLostLife = new HashMap<>(); public GontisMachinationsFirstLostLifeThisTurnWatcher() { - super(GontisMachinationsFirstLostLifeThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); + super(GontisMachinationsFirstLostLifeThisTurnWatcher.class, WatcherScope.GAME); } public GontisMachinationsFirstLostLifeThisTurnWatcher(final GontisMachinationsFirstLostLifeThisTurnWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/g/GrandWarlordRadha.java b/Mage.Sets/src/mage/cards/g/GrandWarlordRadha.java index 508844bc91..09ab854a21 100644 --- a/Mage.Sets/src/mage/cards/g/GrandWarlordRadha.java +++ b/Mage.Sets/src/mage/cards/g/GrandWarlordRadha.java @@ -65,7 +65,7 @@ class CreaturesAttackedWatcher extends Watcher { public final Set attackedThisTurnCreatures = new HashSet<>(); public CreaturesAttackedWatcher() { - super(CreaturesAttackedWatcher.class.getSimpleName(), WatcherScope.GAME); + super(CreaturesAttackedWatcher.class, WatcherScope.GAME); } public CreaturesAttackedWatcher(final CreaturesAttackedWatcher watcher) { @@ -153,7 +153,7 @@ class GrandWarlordRadhaEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - CreaturesAttackedWatcher watcher = (CreaturesAttackedWatcher) game.getState().getWatchers().get(CreaturesAttackedWatcher.class.getSimpleName()); + CreaturesAttackedWatcher watcher = (CreaturesAttackedWatcher) game.getState().getWatcher(CreaturesAttackedWatcher.class); if (watcher != null) { int attackingCreatures = 0; for (MageObjectReference attacker : watcher.getAttackedThisTurnCreatures()) { diff --git a/Mage.Sets/src/mage/cards/g/GrimReminder.java b/Mage.Sets/src/mage/cards/g/GrimReminder.java index 6ad9da49df..80bde45363 100644 --- a/Mage.Sets/src/mage/cards/g/GrimReminder.java +++ b/Mage.Sets/src/mage/cards/g/GrimReminder.java @@ -93,7 +93,7 @@ class GrimReminderEffect extends OneShotEffect { Cards cardsToReveal = new CardsImpl(card); controller.revealCards(sourceObject.getIdName(), cardsToReveal, game); String cardName = card.getName(); - GrimReminderWatcher watcher = (GrimReminderWatcher) game.getState().getWatchers().get(GrimReminderWatcher.class.getSimpleName()); + GrimReminderWatcher watcher = (GrimReminderWatcher) game.getState().getWatcher(GrimReminderWatcher.class); if (watcher != null) { for (UUID playerId : watcher.getPlayersCastSpell(cardName)) { Player player = game.getPlayer(playerId); @@ -116,7 +116,7 @@ class GrimReminderWatcher extends Watcher { private final Map> playersCastSpell = new HashMap<>(); public GrimReminderWatcher() { - super(GrimReminderWatcher.class.getSimpleName(), WatcherScope.GAME); + super(GrimReminderWatcher.class, WatcherScope.GAME); } public GrimReminderWatcher(final GrimReminderWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/g/GrimReturn.java b/Mage.Sets/src/mage/cards/g/GrimReturn.java index 19e46ebcaa..a20245cffc 100644 --- a/Mage.Sets/src/mage/cards/g/GrimReturn.java +++ b/Mage.Sets/src/mage/cards/g/GrimReturn.java @@ -49,7 +49,7 @@ public final class GrimReturn extends CardImpl { @Override public void adjustTargets(Ability ability, Game game) { - CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get(CardsPutIntoGraveyardWatcher.class.getSimpleName()); + CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class); if (watcher != null) { FilterCard filter = new FilterCreatureCard(textFilter); List uuidPredicates = new ArrayList<>(); diff --git a/Mage.Sets/src/mage/cards/g/GrothamaAllDevouring.java b/Mage.Sets/src/mage/cards/g/GrothamaAllDevouring.java index 27a39841c3..6ec3e0da4b 100644 --- a/Mage.Sets/src/mage/cards/g/GrothamaAllDevouring.java +++ b/Mage.Sets/src/mage/cards/g/GrothamaAllDevouring.java @@ -148,7 +148,7 @@ class GrothamaAllDevouringDrawCardsEffect extends OneShotEffect { if (controller == null) { return false; } - GrothamaAllDevouringWatcher watcher = (GrothamaAllDevouringWatcher) game.getState().getWatchers().get(GrothamaAllDevouringWatcher.class.getSimpleName()); + GrothamaAllDevouringWatcher watcher = (GrothamaAllDevouringWatcher) game.getState().getWatcher(GrothamaAllDevouringWatcher.class); if (watcher == null) { return false; } @@ -171,7 +171,7 @@ class GrothamaAllDevouringWatcher extends Watcher { Map> damageMap = new HashMap<>(); GrothamaAllDevouringWatcher() { - super(GrothamaAllDevouringWatcher.class.getSimpleName(), WatcherScope.GAME); + super(GrothamaAllDevouringWatcher.class, WatcherScope.GAME); } GrothamaAllDevouringWatcher(final GrothamaAllDevouringWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/g/Gutterbones.java b/Mage.Sets/src/mage/cards/g/Gutterbones.java index 5868a3db67..4129d10832 100644 --- a/Mage.Sets/src/mage/cards/g/Gutterbones.java +++ b/Mage.Sets/src/mage/cards/g/Gutterbones.java @@ -56,7 +56,7 @@ enum GutterbonesCondition implements Condition { @Override public boolean apply(Game game, Ability source) { if (game.isActivePlayer(source.getControllerId())) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatcher(PlayerLostLifeWatcher.class); return watcher != null && watcher.getAllOppLifeLost(source.getControllerId(), game) > 0; } return false; diff --git a/Mage.Sets/src/mage/cards/h/HallowedMoonlight.java b/Mage.Sets/src/mage/cards/h/HallowedMoonlight.java index 90ccbbcf02..4665df8897 100644 --- a/Mage.Sets/src/mage/cards/h/HallowedMoonlight.java +++ b/Mage.Sets/src/mage/cards/h/HallowedMoonlight.java @@ -83,7 +83,7 @@ class HallowedMoonlightEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { EntersTheBattlefieldEvent entersTheBattlefieldEvent = (EntersTheBattlefieldEvent) event; if (entersTheBattlefieldEvent.getTarget().isCreature()) { - CreatureWasCastWatcher watcher = (CreatureWasCastWatcher) game.getState().getWatchers().get(CreatureWasCastWatcher.class.getSimpleName()); + CreatureWasCastWatcher watcher = game.getState().getWatcher(CreatureWasCastWatcher.class); if (watcher != null && !watcher.wasCreatureCastThisTurn(event.getTargetId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/h/HallsOfMist.java b/Mage.Sets/src/mage/cards/h/HallsOfMist.java index 1896bc612a..72cb16de38 100644 --- a/Mage.Sets/src/mage/cards/h/HallsOfMist.java +++ b/Mage.Sets/src/mage/cards/h/HallsOfMist.java @@ -62,7 +62,7 @@ class CantAttackIfAttackedLastTurnAllEffect extends RestrictionEffect { @Override public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game) { - AttackedLastTurnWatcher watcher = (AttackedLastTurnWatcher) game.getState().getWatchers().get(AttackedLastTurnWatcher.class.getSimpleName()); + AttackedLastTurnWatcher watcher = game.getState().getWatcher(AttackedLastTurnWatcher.class); if (watcher != null) { Set attackingCreatures = watcher.getAttackedLastTurnCreatures(attacker.getControllerId()); MageObjectReference mor = new MageObjectReference(attacker, game); diff --git a/Mage.Sets/src/mage/cards/h/HardenedBerserker.java b/Mage.Sets/src/mage/cards/h/HardenedBerserker.java index 5793f80ee1..dbcc074bfb 100644 --- a/Mage.Sets/src/mage/cards/h/HardenedBerserker.java +++ b/Mage.Sets/src/mage/cards/h/HardenedBerserker.java @@ -62,7 +62,7 @@ class HardenedBerserkerSpellsCostReductionEffect extends CostModificationEffectI @Override public void init(Ability source, Game game) { super.init(source, game); - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null) { spellsCast = watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()); } @@ -76,7 +76,7 @@ class HardenedBerserkerSpellsCostReductionEffect extends CostModificationEffectI @Override public boolean applies(Ability abilityToModify, Ability source, Game game) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null) { if (watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) > spellsCast) { discard(); // only one use diff --git a/Mage.Sets/src/mage/cards/h/HarnessTheStorm.java b/Mage.Sets/src/mage/cards/h/HarnessTheStorm.java index 165ef34ebb..d7eb201d29 100644 --- a/Mage.Sets/src/mage/cards/h/HarnessTheStorm.java +++ b/Mage.Sets/src/mage/cards/h/HarnessTheStorm.java @@ -61,7 +61,7 @@ class HarnessTheStormTriggeredAbility extends SpellCastControllerTriggeredAbilit @Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { - CastFromHandWatcher watcher = (CastFromHandWatcher) game.getState().getWatchers().get(CastFromHandWatcher.class.getSimpleName()); + CastFromHandWatcher watcher = game.getState().getWatcher(CastFromHandWatcher.class); if (watcher != null && watcher.spellWasCastFromHand(event.getSourceId())) { Spell spell = game.getState().getStack().getSpell(event.getSourceId()); if (spell != null) { diff --git a/Mage.Sets/src/mage/cards/h/HeatStroke.java b/Mage.Sets/src/mage/cards/h/HeatStroke.java index 414daf009e..6d4a1982bc 100644 --- a/Mage.Sets/src/mage/cards/h/HeatStroke.java +++ b/Mage.Sets/src/mage/cards/h/HeatStroke.java @@ -66,8 +66,8 @@ class HeatStrokeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - BlockedThisTurnWatcher blockedWatcher = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName()); - WasBlockedThisTurnWatcher wasBlockedThisTurnWatcher = (WasBlockedThisTurnWatcher) game.getState().getWatchers().get(WasBlockedThisTurnWatcher.class.getSimpleName()); + BlockedThisTurnWatcher blockedWatcher = game.getState().getWatcher(BlockedThisTurnWatcher.class); + WasBlockedThisTurnWatcher wasBlockedThisTurnWatcher = game.getState().getWatcher(WasBlockedThisTurnWatcher.class); Set inROI = new HashSet<>(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)); boolean toRet = false; diff --git a/Mage.Sets/src/mage/cards/h/HollowOne.java b/Mage.Sets/src/mage/cards/h/HollowOne.java index 6796e8ad3b..495f14dd6f 100644 --- a/Mage.Sets/src/mage/cards/h/HollowOne.java +++ b/Mage.Sets/src/mage/cards/h/HollowOne.java @@ -66,7 +66,7 @@ class HollowOneReductionEffect extends CostModificationEffectImpl { @Override public boolean apply(Game game, Ability source, Ability abilityToModify) { - CardsCycledOrDiscardedThisTurnWatcher watcher = (CardsCycledOrDiscardedThisTurnWatcher) game.getState().getWatchers().get(CardsCycledOrDiscardedThisTurnWatcher.class.getSimpleName()); + CardsCycledOrDiscardedThisTurnWatcher watcher = game.getState().getWatcher(CardsCycledOrDiscardedThisTurnWatcher.class); if (watcher != null) { CardUtil.reduceCost(abilityToModify, watcher.getNumberOfCardsCycledOrDiscardedThisTurn(source.getControllerId()) * 2); return true; diff --git a/Mage.Sets/src/mage/cards/h/HomicidalBrute.java b/Mage.Sets/src/mage/cards/h/HomicidalBrute.java index 2575371fa1..cfd0e44201 100644 --- a/Mage.Sets/src/mage/cards/h/HomicidalBrute.java +++ b/Mage.Sets/src/mage/cards/h/HomicidalBrute.java @@ -10,6 +10,7 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; +import mage.constants.WatcherScope; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; @@ -73,7 +74,7 @@ class HomicidalBruteTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(this.controllerId)) { - Watcher watcher = game.getState().getWatchers().get("HomicidalBruteWatcher", sourceId); + Watcher watcher = game.getState().getWatcher(HomicidalBruteWatcher.class, sourceId); if (watcher == null || !watcher.conditionMet()) { return true; } @@ -87,3 +88,5 @@ class HomicidalBruteTriggeredAbility extends TriggeredAbilityImpl { } } + + diff --git a/Mage.Sets/src/mage/cards/h/HomicidalBruteWatcher.java b/Mage.Sets/src/mage/cards/h/HomicidalBruteWatcher.java new file mode 100644 index 0000000000..c92ff72fcd --- /dev/null +++ b/Mage.Sets/src/mage/cards/h/HomicidalBruteWatcher.java @@ -0,0 +1,32 @@ +package mage.cards.h; + +import mage.constants.WatcherScope; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.watchers.Watcher; + +public class HomicidalBruteWatcher extends Watcher { + + public HomicidalBruteWatcher() { + super(HomicidalBruteWatcher.class.getSimpleName(), WatcherScope.CARD); + } + + public HomicidalBruteWatcher(final HomicidalBruteWatcher watcher) { + super(watcher); + } + + @Override + public HomicidalBruteWatcher copy() { + return new HomicidalBruteWatcher(this); + } + + @Override + public void watch(GameEvent event, Game game) { + if (condition) { + return; + } + if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(sourceId)) { + condition = true; + } + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java b/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java index 5df2aeefb8..fbc81094ee 100644 --- a/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java +++ b/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java @@ -128,7 +128,7 @@ class HopeOfGhirapurPlayerLostLifePredicate implements ObjectSourcePlayerPredica if (targetPlayer == null) { return false; } - HopeOfGhirapurCombatDamageWatcher watcher = (HopeOfGhirapurCombatDamageWatcher) game.getState().getWatchers().get(HopeOfGhirapurCombatDamageWatcher.class.getSimpleName()); + HopeOfGhirapurCombatDamageWatcher watcher = game.getState().getWatcher(HopeOfGhirapurCombatDamageWatcher.class); if (watcher != null) { return watcher.playerGotCombatDamage(input.getSourceId(), input.getObject().getId(), game); } diff --git a/Mage.Sets/src/mage/cards/h/HotheadedGiant.java b/Mage.Sets/src/mage/cards/h/HotheadedGiant.java index 10100831b6..d5ac4b036f 100644 --- a/Mage.Sets/src/mage/cards/h/HotheadedGiant.java +++ b/Mage.Sets/src/mage/cards/h/HotheadedGiant.java @@ -62,7 +62,7 @@ class CastRedSpellThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - HotHeadedGiantWatcher watcher = (HotHeadedGiantWatcher) game.getState().getWatchers().get(HotHeadedGiantWatcher.class.getSimpleName(), source.getControllerId()); + HotHeadedGiantWatcher watcher = game.getState().getWatcher(HotHeadedGiantWatcher.class, source.getControllerId()); if (watcher != null) { return watcher.conditionMet(); } diff --git a/Mage.Sets/src/mage/cards/h/HuntDown.java b/Mage.Sets/src/mage/cards/h/HuntDown.java index 2d2c6f1fa5..419db8da28 100644 --- a/Mage.Sets/src/mage/cards/h/HuntDown.java +++ b/Mage.Sets/src/mage/cards/h/HuntDown.java @@ -70,7 +70,7 @@ class HuntDownEffect extends RequirementEffect { && blocker.canBlock(source.getTargets().get(1).getFirstTarget(), game)) { Permanent attacker = game.getPermanent(source.getTargets().get(1).getFirstTarget()); if (attacker != null) { - BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); + BlockedAttackerWatcher blockedAttackerWatcher = game.getState().getWatcher(BlockedAttackerWatcher.class); if (blockedAttackerWatcher != null && blockedAttackerWatcher.creatureHasBlockedAttacker(attacker, blocker, game)) { // has already blocked this turn, so no need to do again diff --git a/Mage.Sets/src/mage/cards/i/ImpactResonance.java b/Mage.Sets/src/mage/cards/i/ImpactResonance.java index 3f445d2613..a93cc1eb26 100644 --- a/Mage.Sets/src/mage/cards/i/ImpactResonance.java +++ b/Mage.Sets/src/mage/cards/i/ImpactResonance.java @@ -62,7 +62,7 @@ enum GreatestAmountOfDamageDealtValue implements DynamicValue, MageSingleton { } public int calculate(Game game, UUID controllerId) { - GreatestAmountOfDamageWatcher watcher = (GreatestAmountOfDamageWatcher) game.getState().getWatchers().get(GreatestAmountOfDamageWatcher.class.getSimpleName()); + GreatestAmountOfDamageWatcher watcher = (GreatestAmountOfDamageWatcher) game.getState().getWatcher(GreatestAmountOfDamageWatcher.class); if (watcher != null) { return watcher.getGreatestAmountOfDamage(); } @@ -90,7 +90,7 @@ class GreatestAmountOfDamageWatcher extends Watcher { private int damageAmount; public GreatestAmountOfDamageWatcher() { - super(GreatestAmountOfDamageWatcher.class.getSimpleName(), WatcherScope.GAME); + super(GreatestAmountOfDamageWatcher.class, WatcherScope.GAME); } public GreatestAmountOfDamageWatcher(final GreatestAmountOfDamageWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/i/Impatience.java b/Mage.Sets/src/mage/cards/i/Impatience.java index 93c267c58c..2c08a524bc 100644 --- a/Mage.Sets/src/mage/cards/i/Impatience.java +++ b/Mage.Sets/src/mage/cards/i/Impatience.java @@ -46,7 +46,7 @@ class ImpatienceCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); return watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(game.getActivePlayerId()) == 0; } diff --git a/Mage.Sets/src/mage/cards/i/Imprison.java b/Mage.Sets/src/mage/cards/i/Imprison.java index 6d094bdb9d..9ad1094631 100644 --- a/Mage.Sets/src/mage/cards/i/Imprison.java +++ b/Mage.Sets/src/mage/cards/i/Imprison.java @@ -145,7 +145,7 @@ class ImprisonUnblockEffect extends OneShotEffect { effect.apply(game, source); // Make blocked creatures unblocked - BlockedByOnlyOneCreatureThisCombatWatcher watcher = (BlockedByOnlyOneCreatureThisCombatWatcher) game.getState().getWatchers().get(BlockedByOnlyOneCreatureThisCombatWatcher.class.getSimpleName()); + BlockedByOnlyOneCreatureThisCombatWatcher watcher = (BlockedByOnlyOneCreatureThisCombatWatcher) game.getState().getWatcher(BlockedByOnlyOneCreatureThisCombatWatcher.class); if (watcher != null) { Set combatGroups = watcher.getBlockedOnlyByCreature(permanent.getId()); if (combatGroups != null) { diff --git a/Mage.Sets/src/mage/cards/i/Incinerate.java b/Mage.Sets/src/mage/cards/i/Incinerate.java index 0fa3368ffb..6e00c8c624 100644 --- a/Mage.Sets/src/mage/cards/i/Incinerate.java +++ b/Mage.Sets/src/mage/cards/i/Incinerate.java @@ -70,7 +70,7 @@ class IncinerateEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), source.getSourceId()); + DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatcher(DamagedByWatcher.class, source.getSourceId()); if (watcher != null) { return watcher.wasDamaged(event.getTargetId(), game); } diff --git a/Mage.Sets/src/mage/cards/i/IncursionSpecialist.java b/Mage.Sets/src/mage/cards/i/IncursionSpecialist.java index 756b250d11..720549b1a0 100644 --- a/Mage.Sets/src/mage/cards/i/IncursionSpecialist.java +++ b/Mage.Sets/src/mage/cards/i/IncursionSpecialist.java @@ -69,7 +69,7 @@ class IncursionTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(controllerId)) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2) { return true; } diff --git a/Mage.Sets/src/mage/cards/i/InfernoHellion.java b/Mage.Sets/src/mage/cards/i/InfernoHellion.java index ed2b3254f7..4d2347a799 100644 --- a/Mage.Sets/src/mage/cards/i/InfernoHellion.java +++ b/Mage.Sets/src/mage/cards/i/InfernoHellion.java @@ -66,8 +66,8 @@ enum InfernoHellionCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - AttackedThisTurnWatcher watcherAttacked = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); - BlockedThisTurnWatcher watcherBlocked = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcherAttacked = (AttackedThisTurnWatcher) game.getState().getWatcher(AttackedThisTurnWatcher.class); + BlockedThisTurnWatcher watcherBlocked = (BlockedThisTurnWatcher) game.getState().getWatcher(BlockedThisTurnWatcher.class); MageObjectReference mor = new MageObjectReference(source.getSourceId(), game); if (watcherAttacked == null || watcherBlocked == null) { return false; diff --git a/Mage.Sets/src/mage/cards/i/InfernoTrap.java b/Mage.Sets/src/mage/cards/i/InfernoTrap.java index 8ac6aa5364..5096663102 100644 --- a/Mage.Sets/src/mage/cards/i/InfernoTrap.java +++ b/Mage.Sets/src/mage/cards/i/InfernoTrap.java @@ -53,7 +53,7 @@ enum InfernoTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - InfernoTrapWatcher watcher = (InfernoTrapWatcher) game.getState().getWatchers().get(InfernoTrapWatcher.class.getSimpleName()); + InfernoTrapWatcher watcher = (InfernoTrapWatcher) game.getState().getWatcher(InfernoTrapWatcher.class); if (watcher != null) { Set damagingCreatures = watcher.getDamagingCreatures(source.getControllerId()); return damagingCreatures.size() > 1; @@ -72,7 +72,7 @@ class InfernoTrapWatcher extends Watcher { Map> playerDamagedByCreature = new HashMap<>(); public InfernoTrapWatcher() { - super(InfernoTrapWatcher.class.getSimpleName(), WatcherScope.GAME); + super(InfernoTrapWatcher.class, WatcherScope.GAME); } public InfernoTrapWatcher(final InfernoTrapWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/i/InsatiableRakghoul.java b/Mage.Sets/src/mage/cards/i/InsatiableRakghoul.java index e62ce559f3..f9de112e43 100644 --- a/Mage.Sets/src/mage/cards/i/InsatiableRakghoul.java +++ b/Mage.Sets/src/mage/cards/i/InsatiableRakghoul.java @@ -62,7 +62,7 @@ class InsatiableRakghoulEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - NonArtifactCreaturesDiedWatcher watcher = (NonArtifactCreaturesDiedWatcher) game.getState().getWatchers().get(NonArtifactCreaturesDiedWatcher.class.getSimpleName()); + NonArtifactCreaturesDiedWatcher watcher = (NonArtifactCreaturesDiedWatcher) game.getState().getWatcher(NonArtifactCreaturesDiedWatcher.class); if (watcher != null && watcher.conditionMet()) { Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (permanent != null) { @@ -83,7 +83,7 @@ class InsatiableRakghoulEffect extends OneShotEffect { class NonArtifactCreaturesDiedWatcher extends Watcher { public NonArtifactCreaturesDiedWatcher() { - super(NonArtifactCreaturesDiedWatcher.class.getSimpleName(), WatcherScope.GAME); + super(NonArtifactCreaturesDiedWatcher.class, WatcherScope.GAME); } public NonArtifactCreaturesDiedWatcher(final NonArtifactCreaturesDiedWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/i/Insist.java b/Mage.Sets/src/mage/cards/i/Insist.java index 5c79086b5e..2fcf5c3cac 100644 --- a/Mage.Sets/src/mage/cards/i/Insist.java +++ b/Mage.Sets/src/mage/cards/i/Insist.java @@ -65,7 +65,7 @@ class InsistEffect extends ContinuousRuleModifyingEffectImpl { @Override public void init(Ability source, Game game) { super.init(source, game); - InsistWatcher watcher = (InsistWatcher) game.getState().getWatchers().get(InsistWatcher.class.getSimpleName(), source.getControllerId()); + InsistWatcher watcher = (InsistWatcher) game.getState().getWatcher(InsistWatcher.class, source.getControllerId()); if (watcher != null) { watcher.setReady(); } @@ -93,7 +93,7 @@ class InsistEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); - InsistWatcher watcher = (InsistWatcher) game.getState().getWatchers().get(InsistWatcher.class.getSimpleName(), source.getControllerId()); + InsistWatcher watcher = (InsistWatcher) game.getState().getWatcher(InsistWatcher.class, source.getControllerId()); return spell != null && watcher != null && watcher.isUncounterable(spell.getId()); } } @@ -104,7 +104,7 @@ class InsistWatcher extends Watcher { protected UUID uncounterableSpell; InsistWatcher() { - super(InsistWatcher.class.getSimpleName(), WatcherScope.PLAYER); + super(InsistWatcher.class, WatcherScope.PLAYER); } InsistWatcher(final InsistWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/j/JandorsRing.java b/Mage.Sets/src/mage/cards/j/JandorsRing.java index 6a8425521f..f964fdcbc4 100644 --- a/Mage.Sets/src/mage/cards/j/JandorsRing.java +++ b/Mage.Sets/src/mage/cards/j/JandorsRing.java @@ -71,7 +71,7 @@ class JandorsRingEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - JandorsRingWatcher watcher = (JandorsRingWatcher) game.getState().getWatchers().get(JandorsRingWatcher.class.getSimpleName()); + JandorsRingWatcher watcher = (JandorsRingWatcher) game.getState().getWatcher(JandorsRingWatcher.class); if (watcher != null) { UUID cardId = watcher.getLastDrewCard(source.getControllerId()); Card card = game.getCard(cardId); @@ -97,7 +97,7 @@ class JandorsRingWatcher extends Watcher { Map lastDrawnCards = new HashMap<>(); public JandorsRingWatcher() { - super(JandorsRingWatcher.class.getSimpleName(), WatcherScope.GAME); + super(JandorsRingWatcher.class, WatcherScope.GAME); } public JandorsRingWatcher(final JandorsRingWatcher watcher) { @@ -134,7 +134,7 @@ enum WatchedCardInHandCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - JandorsRingWatcher watcher = (JandorsRingWatcher) game.getState().getWatchers().get(JandorsRingWatcher.class.getSimpleName()); + JandorsRingWatcher watcher = (JandorsRingWatcher) game.getState().getWatcher(JandorsRingWatcher.class); return watcher != null && watcher.lastDrawnCards != null && game.getPlayer(source.getControllerId()).getHand().contains(watcher.getLastDrewCard(source.getControllerId())); diff --git a/Mage.Sets/src/mage/cards/j/JayaBallardTaskMage.java b/Mage.Sets/src/mage/cards/j/JayaBallardTaskMage.java index c6198ccf28..1445166762 100644 --- a/Mage.Sets/src/mage/cards/j/JayaBallardTaskMage.java +++ b/Mage.Sets/src/mage/cards/j/JayaBallardTaskMage.java @@ -103,7 +103,7 @@ class CantRegenerateEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == EventType.REGENERATE) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), source.getSourceId()); + DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatcher(DamagedByWatcher.class, source.getSourceId()); if (watcher != null) { return watcher.wasDamaged(event.getTargetId(), game); } diff --git a/Mage.Sets/src/mage/cards/j/JelevaNephaliasScourge.java b/Mage.Sets/src/mage/cards/j/JelevaNephaliasScourge.java index 2af20fd076..e34b8826b9 100644 --- a/Mage.Sets/src/mage/cards/j/JelevaNephaliasScourge.java +++ b/Mage.Sets/src/mage/cards/j/JelevaNephaliasScourge.java @@ -84,7 +84,7 @@ class JelevaNephaliasScourgeEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); - JelevaNephaliasWatcher watcher = (JelevaNephaliasWatcher) game.getState().getWatchers().get(JelevaNephaliasWatcher.class.getSimpleName()); + JelevaNephaliasWatcher watcher = (JelevaNephaliasWatcher) game.getState().getWatcher(JelevaNephaliasWatcher.class); if (controller != null && sourceObject != null && watcher != null) { int xValue = watcher.getManaSpentToCastLastTime(sourceObject.getId(), sourceObject.getZoneChangeCounter(game) - 1); if (xValue > 0) { @@ -144,7 +144,7 @@ class JelevaNephaliasWatcher extends Watcher { private final Map manaSpendToCast = new HashMap<>(); // cast public JelevaNephaliasWatcher() { - super(JelevaNephaliasWatcher.class.getSimpleName(), WatcherScope.GAME); + super(JelevaNephaliasWatcher.class, WatcherScope.GAME); } public JelevaNephaliasWatcher(final JelevaNephaliasWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/j/JoriEnRuinDiver.java b/Mage.Sets/src/mage/cards/j/JoriEnRuinDiver.java index 5d81780199..ae0a8314fb 100644 --- a/Mage.Sets/src/mage/cards/j/JoriEnRuinDiver.java +++ b/Mage.Sets/src/mage/cards/j/JoriEnRuinDiver.java @@ -67,7 +67,7 @@ class JoriEnTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(controllerId)) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2) { return true; } diff --git a/Mage.Sets/src/mage/cards/j/JovensFerrets.java b/Mage.Sets/src/mage/cards/j/JovensFerrets.java index a4df82c443..95d4099992 100644 --- a/Mage.Sets/src/mage/cards/j/JovensFerrets.java +++ b/Mage.Sets/src/mage/cards/j/JovensFerrets.java @@ -82,7 +82,7 @@ class JovensFerretsEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller != null && sourcePermanent != null) { - BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); + BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatcher(BlockedAttackerWatcher.class); if (watcher != null) { List toTap = new ArrayList<>(); for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { diff --git a/Mage.Sets/src/mage/cards/k/KaradorGhostChieftain.java b/Mage.Sets/src/mage/cards/k/KaradorGhostChieftain.java index 8a64ceeeb1..3e07f6132f 100644 --- a/Mage.Sets/src/mage/cards/k/KaradorGhostChieftain.java +++ b/Mage.Sets/src/mage/cards/k/KaradorGhostChieftain.java @@ -150,7 +150,7 @@ class KaradorGhostChieftainCastFromGraveyardEffect extends AsThoughEffectImpl { public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { if (objectId.equals(getTargetPointer().getFirst(game, source))) { if (affectedControllerId.equals(source.getControllerId())) { - KaradorGhostChieftainWatcher watcher = (KaradorGhostChieftainWatcher) game.getState().getWatchers().get(KaradorGhostChieftainWatcher.class.getSimpleName(), source.getSourceId()); + KaradorGhostChieftainWatcher watcher = (KaradorGhostChieftainWatcher) game.getState().getWatcher(KaradorGhostChieftainWatcher.class, source.getSourceId()); return watcher != null && !watcher.isAbilityUsed(); } } @@ -163,7 +163,7 @@ class KaradorGhostChieftainWatcher extends Watcher { boolean abilityUsed = false; KaradorGhostChieftainWatcher() { - super(KaradorGhostChieftainWatcher.class.getSimpleName(), WatcherScope.CARD); + super(KaradorGhostChieftainWatcher.class, WatcherScope.CARD); } KaradorGhostChieftainWatcher(final KaradorGhostChieftainWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/k/KeldonTwilight.java b/Mage.Sets/src/mage/cards/k/KeldonTwilight.java index 2931cd6845..fe5769b1ee 100644 --- a/Mage.Sets/src/mage/cards/k/KeldonTwilight.java +++ b/Mage.Sets/src/mage/cards/k/KeldonTwilight.java @@ -54,7 +54,7 @@ class KeldonTwilightCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatcher(AttackedThisTurnWatcher.class); if (watcher != null) { return watcher.getAttackedThisTurnCreatures().isEmpty(); } diff --git a/Mage.Sets/src/mage/cards/k/KeranosGodOfStorms.java b/Mage.Sets/src/mage/cards/k/KeranosGodOfStorms.java index 3590d94123..029be9ab30 100644 --- a/Mage.Sets/src/mage/cards/k/KeranosGodOfStorms.java +++ b/Mage.Sets/src/mage/cards/k/KeranosGodOfStorms.java @@ -94,7 +94,7 @@ class KeranosGodOfStormsTriggeredAbility extends TriggeredAbilityImpl { if (event.getPlayerId().equals(this.getControllerId())) { if (game.isActivePlayer(this.getControllerId())) { CardsAmountDrawnThisTurnWatcher watcher = - (CardsAmountDrawnThisTurnWatcher) game.getState().getWatchers().get(CardsAmountDrawnThisTurnWatcher.class.getSimpleName()); + (CardsAmountDrawnThisTurnWatcher) game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class); if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) != 1) { return false; } diff --git a/Mage.Sets/src/mage/cards/k/KessDissidentMage.java b/Mage.Sets/src/mage/cards/k/KessDissidentMage.java index 6cd52ac84b..fca3a34116 100644 --- a/Mage.Sets/src/mage/cards/k/KessDissidentMage.java +++ b/Mage.Sets/src/mage/cards/k/KessDissidentMage.java @@ -93,7 +93,7 @@ class KessDissidentMageCastFromGraveyardEffect extends AsThoughEffectImpl { if (card != null && (card.isInstant() || card.isSorcery()) && game.getState().getZone(objectId).equals(Zone.GRAVEYARD)) { // check if not already a card was cast this turn with this ability - KessDissidentMageWatcher watcher = (KessDissidentMageWatcher) game.getState().getWatchers().get(KessDissidentMageWatcher.class.getSimpleName()); + KessDissidentMageWatcher watcher = (KessDissidentMageWatcher) game.getState().getWatcher(KessDissidentMageWatcher.class); return watcher != null && !watcher.isAbilityUsed(new MageObjectReference(source.getSourceId(), game)); } } @@ -137,7 +137,7 @@ class KessDissidentMageReplacementEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { ZoneChangeEvent zEvent = (ZoneChangeEvent) event; if (zEvent.getToZone() == Zone.GRAVEYARD) { - KessDissidentMageWatcher watcher = (KessDissidentMageWatcher) game.getState().getWatchers().get(KessDissidentMageWatcher.class.getSimpleName()); + KessDissidentMageWatcher watcher = (KessDissidentMageWatcher) game.getState().getWatcher(KessDissidentMageWatcher.class); if (watcher != null && source.getSourceId().equals(watcher.spellCastWasAllowedBy(new MageObjectReference(event.getTargetId(), game)))) { return true; } @@ -153,7 +153,7 @@ class KessDissidentMageWatcher extends Watcher { private final Map castSpells = new HashMap<>(); KessDissidentMageWatcher() { - super(KessDissidentMageWatcher.class.getSimpleName(), WatcherScope.GAME); + super(KessDissidentMageWatcher.class, WatcherScope.GAME); } KessDissidentMageWatcher(final KessDissidentMageWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/k/KiraGreatGlassSpinner.java b/Mage.Sets/src/mage/cards/k/KiraGreatGlassSpinner.java index 97a195a7a9..3ff3bdf030 100644 --- a/Mage.Sets/src/mage/cards/k/KiraGreatGlassSpinner.java +++ b/Mage.Sets/src/mage/cards/k/KiraGreatGlassSpinner.java @@ -82,7 +82,7 @@ class KiraGreatGlassSpinnerAbility extends TriggeredAbilityImpl { if (event.getTargetId().equals(this.getSourceId())) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.isCreature()) { - NumberOfTimesPermanentTargetedATurnWatcher watcher = (NumberOfTimesPermanentTargetedATurnWatcher) game.getState().getWatchers().get(NumberOfTimesPermanentTargetedATurnWatcher.class.getSimpleName()); + NumberOfTimesPermanentTargetedATurnWatcher watcher = (NumberOfTimesPermanentTargetedATurnWatcher) game.getState().getWatcher(NumberOfTimesPermanentTargetedATurnWatcher.class); if (watcher != null && watcher.notMoreThanOnceTargetedThisTurn(permanent, game)) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(event.getSourceId())); diff --git a/Mage.Sets/src/mage/cards/k/KnightsOfTheBlackRose.java b/Mage.Sets/src/mage/cards/k/KnightsOfTheBlackRose.java index 482ed9506d..4e53514648 100644 --- a/Mage.Sets/src/mage/cards/k/KnightsOfTheBlackRose.java +++ b/Mage.Sets/src/mage/cards/k/KnightsOfTheBlackRose.java @@ -85,7 +85,7 @@ class BecomesMonarchTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkInterveningIfClause(Game game) { - MonarchAtTurnStartWatcher watcher = (MonarchAtTurnStartWatcher) game.getState().getWatchers().get(MonarchAtTurnStartWatcher.class.getSimpleName()); + MonarchAtTurnStartWatcher watcher = (MonarchAtTurnStartWatcher) game.getState().getWatcher(MonarchAtTurnStartWatcher.class); return watcher != null && isControlledBy(watcher.getMonarchIdAtTurnStart()); } @@ -105,7 +105,7 @@ class MonarchAtTurnStartWatcher extends Watcher { private UUID monarchIdAtTurnStart; public MonarchAtTurnStartWatcher() { - super(MonarchAtTurnStartWatcher.class.getSimpleName(), WatcherScope.GAME); + super(MonarchAtTurnStartWatcher.class, WatcherScope.GAME); } public MonarchAtTurnStartWatcher(final MonarchAtTurnStartWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/k/KnollspineDragon.java b/Mage.Sets/src/mage/cards/k/KnollspineDragon.java index b1a35e8e06..c549d617f9 100644 --- a/Mage.Sets/src/mage/cards/k/KnollspineDragon.java +++ b/Mage.Sets/src/mage/cards/k/KnollspineDragon.java @@ -68,7 +68,7 @@ class KnollspineDragonEffect extends OneShotEffect { if (controller != null) { new DiscardHandControllerEffect().apply(game, source); if (targetOpponent != null) { - AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatchers().get(AmountOfDamageAPlayerReceivedThisTurnWatcher.class.getSimpleName()); + AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatcher(AmountOfDamageAPlayerReceivedThisTurnWatcher.class); if (watcher != null) { int drawAmount = watcher.getAmountOfDamageReceivedThisTurn(targetOpponent.getId()); controller.drawCards(drawAmount, game); diff --git a/Mage.Sets/src/mage/cards/k/KraumLudevicsOpus.java b/Mage.Sets/src/mage/cards/k/KraumLudevicsOpus.java index bf8957318a..32bf61b0b5 100644 --- a/Mage.Sets/src/mage/cards/k/KraumLudevicsOpus.java +++ b/Mage.Sets/src/mage/cards/k/KraumLudevicsOpus.java @@ -80,7 +80,7 @@ class KraumLudevicsOpusTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (game.getOpponents(controllerId).contains(event.getPlayerId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2) { return true; } diff --git a/Mage.Sets/src/mage/cards/k/KrovikanVampire.java b/Mage.Sets/src/mage/cards/k/KrovikanVampire.java index d6593ff621..8de372ccb8 100644 --- a/Mage.Sets/src/mage/cards/k/KrovikanVampire.java +++ b/Mage.Sets/src/mage/cards/k/KrovikanVampire.java @@ -112,8 +112,8 @@ enum KrovikanVampireInterveningIfCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - KrovikanVampireCreaturesDiedWatcher watcherDied = (KrovikanVampireCreaturesDiedWatcher) game.getState().getWatchers().get(KrovikanVampireCreaturesDiedWatcher.class.getSimpleName()); - KrovikanVampireCreaturesDamagedWatcher watcherDamaged = (KrovikanVampireCreaturesDamagedWatcher) game.getState().getWatchers().get(KrovikanVampireCreaturesDamagedWatcher.class.getSimpleName()); + KrovikanVampireCreaturesDiedWatcher watcherDied = (KrovikanVampireCreaturesDiedWatcher) game.getState().getWatcher(KrovikanVampireCreaturesDiedWatcher.class); + KrovikanVampireCreaturesDamagedWatcher watcherDamaged = (KrovikanVampireCreaturesDamagedWatcher) game.getState().getWatcher(KrovikanVampireCreaturesDamagedWatcher.class); if (watcherDied != null) { Set creaturesThatDiedThisTurn = watcherDied.diedThisTurn; for (UUID mor : creaturesThatDiedThisTurn) { @@ -146,7 +146,7 @@ class KrovikanVampireCreaturesDamagedWatcher extends Watcher { public final Set damagedBySource = new HashSet<>(); public KrovikanVampireCreaturesDamagedWatcher() { - super(KrovikanVampireCreaturesDamagedWatcher.class.getSimpleName(), WatcherScope.GAME); + super(KrovikanVampireCreaturesDamagedWatcher.class, WatcherScope.GAME); } public KrovikanVampireCreaturesDamagedWatcher(final KrovikanVampireCreaturesDamagedWatcher watcher) { @@ -182,7 +182,7 @@ class KrovikanVampireCreaturesDiedWatcher extends Watcher { public final Set diedThisTurn = new HashSet<>(); public KrovikanVampireCreaturesDiedWatcher() { - super(KrovikanVampireCreaturesDiedWatcher.class.getSimpleName(), WatcherScope.GAME); + super(KrovikanVampireCreaturesDiedWatcher.class, WatcherScope.GAME); } public KrovikanVampireCreaturesDiedWatcher(final KrovikanVampireCreaturesDiedWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/k/KumanosBlessing.java b/Mage.Sets/src/mage/cards/k/KumanosBlessing.java index c745c6fd9c..48deb79ec2 100644 --- a/Mage.Sets/src/mage/cards/k/KumanosBlessing.java +++ b/Mage.Sets/src/mage/cards/k/KumanosBlessing.java @@ -94,7 +94,7 @@ class KumanosBlessingEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { ZoneChangeEvent zce = (ZoneChangeEvent) event; if (zce.isDiesEvent()) { - DamagedByEnchantedWatcher watcher = (DamagedByEnchantedWatcher) game.getState().getWatchers().get(DamagedByEnchantedWatcher.class.getSimpleName(), source.getSourceId()); + DamagedByEnchantedWatcher watcher = (DamagedByEnchantedWatcher) game.getState().getWatcher(DamagedByEnchantedWatcher.class, source.getSourceId()); if (watcher != null) { return watcher.wasDamaged(zce.getTarget(), game); } @@ -109,7 +109,7 @@ class DamagedByEnchantedWatcher extends Watcher { private final Set damagedCreatures = new HashSet<>(); public DamagedByEnchantedWatcher() { - super(DamagedByEnchantedWatcher.class.getSimpleName(), WatcherScope.CARD); + super(DamagedByEnchantedWatcher.class, WatcherScope.CARD); } public DamagedByEnchantedWatcher(final DamagedByEnchantedWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/k/KuonOgreAscendant.java b/Mage.Sets/src/mage/cards/k/KuonOgreAscendant.java index ee72d2a3c9..c100115c0c 100644 --- a/Mage.Sets/src/mage/cards/k/KuonOgreAscendant.java +++ b/Mage.Sets/src/mage/cards/k/KuonOgreAscendant.java @@ -89,7 +89,7 @@ enum KuonOgreAscendantCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatchers().get(CreaturesDiedWatcher.class.getSimpleName()); + CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatcher(CreaturesDiedWatcher.class); if (watcher != null) { return watcher.getAmountOfCreaturesDiedThisTurn() > 2; } diff --git a/Mage.Sets/src/mage/cards/k/KydeleChosenOfKruphix.java b/Mage.Sets/src/mage/cards/k/KydeleChosenOfKruphix.java index aedb737dc0..7d40ff99a7 100644 --- a/Mage.Sets/src/mage/cards/k/KydeleChosenOfKruphix.java +++ b/Mage.Sets/src/mage/cards/k/KydeleChosenOfKruphix.java @@ -57,7 +57,7 @@ class CardsDrawnThisTurnDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - KydeleCardsDrawnThisTurnWatcher watcher = (KydeleCardsDrawnThisTurnWatcher) game.getState().getWatchers().get(KydeleCardsDrawnThisTurnWatcher.class.getSimpleName()); + KydeleCardsDrawnThisTurnWatcher watcher = (KydeleCardsDrawnThisTurnWatcher) game.getState().getWatcher(KydeleCardsDrawnThisTurnWatcher.class); if(watcher != null) { return watcher.getCardsDrawnThisTurn(sourceAbility.getControllerId()); } @@ -85,7 +85,7 @@ class KydeleCardsDrawnThisTurnWatcher extends Watcher { private final Map cardsDrawnThisTurn = new HashMap<>(); public KydeleCardsDrawnThisTurnWatcher() { - super(KydeleCardsDrawnThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); + super(KydeleCardsDrawnThisTurnWatcher.class, WatcherScope.GAME); } public KydeleCardsDrawnThisTurnWatcher(final KydeleCardsDrawnThisTurnWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/k/KytheonHeroOfAkros.java b/Mage.Sets/src/mage/cards/k/KytheonHeroOfAkros.java index d420ff39a6..3e128d2ad1 100644 --- a/Mage.Sets/src/mage/cards/k/KytheonHeroOfAkros.java +++ b/Mage.Sets/src/mage/cards/k/KytheonHeroOfAkros.java @@ -71,7 +71,7 @@ class KytheonHeroOfAkrosCondition implements Condition { public boolean apply(Game game, Ability source) { Permanent sourceObject = game.getPermanent(source.getSourceId()); if (sourceObject != null) { - AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatchers().get(AttackedOrBlockedThisCombatWatcher.class.getSimpleName()); + AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatcher(AttackedOrBlockedThisCombatWatcher.class); if (watcher != null) { boolean sourceFound = false; int number = 0; diff --git a/Mage.Sets/src/mage/cards/l/LavaballTrap.java b/Mage.Sets/src/mage/cards/l/LavaballTrap.java index 745a056dc8..f151095cbf 100644 --- a/Mage.Sets/src/mage/cards/l/LavaballTrap.java +++ b/Mage.Sets/src/mage/cards/l/LavaballTrap.java @@ -57,7 +57,7 @@ enum LavaballTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getSimpleName()); + PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatcher(PermanentsEnteredBattlefieldWatcher.class); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { List permanents = watcher.getThisTurnEnteringPermanents(opponentId); diff --git a/Mage.Sets/src/mage/cards/l/Leapfrog.java b/Mage.Sets/src/mage/cards/l/Leapfrog.java index 8e1006f697..f1ceee69ac 100644 --- a/Mage.Sets/src/mage/cards/l/Leapfrog.java +++ b/Mage.Sets/src/mage/cards/l/Leapfrog.java @@ -62,8 +62,8 @@ enum LeapfrogCondition implements Condition { @Override public boolean apply(Game game, Ability source) { SpellsCastWatcher watcher - = (SpellsCastWatcher) game.getState().getWatchers().get( - SpellsCastWatcher.class.getSimpleName() + = (SpellsCastWatcher) game.getState().getWatcher( + SpellsCastWatcher.class ); if (watcher == null) { return false; diff --git a/Mage.Sets/src/mage/cards/l/LeovoldEmissaryOfTrest.java b/Mage.Sets/src/mage/cards/l/LeovoldEmissaryOfTrest.java index 270e050053..1514d64331 100644 --- a/Mage.Sets/src/mage/cards/l/LeovoldEmissaryOfTrest.java +++ b/Mage.Sets/src/mage/cards/l/LeovoldEmissaryOfTrest.java @@ -71,7 +71,7 @@ class LeovoldEmissaryOfTrestEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - CardsAmountDrawnThisTurnWatcher watcher = (CardsAmountDrawnThisTurnWatcher) game.getState().getWatchers().get(CardsAmountDrawnThisTurnWatcher.class.getSimpleName()); + CardsAmountDrawnThisTurnWatcher watcher = (CardsAmountDrawnThisTurnWatcher) game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class); Player controller = game.getPlayer(source.getControllerId()); return watcher != null && controller != null && watcher.getAmountCardsDrawn(event.getPlayerId()) >= 1 && game.isOpponent(controller, event.getPlayerId()); diff --git a/Mage.Sets/src/mage/cards/l/LiciaSanguineTribune.java b/Mage.Sets/src/mage/cards/l/LiciaSanguineTribune.java index 05adae4187..e3d32dcc56 100644 --- a/Mage.Sets/src/mage/cards/l/LiciaSanguineTribune.java +++ b/Mage.Sets/src/mage/cards/l/LiciaSanguineTribune.java @@ -112,9 +112,9 @@ class YouGainLifeCount implements DynamicValue { } public int calculate(Game game, UUID controllerId) { - PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getSimpleName()); + PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatcher(PlayerGainedLifeWatcher.class); if (watcher != null) { - return watcher.getLiveGained(controllerId); + return watcher.getLifeGained(controllerId); } return 0; } diff --git a/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java b/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java index d75b41a30a..2b14385a78 100644 --- a/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java +++ b/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java @@ -53,7 +53,7 @@ class LudevicNecroAlchemistCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatcher(PlayerLostLifeWatcher.class); PlayerList playerList = game.getState().getPlayerList().copy(); Player currentPlayer; UUID sourcePlayerId = source.getControllerId(); diff --git a/Mage.Sets/src/mage/cards/l/LuminarchAscension.java b/Mage.Sets/src/mage/cards/l/LuminarchAscension.java index 045707bfda..91f5d47531 100644 --- a/Mage.Sets/src/mage/cards/l/LuminarchAscension.java +++ b/Mage.Sets/src/mage/cards/l/LuminarchAscension.java @@ -119,7 +119,7 @@ enum YouLostNoLifeThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatcher(PlayerLostLifeWatcher.class); if (watcher != null) { return (watcher.getLifeLost(source.getControllerId()) == 0); } diff --git a/Mage.Sets/src/mage/cards/l/LureOfPrey.java b/Mage.Sets/src/mage/cards/l/LureOfPrey.java index c6b81a46c8..9f14ec0d88 100644 --- a/Mage.Sets/src/mage/cards/l/LureOfPrey.java +++ b/Mage.Sets/src/mage/cards/l/LureOfPrey.java @@ -69,7 +69,7 @@ class LureOfPreyRestrictionEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getSourceId().equals(source.getSourceId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null) { for (UUID playerId : game.getOpponents(source.getControllerId())) { if (watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(playerId) != 0) { diff --git a/Mage.Sets/src/mage/cards/m/MadDog.java b/Mage.Sets/src/mage/cards/m/MadDog.java index 72f18fa119..d88656dffb 100644 --- a/Mage.Sets/src/mage/cards/m/MadDog.java +++ b/Mage.Sets/src/mage/cards/m/MadDog.java @@ -58,8 +58,8 @@ enum MadDogCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Permanent madDog = game.getPermanent(source.getSourceId()); - PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getSimpleName()); - AttackedThisTurnWatcher watcher2 = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatcher(PermanentsEnteredBattlefieldWatcher.class); + AttackedThisTurnWatcher watcher2 = (AttackedThisTurnWatcher) game.getState().getWatcher(AttackedThisTurnWatcher.class); if (watcher != null && watcher2 != null && madDog != null) { diff --git a/Mage.Sets/src/mage/cards/m/MaddeningImp.java b/Mage.Sets/src/mage/cards/m/MaddeningImp.java index 72cda096ce..d782599bf5 100644 --- a/Mage.Sets/src/mage/cards/m/MaddeningImp.java +++ b/Mage.Sets/src/mage/cards/m/MaddeningImp.java @@ -160,7 +160,7 @@ class MaddeningImpDelayedDestroyEffect extends OneShotEffect { continue; } // Creatures that attacked are safe. - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatcher(AttackedThisTurnWatcher.class); if (watcher != null && watcher.getAttackedThisTurnCreatures().contains(mor)) { continue; } diff --git a/Mage.Sets/src/mage/cards/m/MaelstromNexus.java b/Mage.Sets/src/mage/cards/m/MaelstromNexus.java index c88f8d523c..2724861bc3 100644 --- a/Mage.Sets/src/mage/cards/m/MaelstromNexus.java +++ b/Mage.Sets/src/mage/cards/m/MaelstromNexus.java @@ -69,7 +69,7 @@ class MaelstromNexusGainCascadeFirstSpellEffect extends ContinuousEffectImpl { // only spells cast, so no copies of spells if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.isControlledBy(source.getControllerId())) { Spell spell = (Spell) stackObject; - FirstSpellCastThisTurnWatcher watcher = (FirstSpellCastThisTurnWatcher) game.getState().getWatchers().get(FirstSpellCastThisTurnWatcher.class.getSimpleName()); + FirstSpellCastThisTurnWatcher watcher = (FirstSpellCastThisTurnWatcher) game.getState().getWatcher(FirstSpellCastThisTurnWatcher.class); if (watcher != null && spell.getId().equals(watcher.getIdOfFirstCastSpell(source.getControllerId()))) { game.getState().addOtherAbility(spell.getCard(), cascadeAbility); } diff --git a/Mage.Sets/src/mage/cards/m/MagusOfTheMind.java b/Mage.Sets/src/mage/cards/m/MagusOfTheMind.java index d7ae654535..632654bbb9 100644 --- a/Mage.Sets/src/mage/cards/m/MagusOfTheMind.java +++ b/Mage.Sets/src/mage/cards/m/MagusOfTheMind.java @@ -78,7 +78,7 @@ class MagusOfTheMindEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); if(watcher == null){ return false; } diff --git a/Mage.Sets/src/mage/cards/m/ManaMaze.java b/Mage.Sets/src/mage/cards/m/ManaMaze.java index 29502df744..09735df75b 100644 --- a/Mage.Sets/src/mage/cards/m/ManaMaze.java +++ b/Mage.Sets/src/mage/cards/m/ManaMaze.java @@ -63,7 +63,7 @@ class ManaMazeEffect extends ContinuousRuleModifyingEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { Card card = game.getCard(event.getSourceId()); if (card != null) { - LastSpellCastWatcher watcher = (LastSpellCastWatcher) game.getState().getWatchers().get(LastSpellCastWatcher.class.getSimpleName()); + LastSpellCastWatcher watcher = (LastSpellCastWatcher) game.getState().getWatcher(LastSpellCastWatcher.class); if (watcher != null && watcher.lastSpellCast != null) { return !card.getColor(game).intersection(watcher.lastSpellCast.getColor(game)).isColorless(); } @@ -87,7 +87,7 @@ class LastSpellCastWatcher extends Watcher { Spell lastSpellCast = null; public LastSpellCastWatcher() { - super(LastSpellCastWatcher.class.getSimpleName(), WatcherScope.GAME); + super(LastSpellCastWatcher.class, WatcherScope.GAME); } public LastSpellCastWatcher(final LastSpellCastWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/m/MasterWarcraft.java b/Mage.Sets/src/mage/cards/m/MasterWarcraft.java index 641d328715..999d546ef1 100644 --- a/Mage.Sets/src/mage/cards/m/MasterWarcraft.java +++ b/Mage.Sets/src/mage/cards/m/MasterWarcraft.java @@ -79,7 +79,7 @@ public final class MasterWarcraft extends CardImpl { @Override public boolean apply(Game game, Ability source) { - MasterWarcraftCastWatcher watcher = (MasterWarcraftCastWatcher) game.getState().getWatchers().get(MasterWarcraftCastWatcher.class.getSimpleName()); + MasterWarcraftCastWatcher watcher = (MasterWarcraftCastWatcher) game.getState().getWatcher(MasterWarcraftCastWatcher.class); if (watcher != null) { watcher.increment(); return true; @@ -105,7 +105,7 @@ public final class MasterWarcraft extends CardImpl { @Override public boolean apply(Game game, Ability source) { - ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); + ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatcher(ChooseBlockersRedundancyWatcher.class); if (watcher != null) { watcher.increment(); return true; @@ -153,7 +153,7 @@ class MasterWarcraftChooseAttackersEffect extends ContinuousRuleModifyingEffectI @Override public boolean applies(GameEvent event, Ability source, Game game) { - MasterWarcraftCastWatcher watcher = (MasterWarcraftCastWatcher) game.getState().getWatchers().get(MasterWarcraftCastWatcher.class.getSimpleName()); + MasterWarcraftCastWatcher watcher = (MasterWarcraftCastWatcher) game.getState().getWatcher(MasterWarcraftCastWatcher.class); if(watcher == null){ return false; } @@ -229,7 +229,7 @@ class MasterWarcraftChooseBlockersEffect extends ContinuousRuleModifyingEffectIm @Override public boolean applies(GameEvent event, Ability source, Game game) { - ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); + ChooseBlockersRedundancyWatcher watcher = game.getState().getWatcher(ChooseBlockersRedundancyWatcher.class); if(watcher == null){ return false; } diff --git a/Mage.Sets/src/mage/cards/m/Melee.java b/Mage.Sets/src/mage/cards/m/Melee.java index b526764238..0f549f8bfc 100644 --- a/Mage.Sets/src/mage/cards/m/Melee.java +++ b/Mage.Sets/src/mage/cards/m/Melee.java @@ -75,7 +75,7 @@ public final class Melee extends CardImpl { @Override public boolean apply(Game game, Ability source) { - ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); + ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatcher(ChooseBlockersRedundancyWatcher.class); if (watcher != null) { watcher.increment(); return true; @@ -118,7 +118,7 @@ class MeleeChooseBlockersEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); + ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatcher(ChooseBlockersRedundancyWatcher.class); if (watcher == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/m/MercadianAtlas.java b/Mage.Sets/src/mage/cards/m/MercadianAtlas.java index c2d980a6ed..1153218d07 100644 --- a/Mage.Sets/src/mage/cards/m/MercadianAtlas.java +++ b/Mage.Sets/src/mage/cards/m/MercadianAtlas.java @@ -49,7 +49,7 @@ enum MercadianAtlasCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayLandWatcher watcher = (PlayLandWatcher) game.getState().getWatchers().get(PlayLandWatcher.class.getSimpleName()); + PlayLandWatcher watcher = (PlayLandWatcher) game.getState().getWatcher(PlayLandWatcher.class); if (watcher != null) { return !watcher.landPlayed(source.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/m/MetzaliTowerOfTriumph.java b/Mage.Sets/src/mage/cards/m/MetzaliTowerOfTriumph.java index 0b77db9540..5288f95128 100644 --- a/Mage.Sets/src/mage/cards/m/MetzaliTowerOfTriumph.java +++ b/Mage.Sets/src/mage/cards/m/MetzaliTowerOfTriumph.java @@ -90,7 +90,7 @@ class MetzaliTowerOfTriumphEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + Watcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); if (watcher instanceof AttackedThisTurnWatcher) { Set attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures(); List available = new ArrayList<>(); diff --git a/Mage.Sets/src/mage/cards/m/MindbreakTrap.java b/Mage.Sets/src/mage/cards/m/MindbreakTrap.java index 253fc6ef50..eca058beda 100644 --- a/Mage.Sets/src/mage/cards/m/MindbreakTrap.java +++ b/Mage.Sets/src/mage/cards/m/MindbreakTrap.java @@ -52,7 +52,7 @@ enum MindbreakTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { if (watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(opponentId) > 2) { diff --git a/Mage.Sets/src/mage/cards/m/MindsDilation.java b/Mage.Sets/src/mage/cards/m/MindsDilation.java index 941ef597ac..9eb9ef6664 100644 --- a/Mage.Sets/src/mage/cards/m/MindsDilation.java +++ b/Mage.Sets/src/mage/cards/m/MindsDilation.java @@ -65,7 +65,7 @@ class MindsDilationTriggeredAbility extends SpellCastOpponentTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class); if (watcher != null) { List spells = watcher.getSpellsCastThisTurn(event.getPlayerId()); if (spells != null && spells.size() == 1) { diff --git a/Mage.Sets/src/mage/cards/m/MindstormCrown.java b/Mage.Sets/src/mage/cards/m/MindstormCrown.java index c186f02a15..f93c614eb7 100644 --- a/Mage.Sets/src/mage/cards/m/MindstormCrown.java +++ b/Mage.Sets/src/mage/cards/m/MindstormCrown.java @@ -63,7 +63,7 @@ class MindstormCrownEffect extends OneShotEffect { if (player == null) { return false; } - MindstormCrownWatcher watcher = (MindstormCrownWatcher) game.getState().getWatchers().get(MindstormCrownWatcher.class.getSimpleName()); + MindstormCrownWatcher watcher = (MindstormCrownWatcher) game.getState().getWatcher(MindstormCrownWatcher.class); if (watcher != null && watcher.getCardsInHandCount() == 0) { player.drawCards(1, game); } else { @@ -80,7 +80,7 @@ class MindstormCrownWatcher extends Watcher { private int cardsInHandCount; public MindstormCrownWatcher() { - super(MindstormCrownWatcher.class.getSimpleName(), WatcherScope.GAME); + super(MindstormCrownWatcher.class, WatcherScope.GAME); } public MindstormCrownWatcher(final MindstormCrownWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/m/Mistcaller.java b/Mage.Sets/src/mage/cards/m/Mistcaller.java index 88f7d3952e..0424c1f465 100644 --- a/Mage.Sets/src/mage/cards/m/Mistcaller.java +++ b/Mage.Sets/src/mage/cards/m/Mistcaller.java @@ -101,7 +101,7 @@ class ContainmentPriestReplacementEffect extends ReplacementEffectImpl { card = card.getSecondCardFace(); } if (card.isCreature()) { // TODO: Bestow Card cast as Enchantment probably not handled correctly - CreatureWasCastWatcher watcher = (CreatureWasCastWatcher) game.getState().getWatchers().get(CreatureWasCastWatcher.class.getSimpleName()); + CreatureWasCastWatcher watcher = (CreatureWasCastWatcher) game.getState().getWatcher(CreatureWasCastWatcher.class); if (watcher != null && !watcher.wasCreatureCastThisTurn(event.getTargetId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/m/MoggConscripts.java b/Mage.Sets/src/mage/cards/m/MoggConscripts.java index f70bacbbfd..bb8e93bca1 100644 --- a/Mage.Sets/src/mage/cards/m/MoggConscripts.java +++ b/Mage.Sets/src/mage/cards/m/MoggConscripts.java @@ -67,7 +67,7 @@ class MoggConscriptsEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { - PlayerCastCreatureWatcher watcher = (PlayerCastCreatureWatcher) game.getState().getWatchers().get(PlayerCastCreatureWatcher.class.getSimpleName()); + PlayerCastCreatureWatcher watcher = (PlayerCastCreatureWatcher) game.getState().getWatcher(PlayerCastCreatureWatcher.class); if (watcher != null && !watcher.playerDidCastCreatureThisTurn(source.getControllerId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/m/MoltenPsyche.java b/Mage.Sets/src/mage/cards/m/MoltenPsyche.java index 8d5f4594d3..05fd465e01 100644 --- a/Mage.Sets/src/mage/cards/m/MoltenPsyche.java +++ b/Mage.Sets/src/mage/cards/m/MoltenPsyche.java @@ -83,7 +83,7 @@ class MoltenPsycheEffect extends OneShotEffect { } } if (MetalcraftCondition.instance.apply(game, source)) { - MoltenPsycheWatcher watcher = (MoltenPsycheWatcher) game.getState().getWatchers().get(MoltenPsycheWatcher.class.getSimpleName()); + MoltenPsycheWatcher watcher = (MoltenPsycheWatcher) game.getState().getWatcher(MoltenPsycheWatcher.class); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (game.isOpponent(controller, playerId)) { Player player = game.getPlayer(playerId); diff --git a/Mage.Sets/src/mage/cards/m/MuldrothaTheGravetide.java b/Mage.Sets/src/mage/cards/m/MuldrothaTheGravetide.java index f80bf2ab4d..8a06150a05 100644 --- a/Mage.Sets/src/mage/cards/m/MuldrothaTheGravetide.java +++ b/Mage.Sets/src/mage/cards/m/MuldrothaTheGravetide.java @@ -88,7 +88,7 @@ class MuldrothaTheGravetideCastFromGraveyardEffect extends AsThoughEffectImpl { && source.isControlledBy(game.getOwnerId(objectId)) // only from your graveyard && affectedControllerId.equals(game.getActivePlayerId()) // only during your turns (e.g. prevent flash creatures) && Zone.GRAVEYARD.equals(game.getState().getZone(objectId))) { - MuldrothaTheGravetideWatcher watcher = (MuldrothaTheGravetideWatcher) game.getState().getWatchers().get(MuldrothaTheGravetideWatcher.class.getSimpleName()); + MuldrothaTheGravetideWatcher watcher = (MuldrothaTheGravetideWatcher) game.getState().getWatcher(MuldrothaTheGravetideWatcher.class); MageObject mageObject = game.getObject(objectId); if (mageObject != null && watcher != null) { for (CardType cardType : mageObject.getCardType()) { @@ -121,7 +121,7 @@ class MuldrothaTheGravetideWatcher extends Watcher { private Zone fromZone; public MuldrothaTheGravetideWatcher() { - super(MuldrothaTheGravetideWatcher.class.getSimpleName(), WatcherScope.GAME); + super(MuldrothaTheGravetideWatcher.class, WatcherScope.GAME); } public MuldrothaTheGravetideWatcher(final MuldrothaTheGravetideWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/m/MultanisPresence.java b/Mage.Sets/src/mage/cards/m/MultanisPresence.java index 2cfb6d3a7e..977b361a25 100644 --- a/Mage.Sets/src/mage/cards/m/MultanisPresence.java +++ b/Mage.Sets/src/mage/cards/m/MultanisPresence.java @@ -62,7 +62,7 @@ class MultanisPresenceTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - MultanisPresenceWatcher watcher = (MultanisPresenceWatcher) game.getState().getWatchers().get(MultanisPresenceWatcher.class.getSimpleName()); + MultanisPresenceWatcher watcher = (MultanisPresenceWatcher) game.getState().getWatcher(MultanisPresenceWatcher.class); return watcher != null && watcher.getSpellsCastThisTurn(controllerId).contains(event.getTargetId()); } diff --git a/Mage.Sets/src/mage/cards/n/NeedleDrop.java b/Mage.Sets/src/mage/cards/n/NeedleDrop.java index 2b299e4f35..dc640faabe 100644 --- a/Mage.Sets/src/mage/cards/n/NeedleDrop.java +++ b/Mage.Sets/src/mage/cards/n/NeedleDrop.java @@ -58,7 +58,7 @@ class DamagedThisTurnPredicate implements Predicate { @Override public boolean apply(MageItem input, Game game) { - DamageDoneWatcher watcher = (DamageDoneWatcher) game.getState().getWatchers().get(DamageDoneWatcher.class.getSimpleName()); + DamageDoneWatcher watcher = (DamageDoneWatcher) game.getState().getWatcher(DamageDoneWatcher.class); if (watcher != null) { if (input instanceof MageObject) { return watcher.isDamaged(input.getId(), ((MageObject) input).getZoneChangeCounter(game), game); diff --git a/Mage.Sets/src/mage/cards/n/NeedlebiteTrap.java b/Mage.Sets/src/mage/cards/n/NeedlebiteTrap.java index bfa69afdc8..87e3cc6cbc 100644 --- a/Mage.Sets/src/mage/cards/n/NeedlebiteTrap.java +++ b/Mage.Sets/src/mage/cards/n/NeedlebiteTrap.java @@ -51,10 +51,10 @@ enum NeedlebiteTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getSimpleName()); + PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatcher(PlayerGainedLifeWatcher.class); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { - if (watcher.getLiveGained(opponentId) > 0) { + if (watcher.getLifeGained(opponentId) > 0) { return true; } } diff --git a/Mage.Sets/src/mage/cards/n/NoRestForTheWicked.java b/Mage.Sets/src/mage/cards/n/NoRestForTheWicked.java index 063f4958cb..da9b207d8d 100644 --- a/Mage.Sets/src/mage/cards/n/NoRestForTheWicked.java +++ b/Mage.Sets/src/mage/cards/n/NoRestForTheWicked.java @@ -58,7 +58,7 @@ class NoRestForTheWickedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - NoRestForTheWickedWatcher watcher = (NoRestForTheWickedWatcher) game.getState().getWatchers().get(NoRestForTheWickedWatcher.class.getSimpleName()); + NoRestForTheWickedWatcher watcher = (NoRestForTheWickedWatcher) game.getState().getWatcher(NoRestForTheWickedWatcher.class); Player controller = game.getPlayer(source.getControllerId()); if (watcher != null && controller != null) { Cards cardsToHand = new CardsImpl(); @@ -90,7 +90,7 @@ class NoRestForTheWickedWatcher extends Watcher { List cards; public NoRestForTheWickedWatcher() { - super(NoRestForTheWickedWatcher.class.getSimpleName(), WatcherScope.GAME); + super(NoRestForTheWickedWatcher.class, WatcherScope.GAME); this.cards = new ArrayList<>(); } diff --git a/Mage.Sets/src/mage/cards/n/NotionThief.java b/Mage.Sets/src/mage/cards/n/NotionThief.java index 9ff6a3977a..bfaa567718 100644 --- a/Mage.Sets/src/mage/cards/n/NotionThief.java +++ b/Mage.Sets/src/mage/cards/n/NotionThief.java @@ -90,7 +90,7 @@ class NotionThiefReplacementEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { if (game.isActivePlayer(event.getPlayerId()) && game.getStep().getType() == PhaseStep.DRAW) { - CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatchers().get(CardsDrawnDuringDrawStepWatcher.class.getSimpleName()); + CardsDrawnDuringDrawStepWatcher watcher = (CardsDrawnDuringDrawStepWatcher) game.getState().getWatcher(CardsDrawnDuringDrawStepWatcher.class); if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) > 0) { return true; } diff --git a/Mage.Sets/src/mage/cards/n/NotoriousThrong.java b/Mage.Sets/src/mage/cards/n/NotoriousThrong.java index 8663f38d83..ac3a6ec422 100644 --- a/Mage.Sets/src/mage/cards/n/NotoriousThrong.java +++ b/Mage.Sets/src/mage/cards/n/NotoriousThrong.java @@ -70,7 +70,7 @@ class NotoriousThrongEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatchers().get(AmountOfDamageAPlayerReceivedThisTurnWatcher.class.getSimpleName()); + AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatcher(AmountOfDamageAPlayerReceivedThisTurnWatcher.class); if(controller != null && watcher != null) { int numTokens = 0; for(UUID opponentId: game.getOpponents(controller.getId())) { diff --git a/Mage.Sets/src/mage/cards/n/NullstoneGargoyle.java b/Mage.Sets/src/mage/cards/n/NullstoneGargoyle.java index 35cbeedc1d..87c6405485 100644 --- a/Mage.Sets/src/mage/cards/n/NullstoneGargoyle.java +++ b/Mage.Sets/src/mage/cards/n/NullstoneGargoyle.java @@ -74,7 +74,7 @@ class NullstoneGargoyleTriggeredAbility extends TriggeredAbilityImpl { if (spell.isCreature()) { return false; } - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class); if (watcher != null && watcher.getNumberOfNonCreatureSpells() == 1) { for (Effect effect : getEffects()) { effect.setTargetPointer(new FixedTarget(event.getTargetId())); diff --git a/Mage.Sets/src/mage/cards/o/OKagachiVengefulKami.java b/Mage.Sets/src/mage/cards/o/OKagachiVengefulKami.java index b494987c9e..83d4e41083 100644 --- a/Mage.Sets/src/mage/cards/o/OKagachiVengefulKami.java +++ b/Mage.Sets/src/mage/cards/o/OKagachiVengefulKami.java @@ -99,7 +99,7 @@ class OKagachiVengefulKamiTriggeredAbility extends TriggeredAbilityImpl { UUID you = this.getControllerId(); Permanent p = game.getPermanent(event.getSourceId()); if (damageEvent.isCombatDamage() && p != null && p.getId().equals(this.getSourceId())) { - PlayersAttackedLastTurnWatcher watcher = (PlayersAttackedLastTurnWatcher) game.getState().getWatchers().get(PlayersAttackedLastTurnWatcher.class.getSimpleName()); + PlayersAttackedLastTurnWatcher watcher = (PlayersAttackedLastTurnWatcher) game.getState().getWatcher(PlayersAttackedLastTurnWatcher.class); if (watcher != null && watcher.attackedLastTurn(damagedPlayerId, you)) { FilterNonlandPermanent filter = new FilterNonlandPermanent("nonland permanent defending player controls"); filter.add(new ControllerIdPredicate(damagedPlayerId)); diff --git a/Mage.Sets/src/mage/cards/o/OathOfChandra.java b/Mage.Sets/src/mage/cards/o/OathOfChandra.java index 4610ca8f5c..746b23c111 100644 --- a/Mage.Sets/src/mage/cards/o/OathOfChandra.java +++ b/Mage.Sets/src/mage/cards/o/OathOfChandra.java @@ -69,7 +69,7 @@ enum OathOfChandraCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - OathOfChandraWatcher watcher = (OathOfChandraWatcher) game.getState().getWatchers().get(OathOfChandraWatcher.class.getSimpleName()); + OathOfChandraWatcher watcher = (OathOfChandraWatcher) game.getState().getWatcher(OathOfChandraWatcher.class); return watcher != null && watcher.enteredPlaneswalkerForPlayer(source.getControllerId()); } @@ -85,7 +85,7 @@ class OathOfChandraWatcher extends Watcher { private final Set players = new HashSet<>(); public OathOfChandraWatcher() { - super(OathOfChandraWatcher.class.getSimpleName(), WatcherScope.GAME); + super(OathOfChandraWatcher.class, WatcherScope.GAME); } public OathOfChandraWatcher(final OathOfChandraWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/o/OathOfLiliana.java b/Mage.Sets/src/mage/cards/o/OathOfLiliana.java index 5e45a1e6be..c4223e7746 100644 --- a/Mage.Sets/src/mage/cards/o/OathOfLiliana.java +++ b/Mage.Sets/src/mage/cards/o/OathOfLiliana.java @@ -57,7 +57,7 @@ enum OathOfLilianaCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - OathOfLilianaWatcher watcher = (OathOfLilianaWatcher) game.getState().getWatchers().get(OathOfLilianaWatcher.class.getSimpleName()); + OathOfLilianaWatcher watcher = (OathOfLilianaWatcher) game.getState().getWatcher(OathOfLilianaWatcher.class); return watcher != null && watcher.enteredPlaneswalkerForPlayer(source.getControllerId()); } @@ -73,7 +73,7 @@ class OathOfLilianaWatcher extends Watcher { private final Set players = new HashSet<>(); public OathOfLilianaWatcher() { - super(OathOfLilianaWatcher.class.getSimpleName(), WatcherScope.GAME); + super(OathOfLilianaWatcher.class, WatcherScope.GAME); } public OathOfLilianaWatcher(final OathOfLilianaWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/o/OdricMasterTactician.java b/Mage.Sets/src/mage/cards/o/OdricMasterTactician.java index 8b3128f475..1127c3a7ff 100644 --- a/Mage.Sets/src/mage/cards/o/OdricMasterTactician.java +++ b/Mage.Sets/src/mage/cards/o/OdricMasterTactician.java @@ -87,7 +87,7 @@ class OdricMasterTacticianTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean apply(Game game, Ability source) { - ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); + ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatcher(ChooseBlockersRedundancyWatcher.class); if (watcher != null) { watcher.increment(); return true; @@ -130,7 +130,7 @@ class OdricMasterTacticianChooseBlockersEffect extends ContinuousRuleModifyingEf @Override public boolean applies(GameEvent event, Ability source, Game game) { - ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); + ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatcher(ChooseBlockersRedundancyWatcher.class); if(watcher == null){ return false; } diff --git a/Mage.Sets/src/mage/cards/o/OpalPalace.java b/Mage.Sets/src/mage/cards/o/OpalPalace.java index 345496aa2d..05095072c6 100644 --- a/Mage.Sets/src/mage/cards/o/OpalPalace.java +++ b/Mage.Sets/src/mage/cards/o/OpalPalace.java @@ -67,7 +67,7 @@ class OpalPalaceWatcher extends Watcher { private final String originalId; public OpalPalaceWatcher(String originalId) { - super(OpalPalaceWatcher.class.getSimpleName(), WatcherScope.CARD); + super(OpalPalaceWatcher.class, WatcherScope.CARD); this.originalId = originalId; } @@ -130,7 +130,7 @@ class OpalPalaceEntersBattlefieldEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - OpalPalaceWatcher watcher = (OpalPalaceWatcher) game.getState().getWatchers().get(OpalPalaceWatcher.class.getSimpleName(), source.getSourceId()); + OpalPalaceWatcher watcher = (OpalPalaceWatcher) game.getState().getWatcher(OpalPalaceWatcher.class, source.getSourceId()); return watcher != null && watcher.commanderId.contains(event.getTargetId()); } diff --git a/Mage.Sets/src/mage/cards/o/OracleEnVec.java b/Mage.Sets/src/mage/cards/o/OracleEnVec.java index 118fd61524..d8ccfe121c 100644 --- a/Mage.Sets/src/mage/cards/o/OracleEnVec.java +++ b/Mage.Sets/src/mage/cards/o/OracleEnVec.java @@ -243,7 +243,7 @@ class OracleEnVecDestroyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatcher(AttackedThisTurnWatcher.class); if (watcher != null) { for (UUID targetId : chosenCreatures) { Permanent permanent = game.getPermanent(targetId); diff --git a/Mage.Sets/src/mage/cards/o/OratorOfOjutai.java b/Mage.Sets/src/mage/cards/o/OratorOfOjutai.java index 2d698b0f09..fad4709d6a 100644 --- a/Mage.Sets/src/mage/cards/o/OratorOfOjutai.java +++ b/Mage.Sets/src/mage/cards/o/OratorOfOjutai.java @@ -95,7 +95,7 @@ class OratorOfOjutaiTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { //Intervening if must be checked Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId()); - DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName()); + DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class); return event.getTargetId().equals(getSourceId()) && watcher != null && watcher.castWithConditionTrue(sourcePermanent.getSpellAbility().getId()); @@ -135,7 +135,7 @@ class OratorOfOjutaiEffect extends OneShotEffect { if (controller != null) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourcePermanent != null) { - DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName()); + DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class); if (watcher != null && watcher.castWithConditionTrue(sourcePermanent.getSpellAbility().getId())) { controller.drawCards(1, game); return true; diff --git a/Mage.Sets/src/mage/cards/o/Overmaster.java b/Mage.Sets/src/mage/cards/o/Overmaster.java index b5c7fdb07b..48fab4e846 100644 --- a/Mage.Sets/src/mage/cards/o/Overmaster.java +++ b/Mage.Sets/src/mage/cards/o/Overmaster.java @@ -67,7 +67,7 @@ class OvermasterEffect extends ContinuousRuleModifyingEffectImpl { @Override public void init(Ability source, Game game) { super.init(source, game); - OvermasterWatcher watcher = (OvermasterWatcher) game.getState().getWatchers().get(OvermasterWatcher.class.getSimpleName(), source.getControllerId()); + OvermasterWatcher watcher = (OvermasterWatcher) game.getState().getWatcher(OvermasterWatcher.class, source.getControllerId()); if (watcher != null) { watcher.setReady(); } @@ -95,7 +95,7 @@ class OvermasterEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); - OvermasterWatcher watcher = (OvermasterWatcher) game.getState().getWatchers().get(OvermasterWatcher.class.getSimpleName(), source.getControllerId()); + OvermasterWatcher watcher = (OvermasterWatcher) game.getState().getWatcher(OvermasterWatcher.class, source.getControllerId()); return spell != null && watcher != null && watcher.isUncounterable(spell.getId()); } } @@ -106,7 +106,7 @@ class OvermasterWatcher extends Watcher { protected UUID uncounterableSpell; OvermasterWatcher() { - super(OvermasterWatcher.class.getSimpleName(), WatcherScope.PLAYER); + super(OvermasterWatcher.class, WatcherScope.PLAYER); } OvermasterWatcher(final OvermasterWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/p/PalladiaMorsTheRuiner.java b/Mage.Sets/src/mage/cards/p/PalladiaMorsTheRuiner.java index 0ce811c3ee..8a7c20e437 100644 --- a/Mage.Sets/src/mage/cards/p/PalladiaMorsTheRuiner.java +++ b/Mage.Sets/src/mage/cards/p/PalladiaMorsTheRuiner.java @@ -78,7 +78,7 @@ enum PalladiaMorsTheRuinerCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); - PalladiaMorsTheRuinerWatcher watcher = (PalladiaMorsTheRuinerWatcher) game.getState().getWatchers().get(PalladiaMorsTheRuinerWatcher.class.getSimpleName()); + PalladiaMorsTheRuinerWatcher watcher = (PalladiaMorsTheRuinerWatcher) game.getState().getWatcher(PalladiaMorsTheRuinerWatcher.class); return permanent != null && !watcher.getDamagers().contains(new MageObjectReference(permanent, game)); } @@ -94,7 +94,7 @@ class PalladiaMorsTheRuinerWatcher extends Watcher { private final Set damagers = new HashSet(); public PalladiaMorsTheRuinerWatcher() { - super(PalladiaMorsTheRuinerWatcher.class.getSimpleName(), WatcherScope.GAME); + super(PalladiaMorsTheRuinerWatcher.class, WatcherScope.GAME); } public PalladiaMorsTheRuinerWatcher(final PalladiaMorsTheRuinerWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/p/ParadoxHaze.java b/Mage.Sets/src/mage/cards/p/ParadoxHaze.java index eb98a98e32..6262d3d258 100644 --- a/Mage.Sets/src/mage/cards/p/ParadoxHaze.java +++ b/Mage.Sets/src/mage/cards/p/ParadoxHaze.java @@ -80,7 +80,7 @@ class ParadoxHazeTriggeredAbility extends TriggeredAbilityImpl { if (permanent != null) { Player player = game.getPlayer(permanent.getAttachedTo()); if (player != null && game.isActivePlayer(player.getId())) { - FirstTimeStepWatcher watcher = (FirstTimeStepWatcher) game.getState().getWatchers().get(EventType.UPKEEP_STEP_POST.toString() + FirstTimeStepWatcher.class.getSimpleName()); + FirstTimeStepWatcher watcher = game.getState().getWatcher(FirstTimeStepWatcher.class, EventType.UPKEEP_STEP_POST.toString()); if (watcher != null && !watcher.conditionMet()) { this.getEffects().get(0).setTargetPointer(new FixedTarget(player.getId())); return true; diff --git a/Mage.Sets/src/mage/cards/p/PatriciansScorn.java b/Mage.Sets/src/mage/cards/p/PatriciansScorn.java index 0aed2b41de..f263ae2029 100644 --- a/Mage.Sets/src/mage/cards/p/PatriciansScorn.java +++ b/Mage.Sets/src/mage/cards/p/PatriciansScorn.java @@ -52,7 +52,7 @@ class CastWhiteSpellThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PatriciansScornWatcher watcher = (PatriciansScornWatcher) game.getState().getWatchers().get(PatriciansScornWatcher.class.getSimpleName(), source.getSourceId()); + PatriciansScornWatcher watcher = (PatriciansScornWatcher) game.getState().getWatcher(PatriciansScornWatcher.class, source.getSourceId()); if (watcher != null) { return watcher.conditionMet(); } @@ -73,7 +73,7 @@ class PatriciansScornWatcher extends Watcher { } public PatriciansScornWatcher() { - super(PatriciansScornWatcher.class.getSimpleName(), WatcherScope.CARD); + super(PatriciansScornWatcher.class, WatcherScope.CARD); } public PatriciansScornWatcher(final PatriciansScornWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/p/PermafrostTrap.java b/Mage.Sets/src/mage/cards/p/PermafrostTrap.java index 0d6462c7fd..183d061334 100644 --- a/Mage.Sets/src/mage/cards/p/PermafrostTrap.java +++ b/Mage.Sets/src/mage/cards/p/PermafrostTrap.java @@ -54,7 +54,7 @@ enum PermafrostTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getSimpleName()); + PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatcher(PermanentsEnteredBattlefieldWatcher.class); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { List permanents = watcher.getThisTurnEnteringPermanents(opponentId); diff --git a/Mage.Sets/src/mage/cards/p/PetrifiedWoodKin.java b/Mage.Sets/src/mage/cards/p/PetrifiedWoodKin.java index cd47ad163c..25508ab2db 100644 --- a/Mage.Sets/src/mage/cards/p/PetrifiedWoodKin.java +++ b/Mage.Sets/src/mage/cards/p/PetrifiedWoodKin.java @@ -82,7 +82,7 @@ class PetrifiedWoodKinEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - DamageDoneWatcher watcher = (DamageDoneWatcher) game.getState().getWatchers().get(DamageDoneWatcher.class.getSimpleName()); + DamageDoneWatcher watcher = (DamageDoneWatcher) game.getState().getWatcher(DamageDoneWatcher.class); Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (player == null || watcher == null || permanent == null) { return false; diff --git a/Mage.Sets/src/mage/cards/p/PistonFistCyclops.java b/Mage.Sets/src/mage/cards/p/PistonFistCyclops.java index e362ad9416..b7b4cde01a 100644 --- a/Mage.Sets/src/mage/cards/p/PistonFistCyclops.java +++ b/Mage.Sets/src/mage/cards/p/PistonFistCyclops.java @@ -64,8 +64,8 @@ enum PistonFistCyclopsCondition implements Condition { @Override public boolean apply(Game game, Ability source) { SpellsCastWatcher watcher - = (SpellsCastWatcher) game.getState().getWatchers().get( - SpellsCastWatcher.class.getSimpleName() + = (SpellsCastWatcher) game.getState().getWatcher( + SpellsCastWatcher.class ); if (watcher == null) { return false; diff --git a/Mage.Sets/src/mage/cards/p/PlaneswalkersMischief.java b/Mage.Sets/src/mage/cards/p/PlaneswalkersMischief.java index 875e2f697e..d192ebd4e8 100644 --- a/Mage.Sets/src/mage/cards/p/PlaneswalkersMischief.java +++ b/Mage.Sets/src/mage/cards/p/PlaneswalkersMischief.java @@ -155,7 +155,7 @@ class PlaneswalkersMischiefCondition implements Condition { if (!game.getExile().getExileZone(exileId).contains(cardId)) { return false; } - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName(), source.getSourceId()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class, source.getSourceId()); if (watcher != null) { List spells = watcher.getSpellsCastThisTurn(source.getControllerId()); if (spells != null) { diff --git a/Mage.Sets/src/mage/cards/p/PowerSurge.java b/Mage.Sets/src/mage/cards/p/PowerSurge.java index 4467777139..9160647a47 100644 --- a/Mage.Sets/src/mage/cards/p/PowerSurge.java +++ b/Mage.Sets/src/mage/cards/p/PowerSurge.java @@ -64,7 +64,7 @@ class PowerSurgeDamageEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { - PowerSurgeWatcher watcher = (PowerSurgeWatcher) game.getState().getWatchers().get(PowerSurgeWatcher.class.getSimpleName()); + PowerSurgeWatcher watcher = (PowerSurgeWatcher) game.getState().getWatcher(PowerSurgeWatcher.class); if(watcher != null) { int damage = watcher.getUntappedLandCount(); player.damage(damage, source.getSourceId(), game, false, true); @@ -91,7 +91,7 @@ class PowerSurgeWatcher extends Watcher { private int untappedLandCount; public PowerSurgeWatcher() { - super(PowerSurgeWatcher.class.getSimpleName(), WatcherScope.GAME); + super(PowerSurgeWatcher.class, WatcherScope.GAME); } public PowerSurgeWatcher(final PowerSurgeWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/p/PredatoryAdvantage.java b/Mage.Sets/src/mage/cards/p/PredatoryAdvantage.java index 01c526c408..57906d28fd 100644 --- a/Mage.Sets/src/mage/cards/p/PredatoryAdvantage.java +++ b/Mage.Sets/src/mage/cards/p/PredatoryAdvantage.java @@ -48,7 +48,7 @@ class DidNotCastCreatureCondition implements Condition { public boolean apply(Game game, Ability source) { Permanent p = game.getPermanent(source.getSourceId()); if (p != null) { - Watcher watcher = game.getState().getWatchers().get(CastCreatureWatcher.class.getSimpleName(), source.getSourceId()); + Watcher watcher = game.getState().getWatcher(CastCreatureWatcher.class, source.getSourceId()); if (watcher != null && !watcher.conditionMet()) { return true; } @@ -65,7 +65,7 @@ class DidNotCastCreatureCondition implements Condition { class CastCreatureWatcher extends Watcher { public CastCreatureWatcher() { - super(CastCreatureWatcher.class.getSimpleName(), WatcherScope.CARD); + super(CastCreatureWatcher.class, WatcherScope.CARD); } public CastCreatureWatcher(final CastCreatureWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/p/PrematureBurial.java b/Mage.Sets/src/mage/cards/p/PrematureBurial.java index 07656dd653..c6e770944d 100644 --- a/Mage.Sets/src/mage/cards/p/PrematureBurial.java +++ b/Mage.Sets/src/mage/cards/p/PrematureBurial.java @@ -66,7 +66,7 @@ class ETBSinceYourLastTurnTarget extends TargetCreaturePermanent { @Override public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) { System.out.println("canTarget called"); - ETBSinceYourLastTurnWatcher watcher = (ETBSinceYourLastTurnWatcher) game.getState().getWatchers().get(ETBSinceYourLastTurnWatcher.class.getSimpleName()); + ETBSinceYourLastTurnWatcher watcher = (ETBSinceYourLastTurnWatcher) game.getState().getWatcher(ETBSinceYourLastTurnWatcher.class); if (watcher != null){ if (watcher.enteredSinceLastTurn(controllerId, new MageObjectReference(id, game))){ System.out.println(game.getPermanent(id).getIdName()+" entered since the last turn."); @@ -79,7 +79,7 @@ class ETBSinceYourLastTurnTarget extends TargetCreaturePermanent { @Override public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { MageObject targetSource = game.getObject(sourceId); - ETBSinceYourLastTurnWatcher watcher = (ETBSinceYourLastTurnWatcher) game.getState().getWatchers().get(ETBSinceYourLastTurnWatcher.class.getSimpleName()); + ETBSinceYourLastTurnWatcher watcher = (ETBSinceYourLastTurnWatcher) game.getState().getWatcher(ETBSinceYourLastTurnWatcher.class); if(targetSource != null) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { @@ -103,7 +103,7 @@ class ETBSinceYourLastTurnWatcher extends Watcher { private final Map> playerToETBMap; public ETBSinceYourLastTurnWatcher() { - super(ETBSinceYourLastTurnWatcher.class.getSimpleName(), WatcherScope.GAME); + super(ETBSinceYourLastTurnWatcher.class, WatcherScope.GAME); this.playerToETBMap = new HashMap<>(); } diff --git a/Mage.Sets/src/mage/cards/p/PrizedAmalgam.java b/Mage.Sets/src/mage/cards/p/PrizedAmalgam.java index 77d939f26f..dfd29fcb9f 100644 --- a/Mage.Sets/src/mage/cards/p/PrizedAmalgam.java +++ b/Mage.Sets/src/mage/cards/p/PrizedAmalgam.java @@ -89,7 +89,7 @@ class PrizedAmalgamTriggerdAbility extends EntersBattlefieldAllTriggeredAbility if (entersEvent.getFromZone() == Zone.GRAVEYARD) { result = true; } else if (entersEvent.getFromZone() == Zone.STACK && entersEvent.getTarget().isControlledBy(getControllerId())) { - CastFromGraveyardWatcher watcher = (CastFromGraveyardWatcher) game.getState().getWatchers().get(CastFromGraveyardWatcher.class.getSimpleName()); + CastFromGraveyardWatcher watcher = (CastFromGraveyardWatcher) game.getState().getWatcher(CastFromGraveyardWatcher.class); if (watcher != null) { int zcc = game.getState().getZoneChangeCounter(event.getSourceId()); result = watcher.spellWasCastFromGraveyard(event.getSourceId(), zcc - 1); diff --git a/Mage.Sets/src/mage/cards/p/PsychicTheft.java b/Mage.Sets/src/mage/cards/p/PsychicTheft.java index b017003c21..63eee9fde5 100644 --- a/Mage.Sets/src/mage/cards/p/PsychicTheft.java +++ b/Mage.Sets/src/mage/cards/p/PsychicTheft.java @@ -162,7 +162,7 @@ class PsychicTheftCondition implements Condition { if (!game.getExile().getExileZone(exileId).contains(cardId)) { return false; } - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName(), source.getSourceId()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class, source.getSourceId()); if (watcher != null) { List spells = watcher.getSpellsCastThisTurn(source.getControllerId()); if (spells != null) { diff --git a/Mage.Sets/src/mage/cards/p/PyromancersAssault.java b/Mage.Sets/src/mage/cards/p/PyromancersAssault.java index 8bc1f2d92f..7e8f6f41a8 100644 --- a/Mage.Sets/src/mage/cards/p/PyromancersAssault.java +++ b/Mage.Sets/src/mage/cards/p/PyromancersAssault.java @@ -63,7 +63,7 @@ class PyromancersAssaultTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(controllerId)) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2) { return true; } diff --git a/Mage.Sets/src/mage/cards/q/Quicken.java b/Mage.Sets/src/mage/cards/q/Quicken.java index e34973989e..5025cb4e9d 100644 --- a/Mage.Sets/src/mage/cards/q/Quicken.java +++ b/Mage.Sets/src/mage/cards/q/Quicken.java @@ -64,7 +64,7 @@ class QuickenAsThoughEffect extends AsThoughEffectImpl { @Override public void init(Ability source, Game game) { - quickenWatcher = (QuickenWatcher) game.getState().getWatchers().get(QuickenWatcher.class.getSimpleName()); + quickenWatcher = game.getState().getWatcher(QuickenWatcher.class); Card card = game.getCard(source.getSourceId()); if (quickenWatcher != null && card != null) { zoneChangeCounter = card.getZoneChangeCounter(game); @@ -100,7 +100,7 @@ class QuickenWatcher extends Watcher { public List activeQuickenSpells = new ArrayList<>(); public QuickenWatcher() { - super(QuickenWatcher.class.getSimpleName(), WatcherScope.GAME); + super(QuickenWatcher.class, WatcherScope.GAME); } public QuickenWatcher(final QuickenWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/r/RashmiEternitiesCrafter.java b/Mage.Sets/src/mage/cards/r/RashmiEternitiesCrafter.java index d55cf3b457..e6db3a4154 100644 --- a/Mage.Sets/src/mage/cards/r/RashmiEternitiesCrafter.java +++ b/Mage.Sets/src/mage/cards/r/RashmiEternitiesCrafter.java @@ -70,7 +70,7 @@ class RashmiEternitiesCrafterTriggeredAbility extends SpellCastControllerTrigger @Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class); if (watcher != null) { List spells = watcher.getSpellsCastThisTurn(event.getPlayerId()); if (spells != null && spells.size() == 1) { diff --git a/Mage.Sets/src/mage/cards/r/RasputinDreamweaver.java b/Mage.Sets/src/mage/cards/r/RasputinDreamweaver.java index 36a1b7cc43..b4c71ca23e 100644 --- a/Mage.Sets/src/mage/cards/r/RasputinDreamweaver.java +++ b/Mage.Sets/src/mage/cards/r/RasputinDreamweaver.java @@ -80,7 +80,7 @@ enum RasputinDreamweaverStartedUntappedCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - RasputinDreamweaverStartedUntappedWatcher watcher = (RasputinDreamweaverStartedUntappedWatcher) game.getState().getWatchers().get(RasputinDreamweaverStartedUntappedWatcher.class.getSimpleName()); + RasputinDreamweaverStartedUntappedWatcher watcher = (RasputinDreamweaverStartedUntappedWatcher) game.getState().getWatcher(RasputinDreamweaverStartedUntappedWatcher.class); if (watcher != null) { return watcher.startedUntapped(source.getSourceId()); } @@ -104,7 +104,7 @@ class RasputinDreamweaverStartedUntappedWatcher extends Watcher { private final Set startedUntapped = new HashSet<>(0); RasputinDreamweaverStartedUntappedWatcher() { - super(RasputinDreamweaverStartedUntappedWatcher.class.getSimpleName(), WatcherScope.GAME); + super(RasputinDreamweaverStartedUntappedWatcher.class, WatcherScope.GAME); } RasputinDreamweaverStartedUntappedWatcher(final RasputinDreamweaverStartedUntappedWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/r/RavenousTrap.java b/Mage.Sets/src/mage/cards/r/RavenousTrap.java index c1f31a0fda..38b887810a 100644 --- a/Mage.Sets/src/mage/cards/r/RavenousTrap.java +++ b/Mage.Sets/src/mage/cards/r/RavenousTrap.java @@ -50,7 +50,7 @@ enum RavenousTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get(CardsPutIntoGraveyardWatcher.class.getSimpleName()); + CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { if (watcher.getAmountCardsPutToGraveyard(opponentId) > 2) { diff --git a/Mage.Sets/src/mage/cards/r/ReaperFromTheAbyss.java b/Mage.Sets/src/mage/cards/r/ReaperFromTheAbyss.java index 530594cba3..519ff15bcc 100644 --- a/Mage.Sets/src/mage/cards/r/ReaperFromTheAbyss.java +++ b/Mage.Sets/src/mage/cards/r/ReaperFromTheAbyss.java @@ -81,7 +81,7 @@ class ReaperFromTheAbyssAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName()); + Watcher watcher = game.getState().getWatcher(MorbidWatcher.class); return watcher != null && watcher.conditionMet(); } diff --git a/Mage.Sets/src/mage/cards/r/Reciprocate.java b/Mage.Sets/src/mage/cards/r/Reciprocate.java index 90bcb754d0..991cb0711f 100644 --- a/Mage.Sets/src/mage/cards/r/Reciprocate.java +++ b/Mage.Sets/src/mage/cards/r/Reciprocate.java @@ -53,7 +53,7 @@ class ReciprocateTarget extends TargetPermanent { @Override public boolean canTarget(UUID id, Ability source, Game game) { - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), source.getControllerId()); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, source.getControllerId()); if (watcher != null && watcher.hasSourceDoneDamage(id, game)) { return super.canTarget(id, source, game); } @@ -64,7 +64,7 @@ class ReciprocateTarget extends TargetPermanent { public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { Set availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game); Set possibleTargets = new HashSet<>(); - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, sourceControllerId); for (UUID targetId : availablePossibleTargets) { Permanent permanent = game.getPermanent(targetId); if (permanent != null && watcher != null && watcher.hasSourceDoneDamage(targetId, game)) { @@ -83,7 +83,7 @@ class ReciprocateTarget extends TargetPermanent { int count = 0; MageObject targetSource = game.getObject(sourceId); if(targetSource != null) { - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, sourceControllerId); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && watcher != null && watcher.hasSourceDoneDamage(permanent.getId(), game)) { diff --git a/Mage.Sets/src/mage/cards/r/RefractionTrap.java b/Mage.Sets/src/mage/cards/r/RefractionTrap.java index 84d3bc3672..a1c1475e18 100644 --- a/Mage.Sets/src/mage/cards/r/RefractionTrap.java +++ b/Mage.Sets/src/mage/cards/r/RefractionTrap.java @@ -59,7 +59,7 @@ enum RefractionTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { List spells = watcher.getSpellsCastThisTurn(opponentId); diff --git a/Mage.Sets/src/mage/cards/r/RegnaTheRedeemer.java b/Mage.Sets/src/mage/cards/r/RegnaTheRedeemer.java index adcf7f0b30..13beeba6c4 100644 --- a/Mage.Sets/src/mage/cards/r/RegnaTheRedeemer.java +++ b/Mage.Sets/src/mage/cards/r/RegnaTheRedeemer.java @@ -75,12 +75,12 @@ class RegnaTheRedeemerCondition extends IntCompareCondition { @Override protected int getInputValue(Game game, Ability source) { int gainedLife = 0; - PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getSimpleName()); + PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatcher(PlayerGainedLifeWatcher.class); if (watcher != null) { for (UUID playerId : game.getPlayerList()) { Player player = game.getPlayer(playerId); if (player != null && !player.hasOpponent(source.getControllerId(), game)) { - gainedLife = watcher.getLiveGained(playerId); + gainedLife = watcher.getLifeGained(playerId); if (gainedLife > 0) { break; } diff --git a/Mage.Sets/src/mage/cards/r/RelicRunner.java b/Mage.Sets/src/mage/cards/r/RelicRunner.java index 23e3aee8ec..40a2950536 100644 --- a/Mage.Sets/src/mage/cards/r/RelicRunner.java +++ b/Mage.Sets/src/mage/cards/r/RelicRunner.java @@ -58,7 +58,7 @@ class CastHistoricSpellThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class); if (watcher != null) { List spells = watcher.getSpellsCastThisTurn(source.getControllerId()); if (spells != null) { diff --git a/Mage.Sets/src/mage/cards/r/RestoreThePeace.java b/Mage.Sets/src/mage/cards/r/RestoreThePeace.java index 48d3e16fb2..4e7b7719d1 100644 --- a/Mage.Sets/src/mage/cards/r/RestoreThePeace.java +++ b/Mage.Sets/src/mage/cards/r/RestoreThePeace.java @@ -56,7 +56,7 @@ class RestoreThePeaceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName()); + SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatcher(SourceDidDamageWatcher.class); if (watcher != null) { for (UUID permId : watcher.damageSources) { Permanent perm = game.getPermanent(permId); diff --git a/Mage.Sets/src/mage/cards/r/Revenge.java b/Mage.Sets/src/mage/cards/r/Revenge.java index 140696b541..04be56ca00 100644 --- a/Mage.Sets/src/mage/cards/r/Revenge.java +++ b/Mage.Sets/src/mage/cards/r/Revenge.java @@ -62,7 +62,7 @@ enum LostLifeCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatcher(PlayerLostLifeWatcher.class); UUID player = source.getControllerId(); if (watcher != null && player != null) { return watcher.getLifeLost(player) > 0; diff --git a/Mage.Sets/src/mage/cards/r/ReversePolarity.java b/Mage.Sets/src/mage/cards/r/ReversePolarity.java index ca3a31fcb0..344821600e 100644 --- a/Mage.Sets/src/mage/cards/r/ReversePolarity.java +++ b/Mage.Sets/src/mage/cards/r/ReversePolarity.java @@ -46,7 +46,7 @@ class ReversePolarityAmount implements DynamicValue { @Override public int calculate(Game game, Ability source, Effect effect) { - ReversePolarityWatcher watcher = (ReversePolarityWatcher) game.getState().getWatchers().get(ReversePolarityWatcher.class.getSimpleName()); + ReversePolarityWatcher watcher = (ReversePolarityWatcher) game.getState().getWatcher(ReversePolarityWatcher.class); if(watcher != null) { return watcher.getArtifactDamageReceivedThisTurn(source.getControllerId()) * 2; } diff --git a/Mage.Sets/src/mage/cards/r/RicochetTrap.java b/Mage.Sets/src/mage/cards/r/RicochetTrap.java index 414dafbf65..49218c3a20 100644 --- a/Mage.Sets/src/mage/cards/r/RicochetTrap.java +++ b/Mage.Sets/src/mage/cards/r/RicochetTrap.java @@ -61,7 +61,7 @@ enum RicochetTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { List spells = watcher.getSpellsCastThisTurn(opponentId); diff --git a/Mage.Sets/src/mage/cards/r/RimehornAurochs.java b/Mage.Sets/src/mage/cards/r/RimehornAurochs.java index a982d12576..0efb597747 100644 --- a/Mage.Sets/src/mage/cards/r/RimehornAurochs.java +++ b/Mage.Sets/src/mage/cards/r/RimehornAurochs.java @@ -89,7 +89,7 @@ class RimehornAurochsEffect extends RequirementEffect { && blocker.canBlock(source.getTargets().get(1).getFirstTarget(), game)) { Permanent attacker = game.getPermanent(source.getTargets().get(1).getFirstTarget()); if (attacker != null) { - BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); + BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatcher(BlockedAttackerWatcher.class); if (blockedAttackerWatcher != null && blockedAttackerWatcher.creatureHasBlockedAttacker(attacker, blocker, game)) { // has already blocked this turn, so no need to do again diff --git a/Mage.Sets/src/mage/cards/r/RixMaadiGuildmage.java b/Mage.Sets/src/mage/cards/r/RixMaadiGuildmage.java index 891f0b5ed9..6793dcfe59 100644 --- a/Mage.Sets/src/mage/cards/r/RixMaadiGuildmage.java +++ b/Mage.Sets/src/mage/cards/r/RixMaadiGuildmage.java @@ -72,7 +72,7 @@ class PlayerLostLifePredicate implements Predicate { @Override public boolean apply(Player input, Game game) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatcher(PlayerLostLifeWatcher.class); if (watcher != null) { return (0 < watcher.getLifeLost(input.getId())); } diff --git a/Mage.Sets/src/mage/cards/r/RocketLauncher.java b/Mage.Sets/src/mage/cards/r/RocketLauncher.java index 2cc8d0b348..8b3ab028d7 100644 --- a/Mage.Sets/src/mage/cards/r/RocketLauncher.java +++ b/Mage.Sets/src/mage/cards/r/RocketLauncher.java @@ -56,7 +56,7 @@ class RocketLauncherWatcher extends Watcher { UUID cardId = null; public RocketLauncherWatcher(UUID cardId) { - super(RocketLauncherWatcher.class.getSimpleName(), WatcherScope.GAME); + super(RocketLauncherWatcher.class, WatcherScope.GAME); this.changedControllerOR1stTurn = true; this.cardId = cardId; } @@ -97,7 +97,7 @@ enum ControlledTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - RocketLauncherWatcher watcher = (RocketLauncherWatcher) game.getState().getWatchers().get(RocketLauncherWatcher.class.getSimpleName()); + RocketLauncherWatcher watcher = (RocketLauncherWatcher) game.getState().getWatcher(RocketLauncherWatcher.class); return watcher != null && !watcher.changedControllerOR1stTurn; } diff --git a/Mage.Sets/src/mage/cards/r/RuneflareTrap.java b/Mage.Sets/src/mage/cards/r/RuneflareTrap.java index c446765d2a..1f1c8a389b 100644 --- a/Mage.Sets/src/mage/cards/r/RuneflareTrap.java +++ b/Mage.Sets/src/mage/cards/r/RuneflareTrap.java @@ -83,7 +83,7 @@ enum RuneflareTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { CardsAmountDrawnThisTurnWatcher watcher = - (CardsAmountDrawnThisTurnWatcher) game.getState().getWatchers().get(CardsAmountDrawnThisTurnWatcher.class.getSimpleName()); + (CardsAmountDrawnThisTurnWatcher) game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class); return watcher != null && watcher.opponentDrewXOrMoreCards(source.getControllerId(), 3, game); } diff --git a/Mage.Sets/src/mage/cards/r/Runesword.java b/Mage.Sets/src/mage/cards/r/Runesword.java index 0a79d2da0e..2d2276ee34 100644 --- a/Mage.Sets/src/mage/cards/r/Runesword.java +++ b/Mage.Sets/src/mage/cards/r/Runesword.java @@ -136,7 +136,7 @@ class RuneswordCantBeRegeneratedEffect extends ContinuousRuleModifyingEffectImpl @Override public boolean applies(GameEvent event, Ability source, Game game) { if (targetCreatureId != null) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), targetCreatureId); + DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatcher(DamagedByWatcher.class, targetCreatureId); if (watcher != null) { return watcher.wasDamaged(event.getTargetId(), game); } diff --git a/Mage.Sets/src/mage/cards/s/SaheeliTheGifted.java b/Mage.Sets/src/mage/cards/s/SaheeliTheGifted.java index 4d577674f8..cea3d66a03 100644 --- a/Mage.Sets/src/mage/cards/s/SaheeliTheGifted.java +++ b/Mage.Sets/src/mage/cards/s/SaheeliTheGifted.java @@ -86,7 +86,7 @@ class SaheeliTheGiftedCostReductionEffect extends CostModificationEffectImpl { @Override public void init(Ability source, Game game) { super.init(source, game); - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null) { spellsCast = watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()); } @@ -104,7 +104,7 @@ class SaheeliTheGiftedCostReductionEffect extends CostModificationEffectImpl { @Override public boolean applies(Ability abilityToModify, Ability source, Game game) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null) { if (watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) > spellsCast) { discard(); // only one use diff --git a/Mage.Sets/src/mage/cards/s/SavageSummoning.java b/Mage.Sets/src/mage/cards/s/SavageSummoning.java index e92658aa33..7b6e4394f0 100644 --- a/Mage.Sets/src/mage/cards/s/SavageSummoning.java +++ b/Mage.Sets/src/mage/cards/s/SavageSummoning.java @@ -75,7 +75,7 @@ class SavageSummoningAsThoughEffect extends AsThoughEffectImpl { @Override public void init(Ability source, Game game) { - watcher = (SavageSummoningWatcher) game.getState().getWatchers().get(SavageSummoningWatcher.class.getSimpleName(), source.getControllerId()); + watcher = (SavageSummoningWatcher) game.getState().getWatcher(SavageSummoningWatcher.class, source.getControllerId()); Card card = game.getCard(source.getSourceId()); if (watcher != null && card != null) { watcher.setSavageSummoningSpellActive(card, game); @@ -122,7 +122,7 @@ class SavageSummoningWatcher extends Watcher { private Map> cardsCastWithSavageSummoning = new LinkedHashMap<>(); public SavageSummoningWatcher() { - super(SavageSummoningWatcher.class.getSimpleName(), WatcherScope.PLAYER); + super(SavageSummoningWatcher.class, WatcherScope.PLAYER); } public SavageSummoningWatcher(final SavageSummoningWatcher watcher) { @@ -207,7 +207,7 @@ class SavageSummoningCantCounterEffect extends ContinuousRuleModifyingEffectImpl @Override public void init(Ability source, Game game) { - watcher = (SavageSummoningWatcher) game.getState().getWatchers().get(SavageSummoningWatcher.class.getSimpleName(), source.getControllerId()); + watcher = (SavageSummoningWatcher) game.getState().getWatcher(SavageSummoningWatcher.class, source.getControllerId()); Card card = game.getCard(source.getSourceId()); if (watcher == null || card == null) { throw new IllegalArgumentException("Consume Savage watcher or card could not be found"); @@ -265,7 +265,7 @@ class SavageSummoningEntersBattlefieldEffect extends ReplacementEffectImpl { @Override public void init(Ability source, Game game) { - watcher = (SavageSummoningWatcher) game.getState().getWatchers().get(SavageSummoningWatcher.class.getSimpleName(), source.getControllerId()); + watcher = (SavageSummoningWatcher) game.getState().getWatcher(SavageSummoningWatcher.class, source.getControllerId()); Card card = game.getCard(source.getSourceId()); if (watcher == null || card == null) { throw new IllegalArgumentException("Consume Savage watcher or card could not be found"); diff --git a/Mage.Sets/src/mage/cards/s/ScaleguardSentinels.java b/Mage.Sets/src/mage/cards/s/ScaleguardSentinels.java index ee693bf611..e89b8d13a9 100644 --- a/Mage.Sets/src/mage/cards/s/ScaleguardSentinels.java +++ b/Mage.Sets/src/mage/cards/s/ScaleguardSentinels.java @@ -83,7 +83,7 @@ enum ScaleguardSentinelsCondition implements Condition { public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanentEntering(source.getSourceId()); if (sourcePermanent != null) { - DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName()); + DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class); return (watcher != null && watcher.castWithConditionTrue(sourcePermanent.getSpellAbility().getId())); } return false; diff --git a/Mage.Sets/src/mage/cards/s/ScoutsWarning.java b/Mage.Sets/src/mage/cards/s/ScoutsWarning.java index 0c1816f4a3..bf45ce20b0 100644 --- a/Mage.Sets/src/mage/cards/s/ScoutsWarning.java +++ b/Mage.Sets/src/mage/cards/s/ScoutsWarning.java @@ -65,7 +65,7 @@ class ScoutsWarningAsThoughEffect extends AsThoughEffectImpl { @Override public void init(Ability source, Game game) { - watcher = (ScoutsWarningWatcher) game.getState().getWatchers().get(ScoutsWarningWatcher.class.getSimpleName(), source.getControllerId()); + watcher = (ScoutsWarningWatcher) game.getState().getWatcher(ScoutsWarningWatcher.class, source.getControllerId()); Card card = game.getCard(source.getSourceId()); if (watcher != null && card != null) { zoneChangeCounter = card.getZoneChangeCounter(game); diff --git a/Mage.Sets/src/mage/cards/s/SeaTroll.java b/Mage.Sets/src/mage/cards/s/SeaTroll.java index 09a364ec86..2b8cec4d8d 100644 --- a/Mage.Sets/src/mage/cards/s/SeaTroll.java +++ b/Mage.Sets/src/mage/cards/s/SeaTroll.java @@ -103,7 +103,7 @@ class SeaTrollCondition implements Condition { public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourcePermanent != null){ - SeaTrollWatcher watcher = (SeaTrollWatcher) game.getState().getWatchers().get(SeaTrollWatcher.class.getSimpleName()); + SeaTrollWatcher watcher = (SeaTrollWatcher) game.getState().getWatcher(SeaTrollWatcher.class); if (watcher != null) { return watcher.blockedOrBlockedByBlueCreatureThisTurn(new MageObjectReference(sourcePermanent, game)); } diff --git a/Mage.Sets/src/mage/cards/s/SearingBlaze.java b/Mage.Sets/src/mage/cards/s/SearingBlaze.java index cda4d3ce25..f5ee7c4746 100644 --- a/Mage.Sets/src/mage/cards/s/SearingBlaze.java +++ b/Mage.Sets/src/mage/cards/s/SearingBlaze.java @@ -67,7 +67,7 @@ class SearingBlazeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - LandfallWatcher watcher = (LandfallWatcher) game.getState().getWatchers().get(LandfallWatcher.class.getSimpleName()); + LandfallWatcher watcher = (LandfallWatcher) game.getState().getWatcher(LandfallWatcher.class); Permanent creature = game.getPermanent(source.getTargets().get(1).getFirstTarget()); int damage = 1; if (watcher != null && watcher.landPlayed(source.getControllerId())) { diff --git a/Mage.Sets/src/mage/cards/s/SeasonOfTheWitch.java b/Mage.Sets/src/mage/cards/s/SeasonOfTheWitch.java index fcde9f0888..1456379759 100644 --- a/Mage.Sets/src/mage/cards/s/SeasonOfTheWitch.java +++ b/Mage.Sets/src/mage/cards/s/SeasonOfTheWitch.java @@ -87,13 +87,13 @@ class SeasonOfTheWitchEffect extends OneShotEffect { continue; } // Creatures that attacked are safe. - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatcher(AttackedThisTurnWatcher.class); if (watcher != null && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) { continue; } // Creatures that couldn't attack are safe. - CouldAttackThisTurnWatcher watcher2 = (CouldAttackThisTurnWatcher) game.getState().getWatchers().get(CouldAttackThisTurnWatcher.class.getSimpleName()); + CouldAttackThisTurnWatcher watcher2 = (CouldAttackThisTurnWatcher) game.getState().getWatcher(CouldAttackThisTurnWatcher.class); if (watcher2 != null && !watcher2.getCouldAttackThisTurnCreatures().contains(new MageObjectReference(permanent, game))) { continue; @@ -112,7 +112,7 @@ class CouldAttackThisTurnWatcher extends Watcher { public final Set couldAttackThisTurnCreatures = new HashSet<>(); public CouldAttackThisTurnWatcher() { - super(CouldAttackThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); + super(CouldAttackThisTurnWatcher.class, WatcherScope.GAME); } public CouldAttackThisTurnWatcher(final CouldAttackThisTurnWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/SecondGuess.java b/Mage.Sets/src/mage/cards/s/SecondGuess.java index 6a65427e44..48271b75d9 100644 --- a/Mage.Sets/src/mage/cards/s/SecondGuess.java +++ b/Mage.Sets/src/mage/cards/s/SecondGuess.java @@ -49,7 +49,7 @@ class SecondSpellPredicate implements Predicate { @Override public boolean apply(StackObject input, Game game) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null && watcher.getSpellOrder(new MageObjectReference(input.getId(), game), game) == 2) { return true; diff --git a/Mage.Sets/src/mage/cards/s/SecondSunrise.java b/Mage.Sets/src/mage/cards/s/SecondSunrise.java index c4eed33e12..520211741a 100644 --- a/Mage.Sets/src/mage/cards/s/SecondSunrise.java +++ b/Mage.Sets/src/mage/cards/s/SecondSunrise.java @@ -57,7 +57,7 @@ class SecondSunriseEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - SecondSunriseWatcher watcher = (SecondSunriseWatcher) game.getState().getWatchers().get(SecondSunriseWatcher.class.getSimpleName()); + SecondSunriseWatcher watcher = (SecondSunriseWatcher) game.getState().getWatcher(SecondSunriseWatcher.class); if (watcher != null) { for (UUID id : watcher.cards) { Card c = game.getCard(id); @@ -82,7 +82,7 @@ class SecondSunriseWatcher extends Watcher { List cards = new ArrayList<>(); public SecondSunriseWatcher() { - super(SecondSunriseWatcher.class.getSimpleName(), WatcherScope.GAME); + super(SecondSunriseWatcher.class, WatcherScope.GAME); } public SecondSunriseWatcher(final SecondSunriseWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/Seedtime.java b/Mage.Sets/src/mage/cards/s/Seedtime.java index dd90232dcf..af198ef4c6 100644 --- a/Mage.Sets/src/mage/cards/s/Seedtime.java +++ b/Mage.Sets/src/mage/cards/s/Seedtime.java @@ -53,7 +53,7 @@ enum OpponentCastBlueSpellThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { if (opponentId != null) { diff --git a/Mage.Sets/src/mage/cards/s/SeekerOfInsight.java b/Mage.Sets/src/mage/cards/s/SeekerOfInsight.java index 9e1b83cbdd..0e4efa58a0 100644 --- a/Mage.Sets/src/mage/cards/s/SeekerOfInsight.java +++ b/Mage.Sets/src/mage/cards/s/SeekerOfInsight.java @@ -56,7 +56,7 @@ class CastNonCreatureSpellCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class); if (watcher != null) { List spellsCast = watcher.getSpellsCastThisTurn(source.getControllerId()); if (spellsCast != null) { diff --git a/Mage.Sets/src/mage/cards/s/SentinelTower.java b/Mage.Sets/src/mage/cards/s/SentinelTower.java index b0bfffa498..565ac7f858 100644 --- a/Mage.Sets/src/mage/cards/s/SentinelTower.java +++ b/Mage.Sets/src/mage/cards/s/SentinelTower.java @@ -62,7 +62,7 @@ class SentinelTowerTriggeredAbility extends SpellCastAllTriggeredAbility { public boolean checkTrigger(GameEvent event, Game game) { if (game.isActivePlayer(getControllerId()) && super.checkTrigger(event, game)) { - SentinelTowerWatcher watcher = (SentinelTowerWatcher) game.getState().getWatchers().get(SentinelTowerWatcher.class.getSimpleName()); + SentinelTowerWatcher watcher = (SentinelTowerWatcher) game.getState().getWatcher(SentinelTowerWatcher.class); if (watcher == null) { return false; } @@ -101,7 +101,7 @@ class SentinelTowerWatcher extends Watcher { private final List spellsThisTurn; SentinelTowerWatcher() { - super(SentinelTowerWatcher.class.getSimpleName(), WatcherScope.GAME); + super(SentinelTowerWatcher.class, WatcherScope.GAME); this.spellsThisTurn = new ArrayList<>(); } diff --git a/Mage.Sets/src/mage/cards/s/ShadowOfTheGrave.java b/Mage.Sets/src/mage/cards/s/ShadowOfTheGrave.java index c85fcab35d..a41127423f 100644 --- a/Mage.Sets/src/mage/cards/s/ShadowOfTheGrave.java +++ b/Mage.Sets/src/mage/cards/s/ShadowOfTheGrave.java @@ -58,7 +58,7 @@ class ShadowOfTheGraveEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - CardsCycledOrDiscardedThisTurnWatcher watcher = (CardsCycledOrDiscardedThisTurnWatcher) game.getState().getWatchers().get(CardsCycledOrDiscardedThisTurnWatcher.class.getSimpleName()); + CardsCycledOrDiscardedThisTurnWatcher watcher = (CardsCycledOrDiscardedThisTurnWatcher) game.getState().getWatcher(CardsCycledOrDiscardedThisTurnWatcher.class); if (controller != null && watcher != null) { for (Card card : watcher.getCardsCycledOrDiscardedThisTurn(controller.getId()).getCards(game)) { diff --git a/Mage.Sets/src/mage/cards/s/ShapeOfTheWiitigo.java b/Mage.Sets/src/mage/cards/s/ShapeOfTheWiitigo.java index 3e33b199b6..94e77639b9 100644 --- a/Mage.Sets/src/mage/cards/s/ShapeOfTheWiitigo.java +++ b/Mage.Sets/src/mage/cards/s/ShapeOfTheWiitigo.java @@ -70,7 +70,7 @@ class AttachedAttackedOrBlockedSinceYourLastUpkeepCondition implements Condition @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId()); - AttackedOrBlockedSinceYourLastUpkeepWatcher watcher = (AttackedOrBlockedSinceYourLastUpkeepWatcher) game.getState().getWatchers().get(AttackedOrBlockedSinceYourLastUpkeepWatcher.class.getSimpleName()); + AttackedOrBlockedSinceYourLastUpkeepWatcher watcher = (AttackedOrBlockedSinceYourLastUpkeepWatcher) game.getState().getWatcher(AttackedOrBlockedSinceYourLastUpkeepWatcher.class); if (permanent != null && permanent.getAttachedTo() != null && watcher != null) { Permanent attachedTo = game.getBattlefield().getPermanent(permanent.getAttachedTo()); if (attachedTo == null) { @@ -95,7 +95,7 @@ class AttackedOrBlockedSinceYourLastUpkeepWatcher extends Watcher{ private final Map> attackedOrBlockedCreatures = new HashMap<>(); public AttackedOrBlockedSinceYourLastUpkeepWatcher() { - super(AttackedOrBlockedSinceYourLastUpkeepWatcher.class.getSimpleName(), WatcherScope.GAME); + super(AttackedOrBlockedSinceYourLastUpkeepWatcher.class, WatcherScope.GAME); } public AttackedOrBlockedSinceYourLastUpkeepWatcher(AttackedOrBlockedSinceYourLastUpkeepWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/SiftThroughSands.java b/Mage.Sets/src/mage/cards/s/SiftThroughSands.java index bb58142306..c4a30d3530 100644 --- a/Mage.Sets/src/mage/cards/s/SiftThroughSands.java +++ b/Mage.Sets/src/mage/cards/s/SiftThroughSands.java @@ -66,7 +66,7 @@ class SiftThroughSandsCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SiftThroughSandsWatcher watcher = (SiftThroughSandsWatcher) game.getState().getWatchers().get(SiftThroughSandsWatcher.class.getSimpleName(), source.getControllerId()); + SiftThroughSandsWatcher watcher = (SiftThroughSandsWatcher) game.getState().getWatcher(SiftThroughSandsWatcher.class, source.getControllerId()); if (watcher != null) { return watcher.conditionMet(); } @@ -80,7 +80,7 @@ class SiftThroughSandsWatcher extends Watcher { boolean castReachThroughMists = false; public SiftThroughSandsWatcher() { - super(SiftThroughSandsWatcher.class.getSimpleName(), WatcherScope.PLAYER); + super(SiftThroughSandsWatcher.class, WatcherScope.PLAYER); } public SiftThroughSandsWatcher(final SiftThroughSandsWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/SilburlindSnapper.java b/Mage.Sets/src/mage/cards/s/SilburlindSnapper.java index bf16032e77..a94ffb41cb 100644 --- a/Mage.Sets/src/mage/cards/s/SilburlindSnapper.java +++ b/Mage.Sets/src/mage/cards/s/SilburlindSnapper.java @@ -69,7 +69,7 @@ class SilburlindSnapperEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class); if (watcher != null) { List spellsCast = watcher.getSpellsCastThisTurn(source.getControllerId()); if (spellsCast != null) { diff --git a/Mage.Sets/src/mage/cards/s/SilentChantZubera.java b/Mage.Sets/src/mage/cards/s/SilentChantZubera.java index 1d186102d0..b2d0ec1e0b 100644 --- a/Mage.Sets/src/mage/cards/s/SilentChantZubera.java +++ b/Mage.Sets/src/mage/cards/s/SilentChantZubera.java @@ -48,9 +48,9 @@ class SilentChantZuberaDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get(ZuberasDiedWatcher.class.getSimpleName()); + ZuberasDiedWatcher watcher = game.getState().getWatcher(ZuberasDiedWatcher.class); if(watcher != null) { - return watcher.zuberasDiedThisTurn * 2; + return watcher.getZuberasDiedThisTurn() * 2; } return 0; } diff --git a/Mage.Sets/src/mage/cards/s/SilumgarsScorn.java b/Mage.Sets/src/mage/cards/s/SilumgarsScorn.java index ed30b202d8..501006a48c 100644 --- a/Mage.Sets/src/mage/cards/s/SilumgarsScorn.java +++ b/Mage.Sets/src/mage/cards/s/SilumgarsScorn.java @@ -93,7 +93,7 @@ class SilumgarsScornCounterEffect extends OneShotEffect { if (spell != null) { Player player = game.getPlayer(spell.getControllerId()); if (player != null) { - DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatchers().get(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class.getSimpleName()); + DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = (DragonOnTheBattlefieldWhileSpellWasCastWatcher) game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class); boolean condition = watcher != null && watcher.castWithConditionTrue(source.getId()); if (!condition) { for (Cost cost: source.getCosts()) { diff --git a/Mage.Sets/src/mage/cards/s/Simulacrum.java b/Mage.Sets/src/mage/cards/s/Simulacrum.java index a810a5f4c9..93831f5ced 100644 --- a/Mage.Sets/src/mage/cards/s/Simulacrum.java +++ b/Mage.Sets/src/mage/cards/s/Simulacrum.java @@ -47,7 +47,7 @@ class SimulacrumAmount implements DynamicValue { @Override public int calculate(Game game, Ability source, Effect effect) { - AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatchers().get(AmountOfDamageAPlayerReceivedThisTurnWatcher.class.getSimpleName()); + AmountOfDamageAPlayerReceivedThisTurnWatcher watcher = (AmountOfDamageAPlayerReceivedThisTurnWatcher) game.getState().getWatcher(AmountOfDamageAPlayerReceivedThisTurnWatcher.class); if(watcher != null) { return watcher.getAmountOfDamageReceivedThisTurn(source.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/s/SirensCall.java b/Mage.Sets/src/mage/cards/s/SirensCall.java index 9512ea85e4..2006c88e12 100644 --- a/Mage.Sets/src/mage/cards/s/SirensCall.java +++ b/Mage.Sets/src/mage/cards/s/SirensCall.java @@ -120,7 +120,7 @@ class SirensCallDestroyEffect extends OneShotEffect { continue; } // Creatures that attacked are safe. - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatcher(AttackedThisTurnWatcher.class); if (watcher != null && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) { continue; } diff --git a/Mage.Sets/src/mage/cards/s/SkarrganFirebird.java b/Mage.Sets/src/mage/cards/s/SkarrganFirebird.java index ad3da8d578..4d27b8b2c5 100644 --- a/Mage.Sets/src/mage/cards/s/SkarrganFirebird.java +++ b/Mage.Sets/src/mage/cards/s/SkarrganFirebird.java @@ -61,7 +61,7 @@ class OpponentWasDealtDamageCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); + BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatcher(BloodthirstWatcher.class, source.getControllerId()); return watcher != null && watcher.conditionMet(); } diff --git a/Mage.Sets/src/mage/cards/s/Skeletonize.java b/Mage.Sets/src/mage/cards/s/Skeletonize.java index 7eba0bdead..843a88661f 100644 --- a/Mage.Sets/src/mage/cards/s/Skeletonize.java +++ b/Mage.Sets/src/mage/cards/s/Skeletonize.java @@ -95,7 +95,7 @@ class SkeletonizeDelayedTriggeredAbility extends DelayedTriggeredAbility { public boolean checkTrigger(GameEvent event, Game game) { ZoneChangeEvent zce = (ZoneChangeEvent) event; if (zce.isDiesEvent()) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), this.getSourceId()); + DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatcher(DamagedByWatcher.class, this.getSourceId()); if (watcher != null) { return watcher.wasDamaged(zce.getTarget(), game); } diff --git a/Mage.Sets/src/mage/cards/s/SoulReap.java b/Mage.Sets/src/mage/cards/s/SoulReap.java index bd70f570e8..875e08e8dc 100644 --- a/Mage.Sets/src/mage/cards/s/SoulReap.java +++ b/Mage.Sets/src/mage/cards/s/SoulReap.java @@ -65,7 +65,7 @@ class CastBlackSpellThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SoulReapWatcher watcher = (SoulReapWatcher) game.getState().getWatchers().get(SoulReapWatcher.class.getSimpleName(), source.getControllerId()); + SoulReapWatcher watcher = (SoulReapWatcher) game.getState().getWatcher(SoulReapWatcher.class, source.getControllerId()); if (watcher != null) { return watcher.conditionMet(); } @@ -84,7 +84,7 @@ class SoulReapWatcher extends Watcher { private UUID cardId; public SoulReapWatcher(UUID cardId) { - super(SoulReapWatcher.class.getSimpleName(), WatcherScope.PLAYER); + super(SoulReapWatcher.class, WatcherScope.PLAYER); this.cardId = cardId; } diff --git a/Mage.Sets/src/mage/cards/s/SpinerockKnoll.java b/Mage.Sets/src/mage/cards/s/SpinerockKnoll.java index 2bbd0596be..76438de23a 100644 --- a/Mage.Sets/src/mage/cards/s/SpinerockKnoll.java +++ b/Mage.Sets/src/mage/cards/s/SpinerockKnoll.java @@ -68,7 +68,7 @@ class SpinerockKnollCondition extends IntCompareCondition { @Override protected int getInputValue(Game game, Ability source) { int maxDamageReceived = 0; - SpinerockKnollWatcher watcher = (SpinerockKnollWatcher) game.getState().getWatchers().get(SpinerockKnollWatcher.class.getSimpleName(), source.getSourceId()); + SpinerockKnollWatcher watcher = (SpinerockKnollWatcher) game.getState().getWatcher(SpinerockKnollWatcher.class, source.getSourceId()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { int damageReceived = watcher.getDamageReceived(opponentId); diff --git a/Mage.Sets/src/mage/cards/s/SpinyStarfish.java b/Mage.Sets/src/mage/cards/s/SpinyStarfish.java index c2760bd321..cdd137660c 100644 --- a/Mage.Sets/src/mage/cards/s/SpinyStarfish.java +++ b/Mage.Sets/src/mage/cards/s/SpinyStarfish.java @@ -70,7 +70,7 @@ enum SpinyStarfishCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SpinyStarfishWatcher watcher = (SpinyStarfishWatcher) game.getState().getWatchers().get(SpinyStarfishWatcher.class.getSimpleName()); + SpinyStarfishWatcher watcher = (SpinyStarfishWatcher) game.getState().getWatcher(SpinyStarfishWatcher.class); return watcher != null && watcher.regeneratedCount(source.getSourceId()) != 0; } @@ -88,7 +88,7 @@ class SpinyStarfishWatcher extends Watcher { private final Map regeneratedCount = new HashMap<>(); public SpinyStarfishWatcher() { - super(SpinyStarfishWatcher.class.getSimpleName(), WatcherScope.GAME); + super(SpinyStarfishWatcher.class, WatcherScope.GAME); } public SpinyStarfishWatcher(final SpinyStarfishWatcher watcher) { @@ -132,8 +132,8 @@ class SpinyStarfishDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - SpinyStarfishWatcher watcher = (SpinyStarfishWatcher) game.getState().getWatchers().get( - SpinyStarfishWatcher.class.getSimpleName()); + SpinyStarfishWatcher watcher = (SpinyStarfishWatcher) game.getState().getWatcher( + SpinyStarfishWatcher.class); if (watcher != null) { return watcher.regeneratedCount(sourceAbility.getSourceId()); } diff --git a/Mage.Sets/src/mage/cards/s/SpiritOfTheLabyrinth.java b/Mage.Sets/src/mage/cards/s/SpiritOfTheLabyrinth.java index 31da7b75e8..48343e286f 100644 --- a/Mage.Sets/src/mage/cards/s/SpiritOfTheLabyrinth.java +++ b/Mage.Sets/src/mage/cards/s/SpiritOfTheLabyrinth.java @@ -113,7 +113,7 @@ class SpiritOfTheLabyrinthEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - SpiritOfTheLabyrinthWatcher watcher = (SpiritOfTheLabyrinthWatcher) game.getState().getWatchers().get(SpiritOfTheLabyrinthWatcher.class.getSimpleName()); + SpiritOfTheLabyrinthWatcher watcher = (SpiritOfTheLabyrinthWatcher) game.getState().getWatcher(SpiritOfTheLabyrinthWatcher.class); if (watcher != null && watcher.hasPlayerDrewCardThisTurn(event.getPlayerId())) { return true; } diff --git a/Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java b/Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java index 4a056003b4..de54e848be 100644 --- a/Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java +++ b/Mage.Sets/src/mage/cards/s/SpoilsOfBlood.java @@ -59,7 +59,7 @@ class SpoilsOfBloodEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - CreaturesDiedThisTurnWatcher watcher = (CreaturesDiedThisTurnWatcher) game.getState().getWatchers().get(CreaturesDiedThisTurnWatcher.class.getSimpleName()); + CreaturesDiedThisTurnWatcher watcher = (CreaturesDiedThisTurnWatcher) game.getState().getWatcher(CreaturesDiedThisTurnWatcher.class); if (watcher != null) { new CreateTokenEffect(new SpoilsOfBloodHorrorToken(watcher.creaturesDiedThisTurn)).apply(game, source); } @@ -80,7 +80,7 @@ class CreaturesDiedThisTurnWatcher extends Watcher { public int creaturesDiedThisTurn = 0; public CreaturesDiedThisTurnWatcher() { - super(CreaturesDiedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); + super(CreaturesDiedThisTurnWatcher.class, WatcherScope.GAME); } public CreaturesDiedThisTurnWatcher(final CreaturesDiedThisTurnWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/SteelHellkite.java b/Mage.Sets/src/mage/cards/s/SteelHellkite.java index 694efcbf18..abf6b92460 100644 --- a/Mage.Sets/src/mage/cards/s/SteelHellkite.java +++ b/Mage.Sets/src/mage/cards/s/SteelHellkite.java @@ -84,7 +84,7 @@ class SteelHellkiteDestroyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - SteelHellkiteWatcher watcher = (SteelHellkiteWatcher) game.getState().getWatchers().get(SteelHellkiteWatcher.class.getSimpleName()); + SteelHellkiteWatcher watcher = (SteelHellkiteWatcher) game.getState().getWatcher(SteelHellkiteWatcher.class); if (watcher == null || watcher.getDamagedPlayers(source.getSourceId()).isEmpty()) { return false; } @@ -104,7 +104,7 @@ class SteelHellkiteWatcher extends Watcher { private final Map> damageMap = new HashMap<>(); public SteelHellkiteWatcher() { - super(SteelHellkiteWatcher.class.getSimpleName(), WatcherScope.GAME); + super(SteelHellkiteWatcher.class, WatcherScope.GAME); } public SteelHellkiteWatcher(final SteelHellkiteWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/StormEntity.java b/Mage.Sets/src/mage/cards/s/StormEntity.java index 2635920bd0..367cf54800 100644 --- a/Mage.Sets/src/mage/cards/s/StormEntity.java +++ b/Mage.Sets/src/mage/cards/s/StormEntity.java @@ -54,7 +54,7 @@ class OtherSpellsCastThisTurnCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); if(watcher != null ) { return watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn() - 1; } diff --git a/Mage.Sets/src/mage/cards/s/SummoningTrap.java b/Mage.Sets/src/mage/cards/s/SummoningTrap.java index 8bc4391c42..8e50ecedc8 100644 --- a/Mage.Sets/src/mage/cards/s/SummoningTrap.java +++ b/Mage.Sets/src/mage/cards/s/SummoningTrap.java @@ -55,7 +55,7 @@ enum SummoningTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - SummoningTrapWatcher watcher = (SummoningTrapWatcher) game.getState().getWatchers().get(SummoningTrapWatcher.class.getSimpleName()); + SummoningTrapWatcher watcher = (SummoningTrapWatcher) game.getState().getWatcher(SummoningTrapWatcher.class); return watcher != null && watcher.creatureSpellOfPlayerWasCountered(source.getControllerId()); } @@ -70,7 +70,7 @@ class SummoningTrapWatcher extends Watcher { Set players = new HashSet<>(); public SummoningTrapWatcher() { - super(SummoningTrapWatcher.class.getSimpleName(), WatcherScope.GAME); + super(SummoningTrapWatcher.class, WatcherScope.GAME); } public SummoningTrapWatcher(final SummoningTrapWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/s/SupremeLeaderSnoke.java b/Mage.Sets/src/mage/cards/s/SupremeLeaderSnoke.java index c894340e3a..ddc01fed4f 100644 --- a/Mage.Sets/src/mage/cards/s/SupremeLeaderSnoke.java +++ b/Mage.Sets/src/mage/cards/s/SupremeLeaderSnoke.java @@ -95,7 +95,7 @@ class OpponentNoncombatLostLifeCount implements DynamicValue { @Override public int calculate(Game game, Ability source, Effect effect) { - PlayerLostLifeNonCombatWatcher watcher = (PlayerLostLifeNonCombatWatcher) game.getState().getWatchers().get(PlayerLostLifeNonCombatWatcher.class.getSimpleName()); + PlayerLostLifeNonCombatWatcher watcher = (PlayerLostLifeNonCombatWatcher) game.getState().getWatcher(PlayerLostLifeNonCombatWatcher.class); if(watcher != null) { return watcher.getAllOppLifeLost(source.getControllerId(), game); } diff --git a/Mage.Sets/src/mage/cards/s/SylvanLibrary.java b/Mage.Sets/src/mage/cards/s/SylvanLibrary.java index 751a5ab544..d7cc3e6033 100644 --- a/Mage.Sets/src/mage/cards/s/SylvanLibrary.java +++ b/Mage.Sets/src/mage/cards/s/SylvanLibrary.java @@ -72,7 +72,7 @@ class SylvanLibraryEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { controller.drawCards(2, game); - SylvanLibraryCardsDrawnThisTurnWatcher watcher = (SylvanLibraryCardsDrawnThisTurnWatcher) game.getState().getWatchers().get(SylvanLibraryCardsDrawnThisTurnWatcher.class.getSimpleName()); + SylvanLibraryCardsDrawnThisTurnWatcher watcher = (SylvanLibraryCardsDrawnThisTurnWatcher) game.getState().getWatcher(SylvanLibraryCardsDrawnThisTurnWatcher.class); if (watcher != null) { Cards cards = new CardsImpl(); Set cardsDrawnThisTurn = watcher.getCardsDrawnThisTurn(controller.getId()); @@ -119,7 +119,7 @@ class SylvanLibraryCardsDrawnThisTurnWatcher extends Watcher { private final Map> cardsDrawnThisTurn = new HashMap<>(); public SylvanLibraryCardsDrawnThisTurnWatcher() { - super(SylvanLibraryCardsDrawnThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); + super(SylvanLibraryCardsDrawnThisTurnWatcher.class, WatcherScope.GAME); } public SylvanLibraryCardsDrawnThisTurnWatcher(final SylvanLibraryCardsDrawnThisTurnWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/t/TaintedSigil.java b/Mage.Sets/src/mage/cards/t/TaintedSigil.java index d189045f4c..cea1c9d843 100644 --- a/Mage.Sets/src/mage/cards/t/TaintedSigil.java +++ b/Mage.Sets/src/mage/cards/t/TaintedSigil.java @@ -56,7 +56,7 @@ class AllPlayersLostLifeCount implements DynamicValue { } public int calculate(Game game, UUID controllerId) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatcher(PlayerLostLifeWatcher.class); if (watcher != null) { int amountLifeLost = 0; for (UUID playerId : game.getState().getPlayersInRange(controllerId, game)) { diff --git a/Mage.Sets/src/mage/cards/t/TalarasBattalion.java b/Mage.Sets/src/mage/cards/t/TalarasBattalion.java index c7ea37d9da..7db2318cf9 100644 --- a/Mage.Sets/src/mage/cards/t/TalarasBattalion.java +++ b/Mage.Sets/src/mage/cards/t/TalarasBattalion.java @@ -94,7 +94,7 @@ class CastGreenSpellThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - TalarasBattalionWatcher watcher = (TalarasBattalionWatcher) game.getState().getWatchers().get(TalarasBattalionWatcher.class.getSimpleName(), source.getControllerId()); + TalarasBattalionWatcher watcher = (TalarasBattalionWatcher) game.getState().getWatcher(TalarasBattalionWatcher.class, source.getControllerId()); if (watcher != null) { return watcher.conditionMet(); } @@ -112,7 +112,7 @@ class TalarasBattalionWatcher extends Watcher { private final UUID cardId; public TalarasBattalionWatcher(UUID cardId) { - super(TalarasBattalionWatcher.class.getSimpleName(), WatcherScope.PLAYER); + super(TalarasBattalionWatcher.class, WatcherScope.PLAYER); this.cardId = cardId; } diff --git a/Mage.Sets/src/mage/cards/t/TangleKelp.java b/Mage.Sets/src/mage/cards/t/TangleKelp.java index d4dde772df..b563b27194 100644 --- a/Mage.Sets/src/mage/cards/t/TangleKelp.java +++ b/Mage.Sets/src/mage/cards/t/TangleKelp.java @@ -107,7 +107,7 @@ class DontUntapIfAttackedLastTurnEnchantedEffect extends ContinuousRuleModifying if (enchantment != null && enchantment.getAttachedTo() != null && event.getTargetId().equals(enchantment.getAttachedTo())) { Permanent permanent = game.getPermanent(enchantment.getAttachedTo()); if (permanent != null && permanent.isControlledBy(game.getActivePlayerId())) { - AttackedLastTurnWatcher watcher = (AttackedLastTurnWatcher) game.getState().getWatchers().get(AttackedLastTurnWatcher.class.getSimpleName()); + AttackedLastTurnWatcher watcher = (AttackedLastTurnWatcher) game.getState().getWatcher(AttackedLastTurnWatcher.class); if (watcher != null) { Set attackingCreatures = watcher.getAttackedLastTurnCreatures(permanent.getControllerId()); MageObjectReference mor = new MageObjectReference(permanent, game); diff --git a/Mage.Sets/src/mage/cards/t/TapestryOfTheAges.java b/Mage.Sets/src/mage/cards/t/TapestryOfTheAges.java index 2cccde96c9..dcaa4ee476 100644 --- a/Mage.Sets/src/mage/cards/t/TapestryOfTheAges.java +++ b/Mage.Sets/src/mage/cards/t/TapestryOfTheAges.java @@ -56,7 +56,7 @@ enum PlayerCastNonCreatureSpellCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayerCastNonCreatureSpellWatcher watcher = (PlayerCastNonCreatureSpellWatcher) game.getState().getWatchers().get(PlayerCastNonCreatureSpellWatcher.class.getSimpleName()); + PlayerCastNonCreatureSpellWatcher watcher = (PlayerCastNonCreatureSpellWatcher) game.getState().getWatcher(PlayerCastNonCreatureSpellWatcher.class); return watcher != null && watcher.playerDidCastNonCreatureSpellThisTurn(source.getControllerId()); } @@ -71,7 +71,7 @@ class PlayerCastNonCreatureSpellWatcher extends Watcher { Set playerIds = new HashSet<>(); public PlayerCastNonCreatureSpellWatcher() { - super(PlayerCastNonCreatureSpellWatcher.class.getSimpleName(), WatcherScope.GAME); + super(PlayerCastNonCreatureSpellWatcher.class, WatcherScope.GAME); } public PlayerCastNonCreatureSpellWatcher(final PlayerCastNonCreatureSpellWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/t/TerritorialHellkite.java b/Mage.Sets/src/mage/cards/t/TerritorialHellkite.java index e5644379bc..7922cfc542 100644 --- a/Mage.Sets/src/mage/cards/t/TerritorialHellkite.java +++ b/Mage.Sets/src/mage/cards/t/TerritorialHellkite.java @@ -70,7 +70,7 @@ class AttackedLastCombatWatcher extends Watcher { public final Map> attackedLastCombatPlayers = new HashMap<>(); public AttackedLastCombatWatcher() { - super(AttackedLastCombatWatcher.class.getSimpleName(), WatcherScope.GAME); + super(AttackedLastCombatWatcher.class, WatcherScope.GAME); } public AttackedLastCombatWatcher(final AttackedLastCombatWatcher watcher) { @@ -132,7 +132,7 @@ class AttackIfAbleTargetRandoOpponentSourceEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - AttackedLastCombatWatcher watcher = (AttackedLastCombatWatcher) game.getState().getWatchers().get(AttackedLastCombatWatcher.class.getSimpleName()); + AttackedLastCombatWatcher watcher = (AttackedLastCombatWatcher) game.getState().getWatcher(AttackedLastCombatWatcher.class); if (controller != null && sourcePermanent != null && watcher != null) { List opponents = new ArrayList<>(); Map attackedPlayers = watcher.getAttackedLastCombatPlayers(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/t/TheChainVeil.java b/Mage.Sets/src/mage/cards/t/TheChainVeil.java index 21b0484c36..ae68754d6f 100644 --- a/Mage.Sets/src/mage/cards/t/TheChainVeil.java +++ b/Mage.Sets/src/mage/cards/t/TheChainVeil.java @@ -139,7 +139,7 @@ enum TheChainVeilCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - ActivatedLoyaltyAbilityWatcher watcher = (ActivatedLoyaltyAbilityWatcher) game.getState().getWatchers().get(ActivatedLoyaltyAbilityWatcher.class.getSimpleName()); + ActivatedLoyaltyAbilityWatcher watcher = (ActivatedLoyaltyAbilityWatcher) game.getState().getWatcher(ActivatedLoyaltyAbilityWatcher.class); if (watcher != null) { if (!watcher.activatedLoyaltyAbility(source.getControllerId())) { return true; diff --git a/Mage.Sets/src/mage/cards/t/TheFallen.java b/Mage.Sets/src/mage/cards/t/TheFallen.java index 8676d61c57..e28e8cc1aa 100644 --- a/Mage.Sets/src/mage/cards/t/TheFallen.java +++ b/Mage.Sets/src/mage/cards/t/TheFallen.java @@ -62,7 +62,7 @@ class TheFallenEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - TheFallenWatcher watcher = (TheFallenWatcher) game.getState().getWatchers().get(TheFallenWatcher.class.getSimpleName()); + TheFallenWatcher watcher = (TheFallenWatcher) game.getState().getWatcher(TheFallenWatcher.class); if (watcher != null && watcher.getPlayersAndWalkersDealtDamageThisGame(source.getSourceId()) != null) { for (UUID playerId : watcher.getPlayersAndWalkersDealtDamageThisGame(source.getSourceId())) { if (!source.isControlledBy(playerId)) { @@ -80,7 +80,7 @@ class TheFallenWatcher extends Watcher { private Map> playersAndWalkersDealtDamageThisGame = new HashMap<>(); // Map> public TheFallenWatcher() { - super(TheFallenWatcher.class.getSimpleName(), WatcherScope.GAME); + super(TheFallenWatcher.class, WatcherScope.GAME); } public TheFallenWatcher(final TheFallenWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/t/ThirstingAxe.java b/Mage.Sets/src/mage/cards/t/ThirstingAxe.java index c9134558f4..fe76f09921 100644 --- a/Mage.Sets/src/mage/cards/t/ThirstingAxe.java +++ b/Mage.Sets/src/mage/cards/t/ThirstingAxe.java @@ -72,7 +72,7 @@ class EquippedDealtCombatDamageToCreatureCondition implements Condition { Permanent equipment = game.getPermanent(source.getSourceId()); if (equipment != null && equipment.getAttachedTo() != null) { CombatDamageToCreatureWatcher watcher = - (CombatDamageToCreatureWatcher) game.getState().getWatchers().get(CombatDamageToCreatureWatcher.BASIC_KEY); + game.getState().getWatcher(CombatDamageToCreatureWatcher.class); return watcher != null && watcher.dealtDamage(equipment.getAttachedTo(), equipment.getAttachedToZoneChangeCounter(), game); } return false; diff --git a/Mage.Sets/src/mage/cards/t/ThousandYearStorm.java b/Mage.Sets/src/mage/cards/t/ThousandYearStorm.java index 83c624009a..b238a6fad7 100644 --- a/Mage.Sets/src/mage/cards/t/ThousandYearStorm.java +++ b/Mage.Sets/src/mage/cards/t/ThousandYearStorm.java @@ -63,7 +63,7 @@ class ThousandYearStormEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Spell spell = game.getSpellOrLKIStack(getTargetPointer().getFirst(game, source)); if (spell != null) { - ThousandYearWatcher watcher = (ThousandYearWatcher) game.getState().getWatchers().get(ThousandYearWatcher.class.getSimpleName()); + ThousandYearWatcher watcher = (ThousandYearWatcher) game.getState().getWatcher(ThousandYearWatcher.class); if (watcher != null) { int numberOfCopies = watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) - 1; if (numberOfCopies > 0) { diff --git a/Mage.Sets/src/mage/cards/t/ThrillingEncore.java b/Mage.Sets/src/mage/cards/t/ThrillingEncore.java index 67043f5be8..31faffcd6b 100644 --- a/Mage.Sets/src/mage/cards/t/ThrillingEncore.java +++ b/Mage.Sets/src/mage/cards/t/ThrillingEncore.java @@ -58,7 +58,7 @@ class ThrillingEncoreEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get(CardsPutIntoGraveyardWatcher.class.getSimpleName()); + CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class); if (watcher != null) { for (MageObjectReference mor : watcher.getCardsPutToGraveyardFromBattlefield()) { if (game.getState().getZoneChangeCounter(mor.getSourceId()) == mor.getZoneChangeCounter()) { diff --git a/Mage.Sets/src/mage/cards/t/TimeToReflect.java b/Mage.Sets/src/mage/cards/t/TimeToReflect.java index 3ac0599ba4..7629b71b2d 100644 --- a/Mage.Sets/src/mage/cards/t/TimeToReflect.java +++ b/Mage.Sets/src/mage/cards/t/TimeToReflect.java @@ -42,7 +42,7 @@ public final class TimeToReflect extends CardImpl { if (ability instanceof SpellAbility) { List creaturesThatBlockedOrWereBlockedByAZombie = new ArrayList<>(); FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that blocked or was blocked by a Zombie this turn.").copy(); - BlockedOrWasBlockedByAZombieWatcher watcher = (BlockedOrWasBlockedByAZombieWatcher) game.getState().getWatchers().get(BlockedOrWasBlockedByAZombieWatcher.class.getSimpleName()); + BlockedOrWasBlockedByAZombieWatcher watcher = (BlockedOrWasBlockedByAZombieWatcher) game.getState().getWatcher(BlockedOrWasBlockedByAZombieWatcher.class); if (watcher != null) { for (MageObjectReference mor : watcher.getBlockedThisTurnCreatures()) { Permanent permanent = mor.getPermanent(game); @@ -72,7 +72,7 @@ class BlockedOrWasBlockedByAZombieWatcher extends Watcher { private final Set blockedOrWasBlockedByAZombieWatcher; public BlockedOrWasBlockedByAZombieWatcher() { - super(BlockedOrWasBlockedByAZombieWatcher.class.getSimpleName(), WatcherScope.GAME); + super(BlockedOrWasBlockedByAZombieWatcher.class, WatcherScope.GAME); blockedOrWasBlockedByAZombieWatcher = new HashSet<>(); } diff --git a/Mage.Sets/src/mage/cards/t/TotalWar.java b/Mage.Sets/src/mage/cards/t/TotalWar.java index 9527151324..99234465ae 100644 --- a/Mage.Sets/src/mage/cards/t/TotalWar.java +++ b/Mage.Sets/src/mage/cards/t/TotalWar.java @@ -107,7 +107,7 @@ class TotalWarDestroyEffect extends OneShotEffect { continue; } // Creatures that attacked are safe. - AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatchers().get(AttackedOrBlockedThisCombatWatcher.class.getSimpleName()); + AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatcher(AttackedOrBlockedThisCombatWatcher.class); if (watcher != null && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game))) { continue; diff --git a/Mage.Sets/src/mage/cards/t/TunnelIgnus.java b/Mage.Sets/src/mage/cards/t/TunnelIgnus.java index 56eb26d80f..5d65a58905 100644 --- a/Mage.Sets/src/mage/cards/t/TunnelIgnus.java +++ b/Mage.Sets/src/mage/cards/t/TunnelIgnus.java @@ -53,7 +53,7 @@ class TunnelIgnusWatcher extends Watcher { protected Map counts = new HashMap<>(); public TunnelIgnusWatcher() { - super(TunnelIgnusWatcher.class.getSimpleName(), WatcherScope.PLAYER); + super(TunnelIgnusWatcher.class, WatcherScope.PLAYER); } public TunnelIgnusWatcher(final TunnelIgnusWatcher watcher) { @@ -111,7 +111,7 @@ class TunnelIgnusTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.isLand() && game.getOpponents(this.controllerId).contains(permanent.getControllerId())) { - TunnelIgnusWatcher watcher = (TunnelIgnusWatcher) game.getState().getWatchers().get(TunnelIgnusWatcher.class.getSimpleName(), this.controllerId); + TunnelIgnusWatcher watcher = (TunnelIgnusWatcher) game.getState().getWatcher(TunnelIgnusWatcher.class, this.controllerId); if (watcher != null && watcher.counts.get(permanent.getControllerId()) > 1) { for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(permanent.getControllerId())); diff --git a/Mage.Sets/src/mage/cards/t/TuvasaTheSunlit.java b/Mage.Sets/src/mage/cards/t/TuvasaTheSunlit.java index 425cf9f478..85e75029b8 100644 --- a/Mage.Sets/src/mage/cards/t/TuvasaTheSunlit.java +++ b/Mage.Sets/src/mage/cards/t/TuvasaTheSunlit.java @@ -95,8 +95,8 @@ class TuvasaTheSunlitTriggeredAbility extends SpellCastControllerTriggeredAbilit @Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { - TuvasaTheSunlitWatcher watcher = (TuvasaTheSunlitWatcher) game.getState().getWatchers().get( - TuvasaTheSunlitWatcher.class.getSimpleName() + TuvasaTheSunlitWatcher watcher = (TuvasaTheSunlitWatcher) game.getState().getWatcher( + TuvasaTheSunlitWatcher.class ); return watcher != null && event.getTargetId().equals(watcher.getFirstEnchantmentThisTurn(this.getControllerId())); } @@ -119,7 +119,7 @@ class TuvasaTheSunlitWatcher extends Watcher { private final Map firstEnchantmentThisTurn = new HashMap(); public TuvasaTheSunlitWatcher() { - super(TuvasaTheSunlitWatcher.class.getSimpleName(), WatcherScope.GAME); + super(TuvasaTheSunlitWatcher.class, WatcherScope.GAME); } public TuvasaTheSunlitWatcher(final TuvasaTheSunlitWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/t/TwilightShepherd.java b/Mage.Sets/src/mage/cards/t/TwilightShepherd.java index fe12c72f72..8a98334cfa 100644 --- a/Mage.Sets/src/mage/cards/t/TwilightShepherd.java +++ b/Mage.Sets/src/mage/cards/t/TwilightShepherd.java @@ -81,7 +81,7 @@ class TwilightShepherdEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatchers().get(CardsPutIntoGraveyardWatcher.class.getSimpleName()); + CardsPutIntoGraveyardWatcher watcher = (CardsPutIntoGraveyardWatcher) game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && watcher != null) { Set cardsInGraveyard = watcher.getCardsPutToGraveyardFromBattlefield(); diff --git a/Mage.Sets/src/mage/cards/t/TwinningGlass.java b/Mage.Sets/src/mage/cards/t/TwinningGlass.java index 71c723922f..1c3753bf09 100644 --- a/Mage.Sets/src/mage/cards/t/TwinningGlass.java +++ b/Mage.Sets/src/mage/cards/t/TwinningGlass.java @@ -75,7 +75,7 @@ class TwinningGlassEffect extends OneShotEffect { filterCard.add(Predicates.not(new CardTypePredicate(CardType.LAND))); Permanent twinningGlass = game.getPermanent(source.getSourceId()); Player controller = game.getPlayer(source.getControllerId()); - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class); if (twinningGlass == null) { twinningGlass = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); } diff --git a/Mage.Sets/src/mage/cards/t/TymnaTheWeaver.java b/Mage.Sets/src/mage/cards/t/TymnaTheWeaver.java index 087b53f304..f234557217 100644 --- a/Mage.Sets/src/mage/cards/t/TymnaTheWeaver.java +++ b/Mage.Sets/src/mage/cards/t/TymnaTheWeaver.java @@ -76,7 +76,7 @@ class TymnaTheWeaverEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - TymnaTheWeaverWatcher watcher = (TymnaTheWeaverWatcher) game.getState().getWatchers().get(TymnaTheWeaverWatcher.class.getSimpleName()); + TymnaTheWeaverWatcher watcher = (TymnaTheWeaverWatcher) game.getState().getWatcher(TymnaTheWeaverWatcher.class); if (watcher != null) { int cardsToDraw = watcher.opponentsThatGotCombatDamage(source.getControllerId(), game); Cost cost = new PayLifeCost(cardsToDraw); @@ -97,7 +97,7 @@ class TymnaTheWeaverWatcher extends Watcher { private final Map> players = new HashMap<>(); public TymnaTheWeaverWatcher() { - super(TymnaTheWeaverWatcher.class.getSimpleName(), WatcherScope.GAME); + super(TymnaTheWeaverWatcher.class, WatcherScope.GAME); } public TymnaTheWeaverWatcher(final TymnaTheWeaverWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/u/UbaMask.java b/Mage.Sets/src/mage/cards/u/UbaMask.java index 94e4fdad29..8b4257c305 100644 --- a/Mage.Sets/src/mage/cards/u/UbaMask.java +++ b/Mage.Sets/src/mage/cards/u/UbaMask.java @@ -68,7 +68,7 @@ class UbaMaskReplacementEffect extends ReplacementEffectImpl { Card card = player.getLibrary().getFromTop(game); if (card != null) { if (player.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName())) { - UbaMaskExiledCardsWatcher watcher = (UbaMaskExiledCardsWatcher) game.getState().getWatchers().get(UbaMaskExiledCardsWatcher.class.getSimpleName()); + UbaMaskExiledCardsWatcher watcher = (UbaMaskExiledCardsWatcher) game.getState().getWatcher(UbaMaskExiledCardsWatcher.class); if (watcher != null) { watcher.addExiledCard(event.getPlayerId(), card, game); } @@ -116,7 +116,7 @@ class UbaMaskPlayEffect extends AsThoughEffectImpl { if (card != null && affectedControllerId.equals(card.getOwnerId()) && game.getState().getZone(card.getId()) == Zone.EXILED) { - UbaMaskExiledCardsWatcher watcher = (UbaMaskExiledCardsWatcher) game.getState().getWatchers().get(UbaMaskExiledCardsWatcher.class.getSimpleName()); + UbaMaskExiledCardsWatcher watcher = (UbaMaskExiledCardsWatcher) game.getState().getWatcher(UbaMaskExiledCardsWatcher.class); if (watcher != null) { List exiledThisTurn = watcher.getUbaMaskExiledCardsThisTurn(affectedControllerId); return exiledThisTurn != null @@ -132,7 +132,7 @@ class UbaMaskExiledCardsWatcher extends Watcher { private final Map> exiledCards = new HashMap<>(); public UbaMaskExiledCardsWatcher() { - super(UbaMaskExiledCardsWatcher.class.getSimpleName(), WatcherScope.GAME); + super(UbaMaskExiledCardsWatcher.class, WatcherScope.GAME); } public UbaMaskExiledCardsWatcher(final UbaMaskExiledCardsWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/u/UphillBattle.java b/Mage.Sets/src/mage/cards/u/UphillBattle.java index c64a2c8085..051225d86f 100644 --- a/Mage.Sets/src/mage/cards/u/UphillBattle.java +++ b/Mage.Sets/src/mage/cards/u/UphillBattle.java @@ -50,7 +50,7 @@ class PlayCreatureLandWatcher extends Watcher { final Set landPlayed = new HashSet<>(); // land played public PlayCreatureLandWatcher() { - super(PlayCreatureLandWatcher.class.getSimpleName(), WatcherScope.GAME); + super(PlayCreatureLandWatcher.class, WatcherScope.GAME); } public PlayCreatureLandWatcher(final PlayCreatureLandWatcher watcher) { @@ -108,8 +108,8 @@ class UphillBattleTapEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent target = ((EntersTheBattlefieldEvent) event).getTarget(); - CreatureWasCastWatcher creatureSpellWatcher = (CreatureWasCastWatcher) game.getState().getWatchers().get(CreatureWasCastWatcher.class.getSimpleName()); - PlayCreatureLandWatcher landWatcher = (PlayCreatureLandWatcher) game.getState().getWatchers().get(PlayCreatureLandWatcher.class.getSimpleName()); + CreatureWasCastWatcher creatureSpellWatcher = (CreatureWasCastWatcher) game.getState().getWatcher(CreatureWasCastWatcher.class); + PlayCreatureLandWatcher landWatcher = (PlayCreatureLandWatcher) game.getState().getWatcher(PlayCreatureLandWatcher.class); if (target != null && ((creatureSpellWatcher != null && creatureSpellWatcher.wasCreatureCastThisTurn(target.getId())) diff --git a/Mage.Sets/src/mage/cards/u/UrborgJustice.java b/Mage.Sets/src/mage/cards/u/UrborgJustice.java index 526a940374..7bd5f51bde 100644 --- a/Mage.Sets/src/mage/cards/u/UrborgJustice.java +++ b/Mage.Sets/src/mage/cards/u/UrborgJustice.java @@ -61,7 +61,7 @@ class UrborgJusticeDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatchers().get(CreaturesDiedWatcher.class.getSimpleName()); + CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatcher(CreaturesDiedWatcher.class); if (watcher != null) { return watcher.getAmountOfCreaturesDiedThisTurnByOwner(sourceAbility.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/u/UrzasMiter.java b/Mage.Sets/src/mage/cards/u/UrzasMiter.java index 90575263f6..1d67482dee 100644 --- a/Mage.Sets/src/mage/cards/u/UrzasMiter.java +++ b/Mage.Sets/src/mage/cards/u/UrzasMiter.java @@ -60,7 +60,7 @@ class UrzasMiterDoIfCostPaid extends DoIfCostPaid { @Override public boolean apply(Game game, Ability source) { - UrzasMiterWatcher watcher = (UrzasMiterWatcher) game.getState().getWatchers().get(UrzasMiterWatcher.class.getSimpleName()); + UrzasMiterWatcher watcher = (UrzasMiterWatcher) game.getState().getWatcher(UrzasMiterWatcher.class); if(watcher != null && !watcher.cards.contains(source.getFirstTarget())) { return super.apply(game, source); } @@ -74,7 +74,7 @@ class UrzasMiterWatcher extends Watcher { List cards; public UrzasMiterWatcher() { - super(UrzasMiterWatcher.class.getSimpleName(), WatcherScope.PLAYER); + super(UrzasMiterWatcher.class, WatcherScope.PLAYER); this.cards = new ArrayList<>(); } diff --git a/Mage.Sets/src/mage/cards/v/VancesBlastingCannons.java b/Mage.Sets/src/mage/cards/v/VancesBlastingCannons.java index e69e0dc634..2a3f509f6a 100644 --- a/Mage.Sets/src/mage/cards/v/VancesBlastingCannons.java +++ b/Mage.Sets/src/mage/cards/v/VancesBlastingCannons.java @@ -152,7 +152,7 @@ class VancesBlastingCannonsFlipTrigger extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(controllerId)) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 3) { return true; } diff --git a/Mage.Sets/src/mage/cards/v/VeneratedLoxodon.java b/Mage.Sets/src/mage/cards/v/VeneratedLoxodon.java index 34a41b9ab4..4588a1f8da 100644 --- a/Mage.Sets/src/mage/cards/v/VeneratedLoxodon.java +++ b/Mage.Sets/src/mage/cards/v/VeneratedLoxodon.java @@ -74,7 +74,7 @@ class VeneratedLoxodonEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - VeneratedLoxodonWatcher watcher = (VeneratedLoxodonWatcher) game.getState().getWatchers().get(VeneratedLoxodonWatcher.class.getSimpleName()); + VeneratedLoxodonWatcher watcher = (VeneratedLoxodonWatcher) game.getState().getWatcher(VeneratedLoxodonWatcher.class); if (watcher != null) { MageObjectReference mor = new MageObjectReference(source.getSourceId(), source.getSourceObjectZoneChangeCounter() - 1, game); // -1 because of spell on the stack Set creatures = watcher.getConvokingCreatures(mor); @@ -97,7 +97,7 @@ class VeneratedLoxodonWatcher extends Watcher { private final Map> convokingCreatures = new HashMap<>(); public VeneratedLoxodonWatcher() { - super(VeneratedLoxodonWatcher.class.getSimpleName(), WatcherScope.GAME); + super(VeneratedLoxodonWatcher.class, WatcherScope.GAME); } public VeneratedLoxodonWatcher(final VeneratedLoxodonWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/v/Vengevine.java b/Mage.Sets/src/mage/cards/v/Vengevine.java index 4c179aaedd..fd46580314 100644 --- a/Mage.Sets/src/mage/cards/v/Vengevine.java +++ b/Mage.Sets/src/mage/cards/v/Vengevine.java @@ -70,7 +70,7 @@ class VengevineAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(controllerId)) { - Watcher watcher = game.getState().getWatchers().get(VengevineWatcher.class.getSimpleName(), controllerId); + Watcher watcher = game.getState().getWatcher(VengevineWatcher.class, controllerId); if (watcher != null && watcher.conditionMet()) { return true; } @@ -91,7 +91,7 @@ class VengevineWatcher extends Watcher { int creatureSpellCount = 0; public VengevineWatcher() { - super(VengevineWatcher.class.getSimpleName(), WatcherScope.PLAYER); + super(VengevineWatcher.class, WatcherScope.PLAYER); } public VengevineWatcher(final VengevineWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/v/VenomousBreath.java b/Mage.Sets/src/mage/cards/v/VenomousBreath.java index 5741e3df3a..c59b4c585b 100644 --- a/Mage.Sets/src/mage/cards/v/VenomousBreath.java +++ b/Mage.Sets/src/mage/cards/v/VenomousBreath.java @@ -97,7 +97,7 @@ class VenomousBreathEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null && targetCreature != null) { - BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); + BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatcher(BlockedAttackerWatcher.class); if (watcher != null) { List toDestroy = new ArrayList<>(); for (Permanent creature : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) { diff --git a/Mage.Sets/src/mage/cards/v/VialSmasherTheFierce.java b/Mage.Sets/src/mage/cards/v/VialSmasherTheFierce.java index 2f6d1d3d3f..e9c9d4d48f 100644 --- a/Mage.Sets/src/mage/cards/v/VialSmasherTheFierce.java +++ b/Mage.Sets/src/mage/cards/v/VialSmasherTheFierce.java @@ -78,7 +78,7 @@ class VialSmasherTheFierceTriggeredAbility extends SpellCastControllerTriggeredA @Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatcher(SpellsCastWatcher.class); if (watcher != null) { List spells = watcher.getSpellsCastThisTurn(event.getPlayerId()); if (spells != null && spells.size() == 1) { diff --git a/Mage.Sets/src/mage/cards/v/VileRedeemer.java b/Mage.Sets/src/mage/cards/v/VileRedeemer.java index 134fb3934d..9a213b233f 100644 --- a/Mage.Sets/src/mage/cards/v/VileRedeemer.java +++ b/Mage.Sets/src/mage/cards/v/VileRedeemer.java @@ -79,7 +79,7 @@ class VileRedeemerEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - VileRedeemerNonTokenCreaturesDiedWatcher watcher = (VileRedeemerNonTokenCreaturesDiedWatcher) game.getState().getWatchers().get(VileRedeemerNonTokenCreaturesDiedWatcher.class.getSimpleName()); + VileRedeemerNonTokenCreaturesDiedWatcher watcher = (VileRedeemerNonTokenCreaturesDiedWatcher) game.getState().getWatcher(VileRedeemerNonTokenCreaturesDiedWatcher.class); if (watcher != null) { int amount = watcher.getAmountOfNontokenCreatureDiedThisTurn(controller.getId()); if (amount > 0) { diff --git a/Mage.Sets/src/mage/cards/v/VizierOfDeferment.java b/Mage.Sets/src/mage/cards/v/VizierOfDeferment.java index 227ecc40a8..cde3531f21 100644 --- a/Mage.Sets/src/mage/cards/v/VizierOfDeferment.java +++ b/Mage.Sets/src/mage/cards/v/VizierOfDeferment.java @@ -60,8 +60,8 @@ public final class VizierOfDeferment extends CardImpl { if (ability instanceof EntersBattlefieldTriggeredAbility) { List creaturesThatCanBeTargeted = new ArrayList<>(); FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that attacked or blocked this turn."); - AttackedThisTurnWatcher watcherAttacked = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); - BlockedThisTurnWatcher watcherBlocked = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcherAttacked = (AttackedThisTurnWatcher) game.getState().getWatcher(AttackedThisTurnWatcher.class); + BlockedThisTurnWatcher watcherBlocked = (BlockedThisTurnWatcher) game.getState().getWatcher(BlockedThisTurnWatcher.class); if (watcherAttacked != null) { for (MageObjectReference mor : watcherAttacked.getAttackedThisTurnCreatures()) { Permanent permanent = mor.getPermanent(game); diff --git a/Mage.Sets/src/mage/cards/v/VizierOfManyFaces.java b/Mage.Sets/src/mage/cards/v/VizierOfManyFaces.java index 39c9d7a529..a4583ecc9e 100644 --- a/Mage.Sets/src/mage/cards/v/VizierOfManyFaces.java +++ b/Mage.Sets/src/mage/cards/v/VizierOfManyFaces.java @@ -72,7 +72,7 @@ class VizierOfManyFacesApplyToPermanent extends ApplyToPermanent { for (Permanent entering : game.getPermanentsEntering().values()) { if (entering.getId().equals(copyToObjectId) && entering instanceof PermanentToken) { UUID originalCardId = ((PermanentToken) entering).getToken().getCopySourceCard().getId(); - EmbalmedThisTurnWatcher watcher = (EmbalmedThisTurnWatcher) game.getState().getWatchers().get(EmbalmedThisTurnWatcher.class.getSimpleName()); + EmbalmedThisTurnWatcher watcher = (EmbalmedThisTurnWatcher) game.getState().getWatcher(EmbalmedThisTurnWatcher.class); if (watcher != null) { for (MageObjectReference mor : watcher.getEmbalmedThisTurnCards()) { if (mor.getSourceId().equals(originalCardId) && game.getState().getZoneChangeCounter(originalCardId) == mor.getZoneChangeCounter()) { @@ -97,7 +97,7 @@ class EmbalmedThisTurnWatcher extends Watcher { private final Set embalmedThisTurnTokens; public EmbalmedThisTurnWatcher() { - super(EmbalmedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME); + super(EmbalmedThisTurnWatcher.class, WatcherScope.GAME); embalmedThisTurnTokens = new HashSet<>(); } diff --git a/Mage.Sets/src/mage/cards/v/VodalianWarMachine.java b/Mage.Sets/src/mage/cards/v/VodalianWarMachine.java index 85ee063331..bbc9b854b5 100644 --- a/Mage.Sets/src/mage/cards/v/VodalianWarMachine.java +++ b/Mage.Sets/src/mage/cards/v/VodalianWarMachine.java @@ -143,7 +143,7 @@ class VodalianWarMachineEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourcePermanent != null) { - VodalianWarMachineWatcher watcher = (VodalianWarMachineWatcher) game.getState().getWatchers().get(VodalianWarMachineWatcher.class.getSimpleName()); + VodalianWarMachineWatcher watcher = (VodalianWarMachineWatcher) game.getState().getWatcher(VodalianWarMachineWatcher.class); if (watcher != null && watcher.getTappedMerfolkIds(sourcePermanent, game) != null) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { if (watcher.getTappedMerfolkIds(sourcePermanent, game).contains(new MageObjectReference(permanent, game))) { @@ -163,7 +163,7 @@ class VodalianWarMachineWatcher extends Watcher { public Map> tappedMerfolkIds = new HashMap<>(); public VodalianWarMachineWatcher() { - super(VodalianWarMachineWatcher.class.getSimpleName(), WatcherScope.GAME); + super(VodalianWarMachineWatcher.class, WatcherScope.GAME); } public VodalianWarMachineWatcher(final VodalianWarMachineWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/w/WarElemental.java b/Mage.Sets/src/mage/cards/w/WarElemental.java index ff55ba6e77..08fdeccdaa 100644 --- a/Mage.Sets/src/mage/cards/w/WarElemental.java +++ b/Mage.Sets/src/mage/cards/w/WarElemental.java @@ -116,7 +116,7 @@ class OpponentWasDealtDamageCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); + BloodthirstWatcher watcher = game.getState().getWatcher(BloodthirstWatcher.class, source.getControllerId()); return watcher != null && watcher.conditionMet(); } diff --git a/Mage.Sets/src/mage/cards/w/WhiplashTrap.java b/Mage.Sets/src/mage/cards/w/WhiplashTrap.java index 0abe74629c..26be4131c9 100644 --- a/Mage.Sets/src/mage/cards/w/WhiplashTrap.java +++ b/Mage.Sets/src/mage/cards/w/WhiplashTrap.java @@ -52,7 +52,7 @@ enum WhiplashTrapCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PermanentsEnteredBattlefieldWatcher watcher = (PermanentsEnteredBattlefieldWatcher) game.getState().getWatchers().get(PermanentsEnteredBattlefieldWatcher.class.getSimpleName()); + PermanentsEnteredBattlefieldWatcher watcher = game.getState().getWatcher(PermanentsEnteredBattlefieldWatcher.class); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { List permanents = watcher.getThisTurnEnteringPermanents(opponentId); diff --git a/Mage.Sets/src/mage/cards/w/WhisperingSnitch.java b/Mage.Sets/src/mage/cards/w/WhisperingSnitch.java index 6d88e9d1af..baa075c2b9 100644 --- a/Mage.Sets/src/mage/cards/w/WhisperingSnitch.java +++ b/Mage.Sets/src/mage/cards/w/WhisperingSnitch.java @@ -66,7 +66,7 @@ class WhisperingSnitchTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(getControllerId())) { - WhisperingSnitchWatcher watcher = (WhisperingSnitchWatcher) game.getState().getWatchers().get(WhisperingSnitchWatcher.class.getSimpleName()); + WhisperingSnitchWatcher watcher = game.getState().getWatcher(WhisperingSnitchWatcher.class); return watcher != null && watcher.getTimesSurveiled(getControllerId()) == 1; } return false; @@ -89,7 +89,7 @@ class WhisperingSnitchWatcher extends Watcher { private final Map timesSurveiled = new HashMap<>(); public WhisperingSnitchWatcher() { - super(WhisperingSnitchWatcher.class.getSimpleName(), WatcherScope.GAME); + super(WhisperingSnitchWatcher.class, WatcherScope.GAME); } public WhisperingSnitchWatcher(final WhisperingSnitchWatcher watcher) { diff --git a/Mage.Sets/src/mage/cards/w/WickedAkuba.java b/Mage.Sets/src/mage/cards/w/WickedAkuba.java index 5b430956d8..f79b54064d 100644 --- a/Mage.Sets/src/mage/cards/w/WickedAkuba.java +++ b/Mage.Sets/src/mage/cards/w/WickedAkuba.java @@ -60,7 +60,7 @@ class WickedAkubaPredicate implements ObjectSourcePlayerPredicate input, Game game) { - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), input.getObject().getId()); + PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, input.getObject().getId()); if (watcher != null) { return watcher.hasSourceDoneDamage(input.getSourceId(), game); } diff --git a/Mage.Sets/src/mage/cards/w/WildPair.java b/Mage.Sets/src/mage/cards/w/WildPair.java index ee5d269b22..84eb87403b 100644 --- a/Mage.Sets/src/mage/cards/w/WildPair.java +++ b/Mage.Sets/src/mage/cards/w/WildPair.java @@ -135,7 +135,7 @@ class CastFromHandTargetCondition implements Condition { return false; } } - CastFromHandWatcher watcher = (CastFromHandWatcher) game.getState().getWatchers().get(CastFromHandWatcher.class.getSimpleName()); + CastFromHandWatcher watcher = (CastFromHandWatcher) game.getState().getWatcher(CastFromHandWatcher.class); if (watcher != null && watcher.spellWasCastFromHand(targetId)) { return true; } diff --git a/Mage.Sets/src/mage/cards/w/WindbriskHeights.java b/Mage.Sets/src/mage/cards/w/WindbriskHeights.java index 6777d79f33..d24dd98d9a 100644 --- a/Mage.Sets/src/mage/cards/w/WindbriskHeights.java +++ b/Mage.Sets/src/mage/cards/w/WindbriskHeights.java @@ -54,7 +54,7 @@ enum WindbriskHeightsAttackersCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get(PlayerAttackedWatcher.class.getSimpleName()); + PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatcher(PlayerAttackedWatcher.class); return watcher != null && watcher.getNumberOfAttackersCurrentTurn(source.getControllerId()) >= 3; } diff --git a/Mage.Sets/src/mage/cards/w/WorldAtWar.java b/Mage.Sets/src/mage/cards/w/WorldAtWar.java index 0658ecda70..01dbdcae33 100644 --- a/Mage.Sets/src/mage/cards/w/WorldAtWar.java +++ b/Mage.Sets/src/mage/cards/w/WorldAtWar.java @@ -142,7 +142,7 @@ class UntapAttackingThisTurnEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + Watcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); if (watcher instanceof AttackedThisTurnWatcher) { Set attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures(); for (MageObjectReference mor : attackedThisTurn) { diff --git a/Mage.Sets/src/mage/cards/w/WoundReflection.java b/Mage.Sets/src/mage/cards/w/WoundReflection.java index 408a349715..c91bcf02fc 100644 --- a/Mage.Sets/src/mage/cards/w/WoundReflection.java +++ b/Mage.Sets/src/mage/cards/w/WoundReflection.java @@ -57,7 +57,7 @@ class WoundReflectionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatcher(PlayerLostLifeWatcher.class); if (controller != null && watcher != null) { for (UUID playerId : game.getOpponents(controller.getId())) { Player opponent = game.getPlayer(playerId); diff --git a/Mage.Sets/src/mage/cards/y/YdwenEfreet.java b/Mage.Sets/src/mage/cards/y/YdwenEfreet.java index b1dd810f90..9051ac2ca0 100644 --- a/Mage.Sets/src/mage/cards/y/YdwenEfreet.java +++ b/Mage.Sets/src/mage/cards/y/YdwenEfreet.java @@ -65,7 +65,7 @@ class YdwenEfreetEffect extends OneShotEffect { creature.setMaxBlocks(0); // Make blocked creatures unblocked - BlockedByOnlyOneCreatureThisCombatWatcher watcher = (BlockedByOnlyOneCreatureThisCombatWatcher) game.getState().getWatchers().get(BlockedByOnlyOneCreatureThisCombatWatcher.class.getSimpleName()); + BlockedByOnlyOneCreatureThisCombatWatcher watcher = game.getState().getWatcher(BlockedByOnlyOneCreatureThisCombatWatcher.class); if (watcher != null) { Set combatGroups = watcher.getBlockedOnlyByCreature(creature.getId()); if (combatGroups != null) { diff --git a/Mage/src/main/java/mage/abilities/common/AttacksFirstTimeTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksFirstTimeTriggeredAbility.java index 8cef6957df..6c0af59f42 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksFirstTimeTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksFirstTimeTriggeredAbility.java @@ -35,7 +35,7 @@ public class AttacksFirstTimeTriggeredAbility extends TriggeredAbilityImpl { if (!event.getSourceId().equals(this.getSourceId())) { return false; } - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); if (watcher == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/AttackedOrBlockedThisCombatSourceCondition.java b/Mage/src/main/java/mage/abilities/condition/common/AttackedOrBlockedThisCombatSourceCondition.java index ef4a90dc6c..17ee4adf33 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/AttackedOrBlockedThisCombatSourceCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/AttackedOrBlockedThisCombatSourceCondition.java @@ -24,7 +24,7 @@ public enum AttackedOrBlockedThisCombatSourceCondition implements Condition { public boolean apply(Game game, Ability source) { Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourceObject != null) { - AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatchers().get(AttackedOrBlockedThisCombatWatcher.class.getSimpleName()); + AttackedOrBlockedThisCombatWatcher watcher = game.getState().getWatcher(AttackedOrBlockedThisCombatWatcher.class); if (watcher != null) { for (MageObjectReference mor : watcher.getAttackedThisTurnCreatures()) { if (mor.refersTo(sourceObject, game)) { diff --git a/Mage/src/main/java/mage/abilities/condition/common/AttackedThisStepCondition.java b/Mage/src/main/java/mage/abilities/condition/common/AttackedThisStepCondition.java index babbd9580c..026ae5b498 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/AttackedThisStepCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/AttackedThisStepCondition.java @@ -15,7 +15,7 @@ public enum AttackedThisStepCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayerAttackedStepWatcher watcher = (PlayerAttackedStepWatcher) game.getState().getWatchers().get(PlayerAttackedStepWatcher.class.getSimpleName()); + PlayerAttackedStepWatcher watcher = game.getState().getWatcher(PlayerAttackedStepWatcher.class); return watcher != null && watcher.getNumberAttackingCurrentStep(source.getControllerId()) > 0; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/AttackedThisTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/AttackedThisTurnCondition.java index ccd336f20a..5ee7dfb4a8 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/AttackedThisTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/AttackedThisTurnCondition.java @@ -19,7 +19,7 @@ public enum AttackedThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); return watcher != null && !watcher.getAttackedThisTurnCreatures().isEmpty(); } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/AttackedThisTurnSourceCondition.java b/Mage/src/main/java/mage/abilities/condition/common/AttackedThisTurnSourceCondition.java index 58f3719ec7..0bf152ec76 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/AttackedThisTurnSourceCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/AttackedThisTurnSourceCondition.java @@ -18,7 +18,7 @@ public enum AttackedThisTurnSourceCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); return sourcePermanent != null && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(sourcePermanent, game)); } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/BlockedThisTurnSourceCondition.java b/Mage/src/main/java/mage/abilities/condition/common/BlockedThisTurnSourceCondition.java index d6578996f6..93f37e89a2 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/BlockedThisTurnSourceCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/BlockedThisTurnSourceCondition.java @@ -18,7 +18,7 @@ public enum BlockedThisTurnSourceCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); - BlockedThisTurnWatcher watcher = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName()); + BlockedThisTurnWatcher watcher = game.getState().getWatcher(BlockedThisTurnWatcher.class); return sourcePermanent != null && watcher.getBlockedThisTurnCreatures().contains(new MageObjectReference(sourcePermanent, game)); } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/CastFromHandSourceCondition.java b/Mage/src/main/java/mage/abilities/condition/common/CastFromHandSourceCondition.java index c813524465..1a584533ec 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/CastFromHandSourceCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/CastFromHandSourceCondition.java @@ -33,7 +33,7 @@ public enum CastFromHandSourceCondition implements Condition { return false; } } - CastFromHandWatcher watcher = (CastFromHandWatcher) game.getState().getWatchers().get(CastFromHandWatcher.class.getSimpleName()); + CastFromHandWatcher watcher = game.getState().getWatcher(CastFromHandWatcher.class); if (watcher != null && watcher.spellWasCastFromHand(source.getSourceId())) { return true; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/ControllerAttackedThisTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/ControllerAttackedThisTurnCondition.java index b327e6e214..d7f732d11a 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/ControllerAttackedThisTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/ControllerAttackedThisTurnCondition.java @@ -15,7 +15,7 @@ public enum ControllerAttackedThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); return source.isControlledBy(game.getActivePlayerId()) && watcher != null && !watcher.getAttackedThisTurnCreatures().isEmpty(); } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/DealtDamageToAnOpponent.java b/Mage/src/main/java/mage/abilities/condition/common/DealtDamageToAnOpponent.java index 4e83de1baf..57e4830640 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/DealtDamageToAnOpponent.java +++ b/Mage/src/main/java/mage/abilities/condition/common/DealtDamageToAnOpponent.java @@ -15,7 +15,7 @@ public class DealtDamageToAnOpponent implements Condition { @Override public boolean apply(Game game, Ability source) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { - PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), opponentId); + PlayerDamagedBySourceWatcher watcher = game.getState().getWatcher(PlayerDamagedBySourceWatcher.class, opponentId); if (watcher != null) { if (watcher.hasSourceDoneDamage(source.getSourceId(), game)) { return true; diff --git a/Mage/src/main/java/mage/abilities/condition/common/HateCondition.java b/Mage/src/main/java/mage/abilities/condition/common/HateCondition.java index 72216794d6..1db22ed9f8 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/HateCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/HateCondition.java @@ -18,7 +18,7 @@ public enum HateCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - LifeLossOtherFromCombatWatcher watcher = (LifeLossOtherFromCombatWatcher) game.getState().getWatchers().get(LifeLossOtherFromCombatWatcher.class.getSimpleName()); + LifeLossOtherFromCombatWatcher watcher = game.getState().getWatcher(LifeLossOtherFromCombatWatcher.class); return watcher != null && watcher.opponentLostLifeOtherFromCombat(source.getControllerId(), game); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/LandfallCondition.java b/Mage/src/main/java/mage/abilities/condition/common/LandfallCondition.java index 44686f489e..2b6d991c54 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/LandfallCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/LandfallCondition.java @@ -13,7 +13,7 @@ public enum LandfallCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - LandfallWatcher watcher = (LandfallWatcher) game.getState().getWatchers().get(LandfallWatcher.class.getSimpleName()); + LandfallWatcher watcher = game.getState().getWatcher(LandfallWatcher.class); return watcher != null && watcher.landPlayed(source.getControllerId()); } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/LiveLostLastTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/LiveLostLastTurnCondition.java index 1dcaaea74f..7025aca0bc 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/LiveLostLastTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/LiveLostLastTurnCondition.java @@ -17,7 +17,7 @@ public enum LiveLostLastTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); if (watcher != null) { return watcher.getLifeLostLastTurn(source.getControllerId()) > 0; } else { diff --git a/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java b/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java index 5a0737d0a8..d512e91716 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/ManaWasSpentCondition.java @@ -30,7 +30,7 @@ public class ManaWasSpentCondition implements Condition { if (source.getAbilityType() == AbilityType.SPELL) { return (source.getManaCostsToPay().getPayment().getColor(coloredManaSymbol) > 0); } - ManaSpentToCastWatcher watcher = (ManaSpentToCastWatcher) game.getState().getWatchers().get(ManaSpentToCastWatcher.class.getSimpleName(), source.getSourceId()); + ManaSpentToCastWatcher watcher = game.getState().getWatcher(ManaSpentToCastWatcher.class, source.getSourceId()); if (watcher != null) { Mana payment = watcher.getAndResetLastPayment(); if (payment != null) { @@ -42,7 +42,7 @@ public class ManaWasSpentCondition implements Condition { @Override public String toString() { - return new StringBuilder("{").append(coloredManaSymbol.toString()).append("} was spent to cast it").toString(); + return "{" + coloredManaSymbol.toString() + "} was spent to cast it"; } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/MorbidCondition.java b/Mage/src/main/java/mage/abilities/condition/common/MorbidCondition.java index b127435975..f6b939cc6e 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/MorbidCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/MorbidCondition.java @@ -16,7 +16,7 @@ public enum MorbidCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName()); + MorbidWatcher watcher = game.getState().getWatcher(MorbidWatcher.class); return watcher != null && watcher.conditionMet(); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java index 72dc12c321..ac1253311a 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java @@ -23,7 +23,7 @@ public enum NoSpellsWereCastLastTurnCondition implements Condition { return false; } - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); if(watcher == null){ return false; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java b/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java index 03c5e6c839..c509ebabc1 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java @@ -23,7 +23,7 @@ public class OpponentLostLifeCondition extends IntCompareCondition { @Override protected int getInputValue(Game game, Ability source) { int maxLostLive = 0; - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { int lostLive = watcher.getLifeLost(opponentId); diff --git a/Mage/src/main/java/mage/abilities/condition/common/PlayLandCondition.java b/Mage/src/main/java/mage/abilities/condition/common/PlayLandCondition.java index 121dfec822..cab3b23a32 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/PlayLandCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/PlayLandCondition.java @@ -13,7 +13,7 @@ public enum PlayLandCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayLandWatcher watcher = (PlayLandWatcher) game.getState().getWatchers().get(PlayLandWatcher.class.getSimpleName()); + PlayLandWatcher watcher = game.getState().getWatcher(PlayLandWatcher.class); return watcher != null && watcher.landPlayed(source.getControllerId()); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/RaidCondition.java b/Mage/src/main/java/mage/abilities/condition/common/RaidCondition.java index a821a30d30..85dcb3c2d9 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/RaidCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/RaidCondition.java @@ -15,7 +15,7 @@ public enum RaidCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get(PlayerAttackedWatcher.class.getSimpleName()); + PlayerAttackedWatcher watcher = game.getState().getWatcher(PlayerAttackedWatcher.class); return watcher != null && watcher.getNumberOfAttackersCurrentTurn(source.getControllerId()) > 0; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/RevoltCondition.java b/Mage/src/main/java/mage/abilities/condition/common/RevoltCondition.java index 1c3feabc9e..db68abf028 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/RevoltCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/RevoltCondition.java @@ -15,7 +15,7 @@ public enum RevoltCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - RevoltWatcher watcher = (RevoltWatcher) game.getState().getWatchers().get(RevoltWatcher.class.getSimpleName()); + RevoltWatcher watcher = game.getState().getWatcher(RevoltWatcher.class); return watcher != null && watcher.revoltActive(source.getControllerId()); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/SourceDealtDamageCondition.java b/Mage/src/main/java/mage/abilities/condition/common/SourceDealtDamageCondition.java index 38bb87a2c2..7a9f111d22 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/SourceDealtDamageCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/SourceDealtDamageCondition.java @@ -24,7 +24,7 @@ public class SourceDealtDamageCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - DamageDoneWatcher watcher = (DamageDoneWatcher) game.getState().getWatchers().get(DamageDoneWatcher.class.getSimpleName()); + DamageDoneWatcher watcher = game.getState().getWatcher(DamageDoneWatcher.class); return watcher != null && watcher.damageDoneBy(source.getSourceId(), source.getSourceObjectZoneChangeCounter(), game) >= value; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/TargetAttackedThisTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/TargetAttackedThisTurnCondition.java index f81afcc01e..561a3afd29 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/TargetAttackedThisTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/TargetAttackedThisTurnCondition.java @@ -17,7 +17,7 @@ public enum TargetAttackedThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Permanent creature = game.getPermanentOrLKIBattlefield(source.getTargets().getFirstTarget()); - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); return creature != null && watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(creature, game)); } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java index 498dc96ed1..1f905605a4 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java @@ -15,7 +15,7 @@ public enum TwoOrMoreSpellsWereCastLastTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); if(watcher == null){ return false; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/WatcherCondition.java b/Mage/src/main/java/mage/abilities/condition/common/WatcherCondition.java deleted file mode 100644 index 94d6e45f03..0000000000 --- a/Mage/src/main/java/mage/abilities/condition/common/WatcherCondition.java +++ /dev/null @@ -1,51 +0,0 @@ -package mage.abilities.condition.common; - -import mage.abilities.Ability; -import mage.abilities.condition.Condition; -import mage.constants.WatcherScope; -import mage.game.Game; -import mage.watchers.Watcher; - -/** - * - * @author Quercitron - */ -public class WatcherCondition implements Condition { - - private final String watcherKey; - private final WatcherScope watcherScope; - private final String text; - - public WatcherCondition(String watcherKey, WatcherScope watcherScope) { - this(watcherKey, watcherScope, ""); - } - - public WatcherCondition(String watcherKey, WatcherScope watcherScope, String text) { - this.watcherKey = watcherKey; - this.watcherScope = watcherScope; - this.text = text; - } - - @Override - public boolean apply(Game game, Ability source) { - Watcher watcher = null; - switch (watcherScope) { - case GAME: - watcher = game.getState().getWatchers().get(watcherKey); - break; - case PLAYER: - watcher = game.getState().getWatchers().get(watcherKey, source.getControllerId()); - break; - case CARD: - watcher = game.getState().getWatchers().get(watcherKey, source.getSourceId()); - break; - } - return watcher != null && watcher.conditionMet(); - } - - @Override - public String toString() { - return text; - } - -} diff --git a/Mage/src/main/java/mage/abilities/condition/common/YouGainedLifeCondition.java b/Mage/src/main/java/mage/abilities/condition/common/YouGainedLifeCondition.java index a33a4d9bd0..d8ab429719 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/YouGainedLifeCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/YouGainedLifeCondition.java @@ -18,9 +18,9 @@ public class YouGainedLifeCondition extends IntCompareCondition { @Override protected int getInputValue(Game game, Ability source) { int gainedLife = 0; - PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getSimpleName()); + PlayerGainedLifeWatcher watcher = game.getState().getWatcher(PlayerGainedLifeWatcher.class); if (watcher != null) { - gainedLife = watcher.getLiveGained(source.getControllerId()); + gainedLife = watcher.getLifeGained(source.getControllerId()); } return gainedLife; } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/AttackedThisTurnOpponentsCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/AttackedThisTurnOpponentsCount.java index 69a12d8c92..1e69de1d4f 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/AttackedThisTurnOpponentsCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/AttackedThisTurnOpponentsCount.java @@ -20,7 +20,7 @@ public class AttackedThisTurnOpponentsCount implements DynamicValue { } public int calculate(Game game, UUID controllerId) { - PlayersAttackedThisTurnWatcher watcher = (PlayersAttackedThisTurnWatcher) game.getState().getWatchers().get(PlayersAttackedThisTurnWatcher.class.getSimpleName()); + PlayersAttackedThisTurnWatcher watcher = game.getState().getWatcher(PlayersAttackedThisTurnWatcher.class); if (watcher != null) { return watcher.getAttackedOpponentsCount(controllerId); } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java index 94107fb35c..2663f6a040 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ControllerGotLifeCount.java @@ -33,9 +33,9 @@ public class ControllerGotLifeCount implements DynamicValue, MageSingleton { } public int calculate(Game game, UUID controllerId) { - PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getSimpleName()); + PlayerGainedLifeWatcher watcher = game.getState().getWatcher(PlayerGainedLifeWatcher.class); if (watcher != null) { - return watcher.getLiveGained(controllerId); + return watcher.getLifeGained(controllerId); } return 0; } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesDiedThisTurnCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesDiedThisTurnCount.java index 806a27fd4c..ef2ae61ed2 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesDiedThisTurnCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/CreaturesDiedThisTurnCount.java @@ -14,7 +14,7 @@ public class CreaturesDiedThisTurnCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - CreaturesDiedWatcher watcher = (CreaturesDiedWatcher) game.getState().getWatchers().get(CreaturesDiedWatcher.class.getSimpleName()); + CreaturesDiedWatcher watcher = game.getState().getWatcher(CreaturesDiedWatcher.class); if (watcher != null) { return watcher.getAmountOfCreaturesDiedThisTurn(); } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/OpponentsLostLifeCount.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/OpponentsLostLifeCount.java index 1133be57bd..0be9fa437a 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/OpponentsLostLifeCount.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/OpponentsLostLifeCount.java @@ -20,7 +20,7 @@ public class OpponentsLostLifeCount implements DynamicValue { } public int calculate(Game game, UUID controllerId) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); if (watcher != null) { return watcher.getAllOppLifeLost(controllerId, game); } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ZuberasDiedDynamicValue.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ZuberasDiedDynamicValue.java index c6dc8094ff..e81289233c 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ZuberasDiedDynamicValue.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ZuberasDiedDynamicValue.java @@ -13,11 +13,11 @@ public class ZuberasDiedDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get(ZuberasDiedWatcher.class.getSimpleName()); + ZuberasDiedWatcher watcher = game.getState().getWatcher(ZuberasDiedWatcher.class); if(watcher == null){ return 0; } - return watcher.zuberasDiedThisTurn; + return watcher.getZuberasDiedThisTurn(); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/UntapAllThatAttackedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/UntapAllThatAttackedEffect.java index 78834f82ae..385ff814ec 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/UntapAllThatAttackedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/UntapAllThatAttackedEffect.java @@ -36,9 +36,9 @@ public class UntapAllThatAttackedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); - if (watcher instanceof AttackedThisTurnWatcher) { - Set attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures(); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); + if (watcher != null) { + Set attackedThisTurn = watcher.getAttackedThisTurnCreatures(); for (MageObjectReference mor : attackedThisTurn) { Permanent permanent = mor.getPermanent(game); if (permanent != null && permanent.isCreature()) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAllEffect.java index b4c4ec8f1d..43e14562a2 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleAllEffect.java @@ -60,7 +60,7 @@ public class AttacksIfAbleAllEffect extends RequirementEffect { if (eachCombat) { return true; } - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); return watcher != null && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game)); } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleSourceEffect.java index 44b4356b8e..bf62c5c642 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/AttacksIfAbleSourceEffect.java @@ -47,7 +47,7 @@ public class AttacksIfAbleSourceEffect extends RequirementEffect { if (eachCombat) { return true; } - AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + AttackedThisTurnWatcher watcher = game.getState().getWatcher(AttackedThisTurnWatcher.class); return watcher != null && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game)); } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java index 5c713db1f6..d8806469c3 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByAllTargetEffect.java @@ -19,9 +19,9 @@ public class MustBeBlockedByAllTargetEffect extends RequirementEffect { public MustBeBlockedByAllTargetEffect(Duration duration) { super(duration); - staticText = new StringBuilder("All creatures able to block target creature ") - .append(this.getDuration() == Duration.EndOfTurn ? "this turn ":"") - .append("do so").toString(); + staticText = "All creatures able to block target creature " + + (this.getDuration() == Duration.EndOfTurn ? "this turn " : "") + + "do so"; } public MustBeBlockedByAllTargetEffect(final MustBeBlockedByAllTargetEffect effect) { @@ -33,7 +33,7 @@ public class MustBeBlockedByAllTargetEffect extends RequirementEffect { Permanent attackingCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (attackingCreature != null && attackingCreature.isAttacking()) { if (source.getAbilityType() != AbilityType.STATIC) { - BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); + BlockedAttackerWatcher blockedAttackerWatcher = game.getState().getWatcher(BlockedAttackerWatcher.class); if (blockedAttackerWatcher != null && blockedAttackerWatcher.creatureHasBlockedAttacker(attackingCreature, permanent, game)) { // has already blocked this turn, so no need to do again return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByTargetSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByTargetSourceEffect.java index 81fba0f3d3..d56b0e8b0e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByTargetSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/MustBeBlockedByTargetSourceEffect.java @@ -36,7 +36,7 @@ public class MustBeBlockedByTargetSourceEffect extends RequirementEffect { if (blocker != null && blocker.canBlock(source.getSourceId(), game)) { Permanent attacker = (Permanent) source.getSourceObjectIfItStillExists(game); if (attacker != null) { - BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); + BlockedAttackerWatcher blockedAttackerWatcher = game.getState().getWatcher(BlockedAttackerWatcher.class); if (blockedAttackerWatcher != null && blockedAttackerWatcher.creatureHasBlockedAttacker(attacker, blocker, game)) { // has already blocked this turn, so no need to do again return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/CantCastMoreThanOneSpellEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/CantCastMoreThanOneSpellEffect.java index e20ec58717..4901a687ec 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/CantCastMoreThanOneSpellEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/CantCastMoreThanOneSpellEffect.java @@ -69,7 +69,7 @@ public class CantCastMoreThanOneSpellEffect extends ContinuousRuleModifyingEffec return false; } } - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); return watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) > 0; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/replacement/DealtDamageToCreatureBySourceDies.java b/Mage/src/main/java/mage/abilities/effects/common/replacement/DealtDamageToCreatureBySourceDies.java index 673acae848..0c974f4021 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/replacement/DealtDamageToCreatureBySourceDies.java +++ b/Mage/src/main/java/mage/abilities/effects/common/replacement/DealtDamageToCreatureBySourceDies.java @@ -63,7 +63,7 @@ public class DealtDamageToCreatureBySourceDies extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { ZoneChangeEvent zce = (ZoneChangeEvent) event; if (zce.isDiesEvent()) { - DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), source.getSourceId()); + DamagedByWatcher watcher = game.getState().getWatcher(DamagedByWatcher.class, source.getSourceId()); if (watcher != null) { return watcher.wasDamaged(zce.getTarget(), game); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CastOnlyIfYouHaveCastAnotherSpellEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CastOnlyIfYouHaveCastAnotherSpellEffect.java index 7126808c81..e3de9c3cf7 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CastOnlyIfYouHaveCastAnotherSpellEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/CastOnlyIfYouHaveCastAnotherSpellEffect.java @@ -32,7 +32,7 @@ public class CastOnlyIfYouHaveCastAnotherSpellEffect extends ContinuousRuleModif @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getSourceId().equals(source.getSourceId())) { - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) == 0) { return true; } diff --git a/Mage/src/main/java/mage/abilities/keyword/BloodthirstAbility.java b/Mage/src/main/java/mage/abilities/keyword/BloodthirstAbility.java index 873e0c82c9..885301b7a5 100644 --- a/Mage/src/main/java/mage/abilities/keyword/BloodthirstAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/BloodthirstAbility.java @@ -69,15 +69,15 @@ class BloodthirstEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); + BloodthirstWatcher watcher = game.getState().getWatcher(BloodthirstWatcher.class, source.getControllerId()); if (watcher != null && watcher.conditionMet()) { Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (permanent != null) { ArrayList appliedEffects = (ArrayList) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game, appliedEffects); } + return true; } - return true; } return false; } diff --git a/Mage/src/main/java/mage/abilities/keyword/ExertAbility.java b/Mage/src/main/java/mage/abilities/keyword/ExertAbility.java index 7dac00d4bd..e926b1318d 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ExertAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ExertAbility.java @@ -109,7 +109,7 @@ class ExertReplacementEffect extends ReplacementEffectImpl { if (creature != null && controller != null) { if (exertOnlyOncePerTurn) { MageObjectReference creatureReference = new MageObjectReference(creature.getId(), creature.getZoneChangeCounter(game), game); - ExertedThisTurnWatcher watcher = (ExertedThisTurnWatcher) game.getState().getWatchers().get(ExertedThisTurnWatcher.class.getSimpleName()); + ExertedThisTurnWatcher watcher = game.getState().getWatcher(ExertedThisTurnWatcher.class); if (watcher != null && watcher.getExertedThisTurnCreatures().contains(creatureReference)) { return false; } diff --git a/Mage/src/main/java/mage/abilities/keyword/GravestormAbility.java b/Mage/src/main/java/mage/abilities/keyword/GravestormAbility.java index 7783f32d9d..ab4823303e 100644 --- a/Mage/src/main/java/mage/abilities/keyword/GravestormAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/GravestormAbility.java @@ -74,7 +74,7 @@ class GravestormEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { MageObjectReference spellRef = (MageObjectReference) this.getValue("GravestormSpellRef"); if (spellRef != null) { - GravestormWatcher watcher = (GravestormWatcher) game.getState().getWatchers().get(GravestormWatcher.class.getSimpleName()); + GravestormWatcher watcher = game.getState().getWatcher(GravestormWatcher.class); if(watcher != null) { int gravestormCount = watcher.getGravestormCount(); if (gravestormCount > 0) { diff --git a/Mage/src/main/java/mage/abilities/keyword/MeleeAbility.java b/Mage/src/main/java/mage/abilities/keyword/MeleeAbility.java index 0ca8676bbb..aeb04bc04e 100644 --- a/Mage/src/main/java/mage/abilities/keyword/MeleeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/MeleeAbility.java @@ -88,7 +88,7 @@ class MeleeDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - MeleeWatcher watcher = (MeleeWatcher) game.getState().getWatchers().get(MeleeWatcher.class.getSimpleName()); + MeleeWatcher watcher = game.getState().getWatcher(MeleeWatcher.class); if (watcher != null) { if (!valueChecked) { this.lockedInValue = watcher.getNumberOfAttackedPlayers(sourceAbility.getControllerId()); diff --git a/Mage/src/main/java/mage/abilities/keyword/ProwlAbility.java b/Mage/src/main/java/mage/abilities/keyword/ProwlAbility.java index 3bc23ba84f..3e3ff1ca3c 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ProwlAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ProwlAbility.java @@ -92,7 +92,7 @@ public class ProwlAbility extends StaticAbility implements AlternativeSourceCost public boolean askToActivateAlternativeCosts(Ability ability, Game game) { if (ability instanceof SpellAbility) { Player player = game.getPlayer(controllerId); - ProwlWatcher prowlWatcher = (ProwlWatcher) game.getState().getWatchers().get(ProwlWatcher.class.getSimpleName()); + ProwlWatcher prowlWatcher = game.getState().getWatcher(ProwlWatcher.class); Card card = game.getCard(ability.getSourceId()); if (player == null || prowlWatcher == null || card == null) { throw new IllegalArgumentException("Params can't be null"); @@ -108,7 +108,7 @@ public class ProwlAbility extends StaticAbility implements AlternativeSourceCost this.resetProwl(); for (AlternativeCost2 prowlCost : prowlCosts) { if (prowlCost.canPay(ability, sourceId, controllerId, game) - && player.chooseUse(Outcome.Benefit, new StringBuilder("Cast for ").append(PROWL_KEYWORD).append(" cost ").append(prowlCost.getText(true)).append(" ?").toString(), ability, game)) { + && player.chooseUse(Outcome.Benefit, "Cast for " + PROWL_KEYWORD + " cost " + prowlCost.getText(true) + " ?", ability, game)) { prowlCost.activate(); ability.getManaCostsToPay().clear(); ability.getCosts().clear(); diff --git a/Mage/src/main/java/mage/abilities/keyword/SpectacleAbility.java b/Mage/src/main/java/mage/abilities/keyword/SpectacleAbility.java index e646742d6a..8f3d172b23 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SpectacleAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SpectacleAbility.java @@ -40,7 +40,7 @@ public class SpectacleAbility extends SpellAbility { @Override public ActivationStatus canActivate(UUID playerId, Game game) { - PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); + PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); if (watcher != null && watcher.getAllOppLifeLost(playerId, game) > 0) { return super.canActivate(playerId, game); } diff --git a/Mage/src/main/java/mage/abilities/keyword/StormAbility.java b/Mage/src/main/java/mage/abilities/keyword/StormAbility.java index 45b99a4ab6..4e1b33d676 100644 --- a/Mage/src/main/java/mage/abilities/keyword/StormAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/StormAbility.java @@ -74,7 +74,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.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null) { int stormCount = watcher.getSpellOrder(spellRef, game) - 1; if (stormCount > 0) { diff --git a/Mage/src/main/java/mage/abilities/keyword/SurgeAbility.java b/Mage/src/main/java/mage/abilities/keyword/SurgeAbility.java index a94231fb4b..0e4c28b540 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SurgeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SurgeAbility.java @@ -42,7 +42,7 @@ public class SurgeAbility extends SpellAbility { @Override public ActivationStatus canActivate(UUID playerId, Game game) { // check if controller or teammate has already cast a spell this turn - CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class); if (watcher != null) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage/src/main/java/mage/filter/predicate/permanent/BlockedByIdPredicate.java b/Mage/src/main/java/mage/filter/predicate/permanent/BlockedByIdPredicate.java index b1ba27d400..135281a0e1 100644 --- a/Mage/src/main/java/mage/filter/predicate/permanent/BlockedByIdPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/permanent/BlockedByIdPredicate.java @@ -28,7 +28,7 @@ public class BlockedByIdPredicate implements Predicate { } // Check if the blockerId was blocked before, if it does no longer exists now but so the target attacking is still valid Permanent blocker = game.getPermanentOrLKIBattlefield(blockerId); if (blocker != null) { - BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); + BlockedAttackerWatcher watcher = game.getState().getWatcher(BlockedAttackerWatcher.class); if (watcher != null) { return watcher.creatureHasBlockedAttacker(input, blocker, game); } diff --git a/Mage/src/main/java/mage/filter/predicate/permanent/DamagedPlayerThisTurnPredicate.java b/Mage/src/main/java/mage/filter/predicate/permanent/DamagedPlayerThisTurnPredicate.java index 17807a0ea3..191e58133a 100644 --- a/Mage/src/main/java/mage/filter/predicate/permanent/DamagedPlayerThisTurnPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/permanent/DamagedPlayerThisTurnPredicate.java @@ -28,14 +28,14 @@ public class DamagedPlayerThisTurnPredicate implements ObjectPlayerPredicate { return this.turnMods; } + @Deprecated public Watchers getWatchers() { return this.watchers; } + public T getWatcher(Class watcherClass) { + return watcherClass.cast(watchers.get(watcherClass.getSimpleName())); + } + + public T getWatcher(Class watcherClass, UUID uuid) { + return watcherClass.cast(watchers.get(watcherClass.getSimpleName(), uuid.toString())); + } + + public T getWatcher(Class watcherClass,String prefix) { + return watcherClass.cast(watchers.get(watcherClass.getSimpleName(), prefix)); + } + public SpecialActions getSpecialActions() { return this.specialActions; } @@ -1104,6 +1117,10 @@ public class GameState implements Serializable, Copyable { this.watchers.add(watcher); } + public void resetWatchers(){ + this.watchers.reset(); + } + public int getZoneChangeCounter(UUID objectId) { return zoneChangeCounter.getOrDefault(objectId, 1); } diff --git a/Mage/src/main/java/mage/game/command/emblems/JaceUnravelerOfSecretsEmblem.java b/Mage/src/main/java/mage/game/command/emblems/JaceUnravelerOfSecretsEmblem.java index 0ae65c4043..4c5cec028c 100644 --- a/Mage/src/main/java/mage/game/command/emblems/JaceUnravelerOfSecretsEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/JaceUnravelerOfSecretsEmblem.java @@ -51,7 +51,7 @@ class JaceUnravelerOfSecretsTriggeredAbility extends SpellCastOpponentTriggeredA @Override public boolean checkTrigger(GameEvent event, Game game) { if (super.checkTrigger(event, game)) { - SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName()); + SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class); if (watcher != null) { List spells = watcher.getSpellsCastThisTurn(event.getPlayerId()); if (spells != null && spells.size() == 1) { diff --git a/Mage/src/main/java/mage/game/command/emblems/JayaBallardEmblem.java b/Mage/src/main/java/mage/game/command/emblems/JayaBallardEmblem.java index 45f0b291d7..1984d36f53 100644 --- a/Mage/src/main/java/mage/game/command/emblems/JayaBallardEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/JayaBallardEmblem.java @@ -119,7 +119,7 @@ class JayaBallardReplacementEffect extends ReplacementEffectImpl { if (card != null && (card.isInstant() || card.isSorcery())) { // TODO: Find a way to check, that the spell from graveyard was really cast by the ability of the emblem. // currently every spell cast from graveyard will be exiled. - CastFromGraveyardWatcher watcher = (CastFromGraveyardWatcher) game.getState().getWatchers().get(CastFromGraveyardWatcher.class.getSimpleName()); + CastFromGraveyardWatcher watcher = game.getState().getWatcher(CastFromGraveyardWatcher.class); return watcher != null && watcher.spellWasCastFromGraveyard(event.getTargetId(), game.getState().getZoneChangeCounter(event.getTargetId())); } } diff --git a/Mage/src/main/java/mage/game/command/planes/BantPlane.java b/Mage/src/main/java/mage/game/command/planes/BantPlane.java index a1187a748f..5ea0fc27e6 100644 --- a/Mage/src/main/java/mage/game/command/planes/BantPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/BantPlane.java @@ -107,7 +107,7 @@ class PlanarDieRollCostIncreasingEffect extends CostModificationEffectImpl { public boolean apply(Game game, Ability source, Ability abilityToModify) { Player activePlayer = game.getPlayer(game.getActivePlayerId()); if (activePlayer != null) { - PlanarRollWatcher watcher = (PlanarRollWatcher) game.getState().getWatchers().get(PlanarRollWatcher.class.getSimpleName()); + PlanarRollWatcher watcher = game.getState().getWatcher(PlanarRollWatcher.class); int rolledCounter = 0; if (watcher != null) { rolledCounter = watcher.getNumberTimesPlanarDieRolled(activePlayer.getId()); diff --git a/Mage/src/main/java/mage/watchers/Watcher.java b/Mage/src/main/java/mage/watchers/Watcher.java index 07092b7c89..9a941c0143 100644 --- a/Mage/src/main/java/mage/watchers/Watcher.java +++ b/Mage/src/main/java/mage/watchers/Watcher.java @@ -21,6 +21,10 @@ public abstract class Watcher implements Serializable { protected boolean condition; protected final WatcherScope scope; + public Watcher(Class watcherClass, WatcherScope scope){ + this(watcherClass.getSimpleName(), scope); + } + public Watcher(String basicKey, WatcherScope scope) { this.basicKey = basicKey; this.scope = scope; diff --git a/Mage/src/main/java/mage/watchers/Watchers.java b/Mage/src/main/java/mage/watchers/Watchers.java index af9bf034c8..5cbb45fc06 100644 --- a/Mage/src/main/java/mage/watchers/Watchers.java +++ b/Mage/src/main/java/mage/watchers/Watchers.java @@ -1,22 +1,26 @@ package mage.watchers; -import java.util.HashMap; -import java.util.UUID; import mage.game.Game; import mage.game.events.GameEvent; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; + +import java.util.HashMap; +import java.util.UUID; /** - * * @author BetaSteward_at_googlemail.com */ public class Watchers extends HashMap { + private static Logger logger = LogManager.getLogger(Watcher.class.getSimpleName()); + public Watchers() { } - public Watchers(final Watchers watchers) { - watchers.entrySet().forEach((entry) -> this.put(entry.getKey(), entry.getValue().copy())); + private Watchers(final Watchers watchers) { + watchers.forEach((key, value) -> this.put(key, value.copy())); } public Watchers copy() { @@ -37,7 +41,16 @@ public class Watchers extends HashMap { this.values().forEach(Watcher::reset); } - public Watcher get(String key, UUID id) { - return this.get(id + key); + public Watcher get(String key, String id) { + return get(id + key); + } + + @Override + public Watcher get(Object key) { + if (containsKey(key)) { + return super.get(key); + } + logger.info(key + " not found in watchers"); + return null; } } diff --git a/Mage/src/main/java/mage/watchers/common/PlayerGainedLifeWatcher.java b/Mage/src/main/java/mage/watchers/common/PlayerGainedLifeWatcher.java index fe9ceb02c0..b9a9cba116 100644 --- a/Mage/src/main/java/mage/watchers/common/PlayerGainedLifeWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/PlayerGainedLifeWatcher.java @@ -24,7 +24,7 @@ public class PlayerGainedLifeWatcher extends Watcher { super(PlayerGainedLifeWatcher.class.getSimpleName(), WatcherScope.GAME); } - public PlayerGainedLifeWatcher(final PlayerGainedLifeWatcher watcher) { + private PlayerGainedLifeWatcher(final PlayerGainedLifeWatcher watcher) { super(watcher); for (Entry entry : watcher.amountOfLifeGainedThisTurn.entrySet()) { amountOfLifeGainedThisTurn.put(entry.getKey(), entry.getValue()); @@ -45,7 +45,7 @@ public class PlayerGainedLifeWatcher extends Watcher { } } - public int getLiveGained(UUID playerId) { + public int getLifeGained(UUID playerId) { return amountOfLifeGainedThisTurn.getOrDefault(playerId, 0); } diff --git a/Mage/src/main/java/mage/watchers/common/ZuberasDiedWatcher.java b/Mage/src/main/java/mage/watchers/common/ZuberasDiedWatcher.java index d176bdd186..12625b4c17 100644 --- a/Mage/src/main/java/mage/watchers/common/ZuberasDiedWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/ZuberasDiedWatcher.java @@ -14,7 +14,11 @@ import mage.watchers.Watcher; */ public class ZuberasDiedWatcher extends Watcher { - public int zuberasDiedThisTurn = 0; + public int getZuberasDiedThisTurn() { + return zuberasDiedThisTurn; + } + + private int zuberasDiedThisTurn = 0; public ZuberasDiedWatcher() { super(ZuberasDiedWatcher.class.getSimpleName(), WatcherScope.GAME);