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

@ifloom/plugin-quests

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

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

@ifloom/plugin-quests

advance

Function. Explained in Quests.

Returns the quests record brought up to date with the game state. It never takes progress back.

import { advance } from '@ifloom/plugin-quests'
function advance(record: QuestsState, state: GameState, game: Game): QuestsState

Uses: QuestsState, GameState, Game.

QuestDef

Type. Explained in Quests.

A quest the game declares in data.quests.quests. It needs at least one stage.

import type { QuestDef } from '@ifloom/plugin-quests'
type QuestDef = {
  id: string
  name: string
  description?: string
  storyline?: string
  starts?: Condition
  secret?: boolean
  stages: QuestStage[]
}
FieldTypeOptionalDefaultDescription
idstringThe quest's id.
namestringThe quest's name, such as "Find your feet".
descriptionstringyesThe quest's line or two for the quest list.
storylinestringyesThe id of the storyline the quest belongs to, for a UI that groups quests by storyline.
startsConditionyesThe condition that starts the quest the first time it holds. Without it, only the quests/start effect starts the quest.
secretbooleanyesTrue to leave the quest out of the count of quests to find until it starts.
stagesQuestStage[]The quest's stages, in order. The quest is done when the last stage is.

QuestEntry

Type. Explained in Quests.

A started quest as the player sees it, in view.plugins.quests.active and done.

import type { QuestEntry } from '@ifloom/plugin-quests'
type QuestEntry = {
  id: string
  name: string
  description: string
  storyline: string | null
  hint: string
  stage: number
  stages: number
  startedOn: number
  doneOn: number | null
  tracked: boolean
  updated: boolean
  track: RenderedChoice | null
}
FieldTypeOptionalDefaultDescription
idstringThe quest's id.
namestringThe quest's name.
descriptionstringThe quest's description, or '' when it has none.
storylinestring | nullThe id of the quest's storyline, for a UI that groups quests by storyline, or null.
hintstringThe hint for the stage the player is on, or '' once the quest is done.
stagenumberThe number of the quest's stages done.
stagesnumberThe number of the quest's stages.
startedOnnumberThe turn the quest started on.
doneOnnumber | nullThe turn the quest was done on, or null while it isn't.
trackedbooleanTrue when the player tracks this quest.
updatedbooleanTrue when the quest has started or moved on since the player last looked.
trackRenderedChoice | nullThe button that tracks the quest, or stops tracking it once tracked, or null once the quest is done. Its label is the quests/track or quests/untrack string.

questOf

Function. Explained in Quests.

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

import { questOf } from '@ifloom/plugin-quests'
function questOf(game: Game, id: string): QuestDef | undefined

Uses: Game, QuestDef.

quests

Function. Explained in Quests.

The quests plugin's factory, with its helpers as properties. quests() returns the plugin for the game's plugins, and content calls helpers such as quests.done('bread').

import { quests } from '@ifloom/plugin-quests'
function quests(): DefinedPlugin<QuestsState, QuestsView>

Uses: DefinedPlugin, QuestsState, QuestsView.

HelperSignatureDescription
quests.active(quest: string): ConditionReturns the quests/active condition, which holds while the quest is started and not finished.
quests.done(quest: string): ConditionReturns the quests/done condition, which holds once the quest is finished.
quests.reached(quest: string, stage: string): ConditionReturns the quests/reached condition, which holds once this stage of the quest is done.
quests.start(quest: string): EffectRefReturns the quests/start effect, which starts the quest now if it hasn't started.
quests.track(quest?: string): CommandRefReturns the quests/track command, which tracks the quest, or stops tracking with no argument.
quests.seen(quest?: string): CommandRefReturns the quests/seen command, which marks the quest's news seen, or every quest's with no argument.

questsOf

Function. Explained in Quests.

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

import { questsOf } from '@ifloom/plugin-quests'
function questsOf(game: Game): QuestDef[]

Uses: Game, QuestDef.

QuestsState

Type. Explained in Quests.

The quests a save keeps for the player, their progress, tracking and news. The plugin reads the quests from content.

import type { QuestsState } from '@ifloom/plugin-quests'
type QuestsState = {
  started: Record<string, number>
  reached: Record<string, number>
  done: Record<string, number>
  tracked: string | null
  seen: Record<string, number>
}
FieldTypeOptionalDefaultDescription
startedRecord<string, number>The turn each started quest started on, by quest id.
reachedRecord<string, number>The number of stages done in each started quest, by quest id.
doneRecord<string, number>The turn each finished quest finished on, by quest id.
trackedstring | nullThe id of the quest the player tracks, or null.
seenRecord<string, number>Each quest's progress when the player last looked at it, by quest id. It counts the stages done, plus one once the quest is finished.

QuestStage

Type. Explained in Quests.

A stage the game declares in a QuestDef's stages. The stage is done the first time its done holds after the stages before it.

import type { QuestStage } from '@ifloom/plugin-quests'
type QuestStage = {
  id: string
  hint: string
  done: Condition
}
FieldTypeOptionalDefaultDescription
idstringThe stage's id, unique within its quest.
hintstringThe stage's hint, which the player reads while on this stage.
doneConditionThe condition that marks the stage done, the first time it holds once the stages before it are done.

QuestsView

Type. Explained in Quests.

The quests as the player sees them, in view.plugins.quests.

import type { QuestsView } from '@ifloom/plugin-quests'
type QuestsView = {
  active: QuestEntry[]
  done: QuestEntry[]
  toFind: number
  updates: number
  seen: RenderedChoice | null
}
FieldTypeOptionalDefaultDescription
activeQuestEntry[]The quests started and not finished, the tracked one first and then the newest first.
doneQuestEntry[]The finished quests, the most recent first.
toFindnumberThe number of quests not started yet, secret ones left out.
updatesnumberThe number of quests with news the player hasn't looked at, for a badge.
seenRenderedChoice | nullThe button that marks every quest's news seen, labelled with the quests/allSeen string (Mark all seen), or null while there is none.

@ifloom/plugin-quests/react

QuestLog

Const. Explained in Quests.

Renders the quest log from view.plugins.quests, the active quests with their hints and track buttons, then the finished ones. title sets the heading, such as "Journal", and title={false} leaves it off.

A preset can style the parts quests, quests-title, quest, quest-title, quest-summary, quest-hint, quest-stage, quests-done and quest-done.

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

QUESTS_WORDS

Const. Explained in Quests.

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

import { QUESTS_WORDS } from '@ifloom/plugin-quests/react'
const QUESTS_WORDS: {
  questNew: 'New'
  questStage: '{stage} of {stages}'
  quests: 'Quests'
}
FieldTypeOptionalDefaultDescription
questNew'New'The badge on a quest that has changed since the player last looked.
questStage'{stage} of {stages}'The count of a quest's stages done, with {stage} and {stages}.
quests'Quests'The title of the quest log and its section.

QuestsControls

Type. Explained in Quests.

The quests plugin's view with a function that tracks any quest, as useQuests returns it.

import type { QuestsControls } from '@ifloom/plugin-quests/react'
type QuestsControls = {
  active: QuestEntry[]
  done: QuestEntry[]
  toFind: number
  updates: number
  seen: RenderedChoice | null
  track: (id: string | null) => Result<GameState>
}
FieldTypeOptionalDefaultDescription
activeQuestEntry[]The quests started and not finished, the tracked one first and then the newest first.
doneQuestEntry[]The finished quests, the most recent first.
toFindnumberThe number of quests not started yet, secret ones left out.
updatesnumberThe number of quests with news the player hasn't looked at, for a badge.
seenRenderedChoice | nullThe button that marks every quest's news seen, labelled with the quests/allSeen string (Mark all seen), or null while there is none.
track(id: string | null) => Result<GameState>Sends quests/track for the quest with this id, or stops tracking with null. Each quest's track button does the same for that quest.

QuestsSection

Component. Explained in Quests.

Renders the default layout's Quests section, a button with the count of news from view.plugins.quests.updates that opens the QuestLog in a dialog.

import { QuestsSection } from '@ifloom/plugin-quests/react'
function QuestsSection(): JSX.Element

questsUi

Const. Explained in Quests.

The quests plugin's React UI, for plugins on mountGame or GameProvider. It adds the QuestsSection to the sidebar, renders the quests panel as a QuestLog, and adds the plugin's words.

import { questsUi } from '@ifloom/plugin-quests/react'
const questsUi: PluginUi

Uses: PluginUi.

useQuests

Function. Explained in Quests.

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

import { useQuests } from '@ifloom/plugin-quests/react'
function useQuests(): QuestsControls | null

Uses: QuestsControls.

Last updated on

On this page