movePiece関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Slides a piece one step, or in checkers a step or a capture. Illegal moves return the state unchanged.
インポート
import { movePiece } from "@johnmorrisdotca/narabe";
定義
function movePiece(state: GameState, from: Point, to: Point): GameState
引数
| 名前 | 型 | 説明 |
|---|---|---|
state | GameState | The current immutable game position. |
from | Point | The source point of the group or moving piece. |
to | Point | The destination point of the moving piece. |
戻り値
GameState
The resulting position; a refused or inapplicable action leaves the input position unchanged.
例
import { createGame, movePiece } from "@johnmorrisdotca/narabe";
const checkers = createGame({variant:"checkers"});
console.log(movePiece(checkers,{row:5,col:0},{row:4,col:1}).moves.length);0出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。