Skip to the content

Gunjin軍人

Play five hidden-rank games, keep setups private, share redacted views and replay, and pass one device between players.

Gunjin is the Japanese word 軍人 for a soldier. About the name

Contents

Reference · Salpakan rules

playSalpakanMovefunction

Applies a legal move action, rejecting stale turn numbers.

Import it

import { playSalpakanMove } from "@johnmorrisdotca/gunjin/salpakan";

Definition

function playSalpakanMove(match: ReturnType<typeof createMatch>, player: Player, action: MoveAction): AuthoritativeMatch

Parameters

NameTypeDescription
matchAuthoritativeMatch

The full authoritative match, held by a trusted host or the local hotseat owner.

playerPlayer

The acting player, 0 or 1; the lifecycle checks that this is the expected player.

actionMoveAction

Native source/destination coordinates and the caller’s expected turn.

Returns

AuthoritativeMatch

Applies a legal move action, rejecting stale turn numbers.

Examples

import type { MoveAction, Player } from "@johnmorrisdotca/gunjin";
import { createSalpakanMatch, playSalpakanMove, salpakanRoster, submitSalpakanSetup } from "@johnmorrisdotca/gunjin/salpakan";
import { acknowledgePass } from "@johnmorrisdotca/gunjin/stratego-lite";
import { legalMovesForCurrentPlayer } from "@johnmorrisdotca/gunjin/views";

const salHome=(player: Player)=>salpakanRoster().map((kind,i)=>({kind,x:i%9,y:player===0?7-Math.floor(i/9):Math.floor(i/9)}));
const salBase=createSalpakanMatch();
const salFirst=submitSalpakanSetup(salBase,0,salHome(0),salBase.setupStep);
let salReady=acknowledgePass(salFirst,1,salFirst.turn);
salReady=submitSalpakanSetup(salReady,1,salHome(1),salReady.setupStep);
salReady=acknowledgePass(salReady,0,salReady.turn);
const salAction: MoveAction={...legalMovesForCurrentPlayer(salReady,0)[0]!,expectedTurn:salReady.turn};
console.log(playSalpakanMove(salReady,0,salAction).phase);
pass

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/gunjin 0.2.1.