mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-19 08:14:21 +01:00
The 82-line ENEMY_SPECS table and its kind unions are data, not vocabulary -- that is the block you edit to balance the game. Moved to enemies.ts (143). statusKinds.ts (25) is not cosmetic: enemy specs name the status they inflict and the survivor carries seconds-remaining per status, so leaving StatusKind in types.ts would have made types.ts and enemies.ts mutually dependent. It imports nothing, so the graph is statusKinds <- enemies <- types. 14 files repointed by script rather than by hand, splitting each types import across the three owning modules by symbol. The tests cannot catch a mistyped stat -- they assert behaviour, not the balance table, so a wrong enemy hp passes 160 tests at 100% coverage. Checked separately: 191 numeric pairs before, 191 after, compared as sorted multisets, identical. check and build both pass; bundle 210.11 kB, same as baseline. No reverse_survivors file is over the 250-line cap now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
/**
|
|
* Shared unit vocabulary: arena geometry, the survivor's own dimensions, and
|
|
* enemy construction.
|
|
*
|
|
* This module deliberately imports nothing else from `core/` bar types and
|
|
* vectors. Everything the per-actor step modules need in common lands here, so
|
|
* the simulation's import graph stays a tree rather than the cycle it would be
|
|
* if these lived beside their callers.
|
|
*/
|
|
|
|
import type { Enemy, GameState } from './types'
|
|
import type { EnemyKind } from './enemies'
|
|
import { ARENA } from './types'
|
|
import { ENEMY_SPECS } from './enemies'
|
|
import type { Vec } from './vec'
|
|
|
|
export const SURVIVOR_RADIUS = 12
|
|
export const DANGER_RADIUS = 140
|
|
export const FIRE_RANGE = 260
|
|
export const PROJ_SPEED = 420
|
|
export const PROJ_TTL = 1.5
|
|
export const ENEMY_PROJ_TTL = 2
|
|
export const SPLIT_RADIUS = 22
|
|
export const CENTER: Vec = { x: ARENA.w / 2, y: ARENA.h / 2 }
|
|
|
|
/** Single place enemy speed is derived: difficulty and frenzy both land here. */
|
|
export const enemySpeed = (state: GameState, kind: EnemyKind, frenzyMul: number): number =>
|
|
ENEMY_SPECS[kind].speed * state.difficulty.enemySpeed * frenzyMul
|
|
|
|
export const makeEnemy = (state: GameState, kind: EnemyKind, pos: Vec): Enemy => {
|
|
const id = state.nextId
|
|
state.nextId += 1
|
|
const enemy: Enemy = {
|
|
id,
|
|
kind,
|
|
pos: { x: pos.x, y: pos.y },
|
|
hp: ENEMY_SPECS[kind].hp * state.difficulty.enemyHp,
|
|
hitTimer: 0,
|
|
fireTimer: 0,
|
|
spawnTimer: ENEMY_SPECS[kind].spawnEvery,
|
|
}
|
|
state.enemies.push(enemy)
|
|
return enemy
|
|
}
|