fixed package

This commit is contained in:
2025-12-01 16:18:22 +05:30
parent d9c3ecb252
commit 3c81a8bf29
6 changed files with 17 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
package game
package games
import (
"fmt"

View File

@@ -1,4 +1,4 @@
package modules
package games
type BoardConfig struct {
Rows int

View File

@@ -1,4 +1,4 @@
package game
package games
import (
"errors"

View File

@@ -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
)

View File

@@ -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).

View File

@@ -1,4 +1,4 @@
package game
package structs
// Player represents a participant in the match.
type Player struct {