fix(game): #59 — per-command rejection on PUT /api/v1/order #71
Reference in New Issue
Block a user
Delete Branch "feature/issue-59-invalid-order-per-command"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #59.
Summary
Controller.ValidateOrderno longer short-circuits on the first per-command*GenericError. It applies every command in the order against a transient game-state snapshot and records the outcome on each command's meta (cmdApplied,cmdErrorCode); the order is persisted with per-command verdicts and the engine returns202 + UserGamesOrderso the UI can surface partial-rejection instead ofsync failed: [unavailable] downstream service is unavailable.errorResponsemaps*GenericErrorby code shelf rather than blanket-500 (1xxx → 500/501, 2xxx → 400, 3xxx → 400). Order-level structural rejections (quitnot last command) now correctly answer 400.pkg/errorconstants are reorganised onto three documented shelves with helper predicatesIsInternalCode/IsInputCode/IsGameStateCode. Two pre-existing typos fixed (ErrBeakGroupNumberNotEnough→ErrBreakGroupNumberNotEnough,ErrRaceExinct→ErrRaceExtinct) along with all callsites.game/openapi.yamlpreamble +PUT /api/v1/orderdescription +Commandschema;docs/FUNCTIONAL.md§6.2 + Russian mirror.Test plan
go test ./...green ingame,backend,gateway,pkg/error,pkg/transcoder,pkg/modelgo vet ./...clean across all workspace modulesgame/internal/controller/order_test.gocover the issue scenario, no-short-circuit, simulated state, and structural rejectiongame/internal/router/order_test.goconfirm 202 + body for per-command rejection and 400 forErrInputQuitCommandFollowedByCommandfeature/issue-59-invalid-order-per-command(go-unit,ui-test,integration) — pendingapplied); delete A → produce-A keepscmdErrorCode != 0, rest of the order staysapplied, no blanketsync failed