Reference · Rules, maps and records
battleLossesfunction
WHO LOSES WHAT: the highest die of each side compared, then the next highest, as many pairs as the side with fewer dice threw. The higher die wins its pair; a tie goes to the defender. Each lost pair is one army. Both lists are highest first.
Import it
import { battleLosses } from "@johnmorrisdotca/tenka";
Definition
function battleLosses(attack: readonly number[], defend: readonly number[]): { attackerLost: number; defenderLost: number; }
Parameters
| Name | Type | Description |
|---|---|---|
attack | readonly number[] | The attacker’s sorted dice results. |
defend | readonly number[] | The defender’s sorted dice results. |
Returns
{ attackerLost: number; defenderLost: number; }
WHO LOSES WHAT: the highest die of each side compared, then the next highest, as many pairs as the side with fewer dice threw. The higher die wins its pair; a tie goes to the defender. Each lost pair is one army. Both lists are highest first.
Examples
import { battleLosses } from "@johnmorrisdotca/tenka";
console.log(battleLosses([6,3,1],[4,2]));{ attackerLost: 0, defenderLost: 2 }What it prints (run when this page was built)