Commit Graph

12 Commits

Author SHA1 Message Date
Ilia Denisov af30846091 fix(game): #59 — per-command rejection on PUT /api/v1/order
Tests · Go / test (push) Successful in 2m2s
Tests · Go / test (pull_request) Successful in 3m3s
Tests · Integration / integration (pull_request) Successful in 1m40s
Validation of a player's order now applies every command against a
transient game-state snapshot and records the per-command outcome
(cmdApplied, cmdErrorCode) in each command's meta. The order is
persisted even when some commands are rejected, and the response is
202 + UserGamesOrder so clients can surface the partial failure
without the chain collapsing into "downstream service is unavailable".

Pkg/error consts are reshelved onto three explicit ranges with a
package doc and helpers (IsInternalCode/IsInputCode/IsGameStateCode):
1xxx internal/server (500/501), 2xxx structural input (400), 3xxx
game-state per-command rejection (400 when escaping HTTP, otherwise
recorded as cmdErrorCode). Two pre-existing typos fixed mechanically
(ErrBeakGroupNumberNotEnough -> ErrBreakGroupNumberNotEnough,
ErrRaceExinct -> ErrRaceExtinct) along with all callsites.

Engine errorResponse maps *GenericError by shelf rather than mapping
everything to 500. The Quit-not-last structural check in
Controller.ValidateOrder is preserved and its type assertion fixed
(was a value assertion against a pointer-typed command, so the check
silently never fired).

Backend, gateway and UI are unchanged — they were already correct on
the 202 path; only the engine collapsing per-command rejection into
500 was needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 09:36:29 +02:00
Ilia Denisov 3f1776aa5f loader revisited 2026-03-16 19:52:02 +02:00
IliaDenisov dabe1f091a chore: re-package 2026-03-10 15:46:18 +02:00
Ilia Denisov 269de2184c chore: refactor structure 2025-11-21 21:40:15 +03:00
Ilia Denisov 33efa86065 cmd: merge ship types 2025-10-02 23:22:44 +03:00
Ilia Denisov cafdd10bab refactor: race index by name 2025-10-02 22:41:04 +03:00
Ilia Denisov 0890bf3009 cmd: planet production 2025-10-02 02:05:00 +03:00
Ilia Denisov 8a7e2f57c7 cmd: rename planet 2025-10-01 22:42:23 +03:00
Ilia Denisov 2295840efe cmd: create/delete science 2025-10-01 14:30:36 +03:00
Ilia Denisov bcab29a47f cmd: delete ship type 2025-10-01 00:29:25 +03:00
Ilia Denisov 6f29288096 cmd: create ship type 2025-09-30 23:40:50 +03:00
Ilia Denisov 128d6862a7 Ally/War commands 2025-09-28 22:43:27 +03:00