Skip to content

npc.ts: split the brain-flight half from the behaviour half #4

Description

@cgreening

src/game/npc.ts is 945 lines holding two things: what an NPC decides
(role behaviour, targeting, trader phases) and how it flies (brainFly,
packmates, speedFloor, the brain rate constants).

The flight half is roughly 150 lines and has a clean conceptual boundary —
decide vs act — which the rest of the codebase already draws elsewhere
(FlightDemand for the player, world-step.ts for the phases).

Note before starting: brainFly and friends are methods using this
heavily, so extraction means either free functions over an NpcShip or a named
interface for the fields they touch. The second is what worked for the combat
trainer's ExerciseVerbs, and it made the surface readable rather than just
shorter.

This would land npc.ts near 790 — still over the 400 ceiling, so it stays an
allowlist entry either way. Worth doing for the boundary, not for the number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions