mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
first blocker is assigned all damage initially
This commit is contained in:
@@ -320,18 +320,19 @@ public class VAssignDamage {
|
|||||||
// will assign all damage to defenders and rest to player, if present
|
// will assign all damage to defenders and rest to player, if present
|
||||||
private void initialAssignDamage(boolean onlyFirstBlocker) {
|
private void initialAssignDamage(boolean onlyFirstBlocker) {
|
||||||
int dmgLeft = totalDamageToAssign;
|
int dmgLeft = totalDamageToAssign;
|
||||||
for(DamageTarget dt : defenders) {
|
DamageTarget dtLast = null;
|
||||||
|
for(DamageTarget dt : defenders) { // MUST NOT RUN WITH EMPTY collection
|
||||||
int lethal = getDamageToKill(dt.card);
|
int lethal = getDamageToKill(dt.card);
|
||||||
int damage = Math.min(lethal, dmgLeft);
|
int damage = Math.min(lethal, dmgLeft);
|
||||||
addDamage(dt.card, damage);
|
addDamage(dt.card, damage);
|
||||||
dmgLeft -= damage;
|
dmgLeft -= damage;
|
||||||
|
dtLast = dt;
|
||||||
if ( dmgLeft <= 0 || onlyFirstBlocker ) break;
|
if ( dmgLeft <= 0 || onlyFirstBlocker ) break;
|
||||||
}
|
}
|
||||||
if ( dmgLeft < 0 )
|
if ( dmgLeft < 0 )
|
||||||
throw new RuntimeException("initialAssignDamage managed to assign more damage than it could");
|
throw new RuntimeException("initialAssignDamage managed to assign more damage than it could");
|
||||||
if ( dmgLeft > 0 && !onlyFirstBlocker) { // flush the remaining damage into last defender
|
if ( dmgLeft > 0) { // flush the remaining damage into last defender
|
||||||
DamageTarget dt = defenders.get(defenders.size()-1);
|
addDamage(dtLast.card, dmgLeft );
|
||||||
addDamage(dt.card, dmgLeft );
|
|
||||||
}
|
}
|
||||||
updateLabels();
|
updateLabels();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user