mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
- Combat Damage now more accurate when considering gaining/losing first strike after first strike damage has been dealt.
This commit is contained in:
@@ -59,6 +59,8 @@ public class Combat {
|
|||||||
private Map<Card, List<Card>> blockersOrderedForDamageAssignment = new HashMap<Card, List<Card>>();
|
private Map<Card, List<Card>> blockersOrderedForDamageAssignment = new HashMap<Card, List<Card>>();
|
||||||
private Map<GameEntity, CombatLki> lkiCache = new HashMap<GameEntity, CombatLki>();
|
private Map<GameEntity, CombatLki> lkiCache = new HashMap<GameEntity, CombatLki>();
|
||||||
|
|
||||||
|
private List<Card> combatantDealtFirstStrikeDamage = Lists.newArrayList();
|
||||||
|
|
||||||
|
|
||||||
public Combat(Player attacker) {
|
public Combat(Player attacker) {
|
||||||
playerWhoAttacks = attacker;
|
playerWhoAttacks = attacker;
|
||||||
@@ -423,23 +425,29 @@ public class Combat {
|
|||||||
boolean assignedDamage = false;
|
boolean assignedDamage = false;
|
||||||
|
|
||||||
for (final Card blocker : blockers) {
|
for (final Card blocker : blockers) {
|
||||||
if (blocker.hasDoubleStrike() || blocker.hasFirstStrike() == firstStrikeDamage) {
|
if (!dealDamageThisPhase(blocker, firstStrikeDamage)) {
|
||||||
List<Card> attackers = this.attackersOrderedForDamageAssignment.get(blocker);
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
final int damage = blocker.getNetCombatDamage();
|
if (firstStrikeDamage) {
|
||||||
|
this.combatantDealtFirstStrikeDamage.add(blocker);
|
||||||
|
}
|
||||||
|
|
||||||
if (!attackers.isEmpty()) {
|
List<Card> attackers = this.attackersOrderedForDamageAssignment.get(blocker);
|
||||||
Player attackingPlayer = this.getAttackingPlayer();
|
|
||||||
Player assigningPlayer = blocker.getController();
|
|
||||||
|
|
||||||
if (AttackingBand.isValidBand(attackers, true))
|
final int damage = blocker.getNetCombatDamage();
|
||||||
assigningPlayer = attackingPlayer;
|
|
||||||
|
|
||||||
assignedDamage = true;
|
if (!attackers.isEmpty()) {
|
||||||
Map<Card, Integer> map = assigningPlayer.getController().assignCombatDamage(blocker, attackers, damage, null, assigningPlayer != blocker.getController());
|
Player attackingPlayer = this.getAttackingPlayer();
|
||||||
for (Entry<Card, Integer> dt : map.entrySet()) {
|
Player assigningPlayer = blocker.getController();
|
||||||
dt.getKey().addAssignedDamage(dt.getValue(), blocker);
|
|
||||||
}
|
if (AttackingBand.isValidBand(attackers, true))
|
||||||
|
assigningPlayer = attackingPlayer;
|
||||||
|
|
||||||
|
assignedDamage = true;
|
||||||
|
Map<Card, Integer> map = assigningPlayer.getController().assignCombatDamage(blocker, attackers, damage, null, assigningPlayer != blocker.getController());
|
||||||
|
for (Entry<Card, Integer> dt : map.entrySet()) {
|
||||||
|
dt.getKey().addAssignedDamage(dt.getValue(), blocker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -454,11 +462,14 @@ public class Combat {
|
|||||||
final List<Card> attackers = this.getAttackers();
|
final List<Card> attackers = this.getAttackers();
|
||||||
boolean assignedDamage = false;
|
boolean assignedDamage = false;
|
||||||
for (final Card attacker : attackers) {
|
for (final Card attacker : attackers) {
|
||||||
// If attacker isn't in the right first/regular strike section, continue along
|
if (!dealDamageThisPhase(attacker, firstStrikeDamage)) {
|
||||||
if (!(attacker.hasDoubleStrike() || attacker.hasFirstStrike() == firstStrikeDamage)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (firstStrikeDamage) {
|
||||||
|
this.combatantDealtFirstStrikeDamage.add(attacker);
|
||||||
|
}
|
||||||
|
|
||||||
// If potential damage is 0, continue along
|
// If potential damage is 0, continue along
|
||||||
final int damageDealt = attacker.getNetCombatDamage();
|
final int damageDealt = attacker.getNetCombatDamage();
|
||||||
if (damageDealt <= 0) {
|
if (damageDealt <= 0) {
|
||||||
@@ -504,6 +515,18 @@ public class Combat {
|
|||||||
return assignedDamage;
|
return assignedDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final boolean dealDamageThisPhase(Card combatant, boolean firstStrikeDamage) {
|
||||||
|
// During first strike damage, double strike and first strike deal damage
|
||||||
|
// During regular strike damage, double strike and anyone who hasn't dealt damage deal damage
|
||||||
|
if (combatant.hasDoubleStrike())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (firstStrikeDamage && combatant.hasFirstStrike())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return !firstStrikeDamage && !this.combatantDealtFirstStrikeDamage.contains(combatant);
|
||||||
|
}
|
||||||
|
|
||||||
// Damage to whatever was protected there.
|
// Damage to whatever was protected there.
|
||||||
private final void addDefendingDamage(final int n, final Card source) {
|
private final void addDefendingDamage(final int n, final Card source) {
|
||||||
final GameEntity ge = this.getDefenderByAttacker(source);
|
final GameEntity ge = this.getDefenderByAttacker(source);
|
||||||
@@ -525,6 +548,10 @@ public class Combat {
|
|||||||
public final boolean assignCombatDamage(boolean firstStrikeDamage) {
|
public final boolean assignCombatDamage(boolean firstStrikeDamage) {
|
||||||
boolean assignedDamage = assignAttackersDamage(firstStrikeDamage);
|
boolean assignedDamage = assignAttackersDamage(firstStrikeDamage);
|
||||||
assignedDamage |= assignBlockersDamage(firstStrikeDamage);
|
assignedDamage |= assignBlockersDamage(firstStrikeDamage);
|
||||||
|
if (!firstStrikeDamage) {
|
||||||
|
// Clear first strike damage list since it doesn't matter anymore
|
||||||
|
this.combatantDealtFirstStrikeDamage.clear();
|
||||||
|
}
|
||||||
return assignedDamage;
|
return assignedDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user