refactor: use copy() for targetPointer (#11751)

This commit is contained in:
xenohedron 2024-02-03 01:21:16 -05:00 committed by GitHub
parent da2466d87d
commit 6cf05a554c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 52 additions and 55 deletions

View file

@ -49,7 +49,7 @@ public class CreateDelayedTriggeredAbilityEffect extends OneShotEffect {
DelayedTriggeredAbility delayedAbility = ability.copy();
if (this.copyTargets) {
if (source.getTargets().isEmpty()) {
delayedAbility.getEffects().setTargetPointer(targetPointer);
delayedAbility.getEffects().setTargetPointer(this.getTargetPointer().copy());
} else {
delayedAbility.getTargets().addAll(source.getTargets());
for (Effect effect : delayedAbility.getEffects()) {

View file

@ -60,7 +60,7 @@ public class DoWhenCostPaid extends OneShotEffect {
int bookmark = game.bookmarkState();
if (cost.pay(source, game, source, player.getId(), false)) {
if (ability.getTargets().isEmpty()) {
ability.getEffects().setTargetPointer(getTargetPointer());
ability.getEffects().setTargetPointer(this.getTargetPointer().copy());
}
game.fireReflexiveTriggeredAbility(ability, source);
player.resetStoredBookmark(game);

View file

@ -56,8 +56,8 @@ public class ExileUntilSourceLeavesEffect extends OneShotEffect {
}
ExileTargetEffect effect = new ExileTargetEffect(CardUtil.getCardExileZoneId(game, source), permanent.getIdName());
if (targetPointer != null) { // Grasping Giant
effect.setTargetPointer(targetPointer);
if (this.getTargetPointer() != null) { // Grasping Giant
effect.setTargetPointer(this.getTargetPointer().copy());
}
if (effect.apply(game, source)) {
game.addDelayedTriggeredAbility(new OnLeaveReturnExiledAbility(returnToZone), source);

View file

@ -72,7 +72,7 @@ class ScavengeEffect extends OneShotEffect {
int count = card.getPower().getValue();
if (count > 0) {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(count));
effect.setTargetPointer(getTargetPointer());
effect.setTargetPointer(this.getTargetPointer().copy());
return effect.apply(game, source);
}
}
@ -84,4 +84,4 @@ class ScavengeEffect extends OneShotEffect {
public ScavengeEffect copy() {
return new ScavengeEffect(this);
}
}
}