From 3c81a8bf29a744c33355d182ec540b006447a0b0 Mon Sep 17 00:00:00 2001 From: Vishesh 'ironeagle' Bangotra Date: Mon, 1 Dec 2025 16:18:22 +0530 Subject: [PATCH] fixed package --- plugins/games/battleship.go | 2 +- plugins/games/config.go | 2 +- plugins/games/tic_tac_toe.go | 2 +- plugins/main.go | 23 ++++++++++++----------- plugins/structs/board.go | 2 +- plugins/structs/player.go | 2 +- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/plugins/games/battleship.go b/plugins/games/battleship.go index 2aa3c64..12333ba 100644 --- a/plugins/games/battleship.go +++ b/plugins/games/battleship.go @@ -1,4 +1,4 @@ -package game +package games import ( "fmt" diff --git a/plugins/games/config.go b/plugins/games/config.go index fa5c5d5..b0424d9 100644 --- a/plugins/games/config.go +++ b/plugins/games/config.go @@ -1,4 +1,4 @@ -package modules +package games type BoardConfig struct { Rows int diff --git a/plugins/games/tic_tac_toe.go b/plugins/games/tic_tac_toe.go index 0cc7a1c..5b8eeef 100644 --- a/plugins/games/tic_tac_toe.go +++ b/plugins/games/tic_tac_toe.go @@ -1,4 +1,4 @@ -package game +package games import ( "errors" diff --git a/plugins/main.go b/plugins/main.go index aabb8a9..36bae2a 100644 --- a/plugins/main.go +++ b/plugins/main.go @@ -6,7 +6,7 @@ import ( "github.com/heroiclabs/nakama-common/runtime" - // Adjust these imports to match your project structure + // Project modules "localrepo/plugins/modules" "localrepo/plugins/games" ) @@ -41,23 +41,24 @@ func InitModule( } //-------------------------------------------------------- - // 3. Register MATCHES for ALL games + // 3. Register ALL game rules for GenericMatch //-------------------------------------------------------- - // Build registry: game name → GameRules implementation - registry := map[string]game.GameRules{ - "tictactoe": &game.TicTacToeRules{}, - "battleship": &game.BattleshipRules{}, + registry := map[string]games.GameRules{ + "tictactoe": &games.TicTacToeRules{}, + "battleship": &games.BattleshipRules{}, } - // Register a Generic Match Handler that can run ANY game from registry - if err := initializer.RegisterMatch("generic", modules.NewGenericMatch(registry)); err != nil { + if err := initializer.RegisterMatch( + "generic", + modules.NewGenericMatch(registry), + ); err != nil { logger.Error("Failed to register generic match: %v", err) return err } //-------------------------------------------------------- - // 4. Register Leaderboards dynamically (optional) + // 4. Create Leaderboards //-------------------------------------------------------- leaderboards := []string{ @@ -70,11 +71,11 @@ func InitModule( for _, lb := range leaderboards { err := nk.LeaderboardCreate( ctx, - lb, // leaderboard ID + lb, true, // authoritative "desc", // sort order "incr", // operator - "", // reset schedule (none) + "", // reset schedule map[string]interface{}{}, // metadata ) diff --git a/plugins/structs/board.go b/plugins/structs/board.go index 070f05c..8607708 100644 --- a/plugins/structs/board.go +++ b/plugins/structs/board.go @@ -1,4 +1,4 @@ -package game +package structs // Board is a generic 2D grid for turn-based games. // Cell data is stored as strings, but can represent anything (piece, move, state). diff --git a/plugins/structs/player.go b/plugins/structs/player.go index 201e730..33b8dfd 100644 --- a/plugins/structs/player.go +++ b/plugins/structs/player.go @@ -1,4 +1,4 @@ -package game +package structs // Player represents a participant in the match. type Player struct {