Skip to content

feat: add city-wide troop training pipelines - #24

Merged
prayujt merged 3 commits into
mainfrom
feat/city-training-pipeline
Aug 24, 2026
Merged

prayujt merged 3 commits into
mainfrom
feat/city-training-pipeline

Conversation

@prayujt

@prayujt prayujt commented Aug 24, 2026 •

Copy link
Copy Markdown
Collaborator

Outcome

Moves troop training from independent barracks queues to one durable FIFO pipeline per city. Completed barracks process that pipeline in parallel and spawn each finished army at the barracks lane that trained it.

It also makes active combat readable in real time and introduces durable, player-editable army names.

What changed

  • Makes the city actor authoritative for queue ownership, resource reservation, FIFO assignment, completion, and cancellation.
  • Reserves gold and population when an order enters the queue.
  • Allows only unstarted orders to be cancelled, with a full refund of their recorded gold and population costs.
  • Gives every completed barracks one active lane; idle lanes atomically claim the oldest waiting batch.
  • Uses barracks level as a lane-speed modifier: 1.0x at level 1, then +0.2x per level through 2.8x at level 10.
  • Blocks barracks upgrade/demolition only while that specific barracks has active work.
  • Migrates durable orders to city ownership with optional barracks assignment and database constraints for one active order per barracks.
  • Changes training RPCs to use city IDs, adds CancelTrainingOrder, exposes authoritative order costs, and exposes barracks training speed through game config.
  • Updates the development helper and backend architecture/API documentation.

Combat visibility and balance

  • Exposes cumulative and latest-round troop, militia, and civilian casualties for both sides while a battle is active.
  • Includes completed-round counts and live friendly starting/surviving strength.
  • Keeps opposing starting strength, surviving strength, militia totals, and combat power concealed unless existing disclosure rules allow them.
  • Applies the same casualty disclosure to durable mailbox reports so losses remain reviewable offline.
  • Uses a 1.0 military casualty multiplier while retaining the five-second battle cadence.
  • Derives siege civilian collateral from actual army and militia losses at 0.15 civilian casualties per military casualty, with fractional carry.
  • Preserves at least 30% of the settlement normal 55% core-civilian allocation.
  • Keeps field battles free of civilian casualties.

Army names

  • Persists an army name on every army and snapshots it into battle reports.
  • Defaults generated armies to Army plus the first eight characters of their UUID.
  • Adds an owner-only RenameArmy RPC.
  • Trims names, rejects blanks/control characters, and limits them to 32 characters.
  • Enforces case-insensitive uniqueness per owner in PostgreSQL and maps collisions to AlreadyExists.
  • Streams successful renames immediately.

Compatibility

This intentionally changes unreleased proto and persistence contracts. The matching UI/client work is in web PR #19.

Verification

  • go test ./...
  • go build ./...
  • go vet ./...
  • buf lint
  • goose migration validation
  • clean migration up → down-to-zero → up round trip
  • case-insensitive duplicate-name constraint check

Move durable FIFO ownership to cities while barracks operate parallel speed-scaled lanes. Reserve costs on placement and support full refunds for unstarted cancellations.
Scale collateral losses from actual army and militia casualties at a moderate rate, and preserve at least thirty percent of the settlement core population.
Expose public per-round and cumulative casualties while keeping undisclosed force strength private. Raise the military casualty multiplier to 1.0 and include thorough live battle summaries. Persist owner-unique army names, assign generated defaults, and add an owner-only rename RPC.
@prayujt
prayujt merged commit de6e389 into main Aug 24, 2026
2 checks passed
@prayujt
prayujt deleted the feat/city-training-pipeline branch August 24, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant