Skip to main content

Game Types and Constants Reference

This page is a reference for key types, commands, configuration constants, and AuthService methods used in the game application.

Player and Lane IDs

Source: libs/game/config/src/lib/types.ts

TypeValues
PlayerId'player', 'npc-1', 'npc-2', 'npc-3'
LaneIdSame as PlayerId — each player owns one lane
PhaseKind'preparation', 'combat', 'game-over'

Match Commands

Source: libs/game/core/src/lib/api/types.ts

Send commands via dispatch(state, command).

Command typeRequired fieldsWhen to use
set-move-targetplayerId, pointMove the player avatar
request-plot-actionplayerId, actionQueue a plot action (build, upgrade, sell…)
clear-plot-actionplayerIdCancel all queued actions
move-plot-actionplayerId, actionId, directionReorder the action queue
remove-plot-actionplayerId, actionIdRemove one queued action
purchase-send-packageplayerId, plotId, targetPlayerIdsSend enemies to other players
set-preparation-readyplayerId, readyMark player as ready to start combat
build-tower-atplayerId, towerFamilyId, positionNPC direct build (bypasses plot queue)
build-send-structure-atplayerId, positionNPC direct send structure build

Plot Action Kinds

Source: libs/game/core/src/lib/api/types.ts (PlotActionRequest)

KindDescription
build-towerPlace a new tower family on an empty tower plot
branch-towerUnlock a variant for an existing tower
upgrade-tower-statUpgrade one stat (damage, attackSpeed, range, splashRadius, projectileSpeed, income)
relocate-towerMove a tower to a new position
sell-towerSell tower for sellRefundRate of total cost
build-send-structurePlace a send structure on a send plot
upgrade-send-statUpgrade enemy health, armor, or speed

MatchSnapshot Shape

getSnapshot(state) returns a MatchSnapshot every frame.

MatchSnapshot
├── seed, debug, nowMs
├── phase: { kind, round, remainingMs, readyPlayerIds }
├── alivePlayerIds, aliveNpcIds
├── players: Record<PlayerId, PlayerSnapshot>
│ ├── gold, coreHealth, alive, kills
│ ├── passiveIncomePerRound
│ ├── sendUpgrades: { health, armor, speed }
│ └── builderQueue: BuilderQueueItemSnapshot[]
└── lanes: Record<LaneId, LaneSnapshot>
├── plots: PlotSnapshot[] ← structures live here
├── enemies: EnemySnapshot[]
├── projectiles: ProjectileSnapshot[]
└── avatar: AvatarSnapshot

CreateSoloMatchOptions

Passed to createSoloMatch(options):

FieldTypeRequiredNotes
playerDeckIdDeckIdID of the deck the player selected
seednumberRNG seed, auto-generated if omitted
debugbooleanEnables debug overlay and extra logging
startingRoundnumberSkip to a specific round (requires debug=true)

Balance Constants (SOLO_MATCH_CONFIG.balance)

Source: libs/game/config/src/lib/match-config.ts

ConstantValueNotes
startingGold400Gold at match start
coreHealth200HP of the player's core
prepPhaseMs20 000Max prep phase duration
buildChannelMs1 500Channel time for placing a tower
branchUpgradeChannelMs2 000Channel time for branching a variant
statUpgradeChannelMs1 000Channel time for stat upgrades
sellRefundRate0.75Fraction of total cost returned on sell
relocateBaseCost100Minimum gold cost for relocation
waveHealthScale1.15Enemy HP multiplier per round
waveSpeedScale1.02Enemy speed multiplier per round

Grid Constants

Source: libs/game/config/src/lib/grid.ts

ConstantValueNotes
SOLO_GRID_CELL_SIZE50World-space pixels per grid cell

Buildings occupy a 2×2 footprint (100×100 world units).

Camera Constants (SOLO_MATCH_CONFIG.camera)

FieldValueNotes
defaultZoom1Starting zoom level
minZoom0.85Minimum zoom out
maxZoom1.2Maximum zoom in
edgePanSpeed0.72World units per ms during edge pan

AuthService Public API

Source: apps/game/src/app/auth/auth.service.ts

MethodReturnsNotes
checkSession(forceFresh?)Promise<void>Pass true to bypass cookie cache
clearSession()voidResets isLoggedIn and user to empty state
login(email, password)Promise<{ data, error }>Updates isLoggedIn and user signals
register(name, nickname, email, password)Promise<{ data, error }>Sends verification email on success
logout()Promise<void>Clears signals
forgotPassword(email)Promise<{ data, error }>Sends password reset email
resetPassword(newPassword, token?)Promise<{ data, error }>Completes reset from email link
requestProfileChange(name, nickname)Promise<{ data, error }>Starts confirmed profile change
requestEmailChange(newEmail)Promise<{ data, error }>Starts two-step email change
requestPasswordChange(currentPassword, newPassword)Promise<{ data, error }>Starts confirmed password change
confirmAccountChange(token)Promise<{ data, error }>Applies any pending change
Blocked Methods

These two methods exist in AuthService but call Better Auth endpoints that the API blocks:

  • changeEmail(newEmail, callbackURL?) — calls /api/auth/change-email → blocked, returns CONFIRMATION_REQUIRED
  • changePassword(newPassword, currentPassword) — calls /api/auth/change-password → blocked, returns CONFIRMATION_REQUIRED

Do not use them. Use requestEmailChange and requestPasswordChange instead.

Signals:

SignalTypeNotes
isLoggedInSignal<boolean>true when a session exists
userSignal<User | null>Authenticated user data

User Interface

interface User {
id: string;
email: string;
name: string;
nickname: string;
emailVerified: boolean;
}