From eeccc8490d406b048c29f5df53ab34bd551b4fcc Mon Sep 17 00:00:00 2001 From: Chris H Date: Mon, 8 Jan 2018 23:44:40 -0500 Subject: [PATCH] RepeatSubAbility host isn't set correctly if source changes zone --- .../java/forge/game/ability/effects/RepeatEachEffect.java | 4 ++-- forge-game/src/main/java/forge/game/card/Card.java | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java b/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java index 8999df70720..180c386ac61 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/RepeatEachEffect.java @@ -28,11 +28,11 @@ public class RepeatEachEffect extends SpellAbilityEffect { AbilitySub repeat = sa.getAdditionalAbility("RepeatSubAbility"); - if (repeat != null && !repeat.getHostCard().equals(source)) { + if (repeat != null && !repeat.getHostCard().equalsWithTimestamp(source)) { // TODO: for some reason, the host card of the original additional SA is set to the cloned card when // the ability is copied (e.g. Clone Legion + Swarm Intelligence). Couldn't figure out why this happens, // so this hack is necessary for now to work around this issue. - System.out.println("Warning: RepeatSubAbility had the wrong host set (potentially after cloning the root SA), attempting to correct..."); + System.out.println("Warning: RepeatSubAbility had the wrong host set (potentially after cloning the root SA or changing zones), attempting to correct..."); repeat.setHostCard(source); } diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index 4b47dfaaea1..eb37ae05fe1 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -4776,6 +4776,9 @@ public class Card extends GameEntity implements Comparable { public final void setTimestamp(final long t) { timestamp = t; } + public boolean equalsWithTimestamp(Card c) { + return c == this && c.getTimestamp() == timestamp; + } /** * Assign a random foil finish depending on the card edition.