Commit bc483c819fb624c17031d5610b564a800831801e

Authored by 王家文
1 parent 8b973f60
Exists in master and in 1 other branch dev-wjw

fix🐛:id算法优化

Showing 3 changed files with 6 additions and 2 deletions   Show diff stats
@@ -26,6 +26,7 @@ require ( @@ -26,6 +26,7 @@ require (
26 github.com/go-logfmt/logfmt v0.5.0 // indirect 26 github.com/go-logfmt/logfmt v0.5.0 // indirect
27 github.com/gogo/protobuf v1.3.2 // indirect 27 github.com/gogo/protobuf v1.3.2 // indirect
28 github.com/golang/protobuf v1.4.2 // indirect 28 github.com/golang/protobuf v1.4.2 // indirect
  29 + github.com/google/uuid v1.6.0 // indirect
29 github.com/hashicorp/golang-lru v0.5.4 // indirect 30 github.com/hashicorp/golang-lru v0.5.4 // indirect
30 github.com/jinzhu/inflection v1.0.0 // indirect 31 github.com/jinzhu/inflection v1.0.0 // indirect
31 github.com/jinzhu/now v1.1.5 // indirect 32 github.com/jinzhu/now v1.1.5 // indirect
@@ -177,6 +177,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ @@ -177,6 +177,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
177 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 177 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
178 github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= 178 github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
179 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 179 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
  180 +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
  181 +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
180 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 182 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
181 github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 183 github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
182 github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= 184 github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
service/roomrank/player.go
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 "apigame/util/util-lx/lxalilog" 8 "apigame/util/util-lx/lxalilog"
9 "apigame/util/util-lx/lxtime" 9 "apigame/util/util-lx/lxtime"
10 "apigame/util/utstring" 10 "apigame/util/utstring"
11 - "math/rand" 11 + "github.com/google/uuid"
12 ) 12 )
13 13
14 func tryInitPlayer(gameId string, player *Player) { 14 func tryInitPlayer(gameId string, player *Player) {
@@ -48,7 +48,8 @@ func LoadPlayer(gameId string, playerUid int64, topType int) (player *Player) { @@ -48,7 +48,8 @@ func LoadPlayer(gameId string, playerUid int64, topType int) (player *Player) {
48 // NewRoomRobot 新建房间机器人 48 // NewRoomRobot 新建房间机器人
49 func NewRoomRobot(gameId string, robotConfigId int, userType int) *RoomPlayer { 49 func NewRoomRobot(gameId string, robotConfigId int, userType int) *RoomPlayer {
50 d := &RoomPlayer{ 50 d := &RoomPlayer{
51 - Uid: rand.Int63(), 51 + //Uid: rand.Int63(),
  52 + Uid: int64(uuid.New().ID()),
52 Name: svcommon.GetName(gameId), 53 Name: svcommon.GetName(gameId),
53 Icon: svcommon.GetAvatar(gameId), 54 Icon: svcommon.GetAvatar(gameId),
54 Score: 0, 55 Score: 0,