Card: add turnInController to keep track under which control it entered

This commit is contained in:
Hans Mackowiak
2021-03-27 11:35:52 +01:00
parent 7dcfbc409c
commit 088b4fa07e
5 changed files with 51 additions and 13 deletions

View File

@@ -133,7 +133,7 @@ public class GameAction {
return c;
}
if (zoneFrom == null && !c.isToken()) {
zoneTo.add(c, position);
zoneTo.add(c, position, CardUtil.getLKICopy(c));
checkStaticAbilities();
game.getTriggerHandler().registerActiveTrigger(c, true);
game.fireEvent(new GameEventCardChangeZone(c, zoneFrom, zoneTo));
@@ -471,7 +471,7 @@ public class GameAction {
if (card == c) {
zoneTo.add(copied, position, lastKnownInfo); // the modified state of the card is also reported here (e.g. for Morbid + Awaken)
} else {
zoneTo.add(card, position);
zoneTo.add(card, position, CardUtil.getLKICopy(card));
}
card.setZone(zoneTo);
}
@@ -598,8 +598,6 @@ public class GameAction {
copied.setState(CardStateName.Original, true);
}
unattachCardLeavingBattlefield(copied);
// Remove all changed keywords
copied.removeAllChangedText(game.getNextTimestamp());
} else if (toBattlefield) {
// reset timestamp in changezone effects so they have same timestamp if ETB simutaneously
copied.setTimestamp(game.getNextTimestamp());

View File

@@ -285,6 +285,8 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
private int regeneratedThisTurn = 0;
private int turnInZone;
// the player that under which control it enters
private Player turnInController = null;
private Map<String, Integer> xManaCostPaidByColor;
@@ -1631,6 +1633,14 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
turnInZone = turn;
}
public final Player getTurnInController() {
return turnInController;
}
public final void setTurnInController(final Player p) {
turnInController = p;
}
public final void setManaCost(final ManaCost s) {
currentState.setManaCost(s);
}
@@ -4273,13 +4283,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
updateChangedText();
}
public final void removeAllChangedText(final Long timestamp) {
changedTextTypes.removeAll();
changedTextColors.removeAll();
updateKeywordsOnRemoveChangedText(removeChangedCardKeywords(timestamp));
updateChangedText();
}
private void updateKeywordsChangedText(final Long timestamp) {
if (hasSVar("LockInKeywords")) {
return;

View File

@@ -1002,6 +1002,18 @@ public class CardProperty {
}
}
return false;
} else if (property.startsWith("EnteredUnder")) {
Player u = card.getTurnInController();
if (u == null) {
return false;
}
final String valid = property.substring(13);
if (!u.isValid(valid, sourceController, source, spellAbility)) {
final List<Player> lp = AbilityUtils.getDefinedPlayers(source, valid, spellAbility);
if (!lp.contains(u)) {
return false;
}
}
} else if (property.equals("EnteredSinceYourLastTurn")) {
if (card.getTurnInZone() <= sourceController.getLastTurnNr()) {
return false;

View File

@@ -108,13 +108,15 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
final Zone oldZone = game.getZoneOf(c);
final ZoneType zt = oldZone == null ? ZoneType.Stack : oldZone.getZoneType();
// only if the zoneType differss from this
// only if the zoneType differs from this
// don't go in there is its a control change
if (zt != zoneType) {
c.setTurnInController(getPlayer());
c.setTurnInZone(game.getPhaseHandler().getTurn());
cardsAddedThisTurn.add(zt, latestState != null ? latestState : c);
}
}
c.setTurnInZone(game.getPhaseHandler().getTurn());
if (zoneType != ZoneType.Battlefield) {
c.setTapped(false);
}