@@ -29,6 +29,8 @@ type GameState struct {
2929}
3030
3131var gameStates = make ([]GameState , 7 )
32+ var LOBBY_ENDPOINT_UPSERT string
33+ var UpdateLobby bool
3234
3335type GameTable struct {
3436 Table string `json:"t"`
@@ -45,8 +47,8 @@ var tables = []GameTable{
4547 {Table : "ai3" , Name : "AI Room - 3 bots" , CurPlayers : 0 , MaxPlayers : 6 , maxBots : 3 , Status : 0 },
4648 {Table : "ai4" , Name : "AI Room - 4 bots" , CurPlayers : 0 , MaxPlayers : 6 , maxBots : 4 , Status : 0 },
4749 {Table : "ai5" , Name : "AI Room - 5 bots" , CurPlayers : 0 , MaxPlayers : 6 , maxBots : 5 , Status : 0 },
48- {Table : "river" , Name : "The River" , CurPlayers : 0 , MaxPlayers : 6 , maxBots : 0 , Status : 0 },
49- {Table : "cave" , Name : "Cave of Caerbannog" , CurPlayers : 0 , MaxPlayers : 6 , maxBots : 0 , Status : 0 },
50+ {Table : "river" , Name : "The River" , CurPlayers : 0 , MaxPlayers : 6 , maxBots : 5 , Status : 0 },
51+ {Table : "cave" , Name : "Cave of Caerbannog" , CurPlayers : 0 , MaxPlayers : 6 , maxBots : 5 , Status : 0 },
5052}
5153
5254type Status int
@@ -97,10 +99,14 @@ func main() {
9799 UpdateLobby = os .Getenv ("GO_PROD" ) == "1"
98100
99101 if UpdateLobby {
100- log .Printf ("This instance will update the lobby at " + LOBBY_ENDPOINT_UPSERT )
101102 gin .SetMode (gin .ReleaseMode )
103+ LOBBY_ENDPOINT_UPSERT = "http://lobby.fujinet.online/server"
104+ } else {
105+ LOBBY_ENDPOINT_UPSERT = "http://qalobby.fujinet.online/server"
102106 }
103107
108+ log .Print ("This instance will update the lobby at " + LOBBY_ENDPOINT_UPSERT )
109+
104110 // Determine port for HTTP service.
105111 port := os .Getenv ("PORT" )
106112 if port == "" {
@@ -136,7 +142,6 @@ func main() {
136142
137143 // Set up router and start server
138144 router .SetTrustedProxies (nil ) // Disable trusted proxies because Gin told me to do it.. (neeed to investigate this further)
139-
140145 router .Run (":" + port )
141146}
142147
@@ -272,6 +277,9 @@ func joinTable(c *gin.Context) {
272277 gameStates [tableIndex ].Players = append (gameStates [tableIndex ].Players , newplayer )
273278 gameStates [tableIndex ].Players [len (gameStates [tableIndex ].Players )- 1 ].Playorder = gameStates [tableIndex ].Table .CurPlayers // Set the play order for the new player
274279 gameStates [tableIndex ].Table .CurPlayers ++ // Increment the current players count
280+ if (gameStates [tableIndex ].Table .Table == "cave" || gameStates [tableIndex ].Table .Table == "river" ) && gameStates [tableIndex ].Table .CurPlayers > 1 {
281+ gameStates [tableIndex ].Table .maxBots = 0 // No bots allowed in cave or river if more than 2 or more human players
282+ }
275283 if gameStates [tableIndex ].Table .CurPlayers >= gameStates [tableIndex ].Table .MaxPlayers {
276284 gameStates [tableIndex ].Table .Status = 1 // Set the status to full if max players reached
277285 c .Params = []gin.Param {{Key : "sup" , Value : "1" }}
@@ -328,6 +336,7 @@ func StartNewGame(c *gin.Context) {
328336 c .JSON (http .StatusOK , "New game started on table " + tables [tableIndex ].Table )
329337 }
330338 // fill up the empty slots with AI players if there are less than 6 players up to the maxiumum bots allowed at that table
339+
331340 for i := 0 ; i < gameStates [tableIndex ].Table .maxBots ; i ++ {
332341 if gameStates [tableIndex ].Table .CurPlayers >= (gameStates [tableIndex ].Table .MaxPlayers ) {
333342 break // Stop adding AI players if the maximum number of players is reached
@@ -347,6 +356,10 @@ func StartNewGame(c *gin.Context) {
347356 gameStates [tableIndex ].Players = append (gameStates [tableIndex ].Players , newAIPlayer )
348357 gameStates [tableIndex ].Table .CurPlayers ++
349358 }
359+
360+ if (gameStates [tableIndex ].Table .Table == "cave" || gameStates [tableIndex ].Table .Table == "river" ) && gameStates [tableIndex ].Table .CurPlayers > 1 {
361+ gameStates [tableIndex ].Table .maxBots = 6 // restore max bots to 6 for cave and river tables
362+ }
350363 gameStates [tableIndex ].Table .Status = 3 // Set the table status to playing
351364 tables [tableIndex ].CurPlayers = gameStates [tableIndex ].Table .CurPlayers // Update the quick table view players count
352365 tables [tableIndex ].Status = gameStates [tableIndex ].Table .Status // Update the quick table view status
0 commit comments