Reference · Shizen and Arashi environments
applyPowerDropfunction
Commit a previewed landing as one immutable operation. A failed preview leaves the original state untouched.
Import it
import { applyPowerDrop } from "@johnmorrisdotca/houseki/nature";
Definition
function applyPowerDrop(state: NatureState, request: PowerDropRequest): NatureTransition
Parameters
| Name | Type | Description |
|---|---|---|
state | NatureState | The immutable native state to read or transition; the input is retained. |
request | PowerDropRequest | The native falling piece, pivot id and power/rebound choice. |
Returns
NatureTransition
Commit a previewed landing as one immutable operation. A failed preview leaves the original state untouched.
Examples
import { applyPowerDrop, createNatureState } from "@johnmorrisdotca/houseki/nature";
import type { PowerDropRequest } from "@johnmorrisdotca/houseki/nature";
const state=createNatureState({width:4,height:4,seed:"docs"});
const request:PowerDropRequest={piece:[{id:1,kind:"stone",colour:"red",x:1,y:0}],pivotId:1,power:true};
console.log(applyPowerDrop(state,request).accepted);trueWhat it prints (run when this page was built)