mirror of
https://github.com/HexCardGames/HexDeck.git
synced 2025-09-03 18:48:38 +02:00
40 lines
696 B
Go
40 lines
696 B
Go
package main
|
|
|
|
import (
|
|
"log/slog"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/HexCardGames/HexDeck/api"
|
|
"github.com/HexCardGames/HexDeck/db"
|
|
"github.com/HexCardGames/HexDeck/game"
|
|
"github.com/HexCardGames/HexDeck/utils"
|
|
)
|
|
|
|
func main() {
|
|
logHandler := slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
|
|
Level: slog.LevelDebug,
|
|
})
|
|
slog.SetDefault(slog.New(logHandler))
|
|
|
|
mongoUri := utils.Getenv("MONGO_URI", "")
|
|
if mongoUri == "" {
|
|
slog.Error("MONGO_URI environment variable not set!")
|
|
return
|
|
}
|
|
db.InitDB(mongoUri)
|
|
game.LoadRooms()
|
|
|
|
roomTicker := time.NewTicker(1 * time.Second)
|
|
go func() {
|
|
for {
|
|
select {
|
|
case <-roomTicker.C:
|
|
game.TickRooms(1000)
|
|
}
|
|
}
|
|
}()
|
|
|
|
api.InitApi()
|
|
}
|