Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Magpie
2022-04-23 00:44:36 +02:00
3 changed files with 20 additions and 12 deletions

View File

@@ -1040,9 +1040,9 @@ public class PlayerControllerAi extends PlayerController {
if (sa.isCopied()) { if (sa.isCopied()) {
if (sa.isSpell()) { if (sa.isSpell()) {
if (!sa.getHostCard().isInZone(ZoneType.Stack)) { if (!sa.getHostCard().isInZone(ZoneType.Stack)) {
sa.setHostCard(player.getGame().getAction().moveToStack(sa.getHostCard(), sa)); sa.setHostCard(getGame().getAction().moveToStack(sa.getHostCard(), sa));
} else { } else {
player.getGame().getStackZone().add(sa.getHostCard()); getGame().getStackZone().add(sa.getHostCard());
} }
} }
@@ -1053,13 +1053,13 @@ public class PlayerControllerAi extends PlayerController {
*/ */
if (sa.isMayChooseNewTargets() && !sa.setupTargets()) { if (sa.isMayChooseNewTargets() && !sa.setupTargets()) {
if (sa.isSpell()) { if (sa.isSpell()) {
player.getGame().getAction().ceaseToExist(sa.getHostCard(), false); getGame().getAction().ceaseToExist(sa.getHostCard(), false);
} }
continue; continue;
} }
} }
// need finally add the new spell to the stack // need finally add the new spell to the stack
player.getGame().getStack().add(sa); getGame().getStack().add(sa);
} }
} }
} }

View File

@@ -957,7 +957,10 @@ public class GameAction {
if (c.isInZone(ZoneType.Stack)) { if (c.isInZone(ZoneType.Stack)) {
c.getGame().getStack().remove(c); c.getGame().getStack().remove(c);
} }
// in some corner cases there's no zone yet (copied spell that failed targeting)
if (c.getZone() != null) {
c.getZone().remove(c); c.getZone().remove(c);
}
// CR 603.6c other players LTB triggers should work // CR 603.6c other players LTB triggers should work
if (!skipTrig) { if (!skipTrig) {
@@ -971,14 +974,16 @@ public class GameAction {
if (lki == null) { if (lki == null) {
lki = CardUtil.getLKICopy(c); lki = CardUtil.getLKICopy(c);
} }
if (lki.isInPlay()) {
if (game.getCombat() != null) { if (game.getCombat() != null) {
game.getCombat().removeFromCombat(c);
game.getCombat().saveLKI(lki); game.getCombat().saveLKI(lki);
game.getCombat().removeFromCombat(c);
} }
// again, make sure no triggers run from cards leaving controlled by loser // again, make sure no triggers run from cards leaving controlled by loser
if (!lki.getController().equals(lki.getOwner())) { if (!lki.getController().equals(lki.getOwner())) {
game.getTriggerHandler().registerActiveLTBTrigger(lki); game.getTriggerHandler().registerActiveLTBTrigger(lki);
} }
}
final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(c); final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(c);
runParams.put(AbilityKey.CardLKI, lki); runParams.put(AbilityKey.CardLKI, lki);
runParams.put(AbilityKey.Origin, c.getZone().getZoneType().name()); runParams.put(AbilityKey.Origin, c.getZone().getZoneType().name());

View File

@@ -295,6 +295,9 @@ public class Combat {
// takes LKI into consideration, should use it at all times (though a single iteration over multimap seems faster) // takes LKI into consideration, should use it at all times (though a single iteration over multimap seems faster)
public final AttackingBand getBandOfAttacker(final Card c) { public final AttackingBand getBandOfAttacker(final Card c) {
if (c == null) {
return null;
}
for (AttackingBand ab : attackedByBands.values()) { for (AttackingBand ab : attackedByBands.values()) {
if (ab.contains(c)) { if (ab.contains(c)) {
return ab; return ab;