import type { QuerableProps } from "../queries/types.js"; import type { State } from "../state/state.js"; import { ConditionsContextBase } from "./types.js"; declare class ConditionAssertions, S extends State = Context["state"]> { /** * @asserts subject should be empty. Usable against JS primitives AND Entities. */ empty(): this; /** * @asserts that subject can't hold any more new items. Only makes sense with entities. * @example * ```ts * // Check if grid has some space available * con.entity.is.not.full() * ``` */ full(): this; /** * @asserts that container has index empty */ availableSpotAt(index: number): this; /** * @asserts that **Grid** has spot available at specified column/row */ availableSpotAt(column: number, row: number): this; /** * Compares current subject to given value, no coercion (strict equality). * @asserts that subject is equal to provided value. */ equals(value: T): this; /** * @asserts that value is exactly `true` */ true(): this; /** * @asserts that value is exactly `false` */ false(): this; /** * @asserts that subject is not undefined */ defined(): this; /** * @asserts that subject is undefined */ undefined(): this; /** * @asserts that subject is numerically above the provided value. */ above(value: number): this; /** * @asserts that subject is numerically above OR equal to the provided value. */ aboveEq(value: number): this; /** * @asserts that subject is numerically below the provided value. */ below(value: number): this; /** * @asserts that subject is numerically below or equal to the provided value. */ belowEq(value: number): this; /** * @asserts that subject is equal to one of the provided values. Coercion allowed. */ oneOf(values: any[]): this; /** * @asserts that chosen prop value matches the same prop on subject by alias * @example * ```ts * test().$.entity.its("rank").matchesPropOf("pileTop") * ``` */ matchesPropOf(refName: string): this; /** * @asserts that chosen prop value matches the same prop on other subject * @example * ```ts * const PILE_TOP = test().query({ type: "pile" }).top.grab() * test().$.entity.its("rank").matchesPropOf(PILE_TOP) * ``` */ matchesPropOf(other: unknown): this; /** * @asserts if entity can be selected. Checks if parent extends `SelectableChildrenTrait` */ selectable(): this; selected(): this; /** * @asserts that at least one item or child elements has all given properties */ someEntitiesMatchProps(props: QuerableProps): this; /** * @asserts that all items in collection OR child elements or parent match all given properties */ everyEntityMatchesProps(props: QuerableProps): this; /** * Runs given callback with current `subject` as the only argument. * @asserts if given callback returns truthy * * @example * ```ts * // Will test if target of interaction is in fact a King * test().entity.test((card: ClassicCard) => { * return card.rank === "K" * }) * ``` * * @example * ```ts * import { AssertionTester } from "@cardsgame/server" * * // More generic approach using state-defined variants data * const isAttackCard: AssertionTester = (card, { variant }) => { * return card.rank === variant.attackRank * } * * // ... * * // Will test if target of interaction is "attack card" type * test().entity.test(isAttackCard) * ``` */ test(tester: (subject: unknown, context: Context) => boolean): this; /** * **REQUIRES** `"player"` reference. * * Does current player has a specific UI element presented to him? * If `uiKey` is left empty, function will test if player * has ANY ui interface presented. * Ignores current subject and instead is based on `state` and `player`. * @asserts * @example * ```ts * // player has ANY UI revealed * con.revealedUI() * // player doesn't have ANY UI revealed * con.not.revealedUI() * // player has "rankChooser" revealed * con.revealedUI("rankChooser") * // player doesn't have "rankChooser" revealed * con.not.revealedUI("rankChooser") * ``` */ revealedUI(uiKey?: string): this; /** * **REQUIRES** `"player"` reference. * * @asserts if interacting player/bot currently has the turn. * Will also throw if current `Conditions` wasn't setup with "player" prop. */ itsPlayersTurn(): this; } export { ConditionAssertions };