Small combat fixes for Planeswalkers

This commit is contained in:
tool4EvEr
2021-08-10 21:10:45 +02:00
parent b049c8c09b
commit 805e65d30c
6 changed files with 21 additions and 8 deletions

View File

@@ -3501,7 +3501,13 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
if (changedCardTypes.isEmpty() && changedCardTypesCharacterDefining.isEmpty()) { if (changedCardTypes.isEmpty() && changedCardTypesCharacterDefining.isEmpty()) {
return state.getType(); return state.getType();
} }
return state.getType().getTypeWithChanges(getChangedCardTypes()); // CR 506.4 attacked planeswalkers leave combat
boolean checkCombat = state.getType().isPlaneswalker() && game.getCombat() != null && !game.getCombat().getAttackersOf(this).isEmpty();
CardTypeView types = state.getType().getTypeWithChanges(getChangedCardTypes());
if (checkCombat && !types.isPlaneswalker()) {
game.getCombat().removeFromCombat(this);
}
return types;
} }
public Iterable<CardChangedType> getChangedCardTypes() { public Iterable<CardChangedType> getChangedCardTypes() {
@@ -3569,7 +3575,6 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
final boolean removeLandTypes, final boolean removeCreatureTypes, final boolean removeArtifactTypes, final boolean removeLandTypes, final boolean removeCreatureTypes, final boolean removeArtifactTypes,
final boolean removeEnchantmentTypes, final boolean removeEnchantmentTypes,
final long timestamp, final boolean updateView, final boolean cda) { final long timestamp, final boolean updateView, final boolean cda) {
(cda ? changedCardTypesCharacterDefining : changedCardTypes).put(timestamp, new CardChangedType( (cda ? changedCardTypesCharacterDefining : changedCardTypes).put(timestamp, new CardChangedType(
addType, removeType, removeSuperTypes, removeCardTypes, removeSubTypes, addType, removeType, removeSuperTypes, removeCardTypes, removeSubTypes,
removeLandTypes, removeCreatureTypes, removeArtifactTypes, removeEnchantmentTypes)); removeLandTypes, removeCreatureTypes, removeArtifactTypes, removeEnchantmentTypes));

View File

@@ -1428,7 +1428,14 @@ public class CardProperty {
} }
} }
if (property.equals("attackingYouOrYourPW")) { if (property.equals("attackingYouOrYourPW")) {
Player defender = combat.getDefenderPlayerByAttacker(card); GameEntity defender = combat.getDefenderByAttacker(card);
if (defender instanceof Card) {
// attack on a planeswalker that was removed from combat
if (!((Card)defender).isPlaneswalker()) {
return false;
}
defender = ((Card)defender).getController();
}
if (!sourceController.equals(defender)) { if (!sourceController.equals(defender)) {
return false; return false;
} }

View File

@@ -602,7 +602,7 @@ public class Combat {
for (Card pw : getDefendingPlaneswalkers()) { for (Card pw : getDefendingPlaneswalkers()) {
if (pw.equals(c)) { if (pw.equals(c)) {
Multimap<GameEntity, AttackingBand> attackerBuffer = ArrayListMultimap.create(); Multimap<GameEntity, AttackingBand> attackerBuffer = ArrayListMultimap.create();
Collection<AttackingBand> bands = attackedByBands.get(pw); Collection<AttackingBand> bands = attackedByBands.get(c);
for (AttackingBand abPW : bands) { for (AttackingBand abPW : bands) {
unregisterDefender(c, abPW); unregisterDefender(c, abPW);
// Rule 506.4c workaround to keep creatures in combat // Rule 506.4c workaround to keep creatures in combat
@@ -613,6 +613,7 @@ public class Combat {
} }
bands.clear(); bands.clear();
attackedByBands.putAll(attackerBuffer); attackedByBands.putAll(attackerBuffer);
break;
} }
} }

View File

@@ -1,6 +1,6 @@
Name:Soul Snare Name:Soul Snare
ManaCost:W ManaCost:W
Types:Enchantment Types:Enchantment
A:AB$ ChangeZone | Cost$ W Sac<1/CARDNAME> | ValidTgts$ Creature.attacking+OppCtrl | TgtPrompt$ Select target creature that's attacking you or a planeswalker you control. | Origin$ Battlefield | Destination$ Exile | SpellDescription$ Exile target creature that's attacking you or a planeswalker you control. A:AB$ ChangeZone | Cost$ W Sac<1/CARDNAME> | ValidTgts$ Creature.attackingYouOrYourPW | TgtPrompt$ Select target creature that's attacking you or a planeswalker you control. | Origin$ Battlefield | Destination$ Exile | SpellDescription$ Exile target creature that's attacking you or a planeswalker you control.
SVar:Picture:http://www.wizards.com/global/images/magic/general/soul_snare.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/soul_snare.jpg
Oracle:{W}, Sacrifice Soul Snare: Exile target creature that's attacking you or a planeswalker you control. Oracle:{W}, Sacrifice Soul Snare: Exile target creature that's attacking you or a planeswalker you control.