Reference · Rules, maps and records
tapTerritoryfunction
What tapping territory does now: a new choice, and the move to make at once, if the tap is one.
Import it
import { tapTerritory } from "@johnmorrisdotca/tenka";
Definition
function tapTerritory(game: TenkaGame, choice: TenkaChoice, territory: number): { choice: TenkaChoice; move: TenkaMove | null; }
Parameters
| Name | Type | Description |
|---|---|---|
game | TenkaGame | The current native game state. |
choice | TenkaChoice | The current user-interface selection. |
territory | number | The native territory index. |
Returns
{ choice: TenkaChoice; move: TenkaMove | null; }
The new selection and a move to apply; move is null when the tap only changes the selection.
Examples
import { startTenka, tapTerritory } from "@johnmorrisdotca/tenka";
const game = startTenka(10,["Seat 1","Seat 2"],42)!;
const choice = {from:null,to:null,armies:1,placedOn:null};
console.log(tapTerritory(game,choice,0));{
choice: { from: null, to: null, armies: 0, placedOn: 0 },
move: { kind: 'place', territory: 0, armies: 1 }
}What it prints (run when this page was built)