"this combat" bug (#4547)

* fixed bug in cards using 'this combat'

* handle tracking when creature removed from combat early
This commit is contained in:
hungriestPigeon
2024-01-19 13:49:47 +00:00
committed by GitHub
parent cf2c2ccef7
commit 9cbecf20c1
4 changed files with 11 additions and 23 deletions

View File

@@ -309,5 +309,8 @@ public class CardDamageHistory {
public void endCombat() {
damagedThisCombat.clear();
setCreatureAttackedThisCombat(null, -1);
setCreatureBlockedThisCombat(false);
setCreatureGotBlockedThisCombat(false);
}
}

View File

@@ -31,6 +31,7 @@ import forge.game.spellability.SpellAbility;
import forge.game.spellability.SpellAbilityStackInstance;
import forge.game.staticability.StaticAbilityAssignCombatDamageAsUnblocked;
import forge.game.trigger.TriggerType;
import forge.game.zone.ZoneType;
import forge.util.CardTranslation;
import forge.util.Localizer;
import forge.util.collect.FCollection;
@@ -154,13 +155,18 @@ public class Combat {
lkiCache.clear();
combatantsThatDealtFirstStrikeDamage.clear();
//clear tracking for cards that care about "this combat"
Game game = playerWhoAttacks.getGame();
for (Card c : game.getCardsIncludePhasingIn(ZoneType.Battlefield)) {
c.getDamageHistory().endCombat();
}
playerWhoAttacks.clearAttackedPlayersMyCombat();
//update view for all attackers and blockers
for (Card c : attackers) {
c.getDamageHistory().endCombat();
c.updateAttackingForView();
}
for (Card c : blockers) {
c.getDamageHistory().endCombat();
c.updateBlockingForView();
}
}

View File

@@ -675,7 +675,6 @@ public class PhaseHandler implements java.io.Serializable {
game.getTriggerHandler().runTrigger(TriggerType.AttackersDeclared, runParams, false);
}
playerTurn.clearAttackedPlayersMyCombat();
for (final Card c : combat.getAttackers()) {
CombatUtil.checkDeclaredAttacker(game, c, combat, true);
}
@@ -1275,9 +1274,6 @@ public class PhaseHandler implements java.io.Serializable {
}
public void endCombat() {
for (Player player : game.getPlayers()) {
player.resetCombatantsThisCombat();
}
game.getEndOfCombat().executeUntil();
game.getEndOfCombat().executeUntilEndOfPhase(playerTurn);
if (inCombat()) {

View File

@@ -2741,23 +2741,6 @@ public class Player extends GameEntity implements Comparable<Player> {
view.updateCurrentPlaneName(currentPlanes.toString().replaceAll(" \\(.*","").replace("[",""));
}
public final void resetCombatantsThisCombat() {
// resets the status of attacked/blocked this phase
CardCollectionView list = getCardsIn(ZoneType.Battlefield, false);
for (Card c : list) {
if (c.getDamageHistory().getCreatureAttackedThisCombat() > 0) {
c.getDamageHistory().setCreatureAttackedThisCombat(null, -1);
}
if (c.getDamageHistory().getCreatureBlockedThisCombat()) {
c.getDamageHistory().setCreatureBlockedThisCombat(false);
}
if (c.getDamageHistory().getCreatureGotBlockedThisCombat()) {
c.getDamageHistory().setCreatureGotBlockedThisCombat(false);
}
}
}
public CardCollectionView getInboundTokens() {
return inboundTokens;
}