mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 21:42:07 -08:00
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:
parent
4db79ae3c1
commit
a535cb5adc
320 changed files with 701 additions and 481 deletions
|
|
@ -88,7 +88,7 @@ class EscapesWithEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(counter), source, game, appliedEffects);
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(counter), source.getControllerId(), source, game, appliedEffects);
|
||||
if (this.delayedTriggeredAbility != null) {
|
||||
game.addDelayedTriggeredAbility(this.delayedTriggeredAbility, source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class TurnFaceUpEffect extends OneShotEffect {
|
|||
if (sourcePermanent != null) {
|
||||
if (sourcePermanent.turnFaceUp(source, game, source.getControllerId())) {
|
||||
if (megamorph) {
|
||||
sourcePermanent.addCounters(CounterType.P1P1.createInstance(), source, game);
|
||||
sourcePermanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
|
||||
}
|
||||
game.getState().setValue(source.getSourceId().toString() + "TurnFaceUpX", source.getManaCostsToPay().getX());
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class PayLoyaltyCost extends CostImpl {
|
|||
Permanent planeswalker = game.getPermanent(source.getSourceId());
|
||||
if (planeswalker != null && planeswalker.getCounters(game).getCount(CounterType.LOYALTY) + amount >= 0 && planeswalker.canLoyaltyBeUsed(game)) {
|
||||
if (amount > 0) {
|
||||
planeswalker.addCounters(CounterType.LOYALTY.createInstance(amount), ability, game, false);
|
||||
planeswalker.addCounters(CounterType.LOYALTY.createInstance(amount), source.getControllerId(), ability, game, false);
|
||||
} else if (amount < 0) {
|
||||
planeswalker.removeCounters(CounterType.LOYALTY.getName(), Math.abs(amount), source, game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class PutCountersSourceCost 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) {
|
||||
this.paid = permanent.addCounters(counter, ability, game, false);
|
||||
this.paid = permanent.addCounters(counter, controllerId, ability, game, false);
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,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), source, game);
|
||||
sourceCreature.addCounters(CounterType.P1P1.createInstance(amountCounters), source.getControllerId(), source, game);
|
||||
controller.revealCards(sourceCreature.getIdName(), cards, game);
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class DevourEffect extends ReplacementEffectImpl {
|
|||
} else {
|
||||
amountCounters = devouredCreatures * devourFactor.getFactor();
|
||||
}
|
||||
creature.addCounters(CounterType.P1P1.createInstance(amountCounters), source, game);
|
||||
creature.addCounters(CounterType.P1P1.createInstance(amountCounters), source.getControllerId(), source, game);
|
||||
game.getState().setValue(creature.getId().toString() + "devoured", creaturesDevoured);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class EntersBattlefieldWithXCountersEffect extends OneShotEffect {
|
|||
Counter counterToAdd = counter.copy();
|
||||
counterToAdd.add(amount - counter.getCount());
|
||||
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
|
||||
permanent.addCounters(counterToAdd, source, game, appliedEffects);
|
||||
permanent.addCounters(counterToAdd, source.getControllerId(), source, game, appliedEffects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class AddCounterChoiceSourceEffect extends OneShotEffect {
|
|||
} else {
|
||||
counter = counterType2.createInstance();
|
||||
}
|
||||
return permanent.addCounters(counter, source, game);
|
||||
return permanent.addCounters(counter, source.getControllerId(), source, game);
|
||||
}
|
||||
|
||||
private static final String cap(String string) {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,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(), source, game);
|
||||
permanent.addCounters(counter.copy(), source.getControllerId(), source, game);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts " + counter.getCount() + ' ' + counter.getName().toLowerCase(Locale.ENGLISH)
|
||||
+ " counter on " + permanent.getLogName());
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class AddCountersAttachedEffect extends OneShotEffect {
|
|||
if (countersToAdd > 0) {
|
||||
countersToAdd--;
|
||||
newCounter.add(countersToAdd);
|
||||
attachedTo.addCounters(newCounter, source, game);
|
||||
attachedTo.addCounters(newCounter, source.getControllerId(), source, game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class AddCountersControllerEffect extends OneShotEffect {
|
|||
}
|
||||
Player player = game.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
player.addCounters(counter, source, game);
|
||||
player.addCounters(counter, source.getControllerId(), source, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
|
|||
}
|
||||
newCounter.add(countersToAdd);
|
||||
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
|
||||
card.addCounters(newCounter, source, game, appliedEffects);
|
||||
card.addCounters(newCounter, source.getControllerId(), source, game, appliedEffects);
|
||||
if (informPlayers && !game.isSimulation()) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
|
|
@ -109,7 +109,7 @@ public class AddCountersSourceEffect extends OneShotEffect {
|
|||
newCounter.add(countersToAdd);
|
||||
int before = permanent.getCounters(game).getCount(newCounter.getName());
|
||||
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects");
|
||||
permanent.addCounters(newCounter, source, game, appliedEffects); // if used from a replacement effect, the basic event determines if an effect was already applied to an event
|
||||
permanent.addCounters(newCounter, source.getControllerId(), source, game, appliedEffects); // if used from a replacement effect, the basic event determines if an effect was already applied to an event
|
||||
if (informPlayers && !game.isSimulation()) {
|
||||
int amountAdded = permanent.getCounters(game).getCount(newCounter.getName()) - before;
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
|
|
|
|||
|
|
@ -76,17 +76,17 @@ public class AddCountersTargetEffect extends OneShotEffect {
|
|||
Player player = game.getPlayer(uuid);
|
||||
Card card = game.getCard(targetPointer.getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
permanent.addCounters(newCounter, source, game);
|
||||
permanent.addCounters(newCounter, source.getControllerId(), source, game);
|
||||
affectedTargets++;
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts "
|
||||
+ newCounter.getCount() + ' ' + newCounter.getName().toLowerCase(Locale.ENGLISH) + " counters on " + permanent.getLogName());
|
||||
} else if (player != null) {
|
||||
player.addCounters(newCounter, source, game);
|
||||
player.addCounters(newCounter, source.getControllerId(), source, game);
|
||||
affectedTargets++;
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts "
|
||||
+ newCounter.getCount() + ' ' + newCounter.getName().toLowerCase(Locale.ENGLISH) + " counters on " + player.getLogName());
|
||||
} else if (card != null) {
|
||||
card.addCounters(newCounter, source, game);
|
||||
card.addCounters(newCounter, source.getControllerId(), source, game);
|
||||
affectedTargets++;
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " puts "
|
||||
+ newCounter.getCount() + ' ' + newCounter.getName().toLowerCase(Locale.ENGLISH) + " counters on " + card.getLogName());
|
||||
|
|
|
|||
|
|
@ -44,7 +44,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), source, game);
|
||||
creature.addCounters(CounterType.P1P1.createInstance(amount), source.getControllerId(), source, game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class AddPoisonCounterTargetEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
player.addCounters(CounterType.POISON.createInstance(amount), source, game);
|
||||
player.addCounters(CounterType.POISON.createInstance(amount), source.getControllerId(), source, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class AddRemoveAllTimeSuspentCountersEffect extends OneShotEffect {
|
|||
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(new StringBuilder(sourceObject.getName()).append(": ")
|
||||
|
|
|
|||
|
|
@ -53,7 +53,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)), source, game);
|
||||
permanent.addCounters(counterType.createInstance(multiTarget.getTargetAmount(target)), source.getControllerId(), source, game);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class GetEnergyCountersControllerEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
return controller.addCounters(CounterType.ENERGY.createInstance(value.calculate(game, source, this)), source, game);
|
||||
return controller.addCounters(CounterType.ENERGY.createInstance(value.calculate(game, source, this)), source.getControllerId(), source, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,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), source, game);
|
||||
addTargetCreature.addCounters(counterType.createInstance(amount), source, game);
|
||||
addTargetCreature.addCounters(counterType.createInstance(amount), source.getControllerId(), source, game);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers("Moved " + amount + ' ' + counterType.getName() + " counter" + (amount > 1 ? "s" : "") + " from " + removeTargetCreature.getLogName() + " to " + addTargetCreature.getLogName());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class ProliferateEffect extends OneShotEffect {
|
|||
if (!permanent.getCounters(game).isEmpty()) {
|
||||
for (Counter counter : permanent.getCounters(game).values()) {
|
||||
newCounter = new Counter(counter.getName());
|
||||
permanent.addCounters(newCounter, source, game);
|
||||
permanent.addCounters(newCounter, source.getControllerId(), source, game);
|
||||
}
|
||||
if (newCounter != null) {
|
||||
game.informPlayers(permanent.getName()
|
||||
|
|
@ -74,7 +74,7 @@ public class ProliferateEffect extends OneShotEffect {
|
|||
if (!player.getCounters().isEmpty()) {
|
||||
for (Counter counter : player.getCounters().values()) {
|
||||
newCounter = new Counter(counter.getName());
|
||||
player.addCounters(newCounter, source, game);
|
||||
player.addCounters(newCounter, source.getControllerId(), source, game);
|
||||
}
|
||||
if (newCounter != null) {
|
||||
game.informPlayers(player.getLogName()
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class AdaptEffect extends OneShotEffect {
|
|||
}
|
||||
if (permanent.getCounters(game).getCount(CounterType.P1P1) == 0
|
||||
|| event.getFlag()) {
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(event.getAmount()), source, game);
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(event.getAmount()), source.getControllerId(), source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class AmassEffect extends OneShotEffect {
|
|||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(xValue), source, game);
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(xValue), source.getControllerId(), source, game);
|
||||
this.amassedCreatureId = permanent.getId();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class ExploreSourceEffect extends OneShotEffect {
|
|||
permanentController.moveCards(card, Zone.HAND, source, game);
|
||||
} else {
|
||||
if (game.getState().getZone(permanentId) == Zone.BATTLEFIELD) { // needed in case LKI object is used
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
|
||||
}
|
||||
if (permanentController.chooseUse(Outcome.Neutral, "Put " + card.getLogName() + " in your graveyard?", source, game)) {
|
||||
permanentController.moveCards(card, Zone.GRAVEYARD, source, game);
|
||||
|
|
@ -124,7 +124,7 @@ public class ExploreSourceEffect extends OneShotEffect {
|
|||
&& game.getState().getZone(permanentId) == Zone.BATTLEFIELD) {
|
||||
// If no card is revealed, most likely because that player's library is empty,
|
||||
// the exploring creature receives a +1/+1 counter.
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
|
||||
permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class BloodthirstEffect extends OneShotEffect {
|
|||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
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 true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,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(), source, game);
|
||||
sourceCreature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EVOLVED_CREATURE, sourceCreature.getId(), source, source.getControllerId()));
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,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), source, game);
|
||||
((Card) sourceObject).addCounters(CounterType.P1P1.createInstance(value), source.getControllerId(), source, game);
|
||||
}
|
||||
else {
|
||||
new ServoToken().putOntoBattlefield(value, game, source, controller.getId());
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class GraftDistributeCounterEffect extends OneShotEffect {
|
|||
Permanent targetCreature = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
if (targetCreature != null) {
|
||||
sourcePermanent.removeCounters(CounterType.P1P1.getName(), 1, source, game);
|
||||
targetCreature.addCounters(CounterType.P1P1.createInstance(1), source, game);
|
||||
targetCreature.addCounters(CounterType.P1P1.createInstance(1), source.getControllerId(), source, game);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers("Moved one +1/+1 counter from " + sourcePermanent.getLogName() + " to " + targetCreature.getLogName());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ class ModularDistributeCounterEffect extends OneShotEffect {
|
|||
int numberOfCounters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
|
||||
if (numberOfCounters > 0) {
|
||||
List<UUID> appliedEffects = (ArrayList<UUID>) this.getValue("appliedEffects"); // the basic event is the EntersBattlefieldEvent, so use already applied replacement effects from that event
|
||||
targetArtifact.addCounters(CounterType.P1P1.createInstance(numberOfCounters), source, game, appliedEffects);
|
||||
targetArtifact.addCounters(CounterType.P1P1.createInstance(numberOfCounters), source.getControllerId(), source, game, appliedEffects);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,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.players.Player;
|
||||
|
||||
|
|
@ -73,7 +72,7 @@ class RiotReplacementEffect extends ReplacementEffectImpl {
|
|||
if (creature != null && controller != null) {
|
||||
if (controller.chooseUse(outcome, "Have " + creature.getLogName() + " enter the battlefield with a +1/+1 counter on it or with haste?", null, "+1/+1 counter", "Haste", source, game)) {
|
||||
game.informPlayers(controller.getLogName() + " choose to put a +1/+1 counter on " + creature.getName());
|
||||
creature.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects());
|
||||
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
|
||||
} else {
|
||||
game.addEffect(new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.Custom), source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class SunburstEffect extends OneShotEffect {
|
|||
counter = CounterType.CHARGE.createInstance(countersAmount);
|
||||
}
|
||||
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(counter, source, game, appliedEffects);
|
||||
permanent.addCounters(counter, source.getControllerId(), source, game, appliedEffects);
|
||||
if (!game.isSimulation()) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ class SuspendExileEffect extends OneShotEffect {
|
|||
if (suspend == Integer.MAX_VALUE) {
|
||||
suspend = source.getManaCostsToPay().getX();
|
||||
}
|
||||
card.addCounters(CounterType.TIME.createInstance(suspend), source, game);
|
||||
card.addCounters(CounterType.TIME.createInstance(suspend), source.getControllerId(), source, game);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(controller.getLogName()
|
||||
+ " suspends (" + suspend + ") " + card.getLogName());
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class TributeEffect extends OneShotEffect {
|
|||
game.informPlayers(opponent.getLogName() + " pays tribute to " + sourcePermanent.getLogName());
|
||||
}
|
||||
game.getState().setValue("tributeValue" + source.getSourceId(), "yes");
|
||||
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(tributeValue), true).apply(game, source);
|
||||
return sourcePermanent.addCounters(CounterType.P1P1.createInstance(tributeValue),opponent.getId(),source,game);
|
||||
} else {
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(opponent.getLogName() + " does not pay tribute to " + sourcePermanent.getLogName());
|
||||
|
|
|
|||
|
|
@ -12,7 +12,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.players.Player;
|
||||
|
||||
|
|
@ -78,7 +77,7 @@ class UnleashReplacementEffect extends ReplacementEffectImpl {
|
|||
if (!game.isSimulation()) {
|
||||
game.informPlayers(controller.getLogName() + " unleashes " + creature.getName());
|
||||
}
|
||||
creature.addCounters(CounterType.P1P1.createInstance(), source, game, event.getAppliedEffects());
|
||||
creature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game, event.getAppliedEffects());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -142,13 +142,13 @@ public interface Card extends MageObject {
|
|||
|
||||
void looseAllAbilities(Game game);
|
||||
|
||||
boolean addCounters(Counter counter, Ability source, Game game);
|
||||
boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game);
|
||||
|
||||
boolean addCounters(Counter counter, Ability source, Game game, boolean isEffect);
|
||||
boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, boolean isEffect);
|
||||
|
||||
boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects);
|
||||
boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects);
|
||||
|
||||
boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect);
|
||||
boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect);
|
||||
|
||||
void removeCounters(String name, int amount, Ability source, Game game);
|
||||
|
||||
|
|
|
|||
|
|
@ -602,7 +602,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, source, game);
|
||||
permanent.addCounters(counter, source.getControllerId(), source, game);
|
||||
}
|
||||
game.setEnterWithCounters(permanent.getId(), null);
|
||||
}
|
||||
|
|
@ -715,24 +715,24 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game) {
|
||||
return addCounters(counter, source, game, null, true);
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game) {
|
||||
return addCounters(counter, playerAddingCounters, source, game, null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game, boolean isEffect) {
|
||||
return addCounters(counter, source, game, null, isEffect);
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, boolean isEffect) {
|
||||
return addCounters(counter, playerAddingCounters, source, game, null, isEffect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects) {
|
||||
return addCounters(counter, source, game, appliedEffects, true);
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects) {
|
||||
return addCounters(counter, playerAddingCounters, source, game, appliedEffects, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect) {
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect) {
|
||||
boolean returnCode = true;
|
||||
GameEvent addingAllEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, source, getControllerOrOwner(), counter.getName(), counter.getCount());
|
||||
GameEvent addingAllEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, source, playerAddingCounters, counter.getName(), counter.getCount());
|
||||
addingAllEvent.setAppliedEffects(appliedEffects);
|
||||
addingAllEvent.setFlag(isEffect);
|
||||
if (!game.replaceEvent(addingAllEvent)) {
|
||||
|
|
@ -742,12 +742,12 @@ 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 addingOneEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, source, getControllerOrOwner(), counter.getName(), 1);
|
||||
GameEvent addingOneEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, objectId, source, playerAddingCounters, counter.getName(), 1);
|
||||
addingOneEvent.setAppliedEffects(appliedEffects);
|
||||
addingOneEvent.setFlag(isEffectFlag);
|
||||
if (!game.replaceEvent(addingOneEvent)) {
|
||||
getCounters(game).addCounter(eventCounter);
|
||||
GameEvent addedOneEvent = GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED, objectId, source, getControllerOrOwner(), counter.getName(), 1);
|
||||
GameEvent addedOneEvent = GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED, objectId, source, playerAddingCounters, counter.getName(), 1);
|
||||
addedOneEvent.setFlag(addingOneEvent.getFlag());
|
||||
game.fireEvent(addedOneEvent);
|
||||
} else {
|
||||
|
|
@ -756,7 +756,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
}
|
||||
}
|
||||
if (finalAmount > 0) {
|
||||
GameEvent addedAllEvent = GameEvent.getEvent(GameEvent.EventType.COUNTERS_ADDED, objectId, source, getControllerOrOwner(), counter.getName(), amount);
|
||||
GameEvent addedAllEvent = GameEvent.getEvent(GameEvent.EventType.COUNTERS_ADDED, objectId, source, playerAddingCounters, counter.getName(), amount);
|
||||
addedAllEvent.setFlag(isEffectFlag);
|
||||
game.fireEvent(addedAllEvent);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package mage.cards;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Zone;
|
||||
|
|
@ -10,6 +8,9 @@ import mage.game.Game;
|
|||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author emerald000
|
||||
*/
|
||||
|
|
@ -103,17 +104,17 @@ public abstract class MeldCard extends CardImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects) {
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects) {
|
||||
if (this.isMelded(game)) {
|
||||
return super.addCounters(counter, source, game, appliedEffects);
|
||||
return super.addCounters(counter, playerAddingCounters, source, game, appliedEffects);
|
||||
} else {
|
||||
// can this really happen?
|
||||
boolean returnState = true;
|
||||
if (hasTopHalf(game)) {
|
||||
returnState |= topHalfCard.addCounters(counter, source, game, appliedEffects);
|
||||
returnState |= topHalfCard.addCounters(counter, playerAddingCounters, source, game, appliedEffects);
|
||||
}
|
||||
if (hasBottomHalf(game)) {
|
||||
returnState |= bottomHalfCard.addCounters(counter, source, game, appliedEffects);
|
||||
returnState |= bottomHalfCard.addCounters(counter, playerAddingCounters, source, game, appliedEffects);
|
||||
}
|
||||
return returnState;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -269,6 +269,7 @@ public enum SubType {
|
|||
PEST("Pest", SubTypeSet.CreatureType),
|
||||
PHELDDAGRIF("Phelddagrif", SubTypeSet.CreatureType),
|
||||
PHOENIX("Phoenix", SubTypeSet.CreatureType),
|
||||
PHYREXIAN("Phyrexian", SubTypeSet.CreatureType),
|
||||
PILOT("Pilot", SubTypeSet.CreatureType),
|
||||
PINCHER("Pincher", SubTypeSet.CreatureType),
|
||||
PIRATE("Pirate", SubTypeSet.CreatureType),
|
||||
|
|
|
|||
|
|
@ -960,7 +960,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
} else if (mdi.sourceObject instanceof Permanent) {
|
||||
source = ((Permanent) mdi.sourceObject).getSpellAbility();
|
||||
}
|
||||
addCounters(mdi.counter, source, game);
|
||||
addCounters(mdi.counter, game.getControllerId(mdi.sourceObject.getId()), source, game);
|
||||
}
|
||||
markedDamage.clear();
|
||||
return 0;
|
||||
|
|
@ -1023,7 +1023,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
damageSourceAbility = ((Permanent) attacker).getSpellAbility();
|
||||
}
|
||||
// deal damage immediately
|
||||
addCounters(CounterType.M1M1.createInstance(actualDamage), damageSourceAbility, game);
|
||||
addCounters(CounterType.M1M1.createInstance(actualDamage), game.getControllerId(attackerId), damageSourceAbility, game);
|
||||
}
|
||||
} else {
|
||||
this.damage = CardUtil.addWithOverflowCheck(this.damage, actualDamage);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package mage.game.stack;
|
||||
|
||||
import java.util.*;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
|
|
@ -36,6 +35,8 @@ import mage.util.CardUtil;
|
|||
import mage.util.GameLog;
|
||||
import mage.util.SubTypes;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
|
@ -593,7 +594,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
if (mageObjectAttribute != null) {
|
||||
return mageObjectAttribute.getColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
|
|
@ -959,23 +960,23 @@ public class Spell extends StackObjImpl implements Card {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game) {
|
||||
return card.addCounters(counter, source, game);
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game) {
|
||||
return card.addCounters(counter, playerAddingCounters, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game, boolean isEffect) {
|
||||
return card.addCounters(counter, source, game, isEffect);
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, boolean isEffect) {
|
||||
return card.addCounters(counter, playerAddingCounters, source, game, isEffect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects) {
|
||||
return card.addCounters(counter, source, game, appliedEffects);
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects) {
|
||||
return card.addCounters(counter, playerAddingCounters, source, game, appliedEffects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect) {
|
||||
return card.addCounters(counter, source, game, appliedEffects, isEffect);
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect) {
|
||||
return card.addCounters(counter, playerAddingCounters, source, game, appliedEffects, isEffect);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.game.turn;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.SubType;
|
||||
import mage.counters.CounterType;
|
||||
|
|
@ -10,8 +8,9 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class PreCombatMainStep extends Step {
|
||||
|
|
@ -29,7 +28,7 @@ public class PreCombatMainStep extends Step {
|
|||
this.postStepEvent = EventType.PRECOMBAT_MAIN_STEP_POST;
|
||||
}
|
||||
|
||||
public PreCombatMainStep(final PreCombatMainStep step) {
|
||||
private PreCombatMainStep(final PreCombatMainStep step) {
|
||||
super(step);
|
||||
}
|
||||
|
||||
|
|
@ -38,7 +37,7 @@ public class PreCombatMainStep extends Step {
|
|||
super.beginStep(game, activePlayerId);
|
||||
for (Permanent saga : game.getBattlefield().getAllActivePermanents(filter, activePlayerId, game)) {
|
||||
if (saga != null) {
|
||||
saga.addCounters(CounterType.LORE.createInstance(), null, game);
|
||||
saga.addCounters(CounterType.LORE.createInstance(), activePlayerId, null, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -709,7 +709,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
LinkedHashMap<UUID, ActivatedAbility> getPlayableActivatedAbilities(MageObject object, Zone zone, Game game);
|
||||
|
||||
boolean addCounters(Counter counter, Ability source, Game game);
|
||||
boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game);
|
||||
|
||||
void removeCounters(String name, int amount, Ability source, Game game);
|
||||
|
||||
|
|
|
|||
|
|
@ -2112,7 +2112,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
sourceControllerId = ((Permanent) attacker).getControllerId();
|
||||
}
|
||||
if (sourceAbilities != null && sourceAbilities.containsKey(InfectAbility.getInstance().getId())) {
|
||||
addCounters(CounterType.POISON.createInstance(actualDamage), source, game);
|
||||
addCounters(CounterType.POISON.createInstance(actualDamage), sourceControllerId, source, game);
|
||||
} else {
|
||||
GameEvent damageToLifeLossEvent = new GameEvent(GameEvent.EventType.DAMAGE_CAUSES_LIFE_LOSS,
|
||||
playerId, source, playerId, actualDamage, combatDamage);
|
||||
|
|
@ -2151,10 +2151,12 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, Ability source, Game game) {
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game) {
|
||||
boolean returnCode = true;
|
||||
GameEvent addingAllEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, playerId, source,
|
||||
playerId, counter.getName(), counter.getCount());
|
||||
GameEvent addingAllEvent = GameEvent.getEvent(
|
||||
GameEvent.EventType.ADD_COUNTERS, playerId, source,
|
||||
playerAddingCounters, counter.getName(), counter.getCount()
|
||||
);
|
||||
if (!game.replaceEvent(addingAllEvent)) {
|
||||
int amount = addingAllEvent.getAmount();
|
||||
int finalAmount = amount;
|
||||
|
|
@ -2162,13 +2164,17 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
for (int i = 0; i < amount; i++) {
|
||||
Counter eventCounter = counter.copy();
|
||||
eventCounter.remove(eventCounter.getCount() - 1);
|
||||
GameEvent addingOneEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTER, playerId, source,
|
||||
playerId, counter.getName(), 1);
|
||||
GameEvent addingOneEvent = GameEvent.getEvent(
|
||||
GameEvent.EventType.ADD_COUNTER, playerId, source,
|
||||
playerAddingCounters, counter.getName(), 1
|
||||
);
|
||||
addingOneEvent.setFlag(isEffectFlag);
|
||||
if (!game.replaceEvent(addingOneEvent)) {
|
||||
getCounters().addCounter(eventCounter);
|
||||
GameEvent addedOneEvent = GameEvent.getEvent(GameEvent.EventType.COUNTER_ADDED, playerId, source,
|
||||
playerId, counter.getName(), 1);
|
||||
GameEvent addedOneEvent = GameEvent.getEvent(
|
||||
GameEvent.EventType.COUNTER_ADDED, playerId, source,
|
||||
playerAddingCounters, counter.getName(), 1
|
||||
);
|
||||
addedOneEvent.setFlag(addingOneEvent.getFlag());
|
||||
game.fireEvent(addedOneEvent);
|
||||
} else {
|
||||
|
|
@ -2177,8 +2183,10 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
}
|
||||
if (finalAmount > 0) {
|
||||
GameEvent addedAllEvent = GameEvent.getEvent(GameEvent.EventType.COUNTERS_ADDED, playerId, source,
|
||||
playerId, counter.getName(), amount);
|
||||
GameEvent addedAllEvent = GameEvent.getEvent(
|
||||
GameEvent.EventType.COUNTERS_ADDED, playerId, source,
|
||||
playerAddingCounters, counter.getName(), amount
|
||||
);
|
||||
addedAllEvent.setFlag(addingAllEvent.getFlag());
|
||||
game.fireEvent(addedAllEvent);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue