aboutsummaryrefslogtreecommitdiff
path: root/engine/health/mental-health.ts
blob: 2f86947f42f629d4d51dfcdc5c8f4473fd964514 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import type { GameTime } from 'time'

/** Currently-active mental-health condition. Specific disorder vocabulary
 *  lives in content; the runtime state is shape + kind tag. */
export interface MentalCondition {
  readonly id: string
  readonly kind: string
  readonly onsetAt: GameTime
  readonly severity: number
  readonly inTreatment: boolean
}

/** A condition the character has had and no longer meets active criteria for,
 *  but which still informs relapse probability and event eligibility. */
export interface HistoricalCondition {
  readonly id: string
  readonly kind: string
  readonly startedAt: GameTime
  readonly endedAt: GameTime
  readonly peakSeverity: number
  readonly inRemission: boolean
}

export interface TraumaPattern {
  readonly id: string
  readonly source: string
  readonly firstOnsetAt: GameTime
  readonly hypervigilance: number
  readonly avoidance: number
  readonly intrusions: number
}

export interface CopingStrategy {
  readonly id: string
  readonly kind: string
  readonly adaptive: boolean
  readonly reliance: number
}

export interface Medication {
  readonly id: string
  readonly name: string
  readonly startedAt: GameTime
  readonly endedAt: GameTime | null
  readonly dosage: number
  readonly effectiveness: number
}

/**
 * Hidden even from the character until crisis. The simulation knows; the
 * prose surfaces behaviour, not numbers (docs/08-mental-health.md §"Suicide").
 */
export interface SuicidalRisk {
  readonly current: number
  readonly history: readonly { readonly at: GameTime; readonly value: number }[]
  readonly lastAssessedAt: GameTime
}

export interface MentalHealthState {
  readonly activeConditions: readonly MentalCondition[]
  readonly historyOfConditions: readonly HistoricalCondition[]
  readonly traumaPatterns: readonly TraumaPattern[]
  readonly copingStrategies: readonly CopingStrategy[]
  readonly inTherapy: boolean
  readonly medication: readonly Medication[]
  readonly suicidalRisk: SuicidalRisk
}