2 Commits

Author SHA1 Message Date
3eadb49a72 feat(games): unify ApplyMove signatures + remove unused player conversion
Updated TicTacToeRules and BattleshipRules to implement ApplyMove(state, playerIdx, payload) (bool, bool, int) as required by GameRules.

Added win/draw resolution logic directly inside each game’s ApplyMove return.

Removed obsolete convertToGamePlayers helper.

Updated GenericMatch to call AssignPlayerSymbols with []*structs.Player directly.

Ensured all rule implementations now fully satisfy the GameRules interface.
2025-12-01 17:02:57 +05:30
d9c3ecb252 refactor(server): move shared game logic into games/ and introduce GameConfig system
- Moved common/game.go → plugins/games/rules.go
  - Contains GameRules interface, MovePayload, Player abstraction
  - Centralizes all reusable game rule contract logic

- Added plugins/games/config.go
  - Introduces GameConfiguration struct (players, board size, etc.)
  - Added global GameConfig and RulesRegistry maps
  - Each game (tictactoe, battleship, etc.) now registers its config + rules

- Updated generic_match.go to use:
  - GameConfig for board/players initialization
  - RulesRegistry for rule lookup during MatchInit
  - Removed hardcoded TicTacToe behavior
  - Clean error returns when game param missing or invalid

- Updated folder structure:
    /plugins/
        /games
            rules.go       (formerly common/game.go)
            config.go
            tictactoe.go
            battleship.go
        /structs
        /modules
        main.go

- Ensures GenericMatch pulls:
    m.GameName, m.Mode, m.Config, m.Rules
  directly from config/registry at MatchInit

- Removes old duplicated logic and simplifies how games are registered
2025-12-01 16:05:53 +05:30