aboutsummaryrefslogtreecommitdiff
path: root/engine/entities/world.ts
blob: 45cb4016f846abda6972f27486b7c63367fbc829 (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
import type { GameTime } from '@hollowdark/time'
import type { PersonId, PlaceId, WorldEventId, WorldId } from './base'
import type { ScheduledEvent } from './scheduled-event'

/**
 * Macro economic state tracked at the world scale. Individual characters'
 * economics are derived against this background (docs/09-economy.md
 * §"Macro economy").
 */
export interface MacroEconomicState {
  readonly inflationAnnual: number
  readonly employmentRate: number
  readonly marketIndex: number
  readonly recessionDepth: number
}

export interface RegionPoliticalState {
  readonly stability: number
  readonly currentRegime: string
  readonly tensions: readonly string[]
}

export interface WorldSettings {
  readonly contentVersionAtCreation: string
  readonly schemaVersion: number
}

export interface CrisisState {
  readonly active: boolean
  readonly crisisEventId: string | null
  readonly sceneIndex: number
  readonly startedAt: GameTime | null
}

/**
 * The world container. One continuous world per player (ARCHITECTURE.md §16,
 * docs/16-world-continuity.md). Time in this world never resets once
 * created; successive player characters advance it forward.
 */
export interface World {
  readonly id: WorldId
  readonly seed: string
  readonly createdAt: string // ISO timestamp, real-world clock — not a GameTime

  readonly currentGameTime: GameTime

  readonly currentPlayerCharacterId: PersonId | null
  readonly playedCharacterIds: readonly PersonId[]

  readonly tierOneIds: readonly PersonId[]
  readonly tierTwoIds: readonly PersonId[]

  readonly economy: MacroEconomicState
  readonly politicsByRegion: ReadonlyMap<PlaceId, RegionPoliticalState>

  readonly activeEventIds: readonly WorldEventId[]
  readonly scheduledEvents: readonly ScheduledEvent[]

  readonly crisisState: CrisisState

  readonly settings: WorldSettings
}