Merge branch '1779-lingering-hostage-taker-untilhostleavesplay-issue' into 'master'

Resolve "Lingering Hostage Taker (UntilHostLeavesPlay) issue"

Closes #1779

See merge request core-developers/forge!4261
This commit is contained in:
Hans Mackowiak
2021-03-25 13:51:07 +00:00
3 changed files with 14 additions and 7 deletions

View File

@@ -251,6 +251,7 @@ public class GameAction {
copied.copyChangedTextFrom(c);
// copy exiled properties when adding to stack
// will be cleanup later in MagicStack
copied.setExiledWith(c.getExiledWith());
copied.setExiledBy(c.getExiledBy());
@@ -416,13 +417,7 @@ public class GameAction {
}
if (!zoneTo.is(ZoneType.Exile) && !zoneTo.is(ZoneType.Stack)) {
Card with = c.getExiledWith();
if (with != null) {
with.removeUntilLeavesBattlefield(c);
}
c.setExiledWith(null);
c.setExiledBy(null);
c.cleanupExiledWith();
}
}

View File

@@ -1681,6 +1681,17 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
exiledWith = e;
}
public final void cleanupExiledWith() {
if (exiledWith == null) {
return;
}
exiledWith.removeUntilLeavesBattlefield(this);
exiledWith = null;
exiledBy = null;
}
public final Player getExiledBy() { return exiledBy; }
public final void setExiledBy(final Player ep) {
exiledBy = ep;

View File

@@ -150,6 +150,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
source.setCastSA(cause);
}
source.cleanupExiledWith();
}
// Always add the ability here and always unfreeze the stack