ChangeZoneEffect: Don't modify tapped when replaced

This commit is contained in:
Bug Hunter
2021-05-18 03:50:24 +00:00
committed by Michael Kamensky
parent bb6c5f8e44
commit 32240b6004
20 changed files with 43 additions and 57 deletions

View File

@@ -344,6 +344,7 @@ public class GameAction {
c.updateStateForView();
}
}
return c;
}
}
@@ -373,7 +374,7 @@ public class GameAction {
if (saTargeting != null) {
saTargeting.getTargets().replaceTargetCard(c, cards);
}
// Replace host rememberd cards
// Replace host remembered cards
// But not replace RememberLKI, since it wants to refer to the last known info.
Card hostCard = cause.getHostCard();
if (!cause.hasParam("RememberLKI") && hostCard.isRemembered(c)) {

View File

@@ -30,7 +30,7 @@ public class AnimateEffect extends AnimateEffectBase {
//if host is not on the battlefield don't apply
if (("UntilHostLeavesPlay".equals(sa.getParam("Duration")) || "UntilLoseControlOfHost".equals(sa.getParam("Duration")))
&& !sa.getHostCard().isInPlay()) {
&& !source.isInPlay()) {
return;
}

View File

@@ -44,7 +44,7 @@ public class AssignGroupEffect extends SpellAbilityEffect {
Player chooser = sa.getActivatingPlayer();
if (sa.hasParam("Chooser")) {
final String choose = sa.getParam("Chooser");
chooser = AbilityUtils.getDefinedPlayers(sa.getHostCard(), choose, sa).get(0);
chooser = AbilityUtils.getDefinedPlayers(host, choose, sa).get(0);
}
Multimap<SpellAbility, GameObject> result = ArrayListMultimap.create();

View File

@@ -29,7 +29,7 @@ public class BlockEffect extends SpellAbilityEffect {
List<Card> attackers = new ArrayList<>();
if (sa.hasParam("DefinedAttacker")) {
for (final Card attacker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa)) {
for (final Card attacker : AbilityUtils.getDefinedCards(host, sa.getParam("DefinedAttacker"), sa)) {
if (combat.isAttacking(attacker))
attackers.add(attacker);
}
@@ -37,7 +37,7 @@ public class BlockEffect extends SpellAbilityEffect {
List<Card> blockers = new ArrayList<>();
if (sa.hasParam("DefinedBlocker")) {
for (final Card blocker : AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedBlocker"), sa)) {
for (final Card blocker : AbilityUtils.getDefinedCards(host, sa.getParam("DefinedBlocker"), sa)) {
if (blocker.isCreature() && blocker.isInZone(ZoneType.Battlefield))
blockers.add(blocker);
}

View File

@@ -42,8 +42,10 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
@Override
public void resolve(SpellAbility sa) {
final Card source = sa.getHostCard();
//if host is not on the battlefield don't apply
if ("UntilHostLeavesPlay".equals(sa.getParam("Duration")) && !sa.getHostCard().isInPlay()) {
if ("UntilHostLeavesPlay".equals(sa.getParam("Duration")) && !source.isInPlay()) {
return;
}
@@ -53,7 +55,6 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
CardCollection cards;
List<Player> tgtPlayers = getTargetPlayers(sa);
final Game game = sa.getActivatingPlayer().getGame();
final Card source = sa.getHostCard();
if ((!sa.usesTargeting() && !sa.hasParam("Defined")) || sa.hasParam("UseAllOriginZones")) {
cards = new CardCollection(game.getCardsIn(origin));
@@ -122,7 +123,7 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
}
if (sa.hasParam("ForgetOtherRemembered")) {
sa.getHostCard().clearRemembered();
source.clearRemembered();
}
final String remember = sa.getParam("RememberChanged");
@@ -203,9 +204,6 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
if (sa.hasParam("ExileFaceDown")) {
movedCard.turnFaceDown(true);
}
if (sa.hasParam("Tapped")) {
movedCard.setTapped(true);
}
}
if (remember != null) {

View File

@@ -97,13 +97,13 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
// Player whose cards will change zones
List<Player> fetchers = null;
if (sa.hasParam("DefinedPlayer")) {
fetchers = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("DefinedPlayer"), sa);
fetchers = AbilityUtils.getDefinedPlayers(host, sa.getParam("DefinedPlayer"), sa);
}
if (fetchers == null && sa.hasParam("ValidTgts") && sa.usesTargeting()) {
fetchers = Lists.newArrayList(sa.getTargets().getTargetPlayers());
}
if (fetchers == null) {
fetchers = Lists.newArrayList(sa.getHostCard().getController());
fetchers = Lists.newArrayList(host.getController());
}
final String fetcherNames = Lang.joinHomogenous(fetchers, Player.Accessors.FN_GET_NAME);
@@ -111,7 +111,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
// Player who chooses the cards to move
List<Player> choosers = Lists.newArrayList();
if (sa.hasParam("Chooser")) {
choosers = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Chooser"), sa);
choosers = AbilityUtils.getDefinedPlayers(host, sa.getParam("Chooser"), sa);
}
if (choosers.isEmpty()) {
choosers.add(sa.getActivatingPlayer());
@@ -502,7 +502,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
Player chooser = player;
if (sa.hasParam("Chooser")) {
chooser = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Chooser"), sa).get(0);
chooser = AbilityUtils.getDefinedPlayers(hostCard, sa.getParam("Chooser"), sa).get(0);
}
for (final Card tgtC : tgtCards) {
@@ -636,8 +636,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
hostCard.removeRemembered(gameCard);
}
// Auras without Candidates stay in their current
// location
// Auras without Candidates stay in their current location
if (gameCard.isAura()) {
final SpellAbility saAura = gameCard.getFirstAttachSpell();
if (saAura != null) {
@@ -679,12 +678,6 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
game.getCombat().getBandOfAttacker(movedCard).setBlocked(false);
combatChanged = true;
}
if (sa.hasParam("Tapped") || sa.hasParam("Ninjutsu")) {
movedCard.setTapped(true);
}
if (sa.hasParam("Untapped")) {
movedCard.setTapped(false);
}
movedCard.setTimestamp(ts);
} else {
// might set before card is moved only for nontoken
@@ -812,7 +805,6 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
triggerList.triggerChangesZoneAll(game, sa);
counterTable.triggerCountersPutAll(game);
if (sa.hasParam("AtEOT") && !triggerList.isEmpty()) {
registerDelayedTrigger(sa, sa.getParam("AtEOT"), triggerList.allCards());
}
@@ -1292,11 +1284,6 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
setFaceDownState(c, sa);
}
movedCard = game.getAction().moveToPlay(c, c.getController(), sa, moveParams);
if (sa.hasParam("Tapped")) {
movedCard.setTapped(true);
} else if (sa.hasParam("Untapped")) {
c.setTapped(false);
}
movedCard.setTimestamp(ts);
}

View File

@@ -35,7 +35,7 @@ public class ChoosePlayerEffect extends SpellAbilityEffect {
final TargetRestrictions tgt = sa.getTargetRestrictions();
final FCollectionView<Player> choices = sa.hasParam("Choices") ? AbilityUtils.getDefinedPlayers(
sa.getHostCard(), sa.getParam("Choices"), sa) : sa.getActivatingPlayer().getGame().getPlayersInTurnOrder();
card, sa.getParam("Choices"), sa) : sa.getActivatingPlayer().getGame().getPlayersInTurnOrder();
final String choiceDesc = sa.hasParam("ChoiceTitle") ? sa.getParam("ChoiceTitle") : Localizer.getInstance().getMessage("lblChoosePlayer");
final boolean random = sa.hasParam("Random");

View File

@@ -51,11 +51,11 @@ public class ClashEffect extends SpellAbilityEffect {
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
runParams.put(AbilityKey.Player, player);
runParams.put(AbilityKey.Won, player.equals(winner) ? "True" : "False");
sa.getHostCard().getGame().getTriggerHandler().runTrigger(TriggerType.Clashed, runParams, false);
source.getGame().getTriggerHandler().runTrigger(TriggerType.Clashed, runParams, false);
final Map<AbilityKey, Object> runParams2 = AbilityKey.newMap();
runParams2.put(AbilityKey.Player, opponent);
runParams2.put(AbilityKey.Won, opponent.equals(winner) ? "True" : "False");
sa.getHostCard().getGame().getTriggerHandler().runTrigger(TriggerType.Clashed, runParams2, false);
source.getGame().getTriggerHandler().runTrigger(TriggerType.Clashed, runParams2, false);
}
/**

View File

@@ -99,8 +99,8 @@ public class ControlExchangeEffect extends SpellAbilityEffect {
object2.setController(player1, tStamp);
object1.setController(player2, tStamp);
if (sa.hasParam("RememberExchanged")) {
sa.getHostCard().addRemembered(object1);
sa.getHostCard().addRemembered(object2);
host.addRemembered(object1);
host.addRemembered(object2);
}
}

View File

@@ -41,7 +41,7 @@ public class CountersPutAllEffect extends SpellAbilityEffect {
final Card host = sa.getHostCard();
final Player activator = sa.getActivatingPlayer();
final String type = sa.getParam("CounterType");
final int counterAmount = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("CounterNum"), sa);
final int counterAmount = AbilityUtils.calculateAmount(host, sa.getParam("CounterNum"), sa);
final String valid = sa.getParam("ValidCards");
final ZoneType zone = sa.hasParam("ValidZone") ? ZoneType.smartValueOf(sa.getParam("ValidZone")) : ZoneType.Battlefield;
final boolean etbcounter = sa.hasParam("ETB");
@@ -52,7 +52,7 @@ public class CountersPutAllEffect extends SpellAbilityEffect {
}
CardCollectionView cards = game.getCardsIn(zone);
cards = CardLists.getValidCards(cards, valid, host.getController(), sa.getHostCard(), sa);
cards = CardLists.getValidCards(cards, valid, host.getController(), host, sa);
if (sa.usesTargeting()) {
final Player pl = sa.getTargets().getFirstTargetedPlayer();

View File

@@ -155,16 +155,16 @@ public class CountersPutEffect extends SpellAbilityEffect {
}
Player chooser = activator;
if (sa.hasParam("Chooser")) {
List<Player> choosers = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Chooser"), sa);
List<Player> choosers = AbilityUtils.getDefinedPlayers(card, sa.getParam("Chooser"), sa);
if (choosers.isEmpty()) {
return;
}
chooser = choosers.get(0);
}
int n = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParamOrDefault("ChoiceAmount",
int n = AbilityUtils.calculateAmount(card, sa.getParamOrDefault("ChoiceAmount",
"1"), sa);
int m = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParamOrDefault("MinChoiceAmount",
int m = AbilityUtils.calculateAmount(card, sa.getParamOrDefault("MinChoiceAmount",
sa.getParamOrDefault("ChoiceAmount", "1")), sa);
// no choices allowed
@@ -405,10 +405,10 @@ public class CountersPutEffect extends SpellAbilityEffect {
Player placer = activator;
if (sa.hasParam("Placer")) {
final String pstr = sa.getParam("Placer");
placer = AbilityUtils.getDefinedPlayers(sa.getHostCard(), pstr, sa).get(0);
placer = AbilityUtils.getDefinedPlayers(card, pstr, sa).get(0);
}
int counterAmount = AbilityUtils.calculateAmount(sa.getHostCard(), amount, sa);
int counterAmount = AbilityUtils.calculateAmount(card, amount, sa);
GameEntityCounterTable table = new GameEntityCounterTable();
@@ -422,7 +422,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
List<String> keywords = Arrays.asList(sa.getParam("SharedKeywords").split(" & "));
List<ZoneType> zones = ZoneType.listValueOf(sa.getParam("SharedKeywordsZone"));
String[] restrictions = sa.hasParam("SharedRestrictions") ? sa.getParam("SharedRestrictions").split(",") : new String[]{"Card"};
keywords = CardFactoryUtil.sharedKeywords(keywords, restrictions, zones, sa.getHostCard());
keywords = CardFactoryUtil.sharedKeywords(keywords, restrictions, zones, card);
for (String k : keywords) {
resolvePerType(sa, placer, CounterType.getType(k), counterAmount, table);
}

View File

@@ -82,7 +82,7 @@ public class CountersRemoveEffect extends SpellAbilityEffect {
int cntToRemove = 0;
if (!num.equals("All") && !num.equals("Any")) {
cntToRemove = AbilityUtils.calculateAmount(sa.getHostCard(), num, sa);
cntToRemove = AbilityUtils.calculateAmount(card, num, sa);
}
if (sa.hasParam("Optional")) {

View File

@@ -52,14 +52,14 @@ public class DamageAllEffect extends DamageBaseEffect {
*/
@Override
public void resolve(SpellAbility sa) {
final List<Card> definedSources = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DamageSource"), sa);
final Card source = sa.getHostCard();
final List<Card> definedSources = AbilityUtils.getDefinedCards(source, sa.getParam("DamageSource"), sa);
final Card card = definedSources.get(0);
final Card sourceLKI = card.getGame().getChangeZoneLKIInfo(card);
final Card source = sa.getHostCard();
final Game game = sa.getActivatingPlayer().getGame();
final String damage = sa.getParam("NumDmg");
final int dmg = AbilityUtils.calculateAmount(sa.getHostCard(), damage, sa);
final int dmg = AbilityUtils.calculateAmount(source, damage, sa);
final boolean rememberCard = sa.hasParam("RememberDamaged") || sa.hasParam("RememberDamagedCreature");
final boolean rememberPlayer = sa.hasParam("RememberDamaged") || sa.hasParam("RememberDamagedPlayer");

View File

@@ -13,7 +13,7 @@ public class DamagePreventAllEffect extends DamagePreventEffectBase {
public void resolve(SpellAbility sa) {
final Card source = sa.getHostCard();
final Game game = sa.getActivatingPlayer().getGame();
final int numDam = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa);
final int numDam = AbilityUtils.calculateAmount(source, sa.getParam("Amount"), sa);
String players = "";

View File

@@ -27,7 +27,7 @@ public class MustBlockEffect extends SpellAbilityEffect {
List<Card> cards;
if (sa.hasParam("DefinedAttacker")) {
cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa);
cards = AbilityUtils.getDefinedCards(host, sa.getParam("DefinedAttacker"), sa);
} else {
cards = Lists.newArrayList(host);
}
@@ -37,7 +37,7 @@ public class MustBlockEffect extends SpellAbilityEffect {
Player chooser = activator;
if (sa.hasParam("Chooser")) {
final String choose = sa.getParam("Chooser");
chooser = AbilityUtils.getDefinedPlayers(sa.getHostCard(), choose, sa).get(0);
chooser = AbilityUtils.getDefinedPlayers(host, choose, sa).get(0);
}
CardCollectionView choices = game.getCardsIn(ZoneType.Battlefield);
@@ -81,7 +81,7 @@ public class MustBlockEffect extends SpellAbilityEffect {
String attacker = null;
if (sa.hasParam("DefinedAttacker")) {
final List<Card> cards = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedAttacker"), sa);
final List<Card> cards = AbilityUtils.getDefinedCards(host, sa.getParam("DefinedAttacker"), sa);
attacker = cards.get(0).toString();
} else {
attacker = host.toString();

View File

@@ -48,7 +48,7 @@ public class RevealEffect extends SpellAbilityEffect {
}
} else if (sa.hasParam("RevealDefined")) {
revealed.addAll(AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("RevealDefined"), sa));
revealed.addAll(AbilityUtils.getDefinedCards(host, sa.getParam("RevealDefined"), sa));
} else {
CardCollection valid = new CardCollection(cardsInHand);

View File

@@ -47,7 +47,7 @@ public class SacrificeAllEffect extends SpellAbilityEffect {
CardCollectionView list;
if (sa.hasParam("Defined")) {
list = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa);
list = AbilityUtils.getDefinedCards(card, sa.getParam("Defined"), sa);
} else {
list = game.getCardsIn(ZoneType.Battlefield);
if (sa.hasParam("ValidCards")) {

View File

@@ -27,7 +27,7 @@ public class SetInMotionEffect extends SpellAbilityEffect {
int repeats = 1;
if (sa.hasParam("RepeatNum")) {
repeats = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("RepeatNum"), sa);
repeats = AbilityUtils.calculateAmount(source, sa.getParam("RepeatNum"), sa);
}
for (int i = 0; i < repeats; i++) {

View File

@@ -39,7 +39,7 @@ public class SkipTurnEffect extends SpellAbilityEffect {
final Game game = hostCard.getGame();
final String name = hostCard.getName() + "'s Effect";
final String image = hostCard.getImageKey();
final int numTurns = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("NumTurns"), sa);
final int numTurns = AbilityUtils.calculateAmount(hostCard, sa.getParam("NumTurns"), sa);
String repeffstr = "Event$ BeginTurn | ActiveZones$ Command | ValidPlayer$ You " +
"| Description$ Skip your next " + (numTurns > 1 ? Lang.getNumeral(numTurns) + " turns." : "turn.");
String effect = "DB$ StoreSVar | SVar$ NumTurns | Type$ CountSVar | Expression$ NumTurns/Minus.1";

View File

@@ -68,19 +68,19 @@ public class TwoPilesEffect extends SpellAbilityEffect {
Player separator = card.getController();
if (sa.hasParam("Separator")) {
separator = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Separator"), sa).get(0);
separator = AbilityUtils.getDefinedPlayers(card, sa.getParam("Separator"), sa).get(0);
}
Player chooser = tgtPlayers.get(0);
if (sa.hasParam("Chooser")) {
chooser = AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam("Chooser"), sa).get(0);
chooser = AbilityUtils.getDefinedPlayers(card, sa.getParam("Chooser"), sa).get(0);
}
for (final Player p : tgtPlayers) {
if ((tgt == null) || p.canBeTargetedBy(sa)) {
CardCollectionView pool0;
if (sa.hasParam("DefinedCards")) {
pool0 = AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("DefinedCards"), sa);
pool0 = AbilityUtils.getDefinedCards(card, sa.getParam("DefinedCards"), sa);
} else {
pool0 = p.getCardsIn(zone);
}