summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js35
1 files changed, 18 insertions, 17 deletions
diff --git a/rules.js b/rules.js
index 952a2ba..7910e84 100644
--- a/rules.js
+++ b/rules.js
@@ -2822,50 +2822,51 @@ function gen_battle_card() {
/* RESOLVE BATTLE */
-function roll_loser_combat_losses(side) {
+function roll_loser_combat_losses(side, max_cu) {
let roll = roll_d6()
- let losses = 0
+ let lost = 0
switch (roll) {
case 1:
case 2:
case 3:
- losses = 1
+ lost = 1
break
case 4:
case 5:
- losses = 2
+ lost = 2
break
case 6:
- losses = 3
+ lost = 3
break
}
- log(`${side} LOSSES:\n-${losses} CU ( D${roll} )`)
- return losses
+ lost = Math.min(lost, max_cu)
+ log(`${side} LOSSES:\n-${lost} CU ( D${roll} )`)
+ return lost
}
function roll_winner_combat_losses(side, losing_general) {
let agility = losing_general !== NOBODY ? GENERALS[losing_general].agility : 0
let roll = roll_d6()
- let losses = 0
+ let lost = 0
switch (agility) {
case 0:
- losses = roll === 1 ? 1 : 0
+ lost = roll === 1 ? 1 : 0
break
case 1:
- losses = roll <= 2 ? 1 : 0
+ lost = roll <= 2 ? 1 : 0
break
case 2:
- losses = roll <= 3 ? 1 : 0
+ lost = roll <= 3 ? 1 : 0
break
case 3:
- losses = roll <= 4 ? 1 : 0
+ lost = roll <= 4 ? 1 : 0
break
}
if (losing_general === NOBODY)
- log(`${side} LOSSES:\n-${losses} CU ( D${roll} \xd7 Nobody)`)
+ log(`${side} LOSSES:\n-${lost} CU ( D${roll} \xd7 Nobody)`)
else
- log(`${side} LOSSES:\n-${losses} CU ( D${roll} \xd7 A${agility} G${losing_general} )`)
- return losses
+ log(`${side} LOSSES:\n-${lost} CU ( D${roll} \xd7 A${agility} G${losing_general} )`)
+ return lost
}
function apply_british_combat_losses(max) {
@@ -3007,11 +3008,11 @@ function resolve_battle() {
if (victor === P_BRITAIN) {
log("RESULT:\nBritish victory!")
b_lost_cu = roll_winner_combat_losses("BRITISH", a_g)
- a_lost_cu = roll_loser_combat_losses("AMERICAN")
+ a_lost_cu = roll_loser_combat_losses("AMERICAN", a_cu)
} else {
log("RESULT:\nAmerican victory!")
a_lost_cu = roll_winner_combat_losses("AMERICAN", b_g)
- b_lost_cu = roll_loser_combat_losses("BRITISH")
+ b_lost_cu = roll_loser_combat_losses("BRITISH", b_cu)
}
game.combat.british_losses = apply_british_combat_losses(b_lost_cu)