Refactoring methods which add counters to track which player adds the counters (ready for review) (#7448)

* added parameter for player adding counters to players

* added parameter for player adding counters to cards/permanents

* updated methods to use new parameter

* fixed a few initial errors

* refactored instances of cards that add counters by a player other than the controller

* fixed some instances of incorrect arguments

* refactored abilities that trigger off of a particular player adding counters

* a few more cards that were missed

* [KHM] Implemented Vorinclex, Monstrous Raider

* added test for Vorinclex, Monstrous Raider

* fixed a test failure
This commit is contained in:
Evan Kranzler 2021-01-26 19:06:13 -05:00 committed by GitHub
parent 4db79ae3c1
commit a535cb5adc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
320 changed files with 701 additions and 481 deletions

View file

@ -518,7 +518,7 @@ public final class SystemUtil {
} else if ("loyalty".equalsIgnoreCase(command.zone)) {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(player.getId())) {
if (perm.getName().equals(command.cardName) && perm.getCardType().contains(CardType.PLANESWALKER)) {
perm.addCounters(CounterType.LOYALTY.createInstance(command.Amount), fakeSourceAbility, game);
perm.addCounters(CounterType.LOYALTY.createInstance(command.Amount), fakeSourceAbility.getControllerId(), fakeSourceAbility, game);
}
}
continue;

View file

@ -52,7 +52,7 @@ class AborothCost extends CostImpl {
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.addCounters(CounterType.M1M1.createInstance(), ability, game);
permanent.addCounters(CounterType.M1M1.createInstance(), controllerId, ability, game);
this.paid = true;
return true;
}

View file

@ -93,7 +93,7 @@ class AetherbornMarauderEffect extends OneShotEffect {
}
if (numberToMove > 0) {
fromPermanent.removeCounters(CounterType.P1P1.createInstance(numberToMove), source, game);
sourceObject.addCounters(CounterType.P1P1.createInstance(numberToMove), source, game);
sourceObject.addCounters(CounterType.P1P1.createInstance(numberToMove), source.getControllerId(), source, game);
}
}
}

View file

@ -77,7 +77,7 @@ class MoveCounterToTargetFromSourceEffect extends OneShotEffect {
Permanent toPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (toPermanent != null && sourceObject.getCounters(game).getCount(CounterType.P1P1) > 0) {
sourceObject.removeCounters(CounterType.P1P1.createInstance(), source, game);
toPermanent.addCounters(CounterType.P1P1.createInstance(), source, game);
toPermanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
game.informPlayers("Moved a +1/+1 counter from " + sourceObject.getLogName() + " to " + toPermanent.getLogName());
}
return true;

View file

@ -88,7 +88,7 @@ class AgitatorAntEffect extends OneShotEffect {
targetPermanent.setNotTarget(true);
player.choose(Outcome.BoostCreature, targetPermanent, source.getSourceId(), game);
Permanent permanent = game.getPermanent(targetPermanent.getFirstTarget());
if (permanent == null || !permanent.addCounters(CounterType.P1P1.createInstance(2), source, game)) {
if (permanent == null || !permanent.addCounters(CounterType.P1P1.createInstance(2), player.getId(), source, game)) {
continue;
}
new GoadTargetEffect().setTargetPointer(new FixedTarget(permanent, game)).apply(game, source);

View file

@ -19,7 +19,6 @@ import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
/**
@ -106,7 +105,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")), source, game);
permanent.addCounters(CounterType.CHARGE.createInstance((Integer) this.getValue("damageAmount")), source.getControllerId(), source, game);
}
return true;
}

View file

@ -121,7 +121,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, source, game);
permanent.addCounters(newCounter, source.getControllerId(), source, game);
}
} else {
Choice choice = new ChoiceImpl(true);
@ -135,7 +135,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, source, game);
permanent.addCounters(newCounter, source.getControllerId(), source, game);
break;
}
}
@ -151,7 +151,7 @@ class AnimationModuleEffect extends OneShotEffect {
if (player.getCounters().size() == 1) {
for (Counter counter : player.getCounters().values()) {
Counter newCounter = new Counter(counter.getName());
player.addCounters(newCounter, source, game);
player.addCounters(newCounter, source.getControllerId(), source, game);
}
} else {
Choice choice = new ChoiceImpl(true);
@ -165,7 +165,7 @@ class AnimationModuleEffect extends OneShotEffect {
for (Counter counter : player.getCounters().values()) {
if (counter.getName().equals(choice.getChoice())) {
Counter newCounter = new Counter(counter.getName());
player.addCounters(newCounter, source, game);
player.addCounters(newCounter, source.getControllerId(), source, game);
break;
}
}

View file

@ -75,7 +75,7 @@ class AnthroplasmEffect extends OneShotEffect {
//Remove all +1/+1 counters
permanent.removeCounters(permanent.getCounters(game).get(CounterType.P1P1.getName()), source, game);
//put X +1/+1 counters
permanent.addCounters(CounterType.P1P1.createInstance(source.getManaCostsToPay().getX()), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(source.getManaCostsToPay().getX()), source.getControllerId(), source, game);
return true;
}
return false;

View file

@ -82,9 +82,9 @@ class ApocalypseHydraEffect extends OneShotEffect {
int amount = spellAbility.getManaCostsToPay().getX();
if (amount > 0) {
if (amount < 5) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game);
} else {
permanent.addCounters(CounterType.P1P1.createInstance(amount * 2), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(amount * 2), source.getControllerId(), source, game);
}
}
return true;

View file

@ -89,7 +89,7 @@ class ArbiterOfTheIdealEffect extends OneShotEffect {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
permanent.addCounters(CounterType.MANIFESTATION.createInstance(), source, game);
permanent.addCounters(CounterType.MANIFESTATION.createInstance(), source.getControllerId(), source, game);
ContinuousEffect effect = new AddCardTypeTargetEffect(Duration.Custom, CardType.ENCHANTMENT);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);

View file

@ -80,7 +80,7 @@ class MoveCounterFromTargetToSourceEffect extends OneShotEffect {
Permanent fromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (fromPermanent != null && fromPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
fromPermanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
sourceObject.addCounters(CounterType.P1P1.createInstance(), source, game);
sourceObject.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
game.informPlayers("Moved a +1/+1 counter from " + fromPermanent.getLogName() + " to " + sourceObject.getLogName());
}
return true;

View file

@ -77,7 +77,7 @@ class ArlinnVoiceOfThePackReplacementEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (creature != null) {
creature.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects());
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
}
return false;
}

View file

@ -87,7 +87,7 @@ class ArsenalThresherEffect extends OneShotEffect {
if (arsenalThresher != null) {
controller.revealCards(arsenalThresher.getIdName(), cards, game);
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()), source, game, appliedEffects);
arsenalThresher.addCounters(CounterType.P1P1.createInstance(cards.size()), source.getControllerId(), source, game, appliedEffects);
}
}
}

View file

@ -106,7 +106,7 @@ class AsLuckWouldHaveItEffect extends OneShotEffect {
if (controller != null && permanent != null) {
if (getValue("rolled") != null) {
int amount = (Integer) getValue("rolled");
permanent.addCounters(new Counter("luck", amount), source, game);
permanent.addCounters(new Counter("luck", amount), source.getControllerId(), source, game);
if (permanent.getCounters(game).getCount("luck") >= 100) {
Player player = game.getPlayer(permanent.getControllerId());

View file

@ -85,7 +85,7 @@ class AscendantSpiritWarriorEffect extends OneShotEffect {
if (permanent == null || !permanent.hasSubtype(SubType.WARRIOR, game)) {
return false;
}
permanent.addCounters(CounterType.FLYING.createInstance(), source, game);
permanent.addCounters(CounterType.FLYING.createInstance(), source.getControllerId(), source, game);
game.addEffect(new AddCardSubTypeSourceEffect(
Duration.Custom, SubType.SPIRIT, SubType.WARRIOR, SubType.ANGEL
), source);
@ -119,7 +119,7 @@ class AscendantSpiritAngelEffect extends OneShotEffect {
if (permanent == null || !permanent.hasSubtype(SubType.ANGEL, game)) {
return false;
}
permanent.addCounters(CounterType.P1P1.createInstance(2), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(2), source.getControllerId(), source, game);
game.addEffect(new GainAbilitySourceEffect(new DealsCombatDamageToAPlayerTriggeredAbility(
new DrawCardSourceControllerEffect(1), false
), Duration.Custom), source);

View file

@ -171,7 +171,7 @@ class AscentOfTheWorthyReturnEffect extends OneShotEffect {
if (permanent == null) {
return false;
}
permanent.addCounters(CounterType.FLYING.createInstance(), source, game);
permanent.addCounters(CounterType.FLYING.createInstance(), source.getControllerId(), source, game);
game.addEffect(new AddCardSubTypeTargetEffect(
SubType.ANGEL, Duration.Custom
).setTargetPointer(new FixedTarget(permanent, game)), source);

View file

@ -14,7 +14,6 @@ import mage.constants.*;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -96,7 +95,7 @@ class AzorsElocutorsEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.addCounters(CounterType.FILIBUSTER.createInstance(), source, game);
permanent.addCounters(CounterType.FILIBUSTER.createInstance(), source.getControllerId(), source, game);
if (permanent.getCounters(game).getCount(CounterType.FILIBUSTER) > 4) {
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {

View file

@ -90,7 +90,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), source, game);
toPermanent.addCounters(CounterType.P1P1.createInstance(amountToMove), source, game);
toPermanent.addCounters(CounterType.P1P1.createInstance(amountToMove), source.getControllerId(), source, game);
}
}
return true;

View file

@ -54,7 +54,7 @@ class BlackSunsZenithEffect extends OneShotEffect {
int amount = source.getManaCostsToPay().getX();
for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) {
if (permanent != null && permanent.isCreature()) {
permanent.addCounters(CounterType.M1M1.createInstance(amount), source, game);
permanent.addCounters(CounterType.M1M1.createInstance(amount), source.getControllerId(), source, game);
}
}
return true;

View file

@ -62,9 +62,9 @@ class BladeOfTheBloodchiefEffect extends OneShotEffect {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
if (creature.hasSubtype(SubType.VAMPIRE, game)) {
creature.addCounters(CounterType.P1P1.createInstance(2), source, game);
creature.addCounters(CounterType.P1P1.createInstance(2), source.getControllerId(), source, game);
} else {
creature.addCounters(CounterType.P1P1.createInstance(), source, game);
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
}
}

View file

@ -84,7 +84,7 @@ class BlessingOfFrostEffect extends OneShotEffect {
if (permanent == null) {
continue;
}
permanent.addCounters(CounterType.P1P1.createInstance(target.getTargetAmount(targetId)), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(target.getTargetAmount(targetId)), source.getControllerId(), source, game);
}
}
game.applyEffects();

View file

@ -72,6 +72,6 @@ class BloodCurdleEffect extends OneShotEffect {
if (permanent == null) {
return false;
}
return permanent.addCounters(CounterType.MENACE.createInstance(), source, game);
return permanent.addCounters(CounterType.MENACE.createInstance(), source.getControllerId(), source, game);
}
}

View file

@ -16,7 +16,6 @@ import mage.constants.*;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -119,7 +118,7 @@ class BloodTyrantEffect extends OneShotEffect {
}
Permanent bloodTyrant = game.getPermanent(source.getSourceId());
if (bloodTyrant != null && counters > 0) {
bloodTyrant.addCounters(CounterType.P1P1.createInstance(counters), source, game);
bloodTyrant.addCounters(CounterType.P1P1.createInstance(counters), source.getControllerId(), source, game);
}
return true;
}

View file

@ -15,7 +15,6 @@ import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
/**
@ -78,7 +77,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), source, game);
creature.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game);
}
}
return false;

View file

@ -84,7 +84,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(), source, game);
creature.addCounters(CounterType.M1M1.createInstance(), source.getControllerId(), source, game);
return true;
}
return false;

View file

@ -17,7 +17,6 @@ import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
@ -175,7 +174,7 @@ class BombSquadBeginningEffect extends OneShotEffect {
return false;
}
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
permanent.addCounters(CounterType.FUSE.createInstance(), source, game);
permanent.addCounters(CounterType.FUSE.createInstance(), source.getControllerId(), source, game);
game.informPlayers(card.getName() + " puts a fuse counter on " + permanent.getName());
}

View file

@ -98,7 +98,7 @@ class BorealOutriderEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (creature != null) {
creature.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects());
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
discard();
}
return false;

View file

@ -83,7 +83,7 @@ class BraceForImpactPreventDamageTargetEffect extends PreventionEffectImpl {
if (prevented > 0) {
Permanent targetPermanent = game.getPermanent(source.getTargets().getFirstTarget());
if (targetPermanent != null) {
targetPermanent.addCounters(CounterType.P1P1.createInstance(prevented), source, game);
targetPermanent.addCounters(CounterType.P1P1.createInstance(prevented), source.getControllerId(), source, game);
game.informPlayers("Brace for Impact: Prevented " + prevented + " damage ");
game.informPlayers("Brace for Impact: Adding " + prevented + " +1/+1 counters to " + targetPermanent.getName());
}

View file

@ -88,7 +88,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(), source, game, event.getAppliedEffects());
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
}
return false;
}

View file

@ -99,7 +99,7 @@ class CallOfTheDeathDwellerEffect extends OneShotEffect {
if (player.choose(outcome, target, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.addCounters(CounterType.DEATHTOUCH.createInstance(), source, game);
permanent.addCounters(CounterType.DEATHTOUCH.createInstance(), source.getControllerId(), source, game);
}
}
filter.setMessage("creature to put a menace counter on");
@ -107,7 +107,7 @@ class CallOfTheDeathDwellerEffect extends OneShotEffect {
if (player.choose(outcome, target, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.addCounters(CounterType.MENACE.createInstance(), source, game);
permanent.addCounters(CounterType.MENACE.createInstance(), source.getControllerId(), source, game);
}
}
return true;

View file

@ -78,7 +78,7 @@ class CankerAbominationEffect extends OneShotEffect {
game.informPlayers(cankerAbomination.getName() + ": " + controller.getLogName() + " has chosen " + opponent.getLogName());
int amount = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, opponent.getId(), game).size();
if (amount > 0) {
cankerAbomination.addCounters(CounterType.M1M1.createInstance(amount), source, game);
cankerAbomination.addCounters(CounterType.M1M1.createInstance(amount), source.getControllerId(), source, game);
}
return true;
}

View file

@ -72,7 +72,7 @@ class CannibalizeEffect extends OneShotEffect {
controller.moveCardToExileWithInfo(creature, null, "", source, game, Zone.BATTLEFIELD, true);
exileDone = true;
} else {
creature.addCounters(CounterType.P1P1.createInstance(2), source, game);
creature.addCounters(CounterType.P1P1.createInstance(2), source.getControllerId(), source, game);
game.informPlayers("Added two +1/+1 counters on " + creature.getLogName());
}
count++;

View file

@ -84,7 +84,7 @@ class CauldronsGiftEffect extends OneShotEffect {
}
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
return true;
}

View file

@ -85,7 +85,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(), source, game);
chargingCinderhoof.addCounters(CounterType.FURY.createInstance(), source.getControllerId(), source, game);
} else {
chargingCinderhoof = game.getPermanentOrLKIBattlefield(source.getSourceId());
}

View file

@ -151,7 +151,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), source, game, event.getAppliedEffects());
creature.addCounters(CounterType.P1P1.createInstance(xValue), source.getControllerId(), source, game, event.getAppliedEffects());
game.informPlayers(sourceObject.getLogName() + ": " + creature.getLogName() + " enters the battlefield with " + xValue + " +1/+1 counter" + (xValue > 1 ? "s" : "") + " on it");
}
spellX.remove(key);

View file

@ -106,7 +106,7 @@ class CollectiveEffortEffect extends OneShotEffect {
Player target = game.getPlayer(source.getFirstTarget());
if (target != null) {
for (Permanent p : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, target.getId(), game)) {
p.addCounters(CounterType.P1P1.createInstance(), source, game);
p.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
return true;
}

View file

@ -100,7 +100,7 @@ class CombineGuildmageReplacementEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
if (target != null) {
target.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects());
target.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
}
return false;
}
@ -136,7 +136,7 @@ class CombineGuildmageCounterEffect extends OneShotEffect {
}
if (fromPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
fromPermanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
toPermanent.addCounters(CounterType.P1P1.createInstance(), source, game);
toPermanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
return true;
}

View file

@ -57,12 +57,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), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(1), source.getControllerId(), source, game);
affectedTargets ++;
}
permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(1), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(1), source.getControllerId(), source, game);
affectedTargets ++;
}
return affectedTargets > 0;

View file

@ -68,7 +68,7 @@ class ContagionEngineEffect extends OneShotEffect {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, targetPlayer.getId(), game)) {
creature.addCounters(CounterType.M1M1.createInstance(), source, game);
creature.addCounters(CounterType.M1M1.createInstance(), source.getControllerId(), source, game);
}
return true;
}

View file

@ -78,7 +78,7 @@ class CorrosionUpkeepEffect extends OneShotEffect {
// put a rust counter on each artifact target opponent controls
if (targetPlayer != null) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, targetPlayer.getId(), game)) {
permanent.addCounters(CounterType.RUST.createInstance(), source, game);
permanent.addCounters(CounterType.RUST.createInstance(), source.getControllerId(), source, game);
}
}
// destroy each artifact with converted mana cost less than or equal to the number of rust counters on it

View file

@ -66,6 +66,6 @@ class CradleOfVitalityEffect extends OneShotEffect {
lifeGained = (Integer) this.getValue("gainedLife");
}
return permanent != null && lifeGained > 0
&& permanent.addCounters(CounterType.P1P1.createInstance(lifeGained), source, game);
&& permanent.addCounters(CounterType.P1P1.createInstance(lifeGained), source.getControllerId(), source, game);
}
}

View file

@ -73,7 +73,7 @@ class CrazedFirecatEffect extends OneShotEffect {
break;
}
}
sourceObject.addCounters(CounterType.P1P1.createInstance(flipsWon), source, game);
sourceObject.addCounters(CounterType.P1P1.createInstance(flipsWon), source.getControllerId(), source, game);
return true;
}
return false;

View file

@ -82,7 +82,7 @@ class CrovaxTheCursedEffect extends OneShotEffect {
if (creatures > 0 && controller.chooseUse(outcome, "Sacrifice a creature?", source, game)) {
if (new SacrificeControllerEffect(StaticFilters.FILTER_PERMANENT_CREATURES, 1, "").apply(game, source)) {
if (sourceObject != null) {
sourceObject.addCounters(CounterType.P1P1.createInstance(), source, game);
sourceObject.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
game.informPlayers(controller.getLogName() + " puts a +1/+1 counter on " + sourceObject.getName());
}
}

View file

@ -65,7 +65,7 @@ class CryptbornHorrorEffect extends OneShotEffect {
if (permanent != null) {
int oll = OpponentsLostLifeCount.instance.calculate(game, source, this);
if (oll > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(oll), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(oll), source.getControllerId(), source, game);
}
return true;
}

View file

@ -97,6 +97,6 @@ class CrystallineGiantEffect extends OneShotEffect {
}
return permanent.addCounters(counterTypes.get(
RandomUtil.nextInt(counterTypes.size())
).createInstance(), source, game);
).createInstance(), source.getControllerId(), source, game);
}
}

View file

@ -89,7 +89,7 @@ class CytoplastRootKinEffect extends OneShotEffect {
&& !sourcePermanent.getId().equals(targetPermanent.getId())
&& targetPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
targetPermanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
sourcePermanent.addCounters(CounterType.P1P1.createInstance(), source, game);
sourcePermanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
return true;
}
return false;

View file

@ -90,7 +90,7 @@ class MoveCounterFromTargetToTargetEffect extends OneShotEffect {
Permanent toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (toPermanent != null) {
fromPermanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
toPermanent.addCounters(CounterType.P1P1.createInstance(), source, game);
toPermanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
game.informPlayers(sourceObject.getLogName() + ": Moved a +1/+1 counter from " + fromPermanent.getLogName() +" to " + toPermanent.getLogName());
}
}

View file

@ -76,7 +76,7 @@ class DaredevilDragsterEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && permanent != null) {
permanent.addCounters(CounterType.VELOCITY.createInstance(), source, game);
permanent.addCounters(CounterType.VELOCITY.createInstance(), source.getControllerId(), source, game);
if (permanent.getCounters(game).getCount(CounterType.VELOCITY) >= 2) {
permanent.sacrifice(source, game);
controller.drawCards(2, source, game);

View file

@ -98,7 +98,7 @@ class DarigaazReincarnatedDiesEffect extends ReplacementEffectImpl {
return false;
}
return controller.moveCardToExileWithInfo(permanent, null, null, source, game, Zone.BATTLEFIELD, true)
&& permCard.addCounters(CounterType.EGG.createInstance(3), source, game);
&& permCard.addCounters(CounterType.EGG.createInstance(3), source.getControllerId(), source, game);
}
return false;
}

View file

@ -201,7 +201,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(), source, game);
creature.addCounters(CounterType.LOYALTY.createInstance(), source.getControllerId(), source, game);
}
return false;
}

View file

@ -14,7 +14,6 @@ import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
/**
@ -74,7 +73,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(), source, game, event.getAppliedEffects());
target.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
}
return false;
}

View file

@ -73,7 +73,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, source, game);
permanent.addCounters(newCounter, source.getControllerId(), source, game);
didOne = true;
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
@ -22,8 +20,9 @@ import mage.game.events.GameEvent;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class DefiantGreatmaw extends CardImpl {
@ -44,7 +43,7 @@ public final class DefiantGreatmaw extends CardImpl {
this.addAbility(new DefiantGreatmawTriggeredAbility());
}
public DefiantGreatmaw(final DefiantGreatmaw card) {
private DefiantGreatmaw(final DefiantGreatmaw card) {
super(card);
}
@ -68,7 +67,7 @@ class DefiantGreatmawTriggeredAbility extends TriggeredAbilityImpl {
this.addTarget(new TargetCreaturePermanent(filter));
}
DefiantGreatmawTriggeredAbility(final DefiantGreatmawTriggeredAbility ability) {
private DefiantGreatmawTriggeredAbility(final DefiantGreatmawTriggeredAbility ability) {
super(ability);
}
@ -79,12 +78,9 @@ class DefiantGreatmawTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
boolean weAreDoingIt = isControlledBy(game.getControllerId(event.getSourceId()));
boolean isM1M1Counters = event.getData().equals(CounterType.M1M1.getName());
if (weAreDoingIt && isM1M1Counters && event.getTargetId().equals(this.getSourceId())) {
return true;
}
return false;
return event.getData().equals(CounterType.M1M1.getName())
&& isControlledBy(event.getPlayerId())
&& event.getTargetId().equals(getSourceId());
}
@Override
@ -94,6 +90,7 @@ class DefiantGreatmawTriggeredAbility extends TriggeredAbilityImpl {
@Override
public String getRule() {
return "Whenever you put one or more -1/-1 counters on {this}, remove a -1/-1 counter from another target creature you control.";
return "Whenever you put one or more -1/-1 counters on {this}, " +
"remove a -1/-1 counter from another target creature you control.";
}
}

View file

@ -60,7 +60,7 @@ class DefyDeathEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null && permanent.hasSubtype(SubType.ANGEL, game)) {
permanent.addCounters(CounterType.P1P1.createInstance(2), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(2), source.getControllerId(), source, game);
return true;
}
return false;

View file

@ -72,7 +72,7 @@ class DelayEffect extends OneShotEffect {
boolean hasSuspend = card.getAbilities(game).containsClass(SuspendAbility.class);
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
if (controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getLogName(), source, game, Zone.HAND, true)) {
card.addCounters(CounterType.TIME.createInstance(3), source, game);
card.addCounters(CounterType.TIME.createInstance(3), source.getControllerId(), source, game);
if (!hasSuspend) {
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
}

View file

@ -86,7 +86,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(), source, game);
perm.addCounters(CounterType.CUBE.createInstance(), source.getControllerId(), source, game);
return true;
}
}

View file

@ -86,7 +86,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(), source, game);
sourcePermanent.addCounters(CounterType.DESPAIR.createInstance(), source.getControllerId(), source, game);
}
if (sourcePermanent == null) {
sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);

View file

@ -82,7 +82,7 @@ class DesecrationDemonEffect extends OneShotEffect {
permanent.sacrifice(source, game);
game.informPlayers(opponent.getLogName() + " sacrifices " + permanent.getLogName() + " to tap " + descrationDemon.getLogName() + ". A +1/+1 counter was put on it");
descrationDemon.tap(source, game);
descrationDemon.addCounters(CounterType.P1P1.createInstance(), source, game);
descrationDemon.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
}
}

View file

@ -83,7 +83,7 @@ class DiregrafColossusEffect extends OneShotEffect {
int amount = 0;
amount += player.getGraveyard().count(filter, game);
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game);
}
return true;
}

View file

@ -82,7 +82,7 @@ class DismantleEffect extends OneShotEffect {
counter = CounterType.CHARGE.createInstance(counterCount);
}
if (artifact != null) {
artifact.addCounters(counter, source, game);
artifact.addCounters(counter, source.getControllerId(), source, game);
}
}
}

View file

@ -175,7 +175,7 @@ class DranaTheLastBloodchiefCounterEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (creature != null && mor.refersTo(creature, game)) {
creature.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects());
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
discard();
}
return false;

View file

@ -81,7 +81,7 @@ class DraugrNecromancerReplacementEffect extends ReplacementEffectImpl {
}
controller.moveCards(permanent, Zone.EXILED, source, game);
Card card = game.getCard(permanent.getId());
card.addCounters(CounterType.ICE.createInstance(), source, game);
card.addCounters(CounterType.ICE.createInstance(), source.getControllerId(), source, game);
return true;
}

View file

@ -114,7 +114,7 @@ public final class DustOfMoments extends CardImpl {
final Counter modifiedCounter = new Counter(counterName, countersToRemove);
card.removeCounters(modifiedCounter, source, game);
} else {
card.addCounters(counter, source, game);
card.addCounters(counter, source.getControllerId(), source, game);
}
if (!game.isSimulation()) {
game.informPlayers(sourceObject.getName() + ": " +
@ -139,7 +139,7 @@ public final class DustOfMoments extends CardImpl {
final Counter modifiedCounter = new Counter(counterName, countersToRemove);
card.removeCounters(modifiedCounter, source, game);
} else {
card.addCounters(counter, source, game);
card.addCounters(counter, source.getControllerId(), source, game);
}
if (!game.isSimulation()) {
game.informPlayers(sourceObject.getName() + ": " +

View file

@ -85,7 +85,7 @@ class EbonPraetorEffect extends OneShotEffect {
Permanent sacrificedCreature = ((SacrificeTargetCost) cost).getPermanents().get(0);
Permanent sourceCreature = game.getPermanent(source.getSourceId());
if (sacrificedCreature.hasSubtype(SubType.THRULL, game) && sourceCreature != null) {
sourceCreature.addCounters(CounterType.P1P0.createInstance(), source, game);
sourceCreature.addCounters(CounterType.P1P0.createInstance(), source.getControllerId(), source, game);
return true;
}
}

View file

@ -70,9 +70,9 @@ class ElderCatharAddCountersTargetEffect extends OneShotEffect {
if (permanent != null) {
if (counter != null) {
if (permanent.hasSubtype(SubType.HUMAN, game)) {
permanent.addCounters(counter2.copy(), source, game);
permanent.addCounters(counter2.copy(), source.getControllerId(), source, game);
} else {
permanent.addCounters(counter.copy(), source, game);
permanent.addCounters(counter.copy(), source.getControllerId(), source, game);
}
return true;
}

View file

@ -147,7 +147,7 @@ class ElspethConquersDeathReturnEffect extends OneShotEffect {
outcome, "Choose a type of counter to add",
null, "+1/+1", "Loyalty", source, game
) ? CounterType.P1P1.createInstance() : CounterType.LOYALTY.createInstance();
permanent.addCounters(counter, source, game);
permanent.addCounters(counter, source.getControllerId(), source, game);
return true;
}

View file

@ -92,6 +92,6 @@ class EmielTheBlessedEffect extends OneShotEffect {
return false;
}
int counters = permanent.hasSubtype(SubType.UNICORN, game) ? 2 : 1;
return permanent.addCounters(CounterType.P1P1.createInstance(counters), source, game);
return permanent.addCounters(CounterType.P1P1.createInstance(counters), source.getControllerId(), source, game);
}
}

View file

@ -94,7 +94,7 @@ class EmpoweredAutogeneratorManaEffect extends ManaEffect {
return mana;
}
sourcePermanent.addCounters(CounterType.CHARGE.createInstance(), source, game);
sourcePermanent.addCounters(CounterType.CHARGE.createInstance(), source.getControllerId(), source, game);
int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE);
if (counters == 0) {
return mana;

View file

@ -76,7 +76,7 @@ class EntrailsFeasterEffect extends OneShotEffect {
if (cardChosen != null) {
controller.moveCardsToExile(cardChosen, source, game, true, null, "");
if (sourceObject != null) {
sourceObject.addCounters(CounterType.P1P1.createInstance(), source, game);
sourceObject.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
game.informPlayers(controller.getLogName() + " puts a +1/+1 counter on " + sourceObject.getLogName());
}
}

View file

@ -83,7 +83,7 @@ class EpochrasiteEffect extends OneShotEffect {
if (game.getState().getZone(card.getId()) == Zone.GRAVEYARD) {
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source, game, Zone.GRAVEYARD, true);
card.addCounters(CounterType.TIME.createInstance(3), source, game);
card.addCounters(CounterType.TIME.createInstance(3), source.getControllerId(), source, game);
game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
}
return true;

View file

@ -60,7 +60,7 @@ class EternityVesselEffect extends OneShotEffect {
if (vessel != null && controller != null) {
int amount = controller.getLife();
if (amount > 0) {
vessel.addCounters(CounterType.CHARGE.createInstance(amount), source, game);
vessel.addCounters(CounterType.CHARGE.createInstance(amount), source.getControllerId(), source, game);
}
return true;

View file

@ -140,7 +140,7 @@ class EtrataTheSilencerEffect extends OneShotEffect {
controller.moveCards(creature, Zone.EXILED, source, game);
Card card = game.getCard(source.getFirstTarget());
if (card != null) {
card.addCounters(CounterType.HIT.createInstance(), source, game);
card.addCounters(CounterType.HIT.createInstance(), source.getControllerId(), source, game);
}
int cardsFound = 0;
cardsFound = game.getExile().getAllCards(game).stream().filter((exiledCard) -> (exiledCard.getCounters(game).getCount(CounterType.HIT) >= 1

View file

@ -17,7 +17,6 @@ import mage.counters.Counter;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
/**
@ -79,7 +78,7 @@ class DamageDealtAsIfSourceHadWitherEffect extends ReplacementEffectImpl {
Counter counter = CounterType.M1M1.createInstance(damageAmount);
Permanent creatureDamaged = game.getPermanent(event.getTargetId());
if (creatureDamaged != null) {
creatureDamaged.addCounters(counter, source, game);
creatureDamaged.addCounters(counter, source.getControllerId(), source, game);
}
}
return true;

View file

@ -69,7 +69,7 @@ class EvolutionaryEscalationEffect extends OneShotEffect {
for (Target target: source.getTargets()) {
Permanent targetPermanent = game.getPermanent(target.getFirstTarget());
if (targetPermanent != null) {
targetPermanent.addCounters(counter.copy(), source, game);
targetPermanent.addCounters(counter.copy(), source.getControllerId(), source, game);
addedCounters = true;
}
}

View file

@ -22,9 +22,7 @@ import mage.players.PlayerList;
import mage.target.Target;
import mage.target.common.TargetNonlandPermanent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
* @author LevelX2
@ -78,7 +76,7 @@ class EyeOfDoomEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = new ArrayList<>();
Map<UUID,Permanent>permanents=new HashMap<>();
Target target = new TargetNonlandPermanent();
target.setNotTarget(true);
PlayerList playerList = game.getPlayerList().copy();
@ -89,15 +87,15 @@ class EyeOfDoomEffect extends OneShotEffect {
if (player != null && player.chooseTarget(outcome, target, source, game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanents.add(permanent);
permanents.put(player.getId(),permanent);
game.informPlayers(player.getLogName() + " chooses " + permanent.getName());
}
}
player = playerList.getNext(game, false);
} while (player != null && !player.getId().equals(game.getActivePlayerId()));
for (Permanent permanent : permanents) {
permanent.addCounters(CounterType.DOOM.createInstance(), source, game);
for (Map.Entry<UUID,Permanent> entry : permanents.entrySet()) {
entry.getValue().addCounters(CounterType.DOOM.createInstance(), entry.getKey(), source, game);
}
return true;

View file

@ -87,7 +87,7 @@ class EzuriClawOfProgressEffect extends OneShotEffect {
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) {
int amount = controller.getCounters().getCount(CounterType.EXPERIENCE);
target.addCounters(CounterType.P1P1.createInstance(amount), source, game);
target.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game);
}
return true;
}

View file

@ -78,7 +78,7 @@ class FalkenrathAristocratEffect extends OneShotEffect {
Permanent sacrificedCreature = ((SacrificeTargetCost) cost).getPermanents().get(0);
Permanent sourceCreature = game.getPermanent(source.getSourceId());
if (sacrificedCreature.hasSubtype(SubType.HUMAN, game) && sourceCreature != null) {
sourceCreature.addCounters(CounterType.P1P1.createInstance(), source, game);
sourceCreature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
break;
}
}

View file

@ -74,7 +74,7 @@ class FalkenrathTorturerEffect extends OneShotEffect {
Permanent sacrificedCreature = ((SacrificeTargetCost) cost).getPermanents().get(0);
Permanent sourceCreature = game.getPermanent(source.getSourceId());
if (sacrificedCreature.hasSubtype(SubType.HUMAN, game) && sourceCreature != null) {
sourceCreature.addCounters(CounterType.P1P1.createInstance(), source, game);
sourceCreature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
return true;
}
}

View file

@ -77,7 +77,7 @@ class FateTransferEffect extends OneShotEffect {
Permanent copyCreature = creatureToMoveCountersFrom.copy();
for (Counter counter : copyCreature.getCounters(game).values()) {
creatureToMoveCountersFrom.removeCounters(counter, source, game);
creatureToMoveCountersTo.addCounters(counter, source, game);
creatureToMoveCountersTo.addCounters(counter, source.getControllerId(), source, game);
}
return true;
}

View file

@ -61,7 +61,7 @@ class FearsomeAwakeningEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null && permanent.hasSubtype(SubType.DRAGON, game)) {
permanent.addCounters(CounterType.P1P1.createInstance(2), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(2), source.getControllerId(), source, game);
return true;
}
return false;

View file

@ -72,7 +72,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), source, game);
targetCreature.addCounters(CounterType.P1P1.createInstance(power), source.getControllerId(), source, game);
}
}
return true;

View file

@ -131,7 +131,7 @@ public final class ForgottenAncient extends CardImpl {
//Move all the counters for each chosen creature
for (CounterMovement cm : counterMovements) {
sourcePermanent.removeCounters(CounterType.P1P1.createInstance(cm.counters), source, game);
game.getPermanent(cm.target).addCounters(CounterType.P1P1.createInstance(cm.counters), source, game);
game.getPermanent(cm.target).addCounters(CounterType.P1P1.createInstance(cm.counters), source.getControllerId(), source, game);
}
return true;
}

View file

@ -77,7 +77,7 @@ class FulfillContractEffect extends OneShotEffect {
if (controller != null) {
if (permanentToDestroy != null && permanentToDestroy.destroy(source, game, false)) {
if (permanentToPutCounter != null) {
permanentToPutCounter.addCounters(CounterType.P1P1.createInstance(), source, game);
permanentToPutCounter.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
}
return true;

View file

@ -1,21 +1,21 @@
package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.keyword.SupportAbility;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class GenerousPatron extends CardImpl {
@ -47,11 +47,11 @@ public final class GenerousPatron extends CardImpl {
class GenerousPatronTriggeredAbility extends TriggeredAbilityImpl {
public GenerousPatronTriggeredAbility() {
GenerousPatronTriggeredAbility() {
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), false);
}
public GenerousPatronTriggeredAbility(GenerousPatronTriggeredAbility ability) {
private GenerousPatronTriggeredAbility(GenerousPatronTriggeredAbility ability) {
super(ability);
}
@ -62,7 +62,7 @@ class GenerousPatronTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!isControlledBy(game.getControllerId(event.getSourceId()))) {
if (!isControlledBy(event.getPlayerId())) {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());

View file

@ -139,7 +139,7 @@ class GideonTheOathswornEffect extends OneShotEffect {
for (MageObjectReference mor : attackers) {
Permanent permanent = mor.getPermanent(game);
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
}
return true;

View file

@ -72,7 +72,7 @@ class GilderBairnEffect extends OneShotEffect {
if (target != null) {
for (Counter counter : target.getCounters(game).values()) {
Counter newCounter = new Counter(counter.getName(), counter.getCount());
target.addCounters(newCounter, source, game);
target.addCounters(newCounter, source.getControllerId(), source, game);
}
}
return false;

View file

@ -75,7 +75,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(), source, game);
creature.addCounters(CounterType.M1M1.createInstance(), source.getControllerId(), source, game);
}
}
return true;

View file

@ -127,7 +127,7 @@ class GlyphOfDelusionEffect extends OneShotEffect {
if (source.getTargets().get(1) != null) {
Permanent targetPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (targetPermanent != null) {
targetPermanent.addCounters(CounterType.GLYPH.createInstance(targetPermanent.getPower().getValue()), source, game);
targetPermanent.addCounters(CounterType.GLYPH.createInstance(targetPermanent.getPower().getValue()), source.getControllerId(), source, game);
SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousRuleModifyingEffect(new DontUntapInControllersUntapStepSourceEffect(),
new SourceHasCounterCondition(CounterType.GLYPH)).setText("This creature doesn't untap during your untap step if it has a glyph counter on it"));

View file

@ -73,7 +73,7 @@ class GolgariGraveTrollEffect extends OneShotEffect {
if (permanent != null && player != null) {
int amount = player.getGraveyard().count(StaticFilters.FILTER_CARD_CREATURE, game);
if (amount > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game);
}
return true;
}

View file

@ -19,7 +19,6 @@ import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -158,7 +157,7 @@ class GraveBetrayalReplacementEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (creature != null) {
creature.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects());
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
ContinuousEffect effect = new BecomesBlackZombieAdditionEffect();
effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game) + 1));
game.addEffect(effect, source);

View file

@ -65,7 +65,7 @@ public final class GreenbeltRampager extends CardImpl {
Permanent sourceObject = source.getSourcePermanentIfItStillExists(game);
if (sourceObject != null) {
controller.moveCards(sourceObject, Zone.HAND, source, game);
controller.addCounters(CounterType.ENERGY.createInstance(), source, game);
controller.addCounters(CounterType.ENERGY.createInstance(), source.getControllerId(), source, game);
}
}
return true;

View file

@ -72,7 +72,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), source, game);
targetCreature.addCounters(CounterType.M1M1.createInstance(countersOnGriefTyrant), source.getControllerId(), source, game);
return true;
}
return false;

View file

@ -100,8 +100,8 @@ class GrimdancerEffect extends OneShotEffect {
counter2 = CounterType.LIFELINK.createInstance();
break;
}
permanent.addCounters(counter1, source, game);
permanent.addCounters(counter2, source, game);
permanent.addCounters(counter1, source.getControllerId(), source, game);
permanent.addCounters(counter2, source.getControllerId(), source, game);
return true;
}
}

View file

@ -74,7 +74,7 @@ class GrumgullyTheGenerousReplacementEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
if (creature != null) {
creature.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects());
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
}
return false;
}

View file

@ -19,7 +19,6 @@ import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.watchers.Watcher;
@ -115,7 +114,7 @@ class GuildmagesForumEntersBattlefieldEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent target = ((EntersTheBattlefieldEvent) event).getTarget();
if (target != null) {
target.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects());
target.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
}
return false;
}

View file

@ -70,7 +70,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(), source, game);
targetCreature.addCounters(CounterType.BRIBERY.createInstance(), source.getControllerId(), source, game);
if (controller != null) {
controller.drawCards(1, source, game);
}

View file

@ -15,7 +15,6 @@ import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
@ -102,7 +101,7 @@ class HamletbackGoliathEffect extends OneShotEffect {
Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
Permanent sourceObject = game.getPermanent(source.getSourceId());
if (creature != null && sourceObject != null) {
sourceObject.addCounters(CounterType.P1P1.createInstance(creature.getPower().getValue()), source, game);
sourceObject.addCounters(CounterType.P1P1.createInstance(creature.getPower().getValue()), source.getControllerId(), source, game);
}
return true;
}

View file

@ -72,7 +72,7 @@ class HammerJammerEntersEffect extends EntersBattlefieldWithXCountersEffect {
if (controller != null && permanent != null) {
int amount = controller.rollDice(source, game, 6);
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game, appliedEffects);
permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game, appliedEffects);
return super.apply(game, source);
}
return false;
@ -145,7 +145,7 @@ class HammerJammerEffect extends OneShotEffect {
if (getValue("rolled") != null) {
int amount = (Integer) getValue("rolled");
permanent.removeCounters(CounterType.P1P1.createInstance(permanent.getCounters(game).getCount(CounterType.P1P1)), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game);
return true;
}
}

View file

@ -76,7 +76,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(), source, game);
equipment.addCounters(CounterType.AIM.createInstance(), source.getControllerId(), source, game);
}
return true;
}

View file

@ -1,12 +1,10 @@
package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.CardImpl;
@ -22,8 +20,9 @@ import mage.game.permanent.Permanent;
import mage.game.permanent.token.DeathtouchSnakeToken;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author Styxo
*/
public final class HapatraVizierOfPoisons extends CardImpl {
@ -43,8 +42,7 @@ public final class HapatraVizierOfPoisons extends CardImpl {
this.addAbility(ability);
// Whenever you put one or more -1/-1 counters on a creature, create a 1/1 green Snake creature token with deathtouch.
this.addAbility(new HapatraVizierOfPoisonsTriggeredAbility(new CreateTokenEffect(new DeathtouchSnakeToken()), false));
this.addAbility(new HapatraVizierOfPoisonsTriggeredAbility());
}
public HapatraVizierOfPoisons(final HapatraVizierOfPoisons card) {
@ -59,11 +57,11 @@ public final class HapatraVizierOfPoisons extends CardImpl {
class HapatraVizierOfPoisonsTriggeredAbility extends TriggeredAbilityImpl {
public HapatraVizierOfPoisonsTriggeredAbility(Effect effect, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
HapatraVizierOfPoisonsTriggeredAbility() {
super(Zone.BATTLEFIELD, new CreateTokenEffect(new DeathtouchSnakeToken()), false);
}
public HapatraVizierOfPoisonsTriggeredAbility(HapatraVizierOfPoisonsTriggeredAbility ability) {
private HapatraVizierOfPoisonsTriggeredAbility(HapatraVizierOfPoisonsTriggeredAbility ability) {
super(ability);
}
@ -74,16 +72,15 @@ class HapatraVizierOfPoisonsTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getData().equals(CounterType.M1M1.getName())
&& controllerId.equals(game.getControllerId(event.getSourceId()))) {
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent == null) {
permanent = game.getPermanentEntering(event.getTargetId());
}
return (permanent != null
&& permanent.isCreature());
if (!event.getData().equals(CounterType.M1M1.getName())
|| !isControlledBy(event.getPlayerId())) {
return false;
}
return false;
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent == null) {
permanent = game.getPermanentEntering(event.getTargetId());
}
return permanent != null && permanent.isCreature();
}

Some files were not shown because too many files have changed in this diff Show more