- non-card refactoring related to #8375

This commit is contained in:
Jeff Wadsworth 2021-10-18 14:02:57 -05:00
parent bcac7bd47c
commit 328b1f1eec
31 changed files with 32 additions and 34 deletions

View file

@ -102,7 +102,7 @@ class KinshipBaseEffect extends OneShotEffect {
if (controller.chooseUse(outcome, new StringBuilder("Kinship - Reveal ").append(card.getLogName()).append('?').toString(), source, game)) { if (controller.chooseUse(outcome, new StringBuilder("Kinship - Reveal ").append(card.getLogName()).append('?').toString(), source, game)) {
controller.revealCards(sourcePermanent.getName(), cards, game); controller.revealCards(sourcePermanent.getName(), cards, game);
for (Effect effect : kinshipEffects) { for (Effect effect : kinshipEffects) {
effect.setTargetPointer(new FixedTarget(card.getId())); effect.setTargetPointer(new FixedTarget(card.getId(), game));
if (effect.getEffectType() == EffectType.ONESHOT) { if (effect.getEffectType() == EffectType.ONESHOT) {
effect.apply(game, source); effect.apply(game, source);
} else { } else {

View file

@ -46,7 +46,7 @@ public class BecomesBlockedByCreatureTriggeredAbility extends TriggeredAbilityIm
return false; return false;
} }
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getSourceId())); effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
} }
return true; return true;
} }

View file

@ -15,7 +15,7 @@ import mage.target.targetpointer.FixedTarget;
/** /**
* *
* @author Jeff * @author jeffwadsworth
*/ */
public class BecomesTappedTriggeredAbility extends TriggeredAbilityImpl { public class BecomesTappedTriggeredAbility extends TriggeredAbilityImpl {
@ -57,7 +57,7 @@ public class BecomesTappedTriggeredAbility extends TriggeredAbilityImpl {
Permanent permanent = game.getPermanent(event.getTargetId()); Permanent permanent = game.getPermanent(event.getTargetId());
if (filter.match(permanent, getSourceId(), getControllerId(), game)) { if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (setTargetPointer) { if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId())); this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
} }
return true; return true;
} }

View file

@ -47,7 +47,7 @@ public class BlocksTriggeredAbility extends TriggeredAbilityImpl {
if (event.getSourceId().equals(this.getSourceId())) { if (event.getSourceId().equals(this.getSourceId())) {
if (setTargetPointer) { if (setTargetPointer) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
} }
} }
return true; return true;

View file

@ -51,7 +51,7 @@ public class DealsDamageToACreatureAttachedTriggeredAbility extends TriggeredAbi
&& attachment.isAttachedTo(event.getSourceId())) { && attachment.isAttachedTo(event.getSourceId())) {
if (setTargetPointer) { if (setTargetPointer) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
effect.setValue("damage", event.getAmount()); effect.setValue("damage", event.getAmount());
} }
} }

View file

@ -61,7 +61,7 @@ public class DealsDamageToACreatureTriggeredAbility extends TriggeredAbilityImpl
} }
if (setTargetPointer) { if (setTargetPointer) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
effect.setValue("damage", event.getAmount()); effect.setValue("damage", event.getAmount());
} }
} }

View file

@ -62,7 +62,7 @@ public class DealsDamageToOpponentTriggeredAbility extends TriggeredAbilityImpl
} }
if(setTargetPointer) { if(setTargetPointer) {
for (Effect effect : getEffects()) { for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
effect.setValue("damage", event.getAmount()); effect.setValue("damage", event.getAmount());
} }
} }

View file

@ -67,7 +67,7 @@ public class DealtDamageAndDiedTriggeredAbility extends TriggeredAbilityImpl {
if (damageDealt) { if (damageDealt) {
if (this.setTargetPointer == SetTargetPointer.PERMANENT) { if (this.setTargetPointer == SetTargetPointer.PERMANENT) {
for (Effect effect : getEffects()) { for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
} }
} }
return true; return true;

View file

@ -53,7 +53,7 @@ public class DealtDamageAttachedTriggeredAbility extends TriggeredAbilityImpl {
effect.setValue("damage", event.getAmount()); effect.setValue("damage", event.getAmount());
switch(setTargetPointer) { switch(setTargetPointer) {
case PERMANENT: case PERMANENT:
effect.setTargetPointer(new FixedTarget(targetId)); effect.setTargetPointer(new FixedTarget(targetId, game));
break; break;
case PLAYER: case PLAYER:
effect.setTargetPointer(new FixedTarget(game.getPermanentOrLKIBattlefield(targetId).getControllerId())); effect.setTargetPointer(new FixedTarget(game.getPermanentOrLKIBattlefield(targetId).getControllerId()));

View file

@ -103,7 +103,7 @@ public class EntersBattlefieldOrAttacksAllTriggeredAbility extends TriggeredAbil
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
switch (setTargetPointer) { switch (setTargetPointer) {
case PERMANENT: case PERMANENT:
effect.setTargetPointer(new FixedTarget(attacker.getId())); effect.setTargetPointer(new FixedTarget(attacker.getId(), game));
break; break;
case PLAYER: case PLAYER:
UUID playerId = controlledText ? attacker.getControllerId() : game.getCombat().getDefendingPlayerId(attacker.getId(), game); UUID playerId = controlledText ? attacker.getControllerId() : game.getCombat().getDefendingPlayerId(attacker.getId(), game);

View file

@ -65,7 +65,7 @@ public class ExploitCreatureTriggeredAbility extends TriggeredAbilityImpl {
if (event.getSourceId().equals(getSourceId())) { if (event.getSourceId().equals(getSourceId())) {
for (Effect effect : getEffects()) { for (Effect effect : getEffects()) {
if (setTargetPointer == SetTargetPointer.PERMANENT) { if (setTargetPointer == SetTargetPointer.PERMANENT) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
} }
} }
return true; return true;

View file

@ -31,7 +31,7 @@ public class OpponentSacrificesPermanentTriggeredAbility extends TriggeredAbilit
MageObject object = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); MageObject object = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (object instanceof Permanent) { if (object instanceof Permanent) {
for (Effect effect : getEffects()) { for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
} }
return true; return true;
} }

View file

@ -70,7 +70,7 @@ public class TurnedFaceUpAllTriggeredAbility extends TriggeredAbilityImpl {
if (filter.match(permanent, getSourceId(), getControllerId(), game)) { if (filter.match(permanent, getSourceId(), getControllerId(), game)) {
if (setTargetPointer) { if (setTargetPointer) {
for (Effect effect : getEffects()) { for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
} }
} }
return true; return true;

View file

@ -52,7 +52,7 @@ public class TurnedFaceUpSourceTriggeredAbility extends TriggeredAbilityImpl {
if (event.getTargetId().equals(this.getSourceId())) { if (event.getTargetId().equals(this.getSourceId())) {
if (setTargetPointer) { if (setTargetPointer) {
for (Effect effect: getEffects()) { for (Effect effect: getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
} }
} }
return true; return true;

View file

@ -45,7 +45,7 @@ public class CreateTokenCopySourceEffect extends OneShotEffect {
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect( CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(
source.getControllerId(), null, false, number, tapped, false source.getControllerId(), null, false, number, tapped, false
); );
effect.setTargetPointer(new FixedTarget(source.getSourceId())); effect.setTargetPointer(new FixedTarget(source.getSourceId(), game));
return effect.apply(game, source); return effect.apply(game, source);
} }

View file

@ -74,7 +74,7 @@ public class CipherEffect extends OneShotEffect {
String ruleText = "you may cast a copy of " + sourceCard.getLogName() + " without paying its mana cost"; String ruleText = "you may cast a copy of " + sourceCard.getLogName() + " without paying its mana cost";
Ability ability = new DealsCombatDamageToAPlayerTriggeredAbility(new CipherStoreEffect(source.getSourceId(), ruleText), true); Ability ability = new DealsCombatDamageToAPlayerTriggeredAbility(new CipherStoreEffect(source.getSourceId(), ruleText), true);
ContinuousEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom); ContinuousEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom);
effect.setTargetPointer(new FixedTarget(target.getFirstTarget())); effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
game.addEffect(effect, source); game.addEffect(effect, source);
if (!game.isSimulation()) { if (!game.isSimulation()) {
game.informPlayers(sourceCard.getLogName() + ": Spell ciphered to " + targetCreature.getLogName()); game.informPlayers(sourceCard.getLogName() + ": Spell ciphered to " + targetCreature.getLogName());

View file

@ -34,7 +34,7 @@ public class CrewsVehicleSourceTriggeredAbility extends TriggeredAbilityImpl {
if (event.getTargetId().equals(getSourceId())) { if (event.getTargetId().equals(getSourceId())) {
for (Effect effect : getEffects()) { for (Effect effect : getEffects()) {
// set the vehicle id as target // set the vehicle id as target
effect.setTargetPointer(new FixedTarget(event.getSourceId())); effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
} }
return true; return true;
} }

View file

@ -31,7 +31,7 @@ public class DestroyTargetAtBeginningOfNextEndStepEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
DestroyTargetEffect effect = new DestroyTargetEffect(); DestroyTargetEffect effect = new DestroyTargetEffect();
effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source); game.addDelayedTriggeredAbility(delayedAbility, source);
return true; return true;

View file

@ -78,7 +78,7 @@ public class PopulateEffect extends OneShotEffect {
Effect effect = new CreateTokenCopyTargetEffect( Effect effect = new CreateTokenCopyTargetEffect(
null, null, false, 1, tappedAndAttacking, tappedAndAttacking null, null, false, 1, tappedAndAttacking, tappedAndAttacking
); );
effect.setTargetPointer(new FixedTarget(target.getFirstTarget())); effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
return effect.apply(game, source); return effect.apply(game, source);
} }

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import java.util.UUID; import java.util.UUID;
@ -13,7 +12,6 @@ import mage.constants.Outcome;
import mage.constants.PhaseStep; import mage.constants.PhaseStep;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
/** /**

View file

@ -50,10 +50,10 @@ public class GoadTargetEffect extends OneShotEffect {
or the player that goaded it. (2016-08-23) or the player that goaded it. (2016-08-23)
*/ */
ContinuousEffect effect = new AttacksIfAbleTargetEffect(Duration.UntilYourNextTurn); ContinuousEffect effect = new AttacksIfAbleTargetEffect(Duration.UntilYourNextTurn);
effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source))); effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source), game));
game.addEffect(effect, source); game.addEffect(effect, source);
effect = new CantAttackControllerDueToGoadEffect(Duration.UntilYourNextTurn); // remember current controller effect = new CantAttackControllerDueToGoadEffect(Duration.UntilYourNextTurn); // remember current controller
effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source))); effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source), game));
game.addEffect(effect, source); game.addEffect(effect, source);
game.informPlayers(controller.getLogName() + " is goading " + targetCreature.getLogName()); game.informPlayers(controller.getLogName() + " is goading " + targetCreature.getLogName());
} }

View file

@ -71,7 +71,7 @@ public class BecomesChosenCreatureTypeTargetEffect extends OneShotEffect {
if (chosenType != null && !chosenType.isEmpty()) { if (chosenType != null && !chosenType.isEmpty()) {
// ADD TYPE TO TARGET // ADD TYPE TO TARGET
ContinuousEffect effect = new BecomesCreatureTypeTargetEffect(duration, SubType.byDescription(chosenType)); ContinuousEffect effect = new BecomesCreatureTypeTargetEffect(duration, SubType.byDescription(chosenType));
effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source))); effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source), game));
game.addEffect(effect, source); game.addEffect(effect, source);
return true; return true;
} }

View file

@ -74,7 +74,7 @@ public class BecomesColorOrColorsTargetEffect extends OneShotEffect {
String colors = new String(sb); String colors = new String(sb);
ObjectColor chosenColors = new ObjectColor(colors); ObjectColor chosenColors = new ObjectColor(colors);
ContinuousEffect effect = new BecomesColorTargetEffect(chosenColors, duration); ContinuousEffect effect = new BecomesColorTargetEffect(chosenColors, duration);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
game.addEffect(effect, source); game.addEffect(effect, source);
return true; return true;

View file

@ -61,7 +61,7 @@ public class BoostEquippedEffect extends ContinuousEffectImpl {
if (fixedTarget) { if (fixedTarget) {
Permanent equipment = game.getPermanent(source.getSourceId()); Permanent equipment = game.getPermanent(source.getSourceId());
if (equipment != null && equipment.getAttachedTo() != null) { if (equipment != null && equipment.getAttachedTo() != null) {
this.setTargetPointer(new FixedTarget(equipment.getAttachedTo())); this.setTargetPointer(new FixedTarget(equipment.getAttachedTo(), game));
} }
} }
super.init(source, game); // inits the target pointer so call it after setting the targetPointer super.init(source, game); // inits the target pointer so call it after setting the targetPointer

View file

@ -103,7 +103,7 @@ public class AwakenAbility extends SpellAbility {
} }
} }
if (targetId != null) { if (targetId != null) {
FixedTarget fixedTarget = new FixedTarget(targetId); FixedTarget fixedTarget = new FixedTarget(targetId, game);
ContinuousEffect continuousEffect = new BecomesCreatureTargetEffect(new AwakenElementalToken(), false, true, Duration.Custom); ContinuousEffect continuousEffect = new BecomesCreatureTargetEffect(new AwakenElementalToken(), false, true, Duration.Custom);
continuousEffect.setTargetPointer(fixedTarget); continuousEffect.setTargetPointer(fixedTarget);
game.addEffect(continuousEffect, source); game.addEffect(continuousEffect, source);

View file

@ -88,7 +88,7 @@ public class EvolveAbility extends TriggeredAbilityImpl {
&& triggeringCreature.isControlledBy(this.controllerId)) { && triggeringCreature.isControlledBy(this.controllerId)) {
Permanent sourceCreature = game.getPermanent(sourceId); Permanent sourceCreature = game.getPermanent(sourceId);
if (sourceCreature != null && isPowerOrThoughnessGreater(sourceCreature, triggeringCreature)) { if (sourceCreature != null && isPowerOrThoughnessGreater(sourceCreature, triggeringCreature)) {
this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getTargetId())); this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getTargetId(), game));
return true; return true;
} }
} }

View file

@ -38,7 +38,7 @@ public class FlankingAbility extends TriggeredAbilityImpl {
if (!hasFlankingAbility) { if (!hasFlankingAbility) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getSourceId())); effect.setTargetPointer(new FixedTarget(event.getSourceId(), game));
} }
return true; return true;
} }

View file

@ -139,7 +139,7 @@ public class ForetellAbility extends SpecialAction {
// exile the card face-down // exile the card face-down
effect.setWithName(false); effect.setWithName(false);
effect.setTargetPointer(new FixedTarget(card.getId())); effect.setTargetPointer(new FixedTarget(card.getId(), game));
effect.apply(game, source); effect.apply(game, source);
card.setFaceDown(true, game); card.setFaceDown(true, game);
game.addEffect(new ForetellAddCostEffect(new MageObjectReference(card, game)), source); game.addEffect(new ForetellAddCostEffect(new MageObjectReference(card, game)), source);

View file

@ -72,7 +72,7 @@ public class GraftAbility extends TriggeredAbilityImpl {
&& sourcePermanent.getCounters(game).containsKey(CounterType.P1P1) && sourcePermanent.getCounters(game).containsKey(CounterType.P1P1)
&& filter.match(permanent, game)) { && filter.match(permanent, game)) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId())); effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
} }
return true; return true;
} }

View file

@ -201,7 +201,7 @@ class HauntEffect extends OneShotEffect {
.append(source.getSourceId().toString()) .append(source.getSourceId().toString())
.append(card.getZoneChangeCounter(game) .append(card.getZoneChangeCounter(game)
+ hauntedCreature.getZoneChangeCounter(game)).toString(); // in case it is blinked + hauntedCreature.getZoneChangeCounter(game)).toString(); // in case it is blinked
game.getState().setValue(key, new FixedTarget(targetPointer.getFirst(game, source))); game.getState().setValue(key, new FixedTarget(targetPointer.getFirst(game, source), game));
card.addInfo("hauntinfo", new StringBuilder("Haunting ").append(hauntedCreature.getLogName()).toString(), game); card.addInfo("hauntinfo", new StringBuilder("Haunting ").append(hauntedCreature.getLogName()).toString(), game);
hauntedCreature.addInfo("hauntinfo", new StringBuilder("Haunted by ").append(card.getLogName()).toString(), game); hauntedCreature.addInfo("hauntinfo", new StringBuilder("Haunted by ").append(card.getLogName()).toString(), game);
game.informPlayers(new StringBuilder(card.getName()).append(" haunting ").append(hauntedCreature.getLogName()).toString()); game.informPlayers(new StringBuilder(card.getName()).append(" haunting ").append(hauntedCreature.getLogName()).toString());

View file

@ -58,7 +58,7 @@ class DarettiScrapSavantTriggeredAbility extends TriggeredAbilityImpl {
if (zEvent.isDiesEvent() if (zEvent.isDiesEvent()
&& zEvent.getTarget().isArtifact(game) && zEvent.getTarget().isArtifact(game)
&& zEvent.getTarget().isOwnedBy(this.controllerId)) { && zEvent.getTarget().isOwnedBy(this.controllerId)) {
this.getEffects().setTargetPointer(new FixedTarget(zEvent.getTargetId())); this.getEffects().setTargetPointer(new FixedTarget(zEvent.getTargetId(), game));
return true; return true;
} }
return false; return false;