Reference · Tiles, layouts and deals
canTakefunction
Whether these two slots are a pair that may be taken now.
Import it
import { canTake } from "@johnmorrisdotca/jarajara";
Definition
function canTake(geometry: MahjongGeometry, cells: MahjongCells, rule: MahjongBonusRule, a: number, b: number): boolean
Parameters
| Name | Type | Description |
|---|---|---|
geometry | MahjongGeometry | The stacked layout’s covering and side-blocking relationships. |
cells | string | The face-code string in native slot order; dot marks a removed tile. |
rule | MahjongBonusRule | Grouped or identical bonus matching. |
a | number | The first tile slot or code specified by this signature. |
b | number | The second tile slot or code specified by this signature. |
Returns
boolean
Whether these two slots are a pair that may be taken now.
Examples
import { generateAwase } from "@johnmorrisdotca/jarajara/awase";
import { canTake, freePairs, geometryOf, layoutFor } from "@johnmorrisdotca/jarajara";
const deal = generateAwase(4,"easy",2026);
const layout = layoutFor(4)!;
const geometry = geometryOf(layout);
const cells = deal.givens;
const pair = freePairs(geometry,cells,"group")[0];
console.log(canTake(geometry,cells,"group",pair[0],pair[1]));trueWhat it prints (run when this page was built)