fixed package
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package game
|
||||
package games
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package modules
|
||||
package games
|
||||
|
||||
type BoardConfig struct {
|
||||
Rows int
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package game
|
||||
package games
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package game
|
||||
package structs
|
||||
|
||||
// Player represents a participant in the match.
|
||||
type Player struct {
|
||||
|
||||
Reference in New Issue
Block a user