diff --git a/Mage.Sets/src/mage/cards/a/Aboroth.java b/Mage.Sets/src/mage/cards/a/Aboroth.java index fa27e6a3dd..f1ccef6cbb 100644 --- a/Mage.Sets/src/mage/cards/a/Aboroth.java +++ b/Mage.Sets/src/mage/cards/a/Aboroth.java @@ -1,96 +1,96 @@ -/* - * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of BetaSteward_at_googlemail.com. - */ -package mage.cards.a; - -import java.util.UUID; -import mage.MageInt; -import mage.abilities.Ability; -import mage.abilities.costs.Cost; -import mage.abilities.costs.CostImpl; -import mage.abilities.keyword.CumulativeUpkeepAbility; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.counters.CounterType; -import mage.game.Game; -import mage.game.permanent.Permanent; - -/** - * - * @author Styxo - */ -public class Aboroth extends CardImpl { - - public Aboroth(UUID ownerId, CardSetInfo setInfo) { - super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}{G}"); - - this.subtype.add("Elemental"); - this.power = new MageInt(9); - this.toughness = new MageInt(9); - - // Cumulative upkeep-Put a -1/-1 counter on Aboroth. - this.addAbility(new CumulativeUpkeepAbility(new AborothCost())); - } - - public Aboroth(final Aboroth card) { - super(card); - } - - @Override - public Aboroth copy() { - return new Aboroth(this); - } -} - -class AborothCost extends CostImpl { - - public AborothCost() { - this.text = "Put a -1/-1 counter on Aboroth"; - } - - @Override - public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { - Permanent permanent = game.getPermanent(sourceId); - if (permanent != null) { - permanent.addCounters(CounterType.M1M1.createInstance(), game); - this.paid = true; - return true; - } - return false; - } - - @Override - public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { - return true; - } - - @Override - public AborothCost copy() { - return new AborothCost(); - } -} +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.cards.a; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.costs.Cost; +import mage.abilities.costs.CostImpl; +import mage.abilities.keyword.CumulativeUpkeepAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author Styxo + */ +public class Aboroth extends CardImpl { + + public Aboroth(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}{G}"); + + this.subtype.add("Elemental"); + this.power = new MageInt(9); + this.toughness = new MageInt(9); + + // Cumulative upkeep-Put a -1/-1 counter on Aboroth. + this.addAbility(new CumulativeUpkeepAbility(new AborothCost())); + } + + public Aboroth(final Aboroth card) { + super(card); + } + + @Override + public Aboroth copy() { + return new Aboroth(this); + } +} + +class AborothCost extends CostImpl { + + public AborothCost() { + this.text = "Put a -1/-1 counter on Aboroth"; + } + + @Override + public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { + Permanent permanent = game.getPermanent(sourceId); + if (permanent != null) { + permanent.addCounters(CounterType.M1M1.createInstance(), ability, game); + this.paid = true; + return true; + } + return false; + } + + @Override + public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { + return true; + } + + @Override + public AborothCost copy() { + return new AborothCost(); + } +} diff --git a/Mage.Sets/src/mage/cards/a/AetherbornMarauder.java b/Mage.Sets/src/mage/cards/a/AetherbornMarauder.java index b133f28691..1f32696376 100644 --- a/Mage.Sets/src/mage/cards/a/AetherbornMarauder.java +++ b/Mage.Sets/src/mage/cards/a/AetherbornMarauder.java @@ -119,7 +119,7 @@ class AetherbornMarauderEffect extends OneShotEffect { } if (numberToMove > 0) { fromPermanent.removeCounters(CounterType.P1P1.createInstance(numberToMove), game); - sourceObject.addCounters(CounterType.P1P1.createInstance(numberToMove), game); + sourceObject.addCounters(CounterType.P1P1.createInstance(numberToMove), source, game); } } } diff --git a/Mage.Sets/src/mage/cards/a/AngelheartVial.java b/Mage.Sets/src/mage/cards/a/AngelheartVial.java index 8a0c9c80d0..b118f117a0 100644 --- a/Mage.Sets/src/mage/cards/a/AngelheartVial.java +++ b/Mage.Sets/src/mage/cards/a/AngelheartVial.java @@ -132,7 +132,7 @@ class AngelheartVialEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { - permanent.addCounters(CounterType.CHARGE.createInstance((Integer) this.getValue("damageAmount")), game); + permanent.addCounters(CounterType.CHARGE.createInstance((Integer) this.getValue("damageAmount")), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/a/AnimationModule.java b/Mage.Sets/src/mage/cards/a/AnimationModule.java index 25df14a5af..aec546a8a0 100644 --- a/Mage.Sets/src/mage/cards/a/AnimationModule.java +++ b/Mage.Sets/src/mage/cards/a/AnimationModule.java @@ -147,7 +147,7 @@ class AnimationModuleEffect extends OneShotEffect { if (permanent.getCounters(game).size() == 1) { for (Counter counter : permanent.getCounters(game).values()) { Counter newCounter = new Counter(counter.getName()); - permanent.addCounters(newCounter, game); + permanent.addCounters(newCounter, source, game); } } else { @@ -162,7 +162,7 @@ class AnimationModuleEffect extends OneShotEffect { for (Counter counter : permanent.getCounters(game).values()) { if (counter.getName().equals(choice.getChoice())) { Counter newCounter = new Counter(counter.getName()); - permanent.addCounters(newCounter, game); + permanent.addCounters(newCounter, source, game); break; } } diff --git a/Mage.Sets/src/mage/cards/a/Anthroplasm.java b/Mage.Sets/src/mage/cards/a/Anthroplasm.java index ebacf0a3c6..886ef47a3a 100644 --- a/Mage.Sets/src/mage/cards/a/Anthroplasm.java +++ b/Mage.Sets/src/mage/cards/a/Anthroplasm.java @@ -101,7 +101,7 @@ class AnthroplasmEffect extends OneShotEffect { //Remove all +1/+1 counters permanent.removeCounters(permanent.getCounters(game).get(CounterType.P1P1.getName()), game); //put X +1/+1 counters - permanent.addCounters(CounterType.P1P1.createInstance(source.getManaCostsToPay().getX()), game); + permanent.addCounters(CounterType.P1P1.createInstance(source.getManaCostsToPay().getX()), source, game); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/a/ApocalypseHydra.java b/Mage.Sets/src/mage/cards/a/ApocalypseHydra.java index 51ea9d66d8..0c34f7fcff 100644 --- a/Mage.Sets/src/mage/cards/a/ApocalypseHydra.java +++ b/Mage.Sets/src/mage/cards/a/ApocalypseHydra.java @@ -103,9 +103,9 @@ class ApocalypseHydraEffect extends OneShotEffect { int amount = spellAbility.getManaCostsToPay().getX(); if (amount > 0) { if (amount < 5) { - permanent.addCounters(CounterType.P1P1.createInstance(amount), game); + permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); } else { - permanent.addCounters(CounterType.P1P1.createInstance(amount * 2), game); + permanent.addCounters(CounterType.P1P1.createInstance(amount * 2), source, game); } } } diff --git a/Mage.Sets/src/mage/cards/a/ArbiterOfTheIdeal.java b/Mage.Sets/src/mage/cards/a/ArbiterOfTheIdeal.java index 606c62b0d0..260d14a40c 100644 --- a/Mage.Sets/src/mage/cards/a/ArbiterOfTheIdeal.java +++ b/Mage.Sets/src/mage/cards/a/ArbiterOfTheIdeal.java @@ -125,7 +125,7 @@ class ArbiterOfTheIdealEffect extends OneShotEffect { card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId()); Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { - permanent.addCounters(new Counter("Manifestation"), game); + permanent.addCounters(new Counter("Manifestation"), source, game); ContinuousEffect effect = new AddCardTypeTargetEffect(CardType.ENCHANTMENT, Duration.Custom); effect.setTargetPointer(new FixedTarget(permanent.getId())); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/a/ArsenalThresher.java b/Mage.Sets/src/mage/cards/a/ArsenalThresher.java index 2aabfa47fe..e42500465a 100644 --- a/Mage.Sets/src/mage/cards/a/ArsenalThresher.java +++ b/Mage.Sets/src/mage/cards/a/ArsenalThresher.java @@ -108,7 +108,7 @@ class ArsenalThresherEffect extends OneShotEffect { } if (arsenalThresher != null) { controller.revealCards(arsenalThresher.getIdName(), cards, game); - arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()), game); + arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()), source, game); } } } diff --git a/Mage.Sets/src/mage/cards/a/AzorsElocutors.java b/Mage.Sets/src/mage/cards/a/AzorsElocutors.java index c987aac8c3..2c40818eaf 100644 --- a/Mage.Sets/src/mage/cards/a/AzorsElocutors.java +++ b/Mage.Sets/src/mage/cards/a/AzorsElocutors.java @@ -127,7 +127,7 @@ class AzorsElocutorsEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { - permanent.addCounters(new Counter("filibuster"), game); + permanent.addCounters(new Counter("filibuster"), source, game); if (permanent.getCounters(game).getCount("filibuster") > 4) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/b/Bioshift.java b/Mage.Sets/src/mage/cards/b/Bioshift.java index 764a3b8b11..70ef879b1f 100644 --- a/Mage.Sets/src/mage/cards/b/Bioshift.java +++ b/Mage.Sets/src/mage/cards/b/Bioshift.java @@ -117,7 +117,7 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect { int amountToMove = controller.getAmount(0, amountCounters, "How many counters do you want to move?", game); if (amountToMove > 0) { fromPermanent.removeCounters(CounterType.P1P1.createInstance(amountToMove), game); - toPermanent.addCounters(CounterType.P1P1.createInstance(amountToMove), game); + toPermanent.addCounters(CounterType.P1P1.createInstance(amountToMove), source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/b/BlackSunsZenith.java b/Mage.Sets/src/mage/cards/b/BlackSunsZenith.java index 6f58173e48..4208641b3a 100644 --- a/Mage.Sets/src/mage/cards/b/BlackSunsZenith.java +++ b/Mage.Sets/src/mage/cards/b/BlackSunsZenith.java @@ -81,7 +81,7 @@ class BlackSunsZenithEffect extends OneShotEffect { int amount = source.getManaCostsToPay().getX(); for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) { if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) { - permanent.addCounters(CounterType.M1M1.createInstance(amount), game); + permanent.addCounters(CounterType.M1M1.createInstance(amount), source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/b/BladeOfTheBloodchief.java b/Mage.Sets/src/mage/cards/b/BladeOfTheBloodchief.java index 624d296b9b..8d0d3b2498 100644 --- a/Mage.Sets/src/mage/cards/b/BladeOfTheBloodchief.java +++ b/Mage.Sets/src/mage/cards/b/BladeOfTheBloodchief.java @@ -130,9 +130,9 @@ class BladeOfTheBloodchiefEffect extends OneShotEffect { Permanent creature = game.getPermanent(enchantment.getAttachedTo()); if (creature != null) { if (creature.hasSubtype("Vampire", game)) { - creature.addCounters(CounterType.P1P1.createInstance(2), game); + creature.addCounters(CounterType.P1P1.createInstance(2), source, game); } else { - creature.addCounters(CounterType.P1P1.createInstance(), game); + creature.addCounters(CounterType.P1P1.createInstance(), source, game); } } } diff --git a/Mage.Sets/src/mage/cards/b/BloodTyrant.java b/Mage.Sets/src/mage/cards/b/BloodTyrant.java index 624f4195d6..effe6402bf 100644 --- a/Mage.Sets/src/mage/cards/b/BloodTyrant.java +++ b/Mage.Sets/src/mage/cards/b/BloodTyrant.java @@ -148,7 +148,7 @@ class BloodTyrantEffect extends OneShotEffect { } Permanent bloodTyrant = game.getPermanent(source.getSourceId()); if (bloodTyrant != null && counters > 0) { - bloodTyrant.addCounters(CounterType.P1P1.createInstance(counters), game); + bloodTyrant.addCounters(CounterType.P1P1.createInstance(counters), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/b/BloodsporeThrinax.java b/Mage.Sets/src/mage/cards/b/BloodsporeThrinax.java index 04878a3ceb..51a89786fd 100644 --- a/Mage.Sets/src/mage/cards/b/BloodsporeThrinax.java +++ b/Mage.Sets/src/mage/cards/b/BloodsporeThrinax.java @@ -107,7 +107,7 @@ class BloodsporeThrinaxEntersBattlefieldEffect extends ReplacementEffectImpl { if (sourceCreature != null && creature != null) { int amount = sourceCreature.getCounters(game).getCount(CounterType.P1P1); if (amount > 0) { - creature.addCounters(CounterType.P1P1.createInstance(amount), game); + creature.addCounters(CounterType.P1P1.createInstance(amount), source, game); } } return false; diff --git a/Mage.Sets/src/mage/cards/b/BlowflyInfestation.java b/Mage.Sets/src/mage/cards/b/BlowflyInfestation.java index 78cf0a3a4d..ae4980f72c 100644 --- a/Mage.Sets/src/mage/cards/b/BlowflyInfestation.java +++ b/Mage.Sets/src/mage/cards/b/BlowflyInfestation.java @@ -111,7 +111,7 @@ class BlowflyInfestationEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent creature = game.getPermanent(source.getFirstTarget()); if (creature != null) { - creature.addCounters(CounterType.M1M1.createInstance(), game); + creature.addCounters(CounterType.M1M1.createInstance(), source, game); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/b/BombSquad.java b/Mage.Sets/src/mage/cards/b/BombSquad.java index 330b313a70..6e9784a89c 100644 --- a/Mage.Sets/src/mage/cards/b/BombSquad.java +++ b/Mage.Sets/src/mage/cards/b/BombSquad.java @@ -201,7 +201,7 @@ class BombSquadBeginningEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Card card = game.getCard(source.getSourceId()); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { - permanent.addCounters(CounterType.FUSE.createInstance(), game); + permanent.addCounters(CounterType.FUSE.createInstance(), source, game); game.informPlayers(new StringBuilder(card.getName()).append(" puts a fuse counter on ").append(permanent.getName()).toString()); } diff --git a/Mage.Sets/src/mage/cards/b/BramblewoodParagon.java b/Mage.Sets/src/mage/cards/b/BramblewoodParagon.java index 00f7cba217..f111acdb0a 100644 --- a/Mage.Sets/src/mage/cards/b/BramblewoodParagon.java +++ b/Mage.Sets/src/mage/cards/b/BramblewoodParagon.java @@ -119,7 +119,7 @@ class BramblewoodParagonReplacementEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget(); if (creature != null) { - creature.addCounters(CounterType.P1P1.createInstance(), game); + creature.addCounters(CounterType.P1P1.createInstance(), source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/c/CankerAbomination.java b/Mage.Sets/src/mage/cards/c/CankerAbomination.java index a2e2e610f2..08b82a7291 100644 --- a/Mage.Sets/src/mage/cards/c/CankerAbomination.java +++ b/Mage.Sets/src/mage/cards/c/CankerAbomination.java @@ -103,7 +103,7 @@ class CankerAbominationEffect extends OneShotEffect { game.informPlayers(cankerAbomination.getName() + ": " + controller.getLogName() + " has chosen " + opponent.getLogName()); int amount = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), opponent.getId(), game).size(); if (amount > 0) { - cankerAbomination.addCounters(CounterType.M1M1.createInstance(amount), game); + cankerAbomination.addCounters(CounterType.M1M1.createInstance(amount), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/c/Cannibalize.java b/Mage.Sets/src/mage/cards/c/Cannibalize.java index 0e5a1fe099..8ec6596b60 100644 --- a/Mage.Sets/src/mage/cards/c/Cannibalize.java +++ b/Mage.Sets/src/mage/cards/c/Cannibalize.java @@ -100,7 +100,7 @@ class CannibalizeEffect extends OneShotEffect { controller.moveCardToExileWithInfo(creature, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true); exileDone = true; } else { - creature.addCounters(CounterType.P1P1.createInstance(2), game); + creature.addCounters(CounterType.P1P1.createInstance(2), source, game); game.informPlayers("Added two +1/+1 counters on " + creature.getLogName()); } count++; diff --git a/Mage.Sets/src/mage/cards/c/CarnifexDemon.java b/Mage.Sets/src/mage/cards/c/CarnifexDemon.java index 1174e92e8d..988d798c4f 100644 --- a/Mage.Sets/src/mage/cards/c/CarnifexDemon.java +++ b/Mage.Sets/src/mage/cards/c/CarnifexDemon.java @@ -93,7 +93,7 @@ class CarnifexDemonEffect extends OneShotEffect { if (p != null) { for (Permanent t : game.getBattlefield().getAllActivePermanents()) { if (t.getCardType().contains(CardType.CREATURE) && !t.getId().equals(source.getSourceId())) - t.addCounters(CounterType.M1M1.createInstance(), game); + t.addCounters(CounterType.M1M1.createInstance(), source, game); } } return false; diff --git a/Mage.Sets/src/mage/cards/c/ChargingCinderhorn.java b/Mage.Sets/src/mage/cards/c/ChargingCinderhorn.java index 50f5e6b82c..3b83b66ce6 100644 --- a/Mage.Sets/src/mage/cards/c/ChargingCinderhorn.java +++ b/Mage.Sets/src/mage/cards/c/ChargingCinderhorn.java @@ -121,7 +121,7 @@ class ChargingCinderhornDamageTargetEffect extends OneShotEffect{ public boolean apply(Game game, Ability source) { Permanent chargingCinderhoof = game.getPermanent(source.getSourceId()); if (chargingCinderhoof != null) { - chargingCinderhoof.addCounters(CounterType.FURY.createInstance(), game); + chargingCinderhoof.addCounters(CounterType.FURY.createInstance(), source, game); } else { chargingCinderhoof = game.getPermanentOrLKIBattlefield(source.getSourceId()); } diff --git a/Mage.Sets/src/mage/cards/c/ChorusOfTheConclave.java b/Mage.Sets/src/mage/cards/c/ChorusOfTheConclave.java index 06e57ba5df..c08a79536b 100644 --- a/Mage.Sets/src/mage/cards/c/ChorusOfTheConclave.java +++ b/Mage.Sets/src/mage/cards/c/ChorusOfTheConclave.java @@ -200,7 +200,7 @@ class ChorusOfTheConclaveReplacementEffect2 extends ReplacementEffectImpl { String key = event.getSourceId().toString() + (game.getState().getZoneChangeCounter(event.getSourceId()) - 1); int xValue = spellX.get(key); if (xValue > 0) { - creature.addCounters(CounterType.P1P1.createInstance(xValue), game); + creature.addCounters(CounterType.P1P1.createInstance(xValue), source, game); game.informPlayers(sourceObject.getLogName() + ": " + creature.getLogName() + " enters the battlefield with " + xValue + " +1/+1 counter" + (xValue > 1 ? "s" : "") + " on it"); } spellX.remove(key); diff --git a/Mage.Sets/src/mage/cards/c/CollectiveEffort.java b/Mage.Sets/src/mage/cards/c/CollectiveEffort.java index b148fd8847..8df3f87cde 100644 --- a/Mage.Sets/src/mage/cards/c/CollectiveEffort.java +++ b/Mage.Sets/src/mage/cards/c/CollectiveEffort.java @@ -131,7 +131,7 @@ class CollectiveEffortEffect extends OneShotEffect { Player target = game.getPlayer(source.getFirstTarget()); if (target != null) { for (Permanent p : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), target.getId(), game)) { - p.addCounters(CounterType.P1P1.createInstance(), game); + p.addCounters(CounterType.P1P1.createInstance(), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/c/CommonBond.java b/Mage.Sets/src/mage/cards/c/CommonBond.java index 96f3ac7a27..bbb2f1887f 100644 --- a/Mage.Sets/src/mage/cards/c/CommonBond.java +++ b/Mage.Sets/src/mage/cards/c/CommonBond.java @@ -84,12 +84,12 @@ class CommonBondEffect extends OneShotEffect { int affectedTargets = 0; Permanent permanent = game.getPermanent(source.getTargets().get(0).getFirstTarget()); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(1), game); + permanent.addCounters(CounterType.P1P1.createInstance(1), source, game); affectedTargets ++; } permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(1), game); + permanent.addCounters(CounterType.P1P1.createInstance(1), source, game); affectedTargets ++; } return affectedTargets > 0; diff --git a/Mage.Sets/src/mage/cards/c/ContagionEngine.java b/Mage.Sets/src/mage/cards/c/ContagionEngine.java index 22a5d4e7e1..a87d50e3f4 100644 --- a/Mage.Sets/src/mage/cards/c/ContagionEngine.java +++ b/Mage.Sets/src/mage/cards/c/ContagionEngine.java @@ -96,7 +96,7 @@ class ContagionEngineEffect extends OneShotEffect { Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); if (targetPlayer != null) { for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), targetPlayer.getId(), game)) { - creature.addCounters(CounterType.M1M1.createInstance(), game); + creature.addCounters(CounterType.M1M1.createInstance(), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/c/CradleOfVitality.java b/Mage.Sets/src/mage/cards/c/CradleOfVitality.java index bf359ed833..2343978634 100644 --- a/Mage.Sets/src/mage/cards/c/CradleOfVitality.java +++ b/Mage.Sets/src/mage/cards/c/CradleOfVitality.java @@ -129,7 +129,7 @@ class CradleOfVitalityEffect extends OneShotEffect { Integer amount = (Integer) getValue("amount"); for (UUID uuid : targetPointer.getTargets(game, source)) { Permanent permanent = game.getPermanent(uuid); - permanent.addCounters(CounterType.P1P1.createInstance(amount), game); + permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); affectedTargets ++; } return affectedTargets > 0; diff --git a/Mage.Sets/src/mage/cards/c/CryptbornHorror.java b/Mage.Sets/src/mage/cards/c/CryptbornHorror.java index b2e4c21d08..24be98a363 100644 --- a/Mage.Sets/src/mage/cards/c/CryptbornHorror.java +++ b/Mage.Sets/src/mage/cards/c/CryptbornHorror.java @@ -91,7 +91,7 @@ class CryptbornHorrorEffect extends OneShotEffect { if (permanent != null) { int oll = new OpponentsLostLifeCount().calculate(game, source, this); if (oll > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(oll), game); + permanent.addCounters(CounterType.P1P1.createInstance(oll), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/c/CyclopeanTomb.java b/Mage.Sets/src/mage/cards/c/CyclopeanTomb.java index 65d67df718..38a2568b0c 100644 --- a/Mage.Sets/src/mage/cards/c/CyclopeanTomb.java +++ b/Mage.Sets/src/mage/cards/c/CyclopeanTomb.java @@ -29,24 +29,19 @@ package mage.cards.c; import java.util.HashMap; import java.util.HashSet; -import java.util.List; -import java.util.Map; import java.util.Set; import java.util.UUID; -import mage.MageObject; import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; -import mage.abilities.condition.Condition; +import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility; import mage.abilities.condition.common.IsStepCondition; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.decorator.ConditionalActivatedAbility; -import mage.abilities.decorator.ConditionalOneShotEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; import mage.abilities.effects.common.continuous.BecomesBasicLandTargetEffect; import mage.abilities.effects.common.counter.AddCountersTargetEffect; import mage.abilities.effects.common.counter.RemoveAllCountersTargetEffect; @@ -62,17 +57,15 @@ import mage.constants.WatcherScope; import mage.constants.Zone; import mage.counters.CounterType; import mage.filter.common.FilterLandPermanent; -import mage.filter.predicate.Predicate; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.filter.predicate.permanent.CounterPredicate; +import mage.filter.predicate.permanent.PermanentIdPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetLandPermanent; import mage.target.targetpointer.FixedTarget; -import mage.util.CardUtil; import mage.watchers.Watcher; /** @@ -80,9 +73,9 @@ import mage.watchers.Watcher; * @author MTGfan */ public class CyclopeanTomb extends CardImpl { - + private static final FilterLandPermanent filter = new FilterLandPermanent(); - + static { filter.add(Predicates.not(new SubtypePredicate("Swamp"))); } @@ -97,9 +90,7 @@ public class CyclopeanTomb extends CardImpl { ability.addEffect(new BecomeSwampEffect(Duration.Custom, false, true, "Swamp")); this.addAbility(ability, new CyclopeanTombCounterWatcher()); // When Cyclopean Tomb is put into a graveyard from the battlefield, at the beginning of each of your upkeeps for the rest of the game, remove all mire counters from a land that a mire counter was put onto with Cyclopean Tomb but that a mire counter has not been removed from with Cyclopean Tomb. - Effect effect = new CreateDelayedTriggeredAbilityEffect(new CyclopeanTombDelayedTriggeredAbility()); - effect.setText("at the beginning of each of your upkeeps for the rest of the game, remove all mire counters from a land that a mire counter was put onto with {this} but that a mire counter has not been removed from with {this}."); - this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(effect)); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new CyclopeanTombCreateTriggeredEffect())); } public CyclopeanTomb(final CyclopeanTomb card) { @@ -113,16 +104,16 @@ public class CyclopeanTomb extends CardImpl { } class BecomeSwampEffect extends BecomesBasicLandTargetEffect { - + public BecomeSwampEffect(Duration duration, boolean chooseLandType, boolean loseOther, String... landNames) { super(duration, chooseLandType, loseOther, landNames); - staticText = "That land is a Swamp for as long as it has a mire counter on it."; + staticText = "That land is a Swamp for as long as it has a mire counter on it"; } - + public BecomeSwampEffect(final BecomeSwampEffect effect) { super(effect); } - + @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Permanent land = game.getPermanent(this.targetPointer.getFirst(game, source)); @@ -135,36 +126,42 @@ class BecomeSwampEffect extends BecomesBasicLandTargetEffect { } return true; } - + @Override public BecomeSwampEffect copy() { return new BecomeSwampEffect(this); } } -class CyclopeanTombDelayedTriggeredAbility extends DelayedTriggeredAbility { +class CyclopeanTombCreateTriggeredEffect extends OneShotEffect { - CyclopeanTombDelayedTriggeredAbility() { - super(new CyclopeanTombEffect(), Duration.OneUse, true, false); + public CyclopeanTombCreateTriggeredEffect() { + super(Outcome.Benefit); + this.staticText = "At the beginning of each of your upkeeps for the rest of the game, remove all mire counters from a land that a mire counter was put onto with {this} but that a mire counter has not been removed from with {this}"; } - CyclopeanTombDelayedTriggeredAbility(CyclopeanTombDelayedTriggeredAbility ability) { - super(ability); + public CyclopeanTombCreateTriggeredEffect(final CyclopeanTombCreateTriggeredEffect effect) { + super(effect); } @Override - public CyclopeanTombDelayedTriggeredAbility copy() { - return new CyclopeanTombDelayedTriggeredAbility(this); + public CyclopeanTombCreateTriggeredEffect copy() { + return new CyclopeanTombCreateTriggeredEffect(this); } @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.BEGINNING_PHASE_PRE; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - return event.getPlayerId().equals(this.controllerId); + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Permanent tomb = game.getPermanentOrLKIBattlefield(source.getSourceId()); // we need to set the correct source object + DelayedTriggeredAbility ability = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(new CyclopeanTombEffect(), Duration.EndOfGame, false); + ability.setSourceObject(tomb, game); + ability.setControllerId(source.getControllerId()); + ability.setSourceId(source.getSourceId()); + game.addDelayedTriggeredAbility(ability); + return true; + } + return false; } } @@ -172,9 +169,9 @@ class CyclopeanTombEffect extends OneShotEffect { public CyclopeanTombEffect() { super(Outcome.Benefit); - this.staticText = "at the beginning of each of your upkeeps for the rest of the game, remove all mire counters from a land that a mire counter was put onto with {this} but that a mire counter has not been removed from with {this}."; + this.staticText = "At the beginning of each of your upkeeps for the rest of the game, remove all mire counters from a land that a mire counter was put onto with {this} but that a mire counter has not been removed from with {this}"; } - + public CyclopeanTombEffect(final CyclopeanTombEffect effect) { super(effect); } @@ -187,121 +184,52 @@ class CyclopeanTombEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if(controller != null){ - new ChooseLandEffect().apply(game, source); - Effect effect = new RemoveAllCountersTargetEffect(CounterType.MIRE); - effect.setTargetPointer(new FixedTarget((UUID) game.getState().getValue(source.getSourceId().toString() + "_land"))); - effect.apply(game, source); - //CyclopianTombEffect and CyclopeanTombDelayedTriggeredAbility will maintain a loop - //as long as there are one or more mire counters left to be removed - new ConditionalOneShotEffect(new CreateDelayedTriggeredAbilityEffect(new CyclopeanTombDelayedTriggeredAbility(), false), new CyclopeanTombCounterCondition()).apply(game, source); - return true; - } - return false; - } -} - -class CyclopeanTombCounterCondition implements Condition { - - private static final FilterLandPermanent mireFilter = new FilterLandPermanent(); - - static { - mireFilter.add(new CounterPredicate(CounterType.MIRE)); - } - - public CyclopeanTombCounterCondition() { - } - - @Override - public boolean apply(Game game, Ability source) { - - List permanents = game.getBattlefield().getAllActivePermanents(mireFilter, game); - Permanent cyclopeanTombInstance = game.getPermanentOrLKIBattlefield(source.getSourceId()); + MageObjectReference mor = new MageObjectReference(source.getSourceId(), source.getSourceObjectZoneChangeCounter(), game); CyclopeanTombCounterWatcher watcher = (CyclopeanTombCounterWatcher) game.getState().getWatchers().get(CyclopeanTombCounterWatcher.class.getName()); - - for(Permanent land : permanents) { - if(watcher.landMiredByCyclopeanTombInstance(land, cyclopeanTombInstance, game)) { - return land.getCounters(game).getCount(CounterType.MIRE) > 0; + if (controller != null && watcher != null) { + + Set landRef = watcher.landMiredByCyclopeanTombInstance(mor, game); + if (landRef == null || landRef.isEmpty()) { // no lands got mire counter from that instance + return true; } - } - return false; - } -} - -class ChooseLandEffect extends OneShotEffect { - - public ChooseLandEffect() { - super(Outcome.Neutral); - this.staticText = "choose a land that a mire counter was put onto with Cyclopean Tomb but that a mire counter has not been removed from with Cyclopean Tomb"; - } - - public ChooseLandEffect(final ChooseLandEffect effect) { - super(effect); - } - - @Override - public ChooseLandEffect copy() { - return new ChooseLandEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - - Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getPermanentEntering(source.getSourceId()); - - if (mageObject == null) { - mageObject = game.getObject(source.getSourceId()); - } - - FilterLandPermanent filter = new FilterLandPermanent(); - filter.add(new LandIdPredicate(source)); - - if(controller != null && mageObject != null){ + FilterLandPermanent filter = new FilterLandPermanent("a land with a mire counter added from the Cyclopean Tomb instance (" + landRef.size() + " left)"); + Set idPref = new HashSet<>(); + for (MageObjectReference ref : landRef) { + Permanent land = ref.getPermanent(game); + if (land != null) { + idPref.add(new PermanentIdPredicate(land.getId())); + } + } + filter.add(Predicates.or(idPref)); TargetLandPermanent target = new TargetLandPermanent(1, 1, filter, true); /*Player must choose a land each upkeep. Using the message are above the player hand where frequent interactions * take place is the most logical way to prompt for this scenario. A new constructor added to provide a not optional * option for any cards like this where the player must choose a target in such the way this card requires. - */ - if (controller.chooseTarget(Outcome.Neutral, target, source, game, false)) { + */ + if (controller.chooseTarget(Outcome.Neutral, target, source, game)) { Permanent chosenLand = game.getPermanent(target.getFirstTarget()); - if(chosenLand != null) { - game.getState().setValue(mageObject.getId() + "_land", target.getFirstTarget()); - if (mageObject instanceof Permanent) { - ((Permanent) mageObject).addInfo("chosen land", CardUtil.addToolTipMarkTags("Chosen player: " + chosenLand.getLogName()), game); - } - return true; + if (chosenLand != null) { + Effect effect = new RemoveAllCountersTargetEffect(CounterType.MIRE); + effect.setTargetPointer(new FixedTarget(chosenLand, game)); + effect.apply(game, source); + landRef.remove(new MageObjectReference(chosenLand, game)); } } + + return true; } return false; } } -class LandIdPredicate implements Predicate { - - public Ability source; - - public LandIdPredicate(Ability source) { - this.source = source; - } - - @Override - public boolean apply(Permanent input, Game game) { - Permanent cyclopeanTombInstance = game.getPermanentOrLKIBattlefield(source.getSourceId()); - CyclopeanTombCounterWatcher watcher = (CyclopeanTombCounterWatcher) game.getState().getWatchers().get(CyclopeanTombCounterWatcher.class.getName()); - return watcher.landMiredByCyclopeanTombInstance(input, cyclopeanTombInstance, game); - } -} - class CyclopeanTombCounterWatcher extends Watcher { - + public HashMap> counterData = new HashMap<>(); - + public CyclopeanTombCounterWatcher() { super(CyclopeanTombCounterWatcher.class.getName(), WatcherScope.GAME); } - + public CyclopeanTombCounterWatcher(final CyclopeanTombCounterWatcher watcher) { super(watcher); for (MageObjectReference mageObjectReference : watcher.counterData.keySet()) { @@ -310,7 +238,7 @@ class CyclopeanTombCounterWatcher extends Watcher { counterData.put(mageObjectReference, miredLands); } } - + @Override public CyclopeanTombCounterWatcher copy() { return new CyclopeanTombCounterWatcher(this); @@ -318,27 +246,32 @@ class CyclopeanTombCounterWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if(event.getType() == GameEvent.EventType.COUNTER_ADDED || event.getType() == GameEvent.EventType.COUNTERS_ADDED) { - MageObjectReference cylopeanTombInstance = new MageObjectReference(/*ID needs to go here*/, game); - Set miredLands = counterData.get(cylopeanTombInstance); - if (miredLands != null) { + if (event.getType() == GameEvent.EventType.COUNTERS_ADDED && event.getData().equals(CounterType.MIRE.getName()) && event.getAmount() > 0) { + Permanent tomb = game.getPermanentOrLKIBattlefield(event.getSourceId()); + if (tomb != null) { + MageObjectReference cylopeanTombInstance = new MageObjectReference(tomb, game); + Set miredLands; + if (counterData.containsKey(cylopeanTombInstance)) { + miredLands = counterData.get(cylopeanTombInstance); + } else { + miredLands = new HashSet<>(); + counterData.put(cylopeanTombInstance, miredLands); + } miredLands.add(new MageObjectReference(event.getTargetId(), game)); - } else { - miredLands = new HashSet<>(); - miredLands.add(new MageObjectReference(event.getTargetId(), game)); - counterData.put(cylopeanTombInstance, miredLands); } + } } - + @Override public void reset() { super.reset(); - counterData.clear(); } - public boolean landMiredByCyclopeanTombInstance(Permanent land, Permanent cylopeanTombInstance, Game game) { - Set miredLands = counterData.get(new MageObjectReference(cylopeanTombInstance, game)); - return miredLands != null && miredLands.contains(new MageObjectReference(land, game)); + public Set landMiredByCyclopeanTombInstance(MageObjectReference mor, Game game) { + if (counterData.containsKey(mor)) { + return counterData.get(mor); + } + return null; } } diff --git a/Mage.Sets/src/mage/cards/c/CytoplastRootKin.java b/Mage.Sets/src/mage/cards/c/CytoplastRootKin.java index ec2f756f22..f441496207 100644 --- a/Mage.Sets/src/mage/cards/c/CytoplastRootKin.java +++ b/Mage.Sets/src/mage/cards/c/CytoplastRootKin.java @@ -115,7 +115,7 @@ class CytoplastRootKinEffect extends OneShotEffect { && !sourcePermanent.getId().equals(targetPermanent.getId()) && targetPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) { targetPermanent.removeCounters(CounterType.P1P1.createInstance(), game); - sourcePermanent.addCounters(CounterType.P1P1.createInstance(), game); + sourcePermanent.addCounters(CounterType.P1P1.createInstance(), source, game); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/d/DaghatarTheAdamant.java b/Mage.Sets/src/mage/cards/d/DaghatarTheAdamant.java index 6f4b22641d..ff830a1e69 100644 --- a/Mage.Sets/src/mage/cards/d/DaghatarTheAdamant.java +++ b/Mage.Sets/src/mage/cards/d/DaghatarTheAdamant.java @@ -114,7 +114,7 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect { Permanent toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); if (toPermanent != null) { fromPermanent.removeCounters(CounterType.P1P1.createInstance(), game); - toPermanent.addCounters(CounterType.P1P1.createInstance(), game); + toPermanent.addCounters(CounterType.P1P1.createInstance(), source, game); game.informPlayers(sourceObject.getLogName() + ": Moved a +1/+1 counter from " + fromPermanent.getLogName() +" to " + toPermanent.getLogName()); } } diff --git a/Mage.Sets/src/mage/cards/d/DarkIntimations.java b/Mage.Sets/src/mage/cards/d/DarkIntimations.java index 66a16f93fe..4b9e9da87f 100644 --- a/Mage.Sets/src/mage/cards/d/DarkIntimations.java +++ b/Mage.Sets/src/mage/cards/d/DarkIntimations.java @@ -232,7 +232,7 @@ class DarkIntimationsReplacementEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget(); if (creature != null) { - creature.addCounters(CounterType.LOYALTY.createInstance(), game); + creature.addCounters(CounterType.LOYALTY.createInstance(), source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/d/DearlyDeparted.java b/Mage.Sets/src/mage/cards/d/DearlyDeparted.java index 3e23f61bee..802c1caed2 100644 --- a/Mage.Sets/src/mage/cards/d/DearlyDeparted.java +++ b/Mage.Sets/src/mage/cards/d/DearlyDeparted.java @@ -103,7 +103,7 @@ class DearlyDepartedEntersBattlefieldEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent target = ((EntersTheBattlefieldEvent) event).getTarget(); if (target != null) { - target.addCounters(CounterType.P1P1.createInstance(), game); + target.addCounters(CounterType.P1P1.createInstance(), source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/d/DeepglowSkate.java b/Mage.Sets/src/mage/cards/d/DeepglowSkate.java index 597440d8c6..e41dcc6223 100644 --- a/Mage.Sets/src/mage/cards/d/DeepglowSkate.java +++ b/Mage.Sets/src/mage/cards/d/DeepglowSkate.java @@ -98,7 +98,7 @@ class DeepglowSkateEffect extends OneShotEffect { if (permanent != null) { for (Counter counter : permanent.getCounters(game).values()) { Counter newCounter = new Counter(counter.getName(), counter.getCount()); - permanent.addCounters(newCounter, game); + permanent.addCounters(newCounter, source, game); didOne = true; } } diff --git a/Mage.Sets/src/mage/cards/d/DefyDeath.java b/Mage.Sets/src/mage/cards/d/DefyDeath.java index add843dce7..b8427e4c9c 100644 --- a/Mage.Sets/src/mage/cards/d/DefyDeath.java +++ b/Mage.Sets/src/mage/cards/d/DefyDeath.java @@ -87,7 +87,7 @@ class DefyDeathEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null && permanent.hasSubtype("Angel", game)) { - permanent.addCounters(CounterType.P1P1.createInstance(2), game); + permanent.addCounters(CounterType.P1P1.createInstance(2), source, game); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/d/Delay.java b/Mage.Sets/src/mage/cards/d/Delay.java index 8cc3940f09..262845b5de 100644 --- a/Mage.Sets/src/mage/cards/d/Delay.java +++ b/Mage.Sets/src/mage/cards/d/Delay.java @@ -100,7 +100,7 @@ class DelayEffect extends OneShotEffect { boolean hasSuspend = card.getAbilities().containsClass(SuspendAbility.class); UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game); if (controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getLogName(), source.getSourceId(), game, Zone.HAND, true)) { - card.addCounters(CounterType.TIME.createInstance(3), game); + card.addCounters(CounterType.TIME.createInstance(3), source, game); if (!hasSuspend) { game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source); } diff --git a/Mage.Sets/src/mage/cards/d/DelifsCube.java b/Mage.Sets/src/mage/cards/d/DelifsCube.java index e692f06ff9..265415b85d 100644 --- a/Mage.Sets/src/mage/cards/d/DelifsCube.java +++ b/Mage.Sets/src/mage/cards/d/DelifsCube.java @@ -112,7 +112,7 @@ class DelifsCubeEffect extends OneShotEffect{ public boolean apply(Game game, Ability source) { Permanent perm = game.getPermanent(cubeId); if (perm == null) return false; - perm.addCounters(CounterType.CUBE.createInstance(), game); + perm.addCounters(CounterType.CUBE.createInstance(), source, game); return true; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/d/DescentIntoMadness.java b/Mage.Sets/src/mage/cards/d/DescentIntoMadness.java index 9a12814cbf..1a6db47f33 100644 --- a/Mage.Sets/src/mage/cards/d/DescentIntoMadness.java +++ b/Mage.Sets/src/mage/cards/d/DescentIntoMadness.java @@ -111,7 +111,7 @@ class DescentIntoMadnessEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null && controller != null) { - sourcePermanent.addCounters(CounterType.DESPAIR.createInstance(), game); + sourcePermanent.addCounters(CounterType.DESPAIR.createInstance(), source, game); } if (sourcePermanent == null) { sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); diff --git a/Mage.Sets/src/mage/cards/d/DesecrationDemon.java b/Mage.Sets/src/mage/cards/d/DesecrationDemon.java index c3550fa309..4e33319d83 100644 --- a/Mage.Sets/src/mage/cards/d/DesecrationDemon.java +++ b/Mage.Sets/src/mage/cards/d/DesecrationDemon.java @@ -110,7 +110,7 @@ class DesecrationDemonEffect extends OneShotEffect { permanent.sacrifice(source.getSourceId(), game); game.informPlayers(opponent.getLogName() + " sacrifices " + permanent.getLogName() + " to tap " + descrationDemon.getLogName() + ". A +1/+1 counter was put on it"); descrationDemon.tap(game); - descrationDemon.addCounters(CounterType.P1P1.createInstance(), game); + descrationDemon.addCounters(CounterType.P1P1.createInstance(), source, game); } } } diff --git a/Mage.Sets/src/mage/cards/d/DiregrafColossus.java b/Mage.Sets/src/mage/cards/d/DiregrafColossus.java index a02bbb46e5..4281ccec0b 100644 --- a/Mage.Sets/src/mage/cards/d/DiregrafColossus.java +++ b/Mage.Sets/src/mage/cards/d/DiregrafColossus.java @@ -109,7 +109,7 @@ class DiregrafColossusEffect extends OneShotEffect { int amount = 0; amount += player.getGraveyard().count(filter, game); if (amount > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(amount), game); + permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/d/DustOfMoments.java b/Mage.Sets/src/mage/cards/d/DustOfMoments.java index 9e9a3273a4..658d0dc24b 100644 --- a/Mage.Sets/src/mage/cards/d/DustOfMoments.java +++ b/Mage.Sets/src/mage/cards/d/DustOfMoments.java @@ -29,7 +29,6 @@ package mage.cards.d; import java.util.List; import java.util.UUID; - import mage.MageObject; import mage.abilities.Ability; import mage.abilities.Mode; @@ -53,12 +52,12 @@ import mage.players.Player; /** * * @author Gal Lerman - + * */ public class DustOfMoments extends CardImpl { public DustOfMoments(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{W}"); // Choose one - Remove two time counters from each permanent and each suspended card this.getSpellAbility().addEffect(new RemoveCountersEffect()); @@ -78,171 +77,172 @@ public class DustOfMoments extends CardImpl { return new DustOfMoments(this); } + //TODO: PermanentImpl.getCounters() and CardImpl.getCounters(game) don't return the same value for the same Card + //TODO: This means I can't use a Card generic for Permanents and Exiled cards and use Card.getCounters(game) + //TODO: This is the reason i've copy pasted some logic in DustOfMomentsEffect + //TODO: After this issue is fixed/explained i'll refactor the code + public abstract static class DustOfMomentsEffect extends OneShotEffect { - //TODO: PermanentImpl.getCounters() and CardImpl.getCounters(game) don't return the same value for the same Card - //TODO: This means I can't use a Card generic for Permanents and Exiled cards and use Card.getCounters(game) - //TODO: This is the reason i've copy pasted some logic in DustOfMomentsEffect - //TODO: After this issue is fixed/explained i'll refactor the code - public abstract static class DustOfMomentsEffect extends OneShotEffect { + private final Counter counter; + private final Filter permFilter; + private final Filter exiledFilter; - private final Counter counter; - private final Filter permFilter; - private final Filter exiledFilter; + public DustOfMomentsEffect() { + super(Outcome.Benefit); + this.counter = new Counter(CounterType.TIME.getName(), 2); + this.permFilter = new FilterCard("permanent and each suspended card"); + permFilter.add(new CounterPredicate(CounterType.TIME)); - public DustOfMomentsEffect() { - super(Outcome.Benefit); - this.counter = new Counter(CounterType.TIME.getName(), 2); - this.permFilter = new FilterCard("permanent and each suspended card"); - permFilter.add(new CounterPredicate(CounterType.TIME)); - - this.exiledFilter = new FilterCard("permanent and each suspended card"); - exiledFilter.add(new CardCounterPredicate(CounterType.TIME)); - setText(); - } - - public DustOfMomentsEffect(final DustOfMomentsEffect effect) { - super(effect); - this.counter = effect.counter.copy(); - this.permFilter = effect.permFilter.copy(); - this.exiledFilter = effect.exiledFilter.copy(); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); - if (controller != null && sourceObject != null) { - updatePermanents(game, controller, sourceObject); - updateSuspended(game, controller, sourceObject); - return true; - } - return false; - } - - private void updateSuspended(final Game game, final Player controller, final MageObject sourceObject) { - final List exiledCards = game.getExile().getAllCards(game); - execute(game, controller, sourceObject, exiledCards); - } - - private void updatePermanents(final Game game, final Player controller, final MageObject sourceObject) { - List permanents = game.getBattlefield().getAllActivePermanents(); - executeP(game, controller, sourceObject, permanents); - } - - private void executeP(final Game game, final Player controller, final MageObject sourceObject, final List cards) { - if (cards == null || cards.isEmpty()) { - return; - } - for (Permanent card : cards) { - if (permFilter.match(card, game)) { - final String counterName = counter.getName(); - if (shouldRemoveCounters()) { - final Counter existingCounterOfSameType = card.getCounters(game).get(counterName); - final int countersToRemove = Math.min(existingCounterOfSameType.getCount(), counter.getCount()); - final Counter modifiedCounter = new Counter(counterName, countersToRemove); - card.removeCounters(modifiedCounter, game); - } else { - card.addCounters(counter, game); - } - if (!game.isSimulation()) - game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ") - .append(controller.getLogName()).append(getActionStr()).append("s") - .append(counter.getCount()).append(" ").append(counterName.toLowerCase()) - .append(" counter on ").append(card.getName()).toString()); - } - } - } - - private void execute(final Game game, final Player controller, final MageObject sourceObject, final List cards) { - if (cards == null || cards.isEmpty()) { - return; - } - for (Card card : cards) { - if (exiledFilter.match(card, game)) { - final String counterName = counter.getName(); - if (shouldRemoveCounters()) { - final Counter existingCounterOfSameType = card.getCounters(game).get(counterName); - final int countersToRemove = Math.min(existingCounterOfSameType.getCount(), counter.getCount()); - final Counter modifiedCounter = new Counter(counterName, countersToRemove); - card.removeCounters(modifiedCounter, game); - } else { - card.addCounters(counter, game); - } - if (!game.isSimulation()) - game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ") - .append(controller.getLogName()).append(getActionStr()).append("s ") - .append(counter.getCount()).append(" ").append(counterName.toLowerCase()) - .append(" counter on ").append(card.getName()).toString()); + this.exiledFilter = new FilterCard("permanent and each suspended card"); + exiledFilter.add(new CardCounterPredicate(CounterType.TIME)); + setText(); + } + + public DustOfMomentsEffect(final DustOfMomentsEffect effect) { + super(effect); + this.counter = effect.counter.copy(); + this.permFilter = effect.permFilter.copy(); + this.exiledFilter = effect.exiledFilter.copy(); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (controller != null && sourceObject != null) { + updatePermanents(source, game, controller, sourceObject); + updateSuspended(source, game, controller, sourceObject); + return true; + } + return false; + } + + private void updateSuspended(final Ability source, final Game game, final Player controller, final MageObject sourceObject) { + final List exiledCards = game.getExile().getAllCards(game); + execute(source, game, controller, sourceObject, exiledCards); + } + + private void updatePermanents(final Ability source, final Game game, final Player controller, final MageObject sourceObject) { + List permanents = game.getBattlefield().getAllActivePermanents(); + executeP(source, game, controller, sourceObject, permanents); + } + + private void executeP(final Ability source, final Game game, final Player controller, final MageObject sourceObject, final List cards) { + if (cards == null || cards.isEmpty()) { + return; + } + for (Permanent card : cards) { + if (permFilter.match(card, game)) { + final String counterName = counter.getName(); + if (shouldRemoveCounters()) { + final Counter existingCounterOfSameType = card.getCounters(game).get(counterName); + final int countersToRemove = Math.min(existingCounterOfSameType.getCount(), counter.getCount()); + final Counter modifiedCounter = new Counter(counterName, countersToRemove); + card.removeCounters(modifiedCounter, game); + } else { + card.addCounters(counter, source, game); + } + if (!game.isSimulation()) { + game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ") + .append(controller.getLogName()).append(getActionStr()).append("s") + .append(counter.getCount()).append(" ").append(counterName.toLowerCase()) + .append(" counter on ").append(card.getName()).toString()); + } + } + } + } + + private void execute(final Ability source, final Game game, final Player controller, final MageObject sourceObject, final List cards) { + if (cards == null || cards.isEmpty()) { + return; + } + for (Card card : cards) { + if (exiledFilter.match(card, game)) { + final String counterName = counter.getName(); + if (shouldRemoveCounters()) { + final Counter existingCounterOfSameType = card.getCounters(game).get(counterName); + final int countersToRemove = Math.min(existingCounterOfSameType.getCount(), counter.getCount()); + final Counter modifiedCounter = new Counter(counterName, countersToRemove); + card.removeCounters(modifiedCounter, game); + } else { + card.addCounters(counter, source, game); + } + if (!game.isSimulation()) { + game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ") + .append(controller.getLogName()).append(getActionStr()).append("s ") + .append(counter.getCount()).append(" ").append(counterName.toLowerCase()) + .append(" counter on ").append(card.getName()).toString()); + } + } + } + } + + protected abstract boolean shouldRemoveCounters(); + + protected abstract String getActionStr(); + + private void setText() { + StringBuilder sb = new StringBuilder(); + sb.append(getActionStr()); + if (counter.getCount() > 1) { + sb.append(Integer.toString(counter.getCount())).append(" ").append(counter.getName().toLowerCase()).append(" counters on each "); + } else { + sb.append("a ").append(counter.getName().toLowerCase()).append(" counter on each "); + } + sb.append(permFilter.getMessage()); + staticText = sb.toString(); } - } } - protected abstract boolean shouldRemoveCounters(); + public static class AddCountersEffect extends DustOfMomentsEffect { - protected abstract String getActionStr(); + public AddCountersEffect() { + super(); + } - private void setText() { - StringBuilder sb = new StringBuilder(); - sb.append(getActionStr()); - if (counter.getCount() > 1) { - sb.append(Integer.toString(counter.getCount())).append(" ").append(counter.getName().toLowerCase()).append(" counters on each "); - } else { - sb.append("a ").append(counter.getName().toLowerCase()).append(" counter on each "); - } - sb.append(permFilter.getMessage()); - staticText = sb.toString(); - } - } + public AddCountersEffect(final DustOfMomentsEffect effect) { + super(effect); + } - public static class AddCountersEffect extends DustOfMomentsEffect { + @Override + protected boolean shouldRemoveCounters() { + return false; + } - public AddCountersEffect() { - super(); + @Override + protected String getActionStr() { + return "add"; + } + + @Override + public Effect copy() { + return new AddCountersEffect(this); + } } - public AddCountersEffect(final DustOfMomentsEffect effect) { - super(effect); - } + public static class RemoveCountersEffect extends DustOfMomentsEffect { - @Override - protected boolean shouldRemoveCounters() { - return false; - } + public RemoveCountersEffect() { + super(); + } - @Override - protected String getActionStr() { - return "add"; - } + public RemoveCountersEffect(final DustOfMomentsEffect effect) { + super(effect); + } - @Override - public Effect copy() { - return new AddCountersEffect(this); - } - } + @Override + protected boolean shouldRemoveCounters() { + return true; + } - public static class RemoveCountersEffect extends DustOfMomentsEffect { + @Override + protected String getActionStr() { + return "remove"; + } - public RemoveCountersEffect() { - super(); + @Override + public Effect copy() { + return new RemoveCountersEffect(this); + } } - - public RemoveCountersEffect(final DustOfMomentsEffect effect) { - super(effect); - } - - @Override - protected boolean shouldRemoveCounters() { - return true; - } - - @Override - protected String getActionStr() { - return "remove"; - } - - @Override - public Effect copy() { - return new RemoveCountersEffect(this); - } - } } diff --git a/Mage.Sets/src/mage/cards/e/EbonPraetor.java b/Mage.Sets/src/mage/cards/e/EbonPraetor.java index 399d059a12..380093fd8a 100644 --- a/Mage.Sets/src/mage/cards/e/EbonPraetor.java +++ b/Mage.Sets/src/mage/cards/e/EbonPraetor.java @@ -115,7 +115,7 @@ class EbonPraetorEffect extends OneShotEffect { Permanent sacrificedCreature = ((SacrificeTargetCost) cost).getPermanents().get(0); Permanent sourceCreature = game.getPermanent(source.getSourceId()); if (sacrificedCreature.hasSubtype("Thrull", game) && sourceCreature != null) { - sourceCreature.addCounters(CounterType.P1P0.createInstance(), game); + sourceCreature.addCounters(CounterType.P1P0.createInstance(), source, game); return true; } } diff --git a/Mage.Sets/src/mage/cards/e/ElderCathar.java b/Mage.Sets/src/mage/cards/e/ElderCathar.java index 55540eb827..65045ba693 100644 --- a/Mage.Sets/src/mage/cards/e/ElderCathar.java +++ b/Mage.Sets/src/mage/cards/e/ElderCathar.java @@ -96,9 +96,9 @@ class ElderCatharAddCountersTargetEffect extends OneShotEffect { if (permanent != null) { if (counter != null) { if (permanent.hasSubtype("Human", game)) { - permanent.addCounters(counter2.copy(), game); + permanent.addCounters(counter2.copy(), source, game); } else { - permanent.addCounters(counter.copy(), game); + permanent.addCounters(counter.copy(), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/e/Epochrasite.java b/Mage.Sets/src/mage/cards/e/Epochrasite.java index 226e153081..c29abb4ae6 100644 --- a/Mage.Sets/src/mage/cards/e/Epochrasite.java +++ b/Mage.Sets/src/mage/cards/e/Epochrasite.java @@ -108,7 +108,7 @@ class EpochrasiteEffect extends OneShotEffect { if (game.getState().getZone(card.getId()).equals(Zone.GRAVEYARD)) { UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game); controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source.getSourceId(), game, Zone.GRAVEYARD, true); - card.addCounters(CounterType.TIME.createInstance(3), game); + card.addCounters(CounterType.TIME.createInstance(3), source, game); game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source); } return true; diff --git a/Mage.Sets/src/mage/cards/e/EternityVessel.java b/Mage.Sets/src/mage/cards/e/EternityVessel.java index 6bd16250fe..17a2920380 100644 --- a/Mage.Sets/src/mage/cards/e/EternityVessel.java +++ b/Mage.Sets/src/mage/cards/e/EternityVessel.java @@ -86,7 +86,7 @@ class EternityVesselEffect extends OneShotEffect { if (vessel != null && controller != null) { int amount = controller.getLife(); if (amount > 0) { - vessel.addCounters(CounterType.CHARGE.createInstance(amount), game); + vessel.addCounters(CounterType.CHARGE.createInstance(amount), source, game); } return true; diff --git a/Mage.Sets/src/mage/cards/e/EverlastingTorment.java b/Mage.Sets/src/mage/cards/e/EverlastingTorment.java index 7f35dc3dbd..322dffbe1a 100644 --- a/Mage.Sets/src/mage/cards/e/EverlastingTorment.java +++ b/Mage.Sets/src/mage/cards/e/EverlastingTorment.java @@ -105,7 +105,7 @@ class DamageDealtAsIfSourceHadWitherEffect extends ReplacementEffectImpl { Counter counter = CounterType.M1M1.createInstance(damageAmount); Permanent creatureDamaged = game.getPermanent(event.getTargetId()); if (creatureDamaged != null) { - creatureDamaged.addCounters(counter, game); + creatureDamaged.addCounters(counter, source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/e/EvolutionaryEscalation.java b/Mage.Sets/src/mage/cards/e/EvolutionaryEscalation.java index 322929d631..d20c956063 100644 --- a/Mage.Sets/src/mage/cards/e/EvolutionaryEscalation.java +++ b/Mage.Sets/src/mage/cards/e/EvolutionaryEscalation.java @@ -96,7 +96,7 @@ class EvolutionaryEscalationEffect extends OneShotEffect { for (Target target: source.getTargets()) { Permanent targetPermanent = game.getPermanent(target.getFirstTarget()); if (targetPermanent != null) { - targetPermanent.addCounters(counter.copy(), game); + targetPermanent.addCounters(counter.copy(), source, game); addedCounters = true; } } diff --git a/Mage.Sets/src/mage/cards/e/EyeOfDoom.java b/Mage.Sets/src/mage/cards/e/EyeOfDoom.java index 385b27f0d3..6a665a99c2 100644 --- a/Mage.Sets/src/mage/cards/e/EyeOfDoom.java +++ b/Mage.Sets/src/mage/cards/e/EyeOfDoom.java @@ -123,7 +123,7 @@ class EyeOfDoomEffect extends OneShotEffect { } while (!player.getId().equals(game.getActivePlayerId())); for (Permanent permanent: permanents) { - permanent.addCounters(CounterType.DOOM.createInstance(), game); + permanent.addCounters(CounterType.DOOM.createInstance(), source, game); } return true; diff --git a/Mage.Sets/src/mage/cards/e/EzuriClawOfProgress.java b/Mage.Sets/src/mage/cards/e/EzuriClawOfProgress.java index 18ed147a15..1aee5113fc 100644 --- a/Mage.Sets/src/mage/cards/e/EzuriClawOfProgress.java +++ b/Mage.Sets/src/mage/cards/e/EzuriClawOfProgress.java @@ -119,7 +119,7 @@ class EzuriClawOfProgressEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int amount = controller.getCounters().getCount(CounterType.EXPERIENCE); - target.addCounters(CounterType.P1P1.createInstance(amount), game); + target.addCounters(CounterType.P1P1.createInstance(amount), source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/f/FalkenrathAristocrat.java b/Mage.Sets/src/mage/cards/f/FalkenrathAristocrat.java index b308c249b7..cda6109e11 100644 --- a/Mage.Sets/src/mage/cards/f/FalkenrathAristocrat.java +++ b/Mage.Sets/src/mage/cards/f/FalkenrathAristocrat.java @@ -106,7 +106,7 @@ class FalkenrathAristocratEffect extends OneShotEffect { Permanent sacrificedCreature = ((SacrificeTargetCost) cost).getPermanents().get(0); Permanent sourceCreature = game.getPermanent(source.getSourceId()); if (sacrificedCreature.hasSubtype("Human", game) && sourceCreature != null) { - sourceCreature.addCounters(CounterType.P1P1.createInstance(), game); + sourceCreature.addCounters(CounterType.P1P1.createInstance(), source, game); return true; } } diff --git a/Mage.Sets/src/mage/cards/f/FalkenrathTorturer.java b/Mage.Sets/src/mage/cards/f/FalkenrathTorturer.java index 4ace0b705f..c8df415762 100644 --- a/Mage.Sets/src/mage/cards/f/FalkenrathTorturer.java +++ b/Mage.Sets/src/mage/cards/f/FalkenrathTorturer.java @@ -102,7 +102,7 @@ class FalkenrathTorturerEffect extends OneShotEffect { Permanent sacrificedCreature = ((SacrificeTargetCost) cost).getPermanents().get(0); Permanent sourceCreature = game.getPermanent(source.getSourceId()); if (sacrificedCreature.hasSubtype("Human", game) && sourceCreature != null) { - sourceCreature.addCounters(CounterType.P1P1.createInstance(), game); + sourceCreature.addCounters(CounterType.P1P1.createInstance(), source, game); return true; } } diff --git a/Mage.Sets/src/mage/cards/f/FateTransfer.java b/Mage.Sets/src/mage/cards/f/FateTransfer.java index 1fe3582916..523ac5aa64 100644 --- a/Mage.Sets/src/mage/cards/f/FateTransfer.java +++ b/Mage.Sets/src/mage/cards/f/FateTransfer.java @@ -103,7 +103,7 @@ class FateTransferEffect extends OneShotEffect { Permanent copyCreature = creatureToMoveCountersFrom.copy(); for (Counter counter : copyCreature.getCounters(game).values()) { creatureToMoveCountersFrom.removeCounters(counter, game); - creatureToMoveCountersTo.addCounters(counter, game); + creatureToMoveCountersTo.addCounters(counter, source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/f/FearsomeAwakening.java b/Mage.Sets/src/mage/cards/f/FearsomeAwakening.java index 9ce372bf4b..656b8a555d 100644 --- a/Mage.Sets/src/mage/cards/f/FearsomeAwakening.java +++ b/Mage.Sets/src/mage/cards/f/FearsomeAwakening.java @@ -86,7 +86,7 @@ class FearsomeAwakeningEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null && permanent.hasSubtype("Dragon", game)) { - permanent.addCounters(CounterType.P1P1.createInstance(2), game); + permanent.addCounters(CounterType.P1P1.createInstance(2), source, game); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/f/FleshBlood.java b/Mage.Sets/src/mage/cards/f/FleshBlood.java index 778430ffd6..59f370b415 100644 --- a/Mage.Sets/src/mage/cards/f/FleshBlood.java +++ b/Mage.Sets/src/mage/cards/f/FleshBlood.java @@ -104,7 +104,7 @@ class FleshEffect extends OneShotEffect { if (power > 0) { Permanent targetCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget()); if (targetCreature != null) { - targetCreature.addCounters(CounterType.P1P1.createInstance(power), game); + targetCreature.addCounters(CounterType.P1P1.createInstance(power), source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/f/ForgottenAncient.java b/Mage.Sets/src/mage/cards/f/ForgottenAncient.java index f5d6849fe3..d13001fa77 100644 --- a/Mage.Sets/src/mage/cards/f/ForgottenAncient.java +++ b/Mage.Sets/src/mage/cards/f/ForgottenAncient.java @@ -149,7 +149,7 @@ public class ForgottenAncient extends CardImpl { //Move all the counters for each chosen creature for(CounterMovement cm: counterMovements) { sourcePermanent.removeCounters(CounterType.P1P1.createInstance(cm.counters), game); - game.getPermanent(cm.target).addCounters(CounterType.P1P1.createInstance(cm.counters), game); + game.getPermanent(cm.target).addCounters(CounterType.P1P1.createInstance(cm.counters), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/f/FulfillContract.java b/Mage.Sets/src/mage/cards/f/FulfillContract.java index 85bcf5323d..3c5fb1f093 100644 --- a/Mage.Sets/src/mage/cards/f/FulfillContract.java +++ b/Mage.Sets/src/mage/cards/f/FulfillContract.java @@ -104,7 +104,7 @@ class FulfillContractEffect extends OneShotEffect { if (controller != null) { if (permanentToDestroy != null && permanentToDestroy.destroy(source.getSourceId(), game, false)) { if (permanentToPutCounter != null) { - permanentToPutCounter.addCounters(CounterType.P1P1.createInstance(), game); + permanentToPutCounter.addCounters(CounterType.P1P1.createInstance(), source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/g/GemstoneCaverns.java b/Mage.Sets/src/mage/cards/g/GemstoneCaverns.java index aebc017e86..931d1d875d 100644 --- a/Mage.Sets/src/mage/cards/g/GemstoneCaverns.java +++ b/Mage.Sets/src/mage/cards/g/GemstoneCaverns.java @@ -149,7 +149,7 @@ class GemstoneCavernsEffect extends OneShotEffect { if (card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), source.getControllerId())) { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { - permanent.addCounters(CounterType.LUCK.createInstance(), game); + permanent.addCounters(CounterType.LUCK.createInstance(), source, game); Cost cost = new ExileFromHandCost(new TargetCardInHand()); if (cost.canPay(source, source.getSourceId(), source.getControllerId(), game)) { cost.pay(source, game, source.getSourceId(), source.getControllerId(), true, null); diff --git a/Mage.Sets/src/mage/cards/g/GilderBairn.java b/Mage.Sets/src/mage/cards/g/GilderBairn.java index 321e66118c..1dcbbadf8e 100644 --- a/Mage.Sets/src/mage/cards/g/GilderBairn.java +++ b/Mage.Sets/src/mage/cards/g/GilderBairn.java @@ -107,7 +107,7 @@ class GilderBairnEffect extends OneShotEffect { } for (Counter counter : target.getCounters(game).values()) { Counter newCounter = new Counter(counter.getName(), counter.getCount()); - target.addCounters(newCounter, game); + target.addCounters(newCounter, source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/g/GlisteningOil.java b/Mage.Sets/src/mage/cards/g/GlisteningOil.java index 418cbf6cb7..1c5d0e20aa 100644 --- a/Mage.Sets/src/mage/cards/g/GlisteningOil.java +++ b/Mage.Sets/src/mage/cards/g/GlisteningOil.java @@ -102,7 +102,7 @@ class GlisteningOilEffect extends OneShotEffect { if (enchantment != null && enchantment.getAttachedTo() != null) { Permanent creature = game.getPermanent(enchantment.getAttachedTo()); if (creature != null) { - creature.addCounters(CounterType.M1M1.createInstance(), game); + creature.addCounters(CounterType.M1M1.createInstance(), source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/g/GolgariGraveTroll.java b/Mage.Sets/src/mage/cards/g/GolgariGraveTroll.java index f5c56b1d72..65ff855217 100644 --- a/Mage.Sets/src/mage/cards/g/GolgariGraveTroll.java +++ b/Mage.Sets/src/mage/cards/g/GolgariGraveTroll.java @@ -107,7 +107,7 @@ class GolgariGraveTrollEffect extends OneShotEffect { if (permanent != null && player != null) { int amount = player.getGraveyard().count(filter, game); if (amount > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(amount), game); + permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/g/GraveBetrayal.java b/Mage.Sets/src/mage/cards/g/GraveBetrayal.java index 0a481720e2..3896239246 100644 --- a/Mage.Sets/src/mage/cards/g/GraveBetrayal.java +++ b/Mage.Sets/src/mage/cards/g/GraveBetrayal.java @@ -146,7 +146,7 @@ class GraveBetrayalEffect extends OneShotEffect { Zone currentZone = game.getState().getZone(card.getId()); if (card.putOntoBattlefield(game, currentZone, source.getSourceId(), source.getControllerId())) { Permanent creature = game.getPermanent(card.getId()); - creature.addCounters(CounterType.P1P1.createInstance(), game); + creature.addCounters(CounterType.P1P1.createInstance(), source, game); ContinuousEffect effect = new GraveBetrayalContiniousEffect(); effect.setTargetPointer(new FixedTarget(creature.getId())); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/g/GriefTyrant.java b/Mage.Sets/src/mage/cards/g/GriefTyrant.java index 0d92989871..180849399b 100644 --- a/Mage.Sets/src/mage/cards/g/GriefTyrant.java +++ b/Mage.Sets/src/mage/cards/g/GriefTyrant.java @@ -97,7 +97,7 @@ class GriefTyrantEffect extends OneShotEffect { Permanent griefTyrant = game.getPermanentOrLKIBattlefield(source.getSourceId()); int countersOnGriefTyrant = griefTyrant.getCounters(game).getCount(CounterType.M1M1); if (targetCreature != null) { - targetCreature.addCounters(CounterType.M1M1.createInstance(countersOnGriefTyrant), game); + targetCreature.addCounters(CounterType.M1M1.createInstance(countersOnGriefTyrant), source, game); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/g/GwafaHazidProfiteer.java b/Mage.Sets/src/mage/cards/g/GwafaHazidProfiteer.java index b23018a721..3bb99f3169 100644 --- a/Mage.Sets/src/mage/cards/g/GwafaHazidProfiteer.java +++ b/Mage.Sets/src/mage/cards/g/GwafaHazidProfiteer.java @@ -109,7 +109,7 @@ class GwafaHazidProfiteerEffect1 extends OneShotEffect { Permanent targetCreature = game.getPermanent(source.getFirstTarget()); if (targetCreature != null) { Player controller = game.getPlayer(targetCreature.getControllerId()); - targetCreature.addCounters(CounterType.BRIBERY.createInstance(), game); + targetCreature.addCounters(CounterType.BRIBERY.createInstance(), source, game); if (controller != null) { controller.drawCards(1, game); } diff --git a/Mage.Sets/src/mage/cards/h/HamletbackGoliath.java b/Mage.Sets/src/mage/cards/h/HamletbackGoliath.java index c58d41be45..c0fe849904 100644 --- a/Mage.Sets/src/mage/cards/h/HamletbackGoliath.java +++ b/Mage.Sets/src/mage/cards/h/HamletbackGoliath.java @@ -131,7 +131,7 @@ class HamletbackGoliathEffect extends OneShotEffect { creature = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD); } if (creature != null && sourceObject != null) { - sourceObject.addCounters(CounterType.P1P1.createInstance(creature.getPower().getValue()), game); + sourceObject.addCounters(CounterType.P1P1.createInstance(creature.getPower().getValue()), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/h/Hankyu.java b/Mage.Sets/src/mage/cards/h/Hankyu.java index 5a45860556..a787698b2a 100644 --- a/Mage.Sets/src/mage/cards/h/Hankyu.java +++ b/Mage.Sets/src/mage/cards/h/Hankyu.java @@ -106,7 +106,7 @@ class HankyuAddCounterEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent equipment = game.getPermanent(this.effectGivingEquipmentId); if (equipment != null) { - equipment.addCounters(CounterType.AIM.createInstance(), game); + equipment.addCounters(CounterType.AIM.createInstance(), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/h/HatchetBully.java b/Mage.Sets/src/mage/cards/h/HatchetBully.java index 6a1e5e78a5..84787a811a 100644 --- a/Mage.Sets/src/mage/cards/h/HatchetBully.java +++ b/Mage.Sets/src/mage/cards/h/HatchetBully.java @@ -56,7 +56,7 @@ import mage.target.common.TargetCreatureOrPlayer; public class HatchetBully extends CardImpl { public HatchetBully(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}"); this.subtype.add("Goblin"); this.subtype.add("Warrior"); @@ -104,7 +104,7 @@ class HatchetBullyCost extends CostImpl { public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { Permanent permanent = game.getPermanent(ability.getTargets().get(1).getFirstTarget()); if (permanent != null) { - permanent.addCounters(CounterType.M1M1.createInstance(), game); + permanent.addCounters(CounterType.M1M1.createInstance(), ability, game); this.paid = true; } return paid; @@ -117,7 +117,7 @@ class HatchetBullyCost extends CostImpl { } class HatchetBullyEffect extends OneShotEffect { - + public HatchetBullyEffect() { super(Outcome.Damage); staticText = "{this} deals 2 damage to target creature or player"; diff --git a/Mage.Sets/src/mage/cards/i/ImmaculateMagistrate.java b/Mage.Sets/src/mage/cards/i/ImmaculateMagistrate.java index 1ef151fd9f..d1041acc7d 100644 --- a/Mage.Sets/src/mage/cards/i/ImmaculateMagistrate.java +++ b/Mage.Sets/src/mage/cards/i/ImmaculateMagistrate.java @@ -103,7 +103,7 @@ class ImmaculateMagistrateEffect extends OneShotEffect { if (permanent != null) { int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); if (count > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(count), game); + permanent.addCounters(CounterType.P1P1.createInstance(count), source, game); return true; } } diff --git a/Mage.Sets/src/mage/cards/i/IncreasingSavagery.java b/Mage.Sets/src/mage/cards/i/IncreasingSavagery.java index 2ff7bf31bd..830f108161 100644 --- a/Mage.Sets/src/mage/cards/i/IncreasingSavagery.java +++ b/Mage.Sets/src/mage/cards/i/IncreasingSavagery.java @@ -91,7 +91,7 @@ class IncreasingSavageryEffect extends OneShotEffect { } Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(amount), game); + permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/i/IncrementalBlight.java b/Mage.Sets/src/mage/cards/i/IncrementalBlight.java index 150a56932e..9c2401a85d 100644 --- a/Mage.Sets/src/mage/cards/i/IncrementalBlight.java +++ b/Mage.Sets/src/mage/cards/i/IncrementalBlight.java @@ -105,7 +105,7 @@ class IncrementalBlightEffect extends OneShotEffect { i++; Permanent creature = game.getPermanent(target.getFirstTarget()); if (creature != null) { - creature.addCounters(CounterType.M1M1.createInstance(i), game); + creature.addCounters(CounterType.M1M1.createInstance(i), source, game); } } return false; diff --git a/Mage.Sets/src/mage/cards/i/IncrementalGrowth.java b/Mage.Sets/src/mage/cards/i/IncrementalGrowth.java index 9e72dd90b7..cdea73d6e6 100644 --- a/Mage.Sets/src/mage/cards/i/IncrementalGrowth.java +++ b/Mage.Sets/src/mage/cards/i/IncrementalGrowth.java @@ -106,7 +106,7 @@ class IncrementalGrowthEffect extends OneShotEffect { i++; Permanent creature = game.getPermanent(target.getFirstTarget()); if (creature != null) { - creature.addCounters(CounterType.P1P1.createInstance(i), game); + creature.addCounters(CounterType.P1P1.createInstance(i), source, game); } } return false; diff --git a/Mage.Sets/src/mage/cards/i/InsatiableRakghoul.java b/Mage.Sets/src/mage/cards/i/InsatiableRakghoul.java index f71b9c7658..64f7ca19ff 100644 --- a/Mage.Sets/src/mage/cards/i/InsatiableRakghoul.java +++ b/Mage.Sets/src/mage/cards/i/InsatiableRakghoul.java @@ -91,7 +91,7 @@ class InsatiableRakghoulEffect extends OneShotEffect { if (watcher != null && watcher.conditionMet()) { Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(1), game); + permanent.addCounters(CounterType.P1P1.createInstance(1), source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/j/JhoiraOfTheGhitu.java b/Mage.Sets/src/mage/cards/j/JhoiraOfTheGhitu.java index fc6cb51c7a..7781c9216f 100644 --- a/Mage.Sets/src/mage/cards/j/JhoiraOfTheGhitu.java +++ b/Mage.Sets/src/mage/cards/j/JhoiraOfTheGhitu.java @@ -118,7 +118,7 @@ class JhoiraOfTheGhituSuspendEffect extends OneShotEffect { UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game); if (controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source.getSourceId(), game, Zone.HAND, true)) { - card.addCounters(CounterType.TIME.createInstance(4), game); + card.addCounters(CounterType.TIME.createInstance(4), source, game); if (!hasSuspend) { game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source); } diff --git a/Mage.Sets/src/mage/cards/j/JhoirasTimebug.java b/Mage.Sets/src/mage/cards/j/JhoirasTimebug.java index ec2bc2cdc5..e0335333e9 100644 --- a/Mage.Sets/src/mage/cards/j/JhoirasTimebug.java +++ b/Mage.Sets/src/mage/cards/j/JhoirasTimebug.java @@ -106,7 +106,7 @@ class JhoirasTimebugEffect extends OneShotEffect { Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (permanent != null && permanent.getCounters(game).containsKey(CounterType.TIME)) { if (controller.chooseUse(Outcome.Benefit, "Add a time counter? (Otherwise remove one)", source, game)) { - permanent.addCounters(CounterType.TIME.createInstance(), game); + permanent.addCounters(CounterType.TIME.createInstance(), source, game); } else { permanent.removeCounters(CounterType.TIME.createInstance(), game); @@ -116,7 +116,7 @@ class JhoirasTimebugEffect extends OneShotEffect { Card card = game.getExile().getCard(this.getTargetPointer().getFirst(game, source), game); if (card != null) { if (controller.chooseUse(Outcome.Detriment, "Add a time counter? (Otherwise remove one)", source, game)) { - card.addCounters(CounterType.TIME.createInstance(), game); + card.addCounters(CounterType.TIME.createInstance(), source, game); } else { card.removeCounters(CounterType.TIME.createInstance(), game); diff --git a/Mage.Sets/src/mage/cards/k/KalonianHydra.java b/Mage.Sets/src/mage/cards/k/KalonianHydra.java index 48053dcd7c..366914ba04 100644 --- a/Mage.Sets/src/mage/cards/k/KalonianHydra.java +++ b/Mage.Sets/src/mage/cards/k/KalonianHydra.java @@ -109,7 +109,7 @@ class KalonianHydraEffect extends OneShotEffect { for (Permanent permanent : permanents) { int existingCounters = permanent.getCounters(game).getCount(CounterType.P1P1); if (existingCounters > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(existingCounters), game); + permanent.addCounters(CounterType.P1P1.createInstance(existingCounters), source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/k/KavuPredator.java b/Mage.Sets/src/mage/cards/k/KavuPredator.java index 27c4a4c70a..e9ca37dbe9 100644 --- a/Mage.Sets/src/mage/cards/k/KavuPredator.java +++ b/Mage.Sets/src/mage/cards/k/KavuPredator.java @@ -131,7 +131,7 @@ class KavuPredatorEffect extends OneShotEffect { if (permanent != null) { Integer gainedLife = (Integer) this.getValue("gainedLife"); if (gainedLife != null) { - permanent.addCounters(CounterType.P1P1.createInstance(gainedLife.intValue()), game); + permanent.addCounters(CounterType.P1P1.createInstance(gainedLife.intValue()), source, game); Player player = game.getPlayer(source.getControllerId()); if (player != null) { game.informPlayers(new StringBuilder(player.getLogName()).append(" puts ").append(gainedLife).append(" +1/+1 counter on ").append(permanent.getName()).toString()); diff --git a/Mage.Sets/src/mage/cards/k/KreshTheBloodbraided.java b/Mage.Sets/src/mage/cards/k/KreshTheBloodbraided.java index 54263f8010..1840496333 100644 --- a/Mage.Sets/src/mage/cards/k/KreshTheBloodbraided.java +++ b/Mage.Sets/src/mage/cards/k/KreshTheBloodbraided.java @@ -89,7 +89,7 @@ class KreshTheBloodbraidedEffect extends OneShotEffect { if (permanent != null && kreshTheBloodbraided != null) { int amount = permanent.getPower().getValue(); if (amount > 0) { - kreshTheBloodbraided.addCounters(CounterType.P1P1.createInstance(amount), game); + kreshTheBloodbraided.addCounters(CounterType.P1P1.createInstance(amount), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/l/LeechBonder.java b/Mage.Sets/src/mage/cards/l/LeechBonder.java index 7395e9002c..13b67c6d82 100644 --- a/Mage.Sets/src/mage/cards/l/LeechBonder.java +++ b/Mage.Sets/src/mage/cards/l/LeechBonder.java @@ -129,7 +129,7 @@ class LeechBonderEffect extends OneShotEffect { if (counterType != null) { Counter counter = counterType.createInstance(); fromPermanent.removeCounters(counter, game); - toPermanent.addCounters(counter, game); + toPermanent.addCounters(counter, source, game); return true; } } diff --git a/Mage.Sets/src/mage/cards/l/LieutenantsOfTheGuard.java b/Mage.Sets/src/mage/cards/l/LieutenantsOfTheGuard.java index 9f48fb3291..457d525a3c 100644 --- a/Mage.Sets/src/mage/cards/l/LieutenantsOfTheGuard.java +++ b/Mage.Sets/src/mage/cards/l/LieutenantsOfTheGuard.java @@ -97,7 +97,7 @@ class LieutenantsOfTheGuardDilemmaEffect extends CouncilsDilemmaVoteEffect { //Strength Votes //If strength received zero votes or the permanent is no longer on the battlefield, do not attempt to put P1P1 counters on it. if (voteOneCount > 0 && permanent != null) - permanent.addCounters(CounterType.P1P1.createInstance(voteOneCount), game); + permanent.addCounters(CounterType.P1P1.createInstance(voteOneCount), source, game); //Numbers Votes if (voteTwoCount > 0) { diff --git a/Mage.Sets/src/mage/cards/l/LightningStorm.java b/Mage.Sets/src/mage/cards/l/LightningStorm.java index 363c602f6f..9c856fcada 100644 --- a/Mage.Sets/src/mage/cards/l/LightningStorm.java +++ b/Mage.Sets/src/mage/cards/l/LightningStorm.java @@ -140,7 +140,7 @@ class LightningStormAddCounterEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Spell spell = game.getStack().getSpell(source.getSourceId()); if (spell != null) { - spell.addCounters(CounterType.CHARGE.createInstance(2), game); + spell.addCounters(CounterType.CHARGE.createInstance(2), source, game); return spell.chooseNewTargets(game, ((ActivatedAbilityImpl) source).getActivatorId(), false, false, null); } return false; diff --git a/Mage.Sets/src/mage/cards/l/LivingArmor.java b/Mage.Sets/src/mage/cards/l/LivingArmor.java index 868354f308..4add97b25a 100644 --- a/Mage.Sets/src/mage/cards/l/LivingArmor.java +++ b/Mage.Sets/src/mage/cards/l/LivingArmor.java @@ -89,7 +89,7 @@ public class LivingArmor extends CardImpl { Permanent creature = game.getPermanent(source.getTargets().getFirstTarget()); if (creature != null) { int amount = creature.getConvertedManaCost(); - creature.addCounters(new BoostCounter(0, 1, amount), game); + creature.addCounters(new BoostCounter(0, 1, amount), source, game); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/l/LockjawSnapper.java b/Mage.Sets/src/mage/cards/l/LockjawSnapper.java index acbba6f413..a37b5850ef 100644 --- a/Mage.Sets/src/mage/cards/l/LockjawSnapper.java +++ b/Mage.Sets/src/mage/cards/l/LockjawSnapper.java @@ -99,7 +99,7 @@ class LockjawSnapperEffect extends OneShotEffect { } for (Permanent creature : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { if (creature != null) { - creature.addCounters(CounterType.M1M1.createInstance(), game); + creature.addCounters(CounterType.M1M1.createInstance(), source, game); applied = true; } } diff --git a/Mage.Sets/src/mage/cards/l/LongRoadHome.java b/Mage.Sets/src/mage/cards/l/LongRoadHome.java index 93020099d5..5f39b599ec 100644 --- a/Mage.Sets/src/mage/cards/l/LongRoadHome.java +++ b/Mage.Sets/src/mage/cards/l/LongRoadHome.java @@ -189,7 +189,7 @@ class LongRoadHomeEntersBattlefieldEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(), game); + permanent.addCounters(CounterType.P1P1.createInstance(), source, game); discard(); // use only once } return false; diff --git a/Mage.Sets/src/mage/cards/m/MasterBiomancer.java b/Mage.Sets/src/mage/cards/m/MasterBiomancer.java index e4e5bc9373..7ca2e92b1c 100644 --- a/Mage.Sets/src/mage/cards/m/MasterBiomancer.java +++ b/Mage.Sets/src/mage/cards/m/MasterBiomancer.java @@ -107,7 +107,7 @@ class MasterBiomancerEntersBattlefieldEffect extends ReplacementEffectImpl { if (sourceCreature != null && creature != null) { int power = sourceCreature.getPower().getValue(); if (power > 0) { - creature.addCounters(CounterType.P1P1.createInstance(power), game); + creature.addCounters(CounterType.P1P1.createInstance(power), source, game); } ContinuousEffect effect = new AddCardSubTypeTargetEffect("Mutant", Duration.Custom); effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game) + 1)); diff --git a/Mage.Sets/src/mage/cards/m/MayaelsAria.java b/Mage.Sets/src/mage/cards/m/MayaelsAria.java index 5cdb5b921c..966ac022bc 100644 --- a/Mage.Sets/src/mage/cards/m/MayaelsAria.java +++ b/Mage.Sets/src/mage/cards/m/MayaelsAria.java @@ -97,7 +97,7 @@ class MayaelsAriaEffect extends OneShotEffect { filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 4)); if (game.getState().getBattlefield().countAll(filter, controller.getId(), game) > 0) { for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) { - creature.addCounters(CounterType.P1P1.createInstance(), game); + creature.addCounters(CounterType.P1P1.createInstance(), source, game); } } game.applyEffects(); // needed because otehrwise the +1/+1 counters wouldn't be taken into account diff --git a/Mage.Sets/src/mage/cards/m/Meadowboon.java b/Mage.Sets/src/mage/cards/m/Meadowboon.java index 20c6432fd4..e25b5cd2db 100644 --- a/Mage.Sets/src/mage/cards/m/Meadowboon.java +++ b/Mage.Sets/src/mage/cards/m/Meadowboon.java @@ -91,7 +91,7 @@ class MeadowboonEffect extends OneShotEffect { Player target = game.getPlayer(source.getFirstTarget()); if (target != null) { for (Permanent p : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), target.getId(), game)) { - p.addCounters(CounterType.P1P1.createInstance(), game); + p.addCounters(CounterType.P1P1.createInstance(), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/m/MessengerJays.java b/Mage.Sets/src/mage/cards/m/MessengerJays.java index 936c5845ae..dbbbd2172f 100644 --- a/Mage.Sets/src/mage/cards/m/MessengerJays.java +++ b/Mage.Sets/src/mage/cards/m/MessengerJays.java @@ -99,7 +99,7 @@ class MessengerJaysDilemmaEffect extends CouncilsDilemmaVoteEffect { //Feathers Votes //If feathers received zero votes or the permanent is no longer on the battlefield, do not attempt to put P1P1 counter on it. if (voteOneCount > 0 && permanent != null) - permanent.addCounters(CounterType.P1P1.createInstance(voteOneCount), game); + permanent.addCounters(CounterType.P1P1.createInstance(voteOneCount), source, game); //Quill Votes //Only let the controller loot the appropriate amount of cards if it was voted for. diff --git a/Mage.Sets/src/mage/cards/m/MiraculousRecovery.java b/Mage.Sets/src/mage/cards/m/MiraculousRecovery.java index 6c120a4814..900e953513 100644 --- a/Mage.Sets/src/mage/cards/m/MiraculousRecovery.java +++ b/Mage.Sets/src/mage/cards/m/MiraculousRecovery.java @@ -90,7 +90,7 @@ class MiraculousRecoveryEffect extends OneShotEffect { // targetPointer can't be used because target moved from graveyard to battlefield Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(), game); + permanent.addCounters(CounterType.P1P1.createInstance(), source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/n/NantukoCultivator.java b/Mage.Sets/src/mage/cards/n/NantukoCultivator.java index 986756da52..cd2fc28ffd 100644 --- a/Mage.Sets/src/mage/cards/n/NantukoCultivator.java +++ b/Mage.Sets/src/mage/cards/n/NantukoCultivator.java @@ -91,7 +91,7 @@ class NantukoCultivatorEffect extends OneShotEffect { } Permanent permanent = game.getPermanent(source.getSourceId()); if(permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(count), game); + permanent.addCounters(CounterType.P1P1.createInstance(count), source, game); } player.drawCards(count, game); } diff --git a/Mage.Sets/src/mage/cards/n/NayaSoulbeast.java b/Mage.Sets/src/mage/cards/n/NayaSoulbeast.java index 9a39d46214..e00bef79a6 100644 --- a/Mage.Sets/src/mage/cards/n/NayaSoulbeast.java +++ b/Mage.Sets/src/mage/cards/n/NayaSoulbeast.java @@ -154,7 +154,7 @@ class NayaSoulbeastReplacementEffect extends ReplacementEffectImpl { Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (permanent != null && object instanceof Integer) { int amount = ((Integer) object); - permanent.addCounters(CounterType.P1P1.createInstance(amount), game); + permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/n/NecromanticSummons.java b/Mage.Sets/src/mage/cards/n/NecromanticSummons.java index 9ac60153b8..3748852940 100644 --- a/Mage.Sets/src/mage/cards/n/NecromanticSummons.java +++ b/Mage.Sets/src/mage/cards/n/NecromanticSummons.java @@ -93,7 +93,7 @@ class NecromanticSummoningEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(2), game); + permanent.addCounters(CounterType.P1P1.createInstance(2), source, game); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/n/NightDealings.java b/Mage.Sets/src/mage/cards/n/NightDealings.java index 20f6004eba..0e9aad970a 100644 --- a/Mage.Sets/src/mage/cards/n/NightDealings.java +++ b/Mage.Sets/src/mage/cards/n/NightDealings.java @@ -143,7 +143,7 @@ public class NightDealings extends CardImpl { if (damageAmount != null) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { - permanent.addCounters(CounterType.THEFT.createInstance(damageAmount), game); + permanent.addCounters(CounterType.THEFT.createInstance(damageAmount), source, game); return true; } } diff --git a/Mage.Sets/src/mage/cards/n/NovijenHeartOfProgress.java b/Mage.Sets/src/mage/cards/n/NovijenHeartOfProgress.java index 083f8ebb8b..7c38281d69 100644 --- a/Mage.Sets/src/mage/cards/n/NovijenHeartOfProgress.java +++ b/Mage.Sets/src/mage/cards/n/NovijenHeartOfProgress.java @@ -97,7 +97,7 @@ class NovijenHeartOfProgressEffect extends OneShotEffect { if (controller != null && sourceObject != null) { for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) { if (permanent.getTurnsOnBattlefield() == 0) { - permanent.addCounters(CounterType.P1P1.createInstance(), game); + permanent.addCounters(CounterType.P1P1.createInstance(), source, game); game.informPlayers(sourceObject.getLogName()+ ": " + controller.getLogName() + " puts a +1/+1 counter on " + permanent.getLogName()); } } diff --git a/Mage.Sets/src/mage/cards/o/OathOfGideon.java b/Mage.Sets/src/mage/cards/o/OathOfGideon.java index 3689605592..8a40148156 100644 --- a/Mage.Sets/src/mage/cards/o/OathOfGideon.java +++ b/Mage.Sets/src/mage/cards/o/OathOfGideon.java @@ -106,7 +106,7 @@ class OathOfGideonReplacementEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget(); if (creature != null) { - creature.addCounters(CounterType.LOYALTY.createInstance(), game); + creature.addCounters(CounterType.LOYALTY.createInstance(), source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/o/OonasBlackguard.java b/Mage.Sets/src/mage/cards/o/OonasBlackguard.java index 3083b5abef..6cce1b2eda 100644 --- a/Mage.Sets/src/mage/cards/o/OonasBlackguard.java +++ b/Mage.Sets/src/mage/cards/o/OonasBlackguard.java @@ -121,7 +121,7 @@ class OonasBlackguardReplacementEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget(); if (creature != null) { - creature.addCounters(CounterType.P1P1.createInstance(), game); + creature.addCounters(CounterType.P1P1.createInstance(), source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/o/OpalPalace.java b/Mage.Sets/src/mage/cards/o/OpalPalace.java index 3e4ff98dee..09c48fda37 100644 --- a/Mage.Sets/src/mage/cards/o/OpalPalace.java +++ b/Mage.Sets/src/mage/cards/o/OpalPalace.java @@ -167,7 +167,7 @@ class OpalPalaceEntersBattlefieldEffect extends ReplacementEffectImpl { if (permanent != null) { Integer castCount = (Integer) game.getState().getValue(permanent.getId() + "_castCount"); if (castCount != null && castCount > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(castCount), game); + permanent.addCounters(CounterType.P1P1.createInstance(castCount), source, game); } } return false; diff --git a/Mage.Sets/src/mage/cards/o/OranRiefHydra.java b/Mage.Sets/src/mage/cards/o/OranRiefHydra.java index 3e028a904a..3c38d42aad 100644 --- a/Mage.Sets/src/mage/cards/o/OranRiefHydra.java +++ b/Mage.Sets/src/mage/cards/o/OranRiefHydra.java @@ -144,9 +144,9 @@ class OranRiefHydraEffect extends OneShotEffect { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (land != null && sourcePermanent != null) { if (land.hasSubtype("Forest", game)) { - sourcePermanent.addCounters(CounterType.P1P1.createInstance(2), game); + sourcePermanent.addCounters(CounterType.P1P1.createInstance(2), source, game); } else { - sourcePermanent.addCounters(CounterType.P1P1.createInstance(), game); + sourcePermanent.addCounters(CounterType.P1P1.createInstance(), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/o/OranRiefTheVastwood.java b/Mage.Sets/src/mage/cards/o/OranRiefTheVastwood.java index 1b2ff06c53..a55dcfb3dc 100644 --- a/Mage.Sets/src/mage/cards/o/OranRiefTheVastwood.java +++ b/Mage.Sets/src/mage/cards/o/OranRiefTheVastwood.java @@ -95,7 +95,7 @@ class OranRiefTheVastwoodEffect extends OneShotEffect { filter.add(new ColorPredicate(ObjectColor.GREEN)); for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { if (permanent.getTurnsOnBattlefield() == 0) { - permanent.addCounters(CounterType.P1P1.createInstance(), game); + permanent.addCounters(CounterType.P1P1.createInstance(), source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/o/OrchardElemental.java b/Mage.Sets/src/mage/cards/o/OrchardElemental.java index b53fc6c72b..80b0892944 100644 --- a/Mage.Sets/src/mage/cards/o/OrchardElemental.java +++ b/Mage.Sets/src/mage/cards/o/OrchardElemental.java @@ -95,7 +95,7 @@ class OrchardElementalDilemmaEffect extends CouncilsDilemmaVoteEffect { //Sprout Votes //If sprout received zero votes or the permanent is no longer on the battlefield, do not attempt to put P1P1 counter on it. if (voteOneCount > 0 && permanent != null) - permanent.addCounters(CounterType.P1P1.createInstance(voteOneCount * 2), game); + permanent.addCounters(CounterType.P1P1.createInstance(voteOneCount * 2), source, game); //Harvest Votes if (voteTwoCount > 0) { diff --git a/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java b/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java index a37b2a7f22..f9120163a9 100644 --- a/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java +++ b/Mage.Sets/src/mage/cards/o/OrzhovAdvokist.java @@ -117,7 +117,7 @@ class OrzhovAdvokistEffect extends OneShotEffect { for (UUID creatureId : creatures) { Permanent creature = game.getPermanent(creatureId); if (creature != null) { - creature.addCounters(CounterType.P1P1.createInstance(2), game); + creature.addCounters(CounterType.P1P1.createInstance(2), source, game); } } for (UUID playerId : players) { diff --git a/Mage.Sets/src/mage/cards/o/OtherworldlyJourney.java b/Mage.Sets/src/mage/cards/o/OtherworldlyJourney.java index 9be4122827..0523be13ea 100644 --- a/Mage.Sets/src/mage/cards/o/OtherworldlyJourney.java +++ b/Mage.Sets/src/mage/cards/o/OtherworldlyJourney.java @@ -184,7 +184,7 @@ class OtherworldlyJourneyEntersBattlefieldEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget(); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(), game); + permanent.addCounters(CounterType.P1P1.createInstance(), source, game); discard(); // use only once } return false; diff --git a/Mage.Sets/src/mage/cards/p/PardicDragon.java b/Mage.Sets/src/mage/cards/p/PardicDragon.java index 0f540eae19..d80d164648 100644 --- a/Mage.Sets/src/mage/cards/p/PardicDragon.java +++ b/Mage.Sets/src/mage/cards/p/PardicDragon.java @@ -114,7 +114,7 @@ class PardicDragonEffect extends OneShotEffect { Card sourceCard = game.getCard(source.getSourceId()); if (opponent != null && sourceCard != null) { if (opponent.chooseUse(outcome, new StringBuilder("Put a time counter on ").append(sourceCard.getName()).append("?").toString(), source, game)) { - sourceCard.addCounters(CounterType.TIME.createInstance(), game); + sourceCard.addCounters(CounterType.TIME.createInstance(), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/p/PatronOfTheValiant.java b/Mage.Sets/src/mage/cards/p/PatronOfTheValiant.java index 5b6aeedba8..ae91a31980 100644 --- a/Mage.Sets/src/mage/cards/p/PatronOfTheValiant.java +++ b/Mage.Sets/src/mage/cards/p/PatronOfTheValiant.java @@ -102,7 +102,7 @@ class PatronOfTheValiantEffect extends OneShotEffect { MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { for(Permanent permanent: game.getState().getBattlefield().getAllActivePermanents(filter , controller.getId(), game)) { - permanent.addCounters(CounterType.P1P1.createInstance(), game); + permanent.addCounters(CounterType.P1P1.createInstance(), source, game); game.informPlayers(sourceObject.getName() + ": Put a +1/+1 counter on " + permanent.getLogName()); } } diff --git a/Mage.Sets/src/mage/cards/p/PhylacteryLich.java b/Mage.Sets/src/mage/cards/p/PhylacteryLich.java index 392a6f4791..e3de400aa7 100644 --- a/Mage.Sets/src/mage/cards/p/PhylacteryLich.java +++ b/Mage.Sets/src/mage/cards/p/PhylacteryLich.java @@ -141,7 +141,7 @@ class PhylacteryLichEffect extends OneShotEffect { if (player.choose(Outcome.Neutral, target, source.getSourceId(), game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { - permanent.addCounters(new Counter("phylactery"), game); + permanent.addCounters(new Counter("phylactery"), source, game); } } } diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianHydra.java b/Mage.Sets/src/mage/cards/p/PhyrexianHydra.java index 162b436ea6..240eb09f6b 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianHydra.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianHydra.java @@ -105,7 +105,7 @@ class PhyrexianHydraEffect extends PreventionEffectImpl { } Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { - permanent.addCounters(CounterType.M1M1.createInstance(damage), game); + permanent.addCounters(CounterType.M1M1.createInstance(damage), source, game); } return retValue; } diff --git a/Mage.Sets/src/mage/cards/p/Phytohydra.java b/Mage.Sets/src/mage/cards/p/Phytohydra.java index 0a62331ae1..f1686ecceb 100644 --- a/Mage.Sets/src/mage/cards/p/Phytohydra.java +++ b/Mage.Sets/src/mage/cards/p/Phytohydra.java @@ -86,7 +86,7 @@ class PhytohydraEffect extends ReplacementEffectImpl { DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; Permanent p = game.getPermanent(source.getSourceId()); if (p != null) { - p.addCounters(CounterType.P1P1.createInstance(damageEvent.getAmount()), game); + p.addCounters(CounterType.P1P1.createInstance(damageEvent.getAmount()), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/p/PrimalInstinct.java b/Mage.Sets/src/mage/cards/p/PrimalInstinct.java index 1e424e4e95..199f85b0d6 100644 --- a/Mage.Sets/src/mage/cards/p/PrimalInstinct.java +++ b/Mage.Sets/src/mage/cards/p/PrimalInstinct.java @@ -81,10 +81,10 @@ class PrimalInstictEffect extends OneShotEffect { if (controller != null) { Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source)); if (target != null) { - target.addCounters(CounterType.P1P1.createInstance(), game); + target.addCounters(CounterType.P1P1.createInstance(), source, game); int addCounterCount = target.getCounters(game).getCount(CounterType.P1P1); game.informPlayers("Counters " + addCounterCount); - target.addCounters(CounterType.P1P1.createInstance(addCounterCount), game); + target.addCounters(CounterType.P1P1.createInstance(addCounterCount), source, game); return true; } } diff --git a/Mage.Sets/src/mage/cards/p/PrimordialHydra.java b/Mage.Sets/src/mage/cards/p/PrimordialHydra.java index 705defb2f9..767c394a4c 100644 --- a/Mage.Sets/src/mage/cards/p/PrimordialHydra.java +++ b/Mage.Sets/src/mage/cards/p/PrimordialHydra.java @@ -104,7 +104,7 @@ class PrimordialHydraDoubleEffect extends OneShotEffect { if (sourcePermanent != null) { int amount = sourcePermanent.getCounters(game).getCount(CounterType.P1P1); if (amount > 0) { - sourcePermanent.addCounters(CounterType.P1P1.createInstance(amount), game); + sourcePermanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/p/PyrrhicRevival.java b/Mage.Sets/src/mage/cards/p/PyrrhicRevival.java index fde0fddb3f..cd0a150db0 100644 --- a/Mage.Sets/src/mage/cards/p/PyrrhicRevival.java +++ b/Mage.Sets/src/mage/cards/p/PyrrhicRevival.java @@ -95,7 +95,7 @@ class PyrrhicRevivalEffect extends OneShotEffect { if (card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), card.getOwnerId(), false)) { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { - permanent.addCounters(CounterType.M1M1.createInstance(), game); + permanent.addCounters(CounterType.M1M1.createInstance(), source, game); } result = true; } diff --git a/Mage.Sets/src/mage/cards/q/QuestForUlasTemple.java b/Mage.Sets/src/mage/cards/q/QuestForUlasTemple.java index be5b3d81cb..01f79cbdc3 100644 --- a/Mage.Sets/src/mage/cards/q/QuestForUlasTemple.java +++ b/Mage.Sets/src/mage/cards/q/QuestForUlasTemple.java @@ -107,7 +107,7 @@ class QuestForUlasTempleEffect extends OneShotEffect { controller.revealCards(sourcePermanent.getName(), cards, game); Permanent questForUlasTemple = game.getPermanent(source.getSourceId()); if (questForUlasTemple != null) { - questForUlasTemple.addCounters(CounterType.QUEST.createInstance(), game); + questForUlasTemple.addCounters(CounterType.QUEST.createInstance(), source, game); return true; } } diff --git a/Mage.Sets/src/mage/cards/s/SageOfFables.java b/Mage.Sets/src/mage/cards/s/SageOfFables.java index fe352e2153..df9d74c49b 100644 --- a/Mage.Sets/src/mage/cards/s/SageOfFables.java +++ b/Mage.Sets/src/mage/cards/s/SageOfFables.java @@ -115,7 +115,7 @@ class SageOfFablesReplacementEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget(); if (creature != null) { - creature.addCounters(CounterType.P1P1.createInstance(), game); + creature.addCounters(CounterType.P1P1.createInstance(), source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/s/SavageSummoning.java b/Mage.Sets/src/mage/cards/s/SavageSummoning.java index 5eeac87a73..645a1bf1bd 100644 --- a/Mage.Sets/src/mage/cards/s/SavageSummoning.java +++ b/Mage.Sets/src/mage/cards/s/SavageSummoning.java @@ -316,7 +316,7 @@ class SavageSummoningEntersBattlefieldEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget(); if (creature != null) { - creature.addCounters(CounterType.P1P1.createInstance(), game); + creature.addCounters(CounterType.P1P1.createInstance(), source, game); } discard(); return false; diff --git a/Mage.Sets/src/mage/cards/s/ScaleBlessing.java b/Mage.Sets/src/mage/cards/s/ScaleBlessing.java index 59663bd7c3..e354df9011 100644 --- a/Mage.Sets/src/mage/cards/s/ScaleBlessing.java +++ b/Mage.Sets/src/mage/cards/s/ScaleBlessing.java @@ -99,7 +99,7 @@ class ScaleBlessingEffect extends OneShotEffect { MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { for(Permanent permanent: game.getState().getBattlefield().getAllActivePermanents(filter , controller.getId(), game)) { - permanent.addCounters(CounterType.P1P1.createInstance(), game); + permanent.addCounters(CounterType.P1P1.createInstance(), source, game); game.informPlayers(sourceObject.getName() + ": Put a +1/+1 counter on " + permanent.getLogName()); } } diff --git a/Mage.Sets/src/mage/cards/s/ScarscaleRitual.java b/Mage.Sets/src/mage/cards/s/ScarscaleRitual.java index 57b09dbc31..5f2227cf53 100644 --- a/Mage.Sets/src/mage/cards/s/ScarscaleRitual.java +++ b/Mage.Sets/src/mage/cards/s/ScarscaleRitual.java @@ -51,7 +51,7 @@ import mage.target.common.TargetControlledCreaturePermanent; public class ScarscaleRitual extends CardImpl { public ScarscaleRitual(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{U/B}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{U/B}"); // As an additional cost to cast Scarscale Ritual, put a -1/-1 counter on a creature you control. this.getSpellAbility().addCost(new ScarscaleRitualCost()); @@ -98,7 +98,7 @@ class ScarscaleRitualCost extends CostImpl { controller.chooseTarget(Outcome.UnboostCreature, target, ability, game); Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { - permanent.addCounters(CounterType.M1M1.createInstance(), game); + permanent.addCounters(CounterType.M1M1.createInstance(), ability, game); game.informPlayers(controller.getLogName() + " puts a -1/-1 counter on " + permanent.getLogName()); this.paid = true; } diff --git a/Mage.Sets/src/mage/cards/s/ScavengingOoze.java b/Mage.Sets/src/mage/cards/s/ScavengingOoze.java index 9befe21d9e..edf2930bc9 100644 --- a/Mage.Sets/src/mage/cards/s/ScavengingOoze.java +++ b/Mage.Sets/src/mage/cards/s/ScavengingOoze.java @@ -99,7 +99,7 @@ class ScavengingOozeEffect extends OneShotEffect { if (card.getCardType().contains(CardType.CREATURE)) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null) { - sourcePermanent.addCounters(CounterType.P1P1.createInstance(), game); + sourcePermanent.addCounters(CounterType.P1P1.createInstance(), source, game); } controller.gainLife(1, game); } diff --git a/Mage.Sets/src/mage/cards/s/SelvalasEnforcer.java b/Mage.Sets/src/mage/cards/s/SelvalasEnforcer.java index 82156b2a8a..ab944114f6 100644 --- a/Mage.Sets/src/mage/cards/s/SelvalasEnforcer.java +++ b/Mage.Sets/src/mage/cards/s/SelvalasEnforcer.java @@ -100,7 +100,7 @@ class SelvalasEnforcerEffect extends OneShotEffect { if (parley > 0) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null) { - sourcePermanent.addCounters(CounterType.P1P1.createInstance(parley), game); + sourcePermanent.addCounters(CounterType.P1P1.createInstance(parley), source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/s/ShelteringAncient.java b/Mage.Sets/src/mage/cards/s/ShelteringAncient.java index 6398a7176a..8060c9eef2 100644 --- a/Mage.Sets/src/mage/cards/s/ShelteringAncient.java +++ b/Mage.Sets/src/mage/cards/s/ShelteringAncient.java @@ -55,14 +55,14 @@ import mage.target.common.TargetCreaturePermanent; public class ShelteringAncient extends CardImpl { public ShelteringAncient(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); this.subtype.add("Treefolk"); this.power = new MageInt(5); this.toughness = new MageInt(5); // Trample this.addAbility(TrampleAbility.getInstance()); - + // Cumulative upkeep-Put a +1/+1 counter on a creature an opponent controls. this.addAbility(new CumulativeUpkeepAbility(new ShelteringAncientCost())); } @@ -78,12 +78,13 @@ public class ShelteringAncient extends CardImpl { } class ShelteringAncientCost extends CostImpl { - + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); + static { filter.add(new ControllerPredicate(TargetController.OPPONENT)); } - + ShelteringAncientCost() { this.text = "Put a +1/+1 counter on a creature an opponent controls"; } @@ -96,7 +97,7 @@ class ShelteringAncientCost extends CostImpl { if (target.choose(Outcome.BoostCreature, controllerId, sourceId, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(), game); + permanent.addCounters(CounterType.P1P1.createInstance(), ability, game); this.paid = true; return true; } diff --git a/Mage.Sets/src/mage/cards/s/ShimatsuTheBloodcloaked.java b/Mage.Sets/src/mage/cards/s/ShimatsuTheBloodcloaked.java index 02cfa17aa0..0e6b52f772 100644 --- a/Mage.Sets/src/mage/cards/s/ShimatsuTheBloodcloaked.java +++ b/Mage.Sets/src/mage/cards/s/ShimatsuTheBloodcloaked.java @@ -122,7 +122,7 @@ class ShimatsuTheBloodcloakedEffect extends ReplacementEffectImpl { return false; } } - creature.addCounters(CounterType.P1P1.createInstance(sacrificedCreatures), game); + creature.addCounters(CounterType.P1P1.createInstance(sacrificedCreatures), source, game); } } return false; diff --git a/Mage.Sets/src/mage/cards/s/SimicFluxmage.java b/Mage.Sets/src/mage/cards/s/SimicFluxmage.java index 4eac0373d4..3e2ada4c33 100644 --- a/Mage.Sets/src/mage/cards/s/SimicFluxmage.java +++ b/Mage.Sets/src/mage/cards/s/SimicFluxmage.java @@ -104,7 +104,7 @@ class MoveCounterFromSourceToTargetEffect extends OneShotEffect { Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source)); if (targetPermanent != null) { sourcePermanent.removeCounters(CounterType.P1P1.createInstance(), game); - targetPermanent.addCounters(CounterType.P1P1.createInstance(), game); + targetPermanent.addCounters(CounterType.P1P1.createInstance(), source, game); return true; } } diff --git a/Mage.Sets/src/mage/cards/s/SimicGuildmage.java b/Mage.Sets/src/mage/cards/s/SimicGuildmage.java index c0f7afab4b..5b84b88ce1 100644 --- a/Mage.Sets/src/mage/cards/s/SimicGuildmage.java +++ b/Mage.Sets/src/mage/cards/s/SimicGuildmage.java @@ -140,7 +140,7 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect { return false; } fromPermanent.removeCounters(CounterType.P1P1.createInstance(1), game); - toPermanent.addCounters(CounterType.P1P1.createInstance(1), game); + toPermanent.addCounters(CounterType.P1P1.createInstance(1), source, game); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/s/SithLord.java b/Mage.Sets/src/mage/cards/s/SithLord.java index 1d943531b2..ad00c69e3f 100644 --- a/Mage.Sets/src/mage/cards/s/SithLord.java +++ b/Mage.Sets/src/mage/cards/s/SithLord.java @@ -89,7 +89,7 @@ public class SithLord extends CardImpl { if (permanent != null) { int oll = new OpponentsLostLifeCount().calculate(game, source, this); if (oll > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(oll), game); + permanent.addCounters(CounterType.P1P1.createInstance(oll), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/s/SolidarityOfHeroes.java b/Mage.Sets/src/mage/cards/s/SolidarityOfHeroes.java index 13211a9dbf..607937f269 100644 --- a/Mage.Sets/src/mage/cards/s/SolidarityOfHeroes.java +++ b/Mage.Sets/src/mage/cards/s/SolidarityOfHeroes.java @@ -94,7 +94,7 @@ class SolidarityOfHeroesEffect extends OneShotEffect { if (permanent != null) { int existingCounters = permanent.getCounters(game).getCount(CounterType.P1P1); if (existingCounters > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(existingCounters), game); + permanent.addCounters(CounterType.P1P1.createInstance(existingCounters), source, game); } } } diff --git a/Mage.Sets/src/mage/cards/s/SoulExchange.java b/Mage.Sets/src/mage/cards/s/SoulExchange.java index cce04c2506..fcb574390c 100644 --- a/Mage.Sets/src/mage/cards/s/SoulExchange.java +++ b/Mage.Sets/src/mage/cards/s/SoulExchange.java @@ -102,7 +102,7 @@ class SoulExchangeEffect extends OneShotEffect{ for (Permanent exiled : ((ExileTargetCost) c).getPermanents()) { if (exiled != null){ if(exiled.getSubtype(game).contains("Thrull")){ - game.getPermanent(source.getFirstTarget()).addCounters(CounterType.P2P2.createInstance(), game); + game.getPermanent(source.getFirstTarget()).addCounters(CounterType.P2P2.createInstance(), source, game); return true; } } else return false; diff --git a/Mage.Sets/src/mage/cards/s/SoulsMight.java b/Mage.Sets/src/mage/cards/s/SoulsMight.java index 5b0a4f329a..c10e2043bb 100644 --- a/Mage.Sets/src/mage/cards/s/SoulsMight.java +++ b/Mage.Sets/src/mage/cards/s/SoulsMight.java @@ -84,7 +84,7 @@ class SoulsMightEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null && permanent.getPower().getValue() > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(permanent.getPower().getValue()), game); + permanent.addCounters(CounterType.P1P1.createInstance(permanent.getPower().getValue()), source, game); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/s/SphinxBoneWand.java b/Mage.Sets/src/mage/cards/s/SphinxBoneWand.java index ecee7c871a..9e60f2460f 100644 --- a/Mage.Sets/src/mage/cards/s/SphinxBoneWand.java +++ b/Mage.Sets/src/mage/cards/s/SphinxBoneWand.java @@ -97,7 +97,7 @@ class SphinxBoneWandEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null) { - sourcePermanent.addCounters(CounterType.CHARGE.createInstance(), game); + sourcePermanent.addCounters(CounterType.CHARGE.createInstance(), source, game); int amount = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE); Permanent permanent = game.getPermanent(source.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/s/SpikeCannibal.java b/Mage.Sets/src/mage/cards/s/SpikeCannibal.java index 892cf94479..c64be49332 100644 --- a/Mage.Sets/src/mage/cards/s/SpikeCannibal.java +++ b/Mage.Sets/src/mage/cards/s/SpikeCannibal.java @@ -113,7 +113,7 @@ class SpikeCannibalEffect extends OneShotEffect { if (countersRemoved > 0) { if (sourcePermanent != null) { - sourcePermanent.addCounters(CounterType.P1P1.createInstance(countersRemoved), game); + sourcePermanent.addCounters(CounterType.P1P1.createInstance(countersRemoved), source, game); return true; } } diff --git a/Mage.Sets/src/mage/cards/s/StrengthOfTheTajuru.java b/Mage.Sets/src/mage/cards/s/StrengthOfTheTajuru.java index 648d97afb4..60ec52d794 100644 --- a/Mage.Sets/src/mage/cards/s/StrengthOfTheTajuru.java +++ b/Mage.Sets/src/mage/cards/s/StrengthOfTheTajuru.java @@ -99,7 +99,7 @@ class StrengthOfTheTajuruAddCountersTargetEffect extends OneShotEffect { for (UUID uuid : targetPointer.getTargets(game, source)) { Permanent permanent = game.getPermanent(uuid); if (permanent != null) { - permanent.addCounters(counter.copy(), game); + permanent.addCounters(counter.copy(), source, game); affectedTargets ++; } } diff --git a/Mage.Sets/src/mage/cards/s/SzadekLordOfSecrets.java b/Mage.Sets/src/mage/cards/s/SzadekLordOfSecrets.java index a70b62b731..9ce46cab50 100644 --- a/Mage.Sets/src/mage/cards/s/SzadekLordOfSecrets.java +++ b/Mage.Sets/src/mage/cards/s/SzadekLordOfSecrets.java @@ -98,7 +98,7 @@ class SzadekLordOfSecretsEffect extends ReplacementEffectImpl { if (damageEvent.isCombatDamage()) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(damageEvent.getAmount()), game); + permanent.addCounters(CounterType.P1P1.createInstance(damageEvent.getAmount()), source, game); if (damagedPlayer != null) { damagedPlayer.moveCards(damagedPlayer.getLibrary().getTopCards(game, damageEvent.getAmount()), Zone.GRAVEYARD, source, game); } diff --git a/Mage.Sets/src/mage/cards/t/TalusPaladin.java b/Mage.Sets/src/mage/cards/t/TalusPaladin.java index b107239bb8..5589032369 100644 --- a/Mage.Sets/src/mage/cards/t/TalusPaladin.java +++ b/Mage.Sets/src/mage/cards/t/TalusPaladin.java @@ -147,7 +147,7 @@ class TalusPaladinEffect extends OneShotEffect { if (!player.chooseUse(Outcome.Benefit, sb.toString(), source, game)) { return false; } - taluspPaladin.addCounters(CounterType.P1P1.createInstance(), game); + taluspPaladin.addCounters(CounterType.P1P1.createInstance(), source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/t/TemptWithGlory.java b/Mage.Sets/src/mage/cards/t/TemptWithGlory.java index afabcf1221..088abe7079 100644 --- a/Mage.Sets/src/mage/cards/t/TemptWithGlory.java +++ b/Mage.Sets/src/mage/cards/t/TemptWithGlory.java @@ -48,8 +48,7 @@ import mage.players.Player; public class TemptWithGlory extends CardImpl { public TemptWithGlory(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{5}{W}"); - + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{5}{W}"); // Tempting offer - Put a +1/+1 counter on each creature you control. Each opponent may put a +1/+1 counter on each creature he or she controls. For each opponent who does, put a +1/+1 counter on each creature you control. this.getSpellAbility().addEffect(new TemptWithGloryEffect()); @@ -88,20 +87,20 @@ class TemptWithGloryEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - addCounterToEachCreature(controller.getId(), counter, game); + addCounterToEachCreature(controller.getId(), counter, source, game); int opponentsAddedCounters = 0; for (UUID playerId : game.getOpponents(controller.getId())) { Player opponent = game.getPlayer(playerId); if (opponent != null) { if (opponent.chooseUse(outcome, "Put a +1/+1 counter on each creature you control?", source, game)) { opponentsAddedCounters++; - addCounterToEachCreature(playerId, counter, game); + addCounterToEachCreature(playerId, counter, source, game); game.informPlayers(opponent.getLogName() + " added a +1/+1 counter on each of its creatures"); } } } if (opponentsAddedCounters > 0) { - addCounterToEachCreature(controller.getId(), CounterType.P1P1.createInstance(opponentsAddedCounters), game); + addCounterToEachCreature(controller.getId(), CounterType.P1P1.createInstance(opponentsAddedCounters), source, game); } return true; } @@ -109,9 +108,9 @@ class TemptWithGloryEffect extends OneShotEffect { return false; } - private void addCounterToEachCreature(UUID playerId, Counter counter, Game game) { - for(Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, playerId, game)) { - permanent.addCounters(counter, game); + private void addCounterToEachCreature(UUID playerId, Counter counter, Ability source, Game game) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, playerId, game)) { + permanent.addCounters(counter, source, game); } } } diff --git a/Mage.Sets/src/mage/cards/t/TestOfFaith.java b/Mage.Sets/src/mage/cards/t/TestOfFaith.java index ee02a6e170..79939e1d9a 100644 --- a/Mage.Sets/src/mage/cards/t/TestOfFaith.java +++ b/Mage.Sets/src/mage/cards/t/TestOfFaith.java @@ -111,7 +111,7 @@ class TestOfFaithPreventDamageTargetEffect extends PreventionEffectImpl { if (prevented > 0) { Permanent targetPermanent = game.getPermanent(source.getTargets().getFirstTarget()); if (targetPermanent != null) { - targetPermanent.addCounters(CounterType.P1P1.createInstance(prevented), game); + targetPermanent.addCounters(CounterType.P1P1.createInstance(prevented), source, game); game.informPlayers(new StringBuilder("Test of Faith: Prevented ").append(prevented).append(" damage ").toString()); game.informPlayers("Test of Faith: Adding " + prevented + " +1/+1 counters to " + targetPermanent.getName()); } diff --git a/Mage.Sets/src/mage/cards/t/TheBattleOfEndor.java b/Mage.Sets/src/mage/cards/t/TheBattleOfEndor.java index 5e3bc4ce7c..2fe6ccc4fe 100644 --- a/Mage.Sets/src/mage/cards/t/TheBattleOfEndor.java +++ b/Mage.Sets/src/mage/cards/t/TheBattleOfEndor.java @@ -104,7 +104,7 @@ class TheBattleOfEndorEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) { - permanent.addCounters(CounterType.P1P1.createInstance(source.getManaCostsToPay().getX()), game); + permanent.addCounters(CounterType.P1P1.createInstance(source.getManaCostsToPay().getX()), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/t/TheMimeoplasm.java b/Mage.Sets/src/mage/cards/t/TheMimeoplasm.java index 3280bbff18..58bac08173 100644 --- a/Mage.Sets/src/mage/cards/t/TheMimeoplasm.java +++ b/Mage.Sets/src/mage/cards/t/TheMimeoplasm.java @@ -114,7 +114,7 @@ class TheMimeoplasmEffect extends OneShotEffect { controller.moveCards(cardsToExile, Zone.EXILED, source, game); CopyEffect copyEffect = new CopyEffect(Duration.Custom, cardToCopy, source.getSourceId()); game.addEffect(copyEffect, source); - permanent.addCounters(CounterType.P1P1.createInstance(cardForCounters.getPower().getValue()), game); + permanent.addCounters(CounterType.P1P1.createInstance(cardForCounters.getPower().getValue()), source, game); } } } diff --git a/Mage.Sets/src/mage/cards/t/ThiefOfBlood.java b/Mage.Sets/src/mage/cards/t/ThiefOfBlood.java index 1692334900..a5522f915b 100644 --- a/Mage.Sets/src/mage/cards/t/ThiefOfBlood.java +++ b/Mage.Sets/src/mage/cards/t/ThiefOfBlood.java @@ -109,7 +109,7 @@ class ThiefOfBloodEffect extends OneShotEffect { if (countersRemoved > 0) { Permanent sourcePermanent = game.getPermanentEntering(source.getSourceId()); if (sourcePermanent != null) { - sourcePermanent.addCounters(CounterType.P1P1.createInstance(countersRemoved), game); + sourcePermanent.addCounters(CounterType.P1P1.createInstance(countersRemoved), source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/t/ThoughtGorger.java b/Mage.Sets/src/mage/cards/t/ThoughtGorger.java index 83010ba113..30901e7944 100644 --- a/Mage.Sets/src/mage/cards/t/ThoughtGorger.java +++ b/Mage.Sets/src/mage/cards/t/ThoughtGorger.java @@ -101,7 +101,7 @@ class ThoughtGorgerEffectEnters extends OneShotEffect { Permanent thoughtGorger = game.getPermanent(source.getSourceId()); if (player != null && player.getHand().size() > 0 && thoughtGorger != null ) { int cardsInHand = player.getHand().size(); - thoughtGorger.addCounters(CounterType.P1P1.createInstance(cardsInHand), game); + thoughtGorger.addCounters(CounterType.P1P1.createInstance(cardsInHand), source, game); player.discard(cardsInHand, false, source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/t/Timecrafting.java b/Mage.Sets/src/mage/cards/t/Timecrafting.java index 900936a568..4161428ed9 100644 --- a/Mage.Sets/src/mage/cards/t/Timecrafting.java +++ b/Mage.Sets/src/mage/cards/t/Timecrafting.java @@ -139,12 +139,12 @@ class TimecraftingAddEffect extends OneShotEffect { int xValue = source.getManaCostsToPay().getX(); Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); if (permanent != null) { - permanent.addCounters(CounterType.TIME.createInstance(xValue), game); + permanent.addCounters(CounterType.TIME.createInstance(xValue), source, game); } else { Card card = game.getExile().getCard(this.getTargetPointer().getFirst(game, source), game); if (card != null) { - card.addCounters(CounterType.TIME.createInstance(xValue), game); + card.addCounters(CounterType.TIME.createInstance(xValue), source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/u/UlashtTheHateSeed.java b/Mage.Sets/src/mage/cards/u/UlashtTheHateSeed.java index 4aff34b85d..d2eee0d242 100644 --- a/Mage.Sets/src/mage/cards/u/UlashtTheHateSeed.java +++ b/Mage.Sets/src/mage/cards/u/UlashtTheHateSeed.java @@ -125,7 +125,7 @@ class UlashtTheHateSeedEffect extends OneShotEffect { int amount = game.getBattlefield().count(filterRed, source.getSourceId(), source.getControllerId(), game); amount += game.getBattlefield().count(filterGreen, source.getSourceId(), source.getControllerId(), game); if (amount > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(amount), game); + permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/u/UnbreathingHorde.java b/Mage.Sets/src/mage/cards/u/UnbreathingHorde.java index e2a41bdde0..fc02cbf241 100644 --- a/Mage.Sets/src/mage/cards/u/UnbreathingHorde.java +++ b/Mage.Sets/src/mage/cards/u/UnbreathingHorde.java @@ -106,7 +106,7 @@ class UnbreathingHordeEffect1 extends OneShotEffect { int amount = game.getBattlefield().countAll(filter1, source.getControllerId(), game); amount += player.getGraveyard().count(filter2, game); if (amount > 0) { - permanent.addCounters(CounterType.P1P1.createInstance(amount), game); + permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/u/UrgeToFeed.java b/Mage.Sets/src/mage/cards/u/UrgeToFeed.java index 44070b6514..b474079cbc 100644 --- a/Mage.Sets/src/mage/cards/u/UrgeToFeed.java +++ b/Mage.Sets/src/mage/cards/u/UrgeToFeed.java @@ -101,7 +101,7 @@ class UrgeToFeedEffect extends OneShotEffect { Permanent vampire = game.getPermanent(vampireId); if (vampire != null) { vampire.tap(game); - vampire.addCounters(CounterType.P1P1.createInstance(), game); + vampire.addCounters(CounterType.P1P1.createInstance(), source, game); } } } diff --git a/Mage.Sets/src/mage/cards/v/VastwoodHydra.java b/Mage.Sets/src/mage/cards/v/VastwoodHydra.java index 7b4ffb7cf5..b3245f7864 100644 --- a/Mage.Sets/src/mage/cards/v/VastwoodHydra.java +++ b/Mage.Sets/src/mage/cards/v/VastwoodHydra.java @@ -109,7 +109,7 @@ class VastwoodHydraDistributeEffect extends OneShotEffect { for (UUID target : multiTarget.getTargets()) { Permanent permanent = game.getPermanent(target); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(multiTarget.getTargetAmount(target)), game); + permanent.addCounters(CounterType.P1P1.createInstance(multiTarget.getTargetAmount(target)), source, game); } } } diff --git a/Mage.Sets/src/mage/cards/v/VeneratedTeacher.java b/Mage.Sets/src/mage/cards/v/VeneratedTeacher.java index edcb65747a..b67db7ef5d 100644 --- a/Mage.Sets/src/mage/cards/v/VeneratedTeacher.java +++ b/Mage.Sets/src/mage/cards/v/VeneratedTeacher.java @@ -91,7 +91,7 @@ class VeneratedTeacherEffect extends OneShotEffect { for (Permanent permanent : permanents) { for (Ability ability : permanent.getAbilities()) { if (ability instanceof LevelUpAbility) { - permanent.addCounters(CounterType.LEVEL.createInstance(2), game); + permanent.addCounters(CounterType.LEVEL.createInstance(2), source, game); } } } diff --git a/Mage.Sets/src/mage/cards/v/Vigor.java b/Mage.Sets/src/mage/cards/v/Vigor.java index cfa175d079..e523da56ca 100644 --- a/Mage.Sets/src/mage/cards/v/Vigor.java +++ b/Mage.Sets/src/mage/cards/v/Vigor.java @@ -99,7 +99,7 @@ class VigorReplacementEffect extends ReplacementEffectImpl { event.setAmount(0); Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(preventedDamage), game); + permanent.addCounters(CounterType.P1P1.createInstance(preventedDamage), source, game); } game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), preventedDamage)); return true; diff --git a/Mage.Sets/src/mage/cards/v/VigorMortis.java b/Mage.Sets/src/mage/cards/v/VigorMortis.java index 23a130a0a9..7bf05119ab 100644 --- a/Mage.Sets/src/mage/cards/v/VigorMortis.java +++ b/Mage.Sets/src/mage/cards/v/VigorMortis.java @@ -90,7 +90,7 @@ class VigorMortisAddCounterEffect extends OneShotEffect { // targetPointer can't be used because target moved from graveyard to battlefield Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(), game); + permanent.addCounters(CounterType.P1P1.createInstance(), source, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/v/VorelOfTheHullClade.java b/Mage.Sets/src/mage/cards/v/VorelOfTheHullClade.java index b416d62f55..ed574cb2ea 100644 --- a/Mage.Sets/src/mage/cards/v/VorelOfTheHullClade.java +++ b/Mage.Sets/src/mage/cards/v/VorelOfTheHullClade.java @@ -108,7 +108,7 @@ class VorelOfTheHullCladeEffect extends OneShotEffect { } for (Counter counter : target.getCounters(game).values()) { Counter newCounter = new Counter(counter.getName(), counter.getCount()); - target.addCounters(newCounter, game); + target.addCounters(newCounter, source, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/w/WanderingMage.java b/Mage.Sets/src/mage/cards/w/WanderingMage.java index 794307264e..649bf7cf2d 100644 --- a/Mage.Sets/src/mage/cards/w/WanderingMage.java +++ b/Mage.Sets/src/mage/cards/w/WanderingMage.java @@ -57,7 +57,7 @@ import mage.target.common.TargetCreaturePermanent; * @author fireshoes */ public class WanderingMage extends CardImpl { - + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Cleric or Wizard"); static { @@ -67,7 +67,7 @@ public class WanderingMage extends CardImpl { } public WanderingMage(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{W}{U}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}{U}{B}"); this.subtype.add("Human"); this.subtype.add("Cleric"); this.subtype.add("Wizard"); @@ -75,20 +75,20 @@ public class WanderingMage extends CardImpl { this.toughness = new MageInt(3); // {W}, Pay 1 life: Prevent the next 2 damage that would be dealt to target creature this turn. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageToTargetEffect(Duration.EndOfTurn, 2), new ManaCostsImpl("{W}")); ability.addCost(new PayLifeCost(1)); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); - + // {U}: Prevent the next 1 damage that would be dealt to target Cleric or Wizard creature this turn. - ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, + ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageToTargetEffect(Duration.EndOfTurn, 1), new ManaCostsImpl("{U}")); ability.addTarget(new TargetCreaturePermanent(filter)); this.addAbility(ability); - + // {B}, Put a -1/-1 counter on a creature you control: Prevent the next 2 damage that would be dealt to target player this turn. - ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, + ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageToTargetEffect(Duration.EndOfTurn, 2), new ManaCostsImpl("{B}")); ability.addCost(new WanderingMageCost()); ability.addTarget(new TargetPlayer()); @@ -127,7 +127,7 @@ class WanderingMageCost extends CostImpl { public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { Permanent permanent = game.getPermanent(ability.getTargets().get(1).getFirstTarget()); if (permanent != null) { - permanent.addCounters(CounterType.M1M1.createInstance(), game); + permanent.addCounters(CounterType.M1M1.createInstance(), ability, game); this.paid = true; } return paid; diff --git a/Mage.Sets/src/mage/cards/w/WookieeMystic.java b/Mage.Sets/src/mage/cards/w/WookieeMystic.java index 912191075c..f19f4df0c2 100644 --- a/Mage.Sets/src/mage/cards/w/WookieeMystic.java +++ b/Mage.Sets/src/mage/cards/w/WookieeMystic.java @@ -148,7 +148,7 @@ class WookieeMysticWatcher extends Watcher { if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { if (creatures.contains(event.getSourceId())) { Permanent creature = game.getPermanent(event.getSourceId()); - creature.addCounters(CounterType.P1P1.createInstance(), game); + creature.addCounters(CounterType.P1P1.createInstance(), source, game); creatures.remove(event.getSourceId()); } } diff --git a/Mage.Sets/src/mage/cards/w/WorldheartPhoenix.java b/Mage.Sets/src/mage/cards/w/WorldheartPhoenix.java index 9c8ade9398..7d65b64cee 100644 --- a/Mage.Sets/src/mage/cards/w/WorldheartPhoenix.java +++ b/Mage.Sets/src/mage/cards/w/WorldheartPhoenix.java @@ -141,7 +141,7 @@ public class WorldheartPhoenix extends CardImpl { && permanent.getZoneChangeCounter(game) == spellAbility.getSourceObjectZoneChangeCounter()) { // TODO: No perfect solution because there could be other effects that allow to cast the card for this mana cost if (spellAbility.getManaCosts().getText().equals("{W}{U}{B}{R}{G}")) { - permanent.addCounters(CounterType.P1P1.createInstance(2), game); + permanent.addCounters(CounterType.P1P1.createInstance(2), source, game); } } } diff --git a/Mage.Sets/src/mage/cards/z/ZameckGuildmage.java b/Mage.Sets/src/mage/cards/z/ZameckGuildmage.java index dd4999e810..c107228c59 100644 --- a/Mage.Sets/src/mage/cards/z/ZameckGuildmage.java +++ b/Mage.Sets/src/mage/cards/z/ZameckGuildmage.java @@ -112,7 +112,7 @@ class ZameckGuildmageEntersBattlefieldEffect extends ReplacementEffectImpl { public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent target = ((EntersTheBattlefieldEvent) event).getTarget(); if (target != null) { - target.addCounters(CounterType.P1P1.createInstance(), game); + target.addCounters(CounterType.P1P1.createInstance(), source, game); } return false; } diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index 0f2da26c6b..e86fc59995 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -460,7 +460,7 @@ public class TestPlayer implements Player { for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) { if (permanent.getName().equals(groups[0])) { Counter counter = new Counter(groups[1], Integer.parseInt(groups[2])); - permanent.addCounters(counter, game); + permanent.addCounters(counter, null, game); break; } } diff --git a/Mage/src/main/java/mage/abilities/AbilityImpl.java b/Mage/src/main/java/mage/abilities/AbilityImpl.java index 223c620577..bb8b1497fd 100644 --- a/Mage/src/main/java/mage/abilities/AbilityImpl.java +++ b/Mage/src/main/java/mage/abilities/AbilityImpl.java @@ -1172,10 +1172,11 @@ public abstract class AbilityImpl implements Ability { public void setSourceObject(MageObject sourceObject, Game game) { if (sourceObject == null) { this.sourceObject = game.getObject(sourceId); + this.sourceObjectZoneChangeCounter = game.getState().getZoneChangeCounter(sourceId); } else { this.sourceObject = sourceObject; + this.sourceObjectZoneChangeCounter = this.sourceObject.getZoneChangeCounter(game); } - this.sourceObjectZoneChangeCounter = game.getState().getZoneChangeCounter(sourceId); } @Override diff --git a/Mage/src/main/java/mage/abilities/common/TurnFaceUpAbility.java b/Mage/src/main/java/mage/abilities/common/TurnFaceUpAbility.java index 61a38ad8cb..1d0a8af4dd 100644 --- a/Mage/src/main/java/mage/abilities/common/TurnFaceUpAbility.java +++ b/Mage/src/main/java/mage/abilities/common/TurnFaceUpAbility.java @@ -107,7 +107,7 @@ class TurnFaceUpEffect extends OneShotEffect { if (sourcePermanent != null) { if (sourcePermanent.turnFaceUp(game, source.getControllerId())) { if (megamorph) { - sourcePermanent.addCounters(CounterType.P1P1.createInstance(), game); + sourcePermanent.addCounters(CounterType.P1P1.createInstance(), source, game); } game.getState().setValue(source.getSourceId().toString() + "TurnFaceUpX", source.getManaCostsToPay().getX()); return true; diff --git a/Mage/src/main/java/mage/abilities/costs/common/PutCountersSourceCost.java b/Mage/src/main/java/mage/abilities/costs/common/PutCountersSourceCost.java index 1c522fa402..b5d98d44f1 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/PutCountersSourceCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/PutCountersSourceCost.java @@ -72,7 +72,7 @@ public class PutCountersSourceCost extends CostImpl { public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { Permanent permanent = game.getPermanent(sourceId); if (permanent != null) { - this.paid = permanent.addCounters(counter, game);; + this.paid = permanent.addCounters(counter, null, game);; } return paid; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java index 1a210a2ce6..c396579f05 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AmplifyEffect.java @@ -115,7 +115,7 @@ public class AmplifyEffect extends ReplacementEffectImpl { Cards cards = new CardsImpl(); cards.addAll(target.getTargets()); int amountCounters = cards.size() * amplifyFactor.getFactor(); - sourceCreature.addCounters(CounterType.P1P1.createInstance(amountCounters), game); + sourceCreature.addCounters(CounterType.P1P1.createInstance(amountCounters), source, game); controller.revealCards(sourceCreature.getIdName(), cards, game); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DevourEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DevourEffect.java index 1f060e3720..fdadf86629 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DevourEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DevourEffect.java @@ -133,7 +133,7 @@ public class DevourEffect extends ReplacementEffectImpl { } else { amountCounters = devouredCreatures * devourFactor.getFactor(); } - creature.addCounters(CounterType.P1P1.createInstance(amountCounters), game); + creature.addCounters(CounterType.P1P1.createInstance(amountCounters), source, game); game.getState().setValue(creature.getId().toString() + "devoured", cardSubtypes); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/EntersBattlefieldWithXCountersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/EntersBattlefieldWithXCountersEffect.java index 896fc88c98..10c5ef292c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/EntersBattlefieldWithXCountersEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/EntersBattlefieldWithXCountersEffect.java @@ -75,7 +75,7 @@ public class EntersBattlefieldWithXCountersEffect extends OneShotEffect { if (amount > 0) { Counter counterToAdd = counter.copy(); counterToAdd.add(amount - counter.getCount()); - permanent.addCounters(counterToAdd, game); + permanent.addCounters(counterToAdd, source, game); } } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersAllEffect.java index 709eb78698..0dc24e8709 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersAllEffect.java @@ -66,7 +66,7 @@ public class AddCountersAllEffect extends OneShotEffect { if (controller != null && sourceObject != null) { if (counter != null) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { - permanent.addCounters(counter.copy(), game); + permanent.addCounters(counter.copy(), source, game); if (!game.isSimulation()) { game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts " + counter.getCount() + " " + counter.getName().toLowerCase() + " counter on " + permanent.getLogName()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersAttachedEffect.java index c50a023a5a..a96dfea05f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersAttachedEffect.java @@ -83,7 +83,7 @@ public class AddCountersAttachedEffect extends OneShotEffect { if (attachedTo != null && counter != null) { Counter newCounter = counter.copy(); newCounter.add(amount.calculate(game, source, this)); - attachedTo.addCounters(newCounter, game); + attachedTo.addCounters(newCounter, source, game); } return true; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersSourceEffect.java index 0ea83b7f34..99f46c8f7a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersSourceEffect.java @@ -103,7 +103,7 @@ public class AddCountersSourceEffect extends OneShotEffect { countersToAdd--; } newCounter.add(countersToAdd); - card.addCounters(newCounter, game); + card.addCounters(newCounter, source, game); if (informPlayers && !game.isSimulation()) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { @@ -128,7 +128,7 @@ public class AddCountersSourceEffect extends OneShotEffect { } newCounter.add(countersToAdd); int before = permanent.getCounters(game).getCount(newCounter.getName()); - permanent.addCounters(newCounter, game); + permanent.addCounters(newCounter, source, game); if (informPlayers && !game.isSimulation()) { int amountAdded = permanent.getCounters(game).getCount(newCounter.getName()) - before; Player player = game.getPlayer(source.getControllerId()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersTargetEffect.java index 0056700064..05587f40fb 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersTargetEffect.java @@ -97,7 +97,7 @@ public class AddCountersTargetEffect extends OneShotEffect { } newCounter.add(calculated); int before = permanent.getCounters(game).getCount(counter.getName()); - permanent.addCounters(newCounter, game); + permanent.addCounters(newCounter, source, game); int numberAdded = permanent.getCounters(game).getCount(counter.getName()) - before; affectedTargets++; if (!game.isSimulation()) { @@ -114,7 +114,7 @@ public class AddCountersTargetEffect extends OneShotEffect { + counter.getCount() + " " + counter.getName().toLowerCase() + " counter on " + player.getLogName()); } } else if (card != null) { - card.addCounters(counter, game); + card.addCounters(counter, source, game); if (!game.isSimulation()) { game.informPlayers(new StringBuilder("Added ").append(counter.getCount()).append(" ").append(counter.getName()) .append(" counter to ").append(card.getName()) diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddPlusOneCountersAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddPlusOneCountersAttachedEffect.java index a053016e00..c3d0461a1a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddPlusOneCountersAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddPlusOneCountersAttachedEffect.java @@ -70,7 +70,7 @@ public class AddPlusOneCountersAttachedEffect extends OneShotEffect { if (enchantment != null && enchantment.getAttachedTo() != null) { Permanent creature = game.getPermanent(enchantment.getAttachedTo()); if (creature != null) { - creature.addCounters(CounterType.P1P1.createInstance(amount), game); + creature.addCounters(CounterType.P1P1.createInstance(amount), source, game); } } return true; diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddRemoveAllTimeSuspentCountersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddRemoveAllTimeSuspentCountersEffect.java index 6c1e8525bc..6d84a0614f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddRemoveAllTimeSuspentCountersEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddRemoveAllTimeSuspentCountersEffect.java @@ -29,7 +29,6 @@ package mage.abilities.effects.common.counter; import java.util.ArrayList; import java.util.List; - import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; @@ -51,11 +50,11 @@ public class AddRemoveAllTimeSuspentCountersEffect extends OneShotEffect { private final boolean removeCounter; private final String actionStr; - public AddRemoveAllTimeSuspentCountersEffect(Counter counter, Filter filter, boolean removeCounter) { + public AddRemoveAllTimeSuspentCountersEffect(Counter counter, Filter filter, boolean removeCounter) { super(Outcome.Benefit); this.counter = counter; this.filter = filter; - this.removeCounter= removeCounter; + this.removeCounter = removeCounter; actionStr = removeCounter ? " removes " : " puts "; setText(); } @@ -74,38 +73,39 @@ public class AddRemoveAllTimeSuspentCountersEffect extends OneShotEffect { MageObject sourceObject = game.getObject(source.getSourceId()); if (controller != null && sourceObject != null) { if (counter != null) { - List permanents = new ArrayList(game.getBattlefield().getAllActivePermanents()); - execute(game, controller, sourceObject, permanents, removeCounter); + List permanents = new ArrayList<>(game.getBattlefield().getAllActivePermanents()); + execute(game, controller, sourceObject, source, permanents, removeCounter); final List exiledCards = game.getExile().getAllCards(game); - execute(game, controller, sourceObject, exiledCards, removeCounter); + execute(game, controller, sourceObject, source, exiledCards, removeCounter); } return true; - } + } return false; } - private void execute(final Game game, final Player controller, final MageObject sourceObject, final List cards, final boolean removeCounter) { - for (Card card : cards) { - if (filter.match(card, game)) { - final String counterName = counter.getName(); - if (removeCounter) { - final Counter existingCounterOfSameType = card.getCounters(game).get(counterName); - final int countersToRemove = Math.min(existingCounterOfSameType.getCount(), counter.getCount()); - final Counter modifiedCounter = new Counter(counterName, countersToRemove); - card.removeCounters(modifiedCounter, game); - } else { - card.addCounters(counter, game); + private void execute(final Game game, final Player controller, final MageObject sourceObject, Ability source, final List cards, final boolean removeCounter) { + for (Card card : cards) { + if (filter.match(card, game)) { + final String counterName = counter.getName(); + if (removeCounter) { + final Counter existingCounterOfSameType = card.getCounters(game).get(counterName); + final int countersToRemove = Math.min(existingCounterOfSameType.getCount(), counter.getCount()); + final Counter modifiedCounter = new Counter(counterName, countersToRemove); + card.removeCounters(modifiedCounter, game); + } else { + card.addCounters(counter, source, game); + } + if (!game.isSimulation()) { + game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ") + .append(controller.getLogName()).append(actionStr) + .append(counter.getCount()).append(" ").append(counterName.toLowerCase()) + .append(" counter on ").append(card.getName()).toString()); + } } - if (!game.isSimulation()) - game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ") - .append(controller.getLogName()).append(actionStr) - .append(counter.getCount()).append(" ").append(counterName.toLowerCase()) - .append(" counter on ").append(card.getName()).toString()); } } - } - private void setText() { + private void setText() { StringBuilder sb = new StringBuilder(); final String actionsStr2 = removeCounter ? "remove " : " put "; sb.append(actionsStr2); diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/DistributeCountersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/DistributeCountersEffect.java index d0135d2cd5..0f74a9fb4c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/DistributeCountersEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/DistributeCountersEffect.java @@ -79,7 +79,7 @@ public class DistributeCountersEffect extends OneShotEffect { for (UUID target : multiTarget.getTargets()) { Permanent permanent = game.getPermanent(target); if (permanent != null) { - permanent.addCounters(counterType.createInstance(multiTarget.getTargetAmount(target)), game); + permanent.addCounters(counterType.createInstance(multiTarget.getTargetAmount(target)), source, game); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/MoveCountersTargetsEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/MoveCountersTargetsEffect.java index 775777223c..4979d2ca0f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/MoveCountersTargetsEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/MoveCountersTargetsEffect.java @@ -68,7 +68,7 @@ public class MoveCountersTargetsEffect extends OneShotEffect { Permanent addTargetCreature = game.getPermanent(targetPointer.getTargets(game, source).get(1)); if (removeTargetCreature != null && addTargetCreature != null && removeTargetCreature.getCounters(game).getCount(counterType) >= amount) { removeTargetCreature.removeCounters(counterType.createInstance(amount), game); - addTargetCreature.addCounters(counterType.createInstance(amount), game); + addTargetCreature.addCounters(counterType.createInstance(amount), source, game); if (!game.isSimulation()) { game.informPlayers("Moved " + amount + " " + counterType.getName() + " counter" + (amount > 1 ? "s" : "") + " from " + removeTargetCreature.getLogName() + " to " + addTargetCreature.getLogName()); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java index 7ae35237b8..89f4ff24cd 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/ProliferateEffect.java @@ -79,7 +79,7 @@ public class ProliferateEffect extends OneShotEffect { if (permanent.getCounters(game).size() == 1) { for (Counter counter : permanent.getCounters(game).values()) { Counter newCounter = new Counter(counter.getName()); - permanent.addCounters(newCounter, game); + permanent.addCounters(newCounter, source, game); } } else { Choice choice = new ChoiceImpl(true); @@ -93,7 +93,7 @@ public class ProliferateEffect extends OneShotEffect { for (Counter counter : permanent.getCounters(game).values()) { if (counter.getName().equals(choice.getChoice())) { Counter newCounter = new Counter(counter.getName()); - permanent.addCounters(newCounter, game); + permanent.addCounters(newCounter, source, game); break; } } diff --git a/Mage/src/main/java/mage/abilities/keyword/BloodthirstAbility.java b/Mage/src/main/java/mage/abilities/keyword/BloodthirstAbility.java index 0b8f4d29c6..b57e67959e 100644 --- a/Mage/src/main/java/mage/abilities/keyword/BloodthirstAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/BloodthirstAbility.java @@ -71,7 +71,7 @@ class BloodthirstEffect extends OneShotEffect { if (watcher != null && watcher.conditionMet()) { Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (permanent != null) { - permanent.addCounters(CounterType.P1P1.createInstance(amount), game); + permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); } } return true; diff --git a/Mage/src/main/java/mage/abilities/keyword/EvolveAbility.java b/Mage/src/main/java/mage/abilities/keyword/EvolveAbility.java index e6593bc045..77bebff2ef 100644 --- a/Mage/src/main/java/mage/abilities/keyword/EvolveAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/EvolveAbility.java @@ -166,7 +166,7 @@ class EvolveEffect extends OneShotEffect { if (triggeringCreature != null) { Permanent sourceCreature = game.getPermanent(source.getSourceId()); if (sourceCreature != null && EvolveAbility.isPowerOrThoughnessGreater(sourceCreature, triggeringCreature)) { - sourceCreature.addCounters(CounterType.P1P1.createInstance(), game); + sourceCreature.addCounters(CounterType.P1P1.createInstance(), source, game); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EVOLVED_CREATURE, sourceCreature.getId(), source.getSourceId(), source.getControllerId())); } return true; diff --git a/Mage/src/main/java/mage/abilities/keyword/FabricateAbility.java b/Mage/src/main/java/mage/abilities/keyword/FabricateAbility.java index 5fe9c10588..ed94c7720a 100644 --- a/Mage/src/main/java/mage/abilities/keyword/FabricateAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/FabricateAbility.java @@ -93,7 +93,7 @@ class FabricateEffect extends OneShotEffect { "Create " + CardUtil.numberToText(value, "a") + " 1/1 token" + (value > 1 ? "s" : ""), source, game)) { - ((Card) sourceObject).addCounters(CounterType.P1P1.createInstance(value), game); + ((Card) sourceObject).addCounters(CounterType.P1P1.createInstance(value), source, game); } else { new ServoToken().putOntoBattlefield(value, game, source.getSourceId(), controller.getId()); diff --git a/Mage/src/main/java/mage/abilities/keyword/GraftAbility.java b/Mage/src/main/java/mage/abilities/keyword/GraftAbility.java index c60b3c4bb0..937501a4ea 100644 --- a/Mage/src/main/java/mage/abilities/keyword/GraftAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/GraftAbility.java @@ -173,7 +173,7 @@ class GraftDistributeCounterEffect extends OneShotEffect { Permanent targetCreature = game.getPermanent(targetPointer.getFirst(game, source)); if (targetCreature != null) { sourcePermanent.removeCounters(CounterType.P1P1.getName(), 1, game); - targetCreature.addCounters(CounterType.P1P1.createInstance(1), game); + targetCreature.addCounters(CounterType.P1P1.createInstance(1), source, game); if (!game.isSimulation()) { game.informPlayers("Moved one +1/+1 counter from " + sourcePermanent.getLogName() + " to " + targetCreature.getLogName()); } diff --git a/Mage/src/main/java/mage/abilities/keyword/ModularAbility.java b/Mage/src/main/java/mage/abilities/keyword/ModularAbility.java index 62800ca784..bcac6e5cd6 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ModularAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ModularAbility.java @@ -159,7 +159,7 @@ class ModularDistributeCounterEffect extends OneShotEffect { if (sourcePermanent != null && targetArtifact != null && player != null) { int numberOfCounters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1); if (numberOfCounters > 0) { - targetArtifact.addCounters(CounterType.P1P1.createInstance(numberOfCounters), game); + targetArtifact.addCounters(CounterType.P1P1.createInstance(numberOfCounters), source, game); } return true; } diff --git a/Mage/src/main/java/mage/abilities/keyword/SunburstAbility.java b/Mage/src/main/java/mage/abilities/keyword/SunburstAbility.java index 7c8df41fc8..725d15424b 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SunburstAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SunburstAbility.java @@ -98,7 +98,7 @@ class SunburstEffect extends OneShotEffect { } if (counter != null) { - permanent.addCounters(counter, game); + permanent.addCounters(counter, source, game); if (!game.isSimulation()) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { diff --git a/Mage/src/main/java/mage/abilities/keyword/SuspendAbility.java b/Mage/src/main/java/mage/abilities/keyword/SuspendAbility.java index b3dc8dd964..5de5b130a5 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SuspendAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SuspendAbility.java @@ -293,7 +293,7 @@ class SuspendExileEffect extends OneShotEffect { if (suspend == Integer.MAX_VALUE) { suspend = source.getManaCostsToPay().getX(); } - card.addCounters(CounterType.TIME.createInstance(suspend), game); + card.addCounters(CounterType.TIME.createInstance(suspend), source, game); if (!game.isSimulation()) { game.informPlayers(controller.getLogName() + " suspends (" + suspend + ") " + card.getLogName()); } diff --git a/Mage/src/main/java/mage/abilities/keyword/UnleashAbility.java b/Mage/src/main/java/mage/abilities/keyword/UnleashAbility.java index eb0a9ec4a3..3f9cfbfcaf 100644 --- a/Mage/src/main/java/mage/abilities/keyword/UnleashAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/UnleashAbility.java @@ -105,7 +105,7 @@ class UnleashReplacementEffect extends ReplacementEffectImpl { if (!game.isSimulation()) { game.informPlayers(controller.getLogName() + " unleashes " + creature.getName()); } - creature.addCounters(CounterType.P1P1.createInstance(), game); + creature.addCounters(CounterType.P1P1.createInstance(), source, game); } } return false; diff --git a/Mage/src/main/java/mage/cards/Card.java b/Mage/src/main/java/mage/cards/Card.java index c6546aa53d..672bdd9f4d 100644 --- a/Mage/src/main/java/mage/cards/Card.java +++ b/Mage/src/main/java/mage/cards/Card.java @@ -157,9 +157,9 @@ public interface Card extends MageObject { Counters getCounters(GameState state); - boolean addCounters(Counter counter, Game game); + boolean addCounters(Counter counter, Ability source, Game game); - boolean addCounters(Counter counter, Game game, ArrayList appliedEffects); + boolean addCounters(Counter counter, Ability source, Game game, ArrayList appliedEffects); void removeCounters(String name, int amount, Game game); diff --git a/Mage/src/main/java/mage/cards/CardImpl.java b/Mage/src/main/java/mage/cards/CardImpl.java index d5965330f5..9d5fed0057 100644 --- a/Mage/src/main/java/mage/cards/CardImpl.java +++ b/Mage/src/main/java/mage/cards/CardImpl.java @@ -502,7 +502,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card { Counters countersToAdd = game.getEnterWithCounters(permanent.getId()); if (countersToAdd != null) { for (Counter counter : countersToAdd.values()) { - permanent.addCounters(counter, game); + permanent.addCounters(counter, null, game); } game.setEnterWithCounters(permanent.getId(), null); } @@ -619,14 +619,15 @@ public abstract class CardImpl extends MageObjectImpl implements Card { } @Override - public boolean addCounters(Counter counter, Game game) { - return addCounters(counter, game, null); + public boolean addCounters(Counter counter, Ability source, Game game) { + return addCounters(counter, source, game, null); } @Override - public boolean addCounters(Counter counter, Game game, ArrayList appliedEffects) { + public boolean addCounters(Counter counter, Ability source, Game game, ArrayList appliedEffects) { boolean returnCode = true; - GameEvent countersEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, getControllerOrOwner(), counter.getName(), counter.getCount()); + UUID sourceId = (source == null ? null : source.getSourceId()); + GameEvent countersEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, sourceId, getControllerOrOwner(), counter.getName(), counter.getCount()); countersEvent.setAppliedEffects(appliedEffects); if (!game.replaceEvent(countersEvent)) { int amount = countersEvent.getAmount(); @@ -634,18 +635,18 @@ public abstract class CardImpl extends MageObjectImpl implements Card { for (int i = 0; i < amount; i++) { Counter eventCounter = counter.copy(); eventCounter.remove(eventCounter.getCount() - 1); - GameEvent event = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, getControllerOrOwner(), counter.getName(), 1); + GameEvent event = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, sourceId, getControllerOrOwner(), counter.getName(), 1); event.setAppliedEffects(appliedEffects); if (!game.replaceEvent(event)) { getCounters(game).addCounter(eventCounter); - game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED, objectId, getControllerOrOwner(), counter.getName(), 1)); + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED, objectId, sourceId, getControllerOrOwner(), counter.getName(), 1)); } else { finalAmount--; returnCode = false; } } if (finalAmount > 0) { - game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERS_ADDED, objectId, getControllerOrOwner(), counter.getName(), amount)); + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERS_ADDED, objectId, sourceId, getControllerOrOwner(), counter.getName(), amount)); } } else { returnCode = false; diff --git a/Mage/src/main/java/mage/cards/MeldCard.java b/Mage/src/main/java/mage/cards/MeldCard.java index 3faa8b51ae..bbf2faef5d 100644 --- a/Mage/src/main/java/mage/cards/MeldCard.java +++ b/Mage/src/main/java/mage/cards/MeldCard.java @@ -29,8 +29,8 @@ package mage.cards; import java.util.ArrayList; import java.util.UUID; +import mage.abilities.Ability; import mage.constants.CardType; -import mage.constants.Rarity; import mage.constants.Zone; import mage.counters.Counter; import mage.game.Game; @@ -133,17 +133,17 @@ public abstract class MeldCard extends CardImpl { } @Override - public boolean addCounters(Counter counter, Game game, ArrayList appliedEffects) { + public boolean addCounters(Counter counter, Ability source, Game game, ArrayList appliedEffects) { if (this.isMelded()) { - return super.addCounters(counter, game, appliedEffects); + return super.addCounters(counter, source, game, appliedEffects); } else { // can this really happen? boolean returnState = true; if (hasTopHalf(game)) { - returnState |= topHalfCard.addCounters(counter, game, appliedEffects); + returnState |= topHalfCard.addCounters(counter, source, game, appliedEffects); } if (hasBottomHalf(game)) { - returnState |= bottomHalfCard.addCounters(counter, game, appliedEffects); + returnState |= bottomHalfCard.addCounters(counter, source, game, appliedEffects); } return returnState; } @@ -176,12 +176,12 @@ public abstract class MeldCard extends CardImpl { Permanent permanent = game.getPermanent(objectId); return permanent != null && permanent.removeFromZone(game, fromZone, sourceId); } - boolean topRemoved = hasTopHalf(game) && topHalfCard.removeFromZone(game, fromZone, sourceId); + boolean topRemoved = hasTopHalf(game) && topHalfCard.removeFromZone(game, fromZone, sourceId); if (!topRemoved) { // The top half isn't being moved with the pair anymore. halves.remove(topHalfCard); } - boolean bottomRemoved = hasBottomHalf(game) && bottomHalfCard.removeFromZone(game, fromZone, sourceId); + boolean bottomRemoved = hasBottomHalf(game) && bottomHalfCard.removeFromZone(game, fromZone, sourceId); if (!bottomRemoved) { // The bottom half isn't being moved with the pair anymore. halves.remove(bottomHalfCard); diff --git a/Mage/src/main/java/mage/game/events/GameEvent.java b/Mage/src/main/java/mage/game/events/GameEvent.java index 8adf4f1e77..ee8e2306e4 100644 --- a/Mage/src/main/java/mage/game/events/GameEvent.java +++ b/Mage/src/main/java/mage/game/events/GameEvent.java @@ -344,8 +344,8 @@ public class GameEvent implements Serializable { return new GameEvent(type, targetId, null, playerId); } - public static GameEvent getEvent(EventType type, UUID targetId, UUID playerId, String data, int amount) { - GameEvent event = getEvent(type, targetId, playerId); + public static GameEvent getEvent(EventType type, UUID targetId, UUID sourceId, UUID playerId, String data, int amount) { + GameEvent event = getEvent(type, targetId, sourceId, playerId); event.setAmount(amount); event.setData(data); return event; diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index 0e61767678..6f292279d1 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -787,7 +787,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { return 0; } for (Counter counter : markedDamage) { - addCounters(counter, game); + addCounters(counter, null, game); } markedDamage.clear(); return 0; @@ -832,7 +832,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { markDamage(CounterType.M1M1.createInstance(actualDamage)); } else { // deal damage immediately - addCounters(CounterType.M1M1.createInstance(actualDamage), game); + addCounters(CounterType.M1M1.createInstance(actualDamage), null, game); } } else { this.damage += actualDamage; diff --git a/Mage/src/main/java/mage/game/stack/Spell.java b/Mage/src/main/java/mage/game/stack/Spell.java index db9ef64e6c..ada5635bef 100644 --- a/Mage/src/main/java/mage/game/stack/Spell.java +++ b/Mage/src/main/java/mage/game/stack/Spell.java @@ -851,13 +851,13 @@ public class Spell extends StackObjImpl implements Card { } @Override - public boolean addCounters(Counter counter, Game game) { - return card.addCounters(counter, game); + public boolean addCounters(Counter counter, Ability source, Game game) { + return card.addCounters(counter, source, game); } @Override - public boolean addCounters(Counter counter, Game game, ArrayList appliedEffects) { - return card.addCounters(counter, game, appliedEffects); + public boolean addCounters(Counter counter, Ability source, Game game, ArrayList appliedEffects) { + return card.addCounters(counter, source, game, appliedEffects); } @Override diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index c803bb69ad..c74ad682b1 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -1850,24 +1850,24 @@ public abstract class PlayerImpl implements Player, Serializable { @Override public boolean addCounters(Counter counter, Game game) { boolean returnCode = true; - GameEvent countersEvent = GameEvent.getEvent(EventType.ADD_COUNTERS, playerId, playerId, counter.getName(), counter.getCount()); + GameEvent countersEvent = GameEvent.getEvent(EventType.ADD_COUNTERS, playerId, null, playerId, counter.getName(), counter.getCount()); if (!game.replaceEvent(countersEvent)) { int amount = countersEvent.getAmount(); int finalAmount = amount; for (int i = 0; i < amount; i++) { Counter eventCounter = counter.copy(); eventCounter.remove(amount - 1); - GameEvent event = GameEvent.getEvent(EventType.ADD_COUNTER, playerId, playerId, counter.getName(), 1); + GameEvent event = GameEvent.getEvent(EventType.ADD_COUNTER, playerId, null, playerId, counter.getName(), 1); if (!game.replaceEvent(event)) { getCounters().addCounter(eventCounter); - game.fireEvent(GameEvent.getEvent(EventType.COUNTER_ADDED, playerId, playerId, counter.getName(), 1)); + game.fireEvent(GameEvent.getEvent(EventType.COUNTER_ADDED, playerId, null, playerId, counter.getName(), 1)); } else { finalAmount--; returnCode = false; } } if (finalAmount > 0) { - game.fireEvent(GameEvent.getEvent(EventType.COUNTERS_ADDED, playerId, playerId, counter.getName(), amount)); + game.fireEvent(GameEvent.getEvent(EventType.COUNTERS_ADDED, playerId, null, playerId, counter.getName(), amount)); } } else { returnCode = false;