simulate.go
778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package svcommon
import (
"apigame/configs/confglobal"
"math/rand"
)
// GetName 随机模拟玩家名字
func GetName(gameId string) string {
config, err := confglobal.GetConfig(gameId)
if err == nil {
count := len(config.Names)
if count > 0 {
return config.Names[rand.Intn(count)]
}
}
return "李四"
}
// GetAvatar 随机模拟玩家头像
func GetAvatar(gameId string) string {
config, err := confglobal.GetConfig(gameId)
if err == nil {
count := len(config.Avatars)
if count > 0 {
return config.Avatars[rand.Intn(count)]
}
}
return "lisi_icon"
}
// GetAvatarPath 随机模拟玩家头像路径
func GetAvatarPath(gameId string) string {
config, err := confglobal.GetConfig(gameId)
if err == nil {
return config.AvatarPath
}
return ""
}