feat(battleship): add full placement/battle phases + metadata support + action-based moves

- Added Battleship Fleet definition (carrier, battleship, cruiser, submarine, destroyer)
- Implemented action-based MovePayload (`action: "place" | "shoot"`)
- Added placement and shot validation (ValidatePlacementMove, ValidateShotMove)
- Added ApplyPlacement and ApplyShot with correct ship placement + hit/miss logic
- Added pX_placed, pX_ready tracking and phase switching (placement → battle)
- Added Metadata field to MatchState (for phase/ready tracking)
- Updated MatchInit to initialize placement phase and readiness flags
- Updated MatchLoop to enforce turn order only during battle phase
- Added debug logging for state broadcasts
- Fixed protobuf dependency marking as indirect
This commit is contained in:
2025-12-03 21:00:38 +05:30
parent 10c7933aca
commit 0562d1e0c9
4 changed files with 165 additions and 10 deletions

View File

@@ -2,9 +2,10 @@ package structs
// MatchState holds the full game session state.
type MatchState struct {
Players []*Player `json:"players"`
Boards map[string]*Board `json:"boards"` // Multiple named boards:
Turn int `json:"turn"` // index in Players[]
Winner int `json:"winner"` // -1 = none, >=0 = winner index
GameOver bool `json:"game_over"` // true when the match ends
Players []*Player `json:"players"`
Boards map[string]*Board `json:"boards"` // Multiple named boards:
Turn int `json:"turn"` // index in Players[]
Winner int `json:"winner"` // -1 = none, >=0 = winner index
GameOver bool `json:"game_over"` // true when the match ends
Metadata map[string]interface{} `json:metadata` // metadata
}