修复游戏对象id错误导致的同步问题

This commit is contained in:
2024-10-19 20:39:12 +08:00
parent 83dfff5aa4
commit 4ec023e1c2
+3 -2
View File
@@ -79,7 +79,7 @@ func StartGameListen() {
c.JSON(http.StatusOK, gin.H{}) c.JSON(http.StatusOK, gin.H{})
}) })
// 开始游戏 // 对方同意开始游戏
router.POST("/start_game", func(c *gin.Context) { router.POST("/start_game", func(c *gin.Context) {
user, msg, is := service.PublicPostCheck(c) user, msg, is := service.PublicPostCheck(c)
if !is { if !is {
@@ -89,8 +89,9 @@ func StartGameListen() {
game.itemX = float32(msg["x"].(float64)) game.itemX = float32(msg["x"].(float64))
game.itemY = float32(msg["y"].(float64)) game.itemY = float32(msg["y"].(float64))
game.winSum = int(msg["win"].(float64)) game.winSum = int(msg["win"].(float64))
gameUuid := msg["game_uuid"].(string)
online := &models.Online{ID: user.ID, Ip: user.Ip, Port: user.Port} online := &models.Online{ID: user.ID, Ip: user.Ip, Port: user.Port}
game.AddNet(utils.Uuid.CreateUUID(), 1, online, &user.Users) game.AddNet(gameUuid, 1, online, &user.Users)
game.Show() game.Show()
c.JSON(200, gin.H{"message": "ok"}) c.JSON(200, gin.H{"message": "ok"})
}) })