Skip to the content

Tenka天下

Play seeded world conquest for two to six, with dice battles, cards, computer players and saved games.

Tenka means the world under heaven in Japanese. About the name

Contents

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

NameTypeDescription
attackreadonly number[]

The attacker’s sorted dice results.

defendreadonly 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)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/tenka 2.2.0.