Reference · Rules, tiles and records
swapWithHandfunction
A tile from the hand onto a square that holds one: they change places, the table's tile going to the hand where the other was.
Import it
import { swapWithHand } from "@johnmorrisdotca/kumimoji";
Definition
function swapWithHand(play: TilePlay, handAt: number, square: string): TilePlay
Parameters
| Name | Type | Description |
|---|---|---|
play | TilePlay | The current immutable solo-game progress. |
handAt | number | The zero-based index of a tile in hand. |
square | string | The row,column square name. |
Returns
TilePlay
A tile from the hand onto a square that holds one: they change places, the table's tile going to the hand where the other was.
Examples
import { deal, placeFromHand, swapWithHand } from "@johnmorrisdotca/kumimoji";
const laid = placeFromHand(deal("catdog",3),0,"0,0");
console.log(swapWithHand(laid,0,"0,0").hand);[ 'c', 't' ]What it prints (run when this page was built)