Early development: IFLoom can change until 1.0. What's stable
IFLoom

@ifloom/plugin-statuses

Every export of @ifloom/plugin-statuses and its /react subpath: its signature and its fields.

Generated from the source of @ifloom/plugin-statuses and @ifloom/plugin-statuses/react and its TSDoc by npm run api-docs. Each export links to the page that explains it, where one does.

@ifloom/plugin-statuses

ActiveRecord

Type. Explained in Statuses.

The record a save keeps for one active status, in StatusesState's active. The plugin reads the status's definition from content.

import type { ActiveRecord } from '@ifloom/plugin-statuses'
type ActiveRecord = {
  id: string
  left: number[]
}
FieldTypeOptionalDefaultDescription
idstringThe status's id.
leftnumber[]The turns left on each stack, oldest stack first.

ActiveStatus

Type. Explained in Statuses.

An active status as the player sees it, in view.plugins.statuses.active.

import type { ActiveStatus } from '@ifloom/plugin-statuses'
type ActiveStatus = {
  id: string
  name: string
  description: string
  turnsLeft: number
  stacks: number
  modifiers: StatModifier[]
}
FieldTypeOptionalDefaultDescription
idstringThe status's id.
namestringThe status's name.
descriptionstringThe status's description, or '' when it has none.
turnsLeftnumberThe turns left on the status's longest stack.
stacksnumberThe number of the status's stacks still running, 1 unless it stacks.
modifiersStatModifier[]The status's changes to the stats now, all its stacks together, one entry per stat.

Reapply

Type. Explained in Statuses.

The rule for applying a status that is already active. 'refresh' starts its turns again, and 'stack' adds another stack.

import type { Reapply } from '@ifloom/plugin-statuses'
type Reapply = 'refresh' | 'stack'

StatusDef

Type. Explained in Statuses.

A timed status the game declares in data.statuses.statuses. It lasts turns turns from the turn it is applied in.

import type { StatusDef } from '@ifloom/plugin-statuses'
type StatusDef = {
  id: string
  name: string
  description?: string
  turns: number
  modifiers?: StatusModifier[]
  effects?: { start?: EffectRef[]; turn?: EffectRef[]; end?: EffectRef[] }
  reapply?: Reapply
  max?: number
}
FieldTypeOptionalDefaultDescription
idstringThe status's id.
namestringThe status's name, such as "Caffeinated".
descriptionstringyesThe status's description, a line for the UI to show.
turnsnumberThe number of turns the status lasts, counting the end of the turn it was applied in.
modifiersStatusModifier[]yesThe status's changes to the player's stats while it lasts, per stack. The plugin never writes them to the stats.
effects{ start?: EffectRef[]; turn?: EffectRef[]; end?: EffectRef[] }yesThe status's effects as it runs. start runs as the status starts, turn once per stack at the end of each turn, and end once per stack that runs out. start also runs for each stack added, but not for a refresh or a stack that replaces the oldest at max. The turn effects run before the status's turns go down.
reapplyReapplyyesThe rule for applying the status again while it is active. 'refresh' if left out.
maxnumberyesThe most stacks the status can have, with reapply: 'stack'. A new stack past it replaces the oldest, and there is no limit if left out.

statuses

Function. Explained in Statuses.

The statuses plugin's factory, with its helpers as properties. statuses() returns the plugin for the game's plugins, and content calls helpers such as statuses.apply('caffeinated').

import { statuses } from '@ifloom/plugin-statuses'
function statuses(): DefinedPlugin<StatusesState, StatusesView>

Uses: DefinedPlugin, StatusesState, StatusesView.

HelperSignatureDescription
statuses.active(id: string, stacks?: Range): ConditionReturns the statuses/active condition, which holds while the status is active, with a number of stacks in the range if given.
statuses.apply(id: string): EffectRefReturns the statuses/apply effect, which starts the status, or refreshes or stacks it if it's already active.
statuses.remove(id: string, runEnd?: boolean): EffectRefReturns the statuses/remove effect, which takes every stack of the status off, running its end effects with runEnd.

statusesOf

Function. Explained in Statuses.

Returns the game's timed statuses, from data.statuses.statuses in its content and packs.

import { statusesOf } from '@ifloom/plugin-statuses'
function statusesOf(game: Game): StatusDef[]

Uses: Game, StatusDef.

StatusesState

Type. Explained in Statuses.

The active statuses a save keeps for the player. The plugin reads each status's definition from content.

import type { StatusesState } from '@ifloom/plugin-statuses'
type StatusesState = {
  active: ActiveRecord[]
}
FieldTypeOptionalDefaultDescription
activeActiveRecord[]The active statuses, in the order they were first applied.

StatusesView

Type. Explained in Statuses.

The active statuses as the player sees them, in view.plugins.statuses.

import type { StatusesView } from '@ifloom/plugin-statuses'
type StatusesView = {
  active: ActiveStatus[]
}
FieldTypeOptionalDefaultDescription
activeActiveStatus[]The active statuses, in the order they were first applied.

StatusModifier

Type. Explained in Statuses.

A change a status makes to the value one of the player's stats reads, per stack.

import type { StatusModifier } from '@ifloom/plugin-statuses'
type StatusModifier = {

  // …
}

Plugins add fields of their own to it, which their pages list.

statusOf

Function. Explained in Statuses.

Returns the status with this id, or undefined when the game has none.

import { statusOf } from '@ifloom/plugin-statuses'
function statusOf(game: Game, id: string): StatusDef | undefined

Uses: Game, StatusDef.

@ifloom/plugin-statuses/react

STATUSES_WORDS

Const. Explained in Statuses.

The statuses plugin's UI words, in English. A game rewords any of them with ui.<key> in its strings.

import { STATUSES_WORDS } from '@ifloom/plugin-statuses/react'
const STATUSES_WORDS: {
  modifierAdd: '{n} {stat}'
  modifierMultiply: '×{n} {stat}'
  statusStacks: '×{n}'
  statuses: 'Statuses'
  turnLeft: '1 turn left'
  turnsLeft: '{n} turns left'
}
FieldTypeOptionalDefaultDescription
modifierAdd'{n} {stat}'The line for a modifier that adds to a stat, with the signed {n} and the {stat}.
modifierMultiply'×{n} {stat}'The line for a modifier that multiplies a stat, with {n} and the {stat}.
statusStacks'×{n}'The badge on a status with more than one stack, with {n}.
statuses'Statuses'The title of the status list.
turnLeft'1 turn left'The line on a status with one turn left.
turnsLeft'{n} turns left'The line on a status with {n} turns left.

statusesUi

Const. Explained in Statuses.

The statuses plugin's React UI, for plugins on mountGame or GameProvider. It renders the StatusList under the stats in the sidebar and as the statuses panel, and adds the plugin's words.

import { statusesUi } from '@ifloom/plugin-statuses/react'
const statusesUi: PluginUi

Uses: PluginUi.

StatusList

Const. Explained in Statuses.

Renders the active statuses from view.plugins.statuses.active, each with its name, stacks, turns left, description and changes to the stats. It renders nothing while no status is active or without the plugin.

A preset can style the parts statuses, statuses-title, status, status-label, status-stacks, status-turns, status-summary and status-modifiers.

import { StatusList } from '@ifloom/plugin-statuses/react'
const StatusList: ComponentType<{ className?: string; title?: string | false; }>

useStatuses

Function. Explained in Statuses.

Returns the statuses plugin's view from the running game, or null in a game without the plugin. It re-renders when the view changes.

import { useStatuses } from '@ifloom/plugin-statuses/react'
function useStatuses(): StatusesView | null

Uses: StatusesView.

Last updated on

On this page