Compare commits
58 Commits
9354ada850
...
a9fdefceb7
Author | SHA1 | Date |
---|---|---|
|
a9fdefceb7 | |
|
d82b029a06 | |
|
f78b1edfb3 | |
|
22dc0a767a | |
|
85679c8b42 | |
|
fc3a539e29 | |
|
5a67d8f073 | |
|
3f35e67a40 | |
|
fd43d57ca4 | |
|
7a9bf671eb | |
|
801200f4bd | |
|
e13e239897 | |
|
2ab2ffafdd | |
|
db73856059 | |
|
2b88155177 | |
|
bdac067402 | |
|
b1d365e030 | |
|
c7ca731c33 | |
|
744d52226c | |
|
2d43a4153a | |
|
4d9dd37713 | |
|
8a9a4f0c2d | |
|
f532cee29b | |
|
0fe7ee6d4c | |
|
5d90c143c8 | |
|
1477611d4a | |
|
57def951c1 | |
|
73157b41cf | |
|
fbc14799c1 | |
|
6b83e85469 | |
|
fe88981e9d | |
|
83db9ddddc | |
|
5dcd4175f9 | |
|
126f9579c5 | |
|
2fb75da43e | |
|
353c1904e9 | |
|
37d2c02b98 | |
|
2d12390882 | |
|
1ade65ba36 | |
|
de7712d4e3 | |
|
61515fb4e0 | |
|
3c72d93448 | |
|
345e4db7a5 | |
|
bcb97edff2 | |
|
d96cc23c84 | |
|
794880b644 | |
|
a8d78d5480 | |
|
1d89c089c1 | |
|
27f70e1a94 | |
|
3db93982bf | |
|
9643c40d35 | |
|
dd43f9ea1e | |
|
8255d754b2 | |
|
2ac9bbfee5 | |
|
44cf7fb7b2 | |
|
68f2a3bb80 | |
|
053484de8e | |
|
1d1bf56695 |
|
@ -14,6 +14,12 @@ default:
|
|||
tags:
|
||||
- gitlab
|
||||
|
||||
cache:
|
||||
key: ${CI_COMMIT_REF_SLUG}
|
||||
paths:
|
||||
- ${GOPATH}/pkg/mod
|
||||
- ${GOPATH}/bin
|
||||
|
||||
# 锁定作业,防止并发流水线执行
|
||||
lock_job:
|
||||
stage: lock
|
||||
|
|
|
@ -2,6 +2,7 @@ package common
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"mongo.games.com/goserver/core"
|
||||
)
|
||||
|
@ -53,6 +54,13 @@ func (this *CustomConfiguration) GetString(key string) string {
|
|||
return str
|
||||
}
|
||||
}
|
||||
|
||||
if v, exist := (*this)[strings.ToLower(key)]; exist {
|
||||
if str, ok := v.(string); ok {
|
||||
return str
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -67,6 +75,18 @@ func (this *CustomConfiguration) GetStrings(key string) (strs []string) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
if v, exist := (*this)[strings.ToLower(key)]; exist {
|
||||
if vals, ok := v.([]interface{}); ok {
|
||||
for _, s := range vals {
|
||||
if str, ok := s.(string); ok {
|
||||
strs = append(strs, str)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -86,6 +106,23 @@ func (this *CustomConfiguration) GetCustomCfgs(key string) (strs []*CustomConfig
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
if v, exist := (*this)[strings.ToLower(key)]; exist {
|
||||
if vals, ok := v.([]interface{}); ok {
|
||||
for _, s := range vals {
|
||||
if data, ok := s.(map[string]interface{}); ok {
|
||||
var pkg *CustomConfiguration
|
||||
modelBuff, _ := json.Marshal(data)
|
||||
err := json.Unmarshal(modelBuff, &pkg)
|
||||
if err == nil {
|
||||
strs = append(strs, pkg)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -100,6 +137,18 @@ func (this *CustomConfiguration) GetInts(key string) (strs []int) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
if v, exist := (*this)[strings.ToLower(key)]; exist {
|
||||
if vals, ok := v.([]interface{}); ok {
|
||||
for _, s := range vals {
|
||||
if str, ok := s.(float64); ok {
|
||||
strs = append(strs, int(str))
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
func (this *CustomConfiguration) GetInt(key string) int {
|
||||
|
@ -108,6 +157,12 @@ func (this *CustomConfiguration) GetInt(key string) int {
|
|||
return int(val)
|
||||
}
|
||||
}
|
||||
|
||||
if v, exist := (*this)[strings.ToLower(key)]; exist {
|
||||
if val, ok := v.(float64); ok {
|
||||
return int(val)
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -117,5 +172,10 @@ func (this *CustomConfiguration) GetBool(key string) bool {
|
|||
return val
|
||||
}
|
||||
}
|
||||
if v, exist := (*this)[strings.ToLower(key)]; exist {
|
||||
if val, ok := v.(bool); ok {
|
||||
return val
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -84,6 +84,8 @@ const (
|
|||
GameId_FortuneRabbit = 310 // FortuneRabbit
|
||||
GameId_FortuneOx = 311 // FortuneOx
|
||||
GameId_FortuneMouse = 312 // FortuneMouse
|
||||
GameId_CashMania = 313 // CashMania
|
||||
GameId_GatesOfOlympus = 314 // GatesOfOlympus
|
||||
__GameId_Fishing_Min__ = 400 //################捕鱼类################
|
||||
GameId_HFishing = 401 //欢乐捕鱼
|
||||
GameId_TFishing = 402 //天天捕鱼
|
||||
|
|
|
@ -204,3 +204,8 @@ func StrTimeToTime(s string) time.Time {
|
|||
t, _ := time.ParseInLocation("2006-01-02 15:04:05", s, time.Local)
|
||||
return t
|
||||
}
|
||||
|
||||
func StrRFC3339TimeToTime(s string) time.Time {
|
||||
t, _ := time.Parse(time.RFC3339, s)
|
||||
return t
|
||||
}
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -71,7 +71,7 @@
|
|||
"Name": "十三张(四人场)",
|
||||
"GameId": 211,
|
||||
"Params": [
|
||||
0,
|
||||
4,
|
||||
0,
|
||||
30,
|
||||
50,
|
||||
|
@ -84,7 +84,7 @@
|
|||
"Name": "十三张(八人场)",
|
||||
"GameId": 212,
|
||||
"Params": [
|
||||
1,
|
||||
8,
|
||||
0,
|
||||
30,
|
||||
50,
|
||||
|
@ -97,7 +97,7 @@
|
|||
"Name": "十三张(自由场经典场)",
|
||||
"GameId": 213,
|
||||
"Params": [
|
||||
1,
|
||||
8,
|
||||
0,
|
||||
30,
|
||||
50,
|
||||
|
@ -110,7 +110,7 @@
|
|||
"Name": "十三张(自由场癞子场)",
|
||||
"GameId": 214,
|
||||
"Params": [
|
||||
1,
|
||||
8,
|
||||
0,
|
||||
30,
|
||||
50,
|
||||
|
@ -250,6 +250,18 @@
|
|||
"GameId": 312,
|
||||
"GameDif": "312"
|
||||
},
|
||||
{
|
||||
"Id": 31300,
|
||||
"Name": "CashMania",
|
||||
"GameId": 313,
|
||||
"GameDif": "313"
|
||||
},
|
||||
{
|
||||
"Id": 31400,
|
||||
"Name": "GatesOfOlympus",
|
||||
"GameId": 314,
|
||||
"GameDif": "314"
|
||||
},
|
||||
{
|
||||
"Id": 60800,
|
||||
"Name": "娃娃机",
|
||||
|
|
Binary file not shown.
Binary file not shown.
BIN
data/DB_Task.dat
BIN
data/DB_Task.dat
Binary file not shown.
|
@ -42,7 +42,7 @@ func Register(key string, msgType interface{}, f func(ctx context.Context, compl
|
|||
logger.Logger.Errorf("ETCD %v proto.Unmarshal error:%v", key, err)
|
||||
continue
|
||||
}
|
||||
logger.Logger.Tracef("ETCD 拉取成功 %v ==> %v", string(res.Kvs[i].Key), d)
|
||||
logger.Logger.Debugf("ETCD 拉取成功 %v ==> %v", string(res.Kvs[i].Key), d)
|
||||
event := &clientv3.Event{
|
||||
Type: 0,
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ func Register(key string, msgType interface{}, f func(ctx context.Context, compl
|
|||
logger.Logger.Errorf("ETCD %v josn.Unmarshal error:%v", key, err)
|
||||
continue
|
||||
}
|
||||
logger.Logger.Tracef("ETCD 拉取成功 %v ==> %v", string(res.Kvs[i].Key), d)
|
||||
logger.Logger.Debugf("ETCD 拉取成功 %v ==> %v", string(res.Kvs[i].Key), d)
|
||||
event := &clientv3.Event{
|
||||
Type: 0,
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package fortunemouse
|
||||
|
||||
// 房间类型
|
||||
const (
|
||||
RoomMode_Classic int = iota //经典
|
||||
RoomMode_Max
|
||||
)
|
||||
|
||||
// 场景状态
|
||||
const (
|
||||
FortuneMouseStateStart int = iota //默认状态
|
||||
FortuneMouseStateMax
|
||||
)
|
||||
|
||||
// 玩家操作
|
||||
const (
|
||||
FortuneMousePlayerOpStart int = iota
|
||||
FortuneMousePlayerOpSwitch
|
||||
)
|
||||
const NowByte int64 = 10000
|
||||
|
||||
const GameDataKey = "FortuneData"
|
|
@ -34,6 +34,7 @@ const (
|
|||
ThirteenWaterPlayerOpTest = 3 // test
|
||||
ThirteenWaterPlayerOpReset = 4 // 重新选牌
|
||||
ThirteenWaterPlayerJoin = 5 // 加入游戏
|
||||
ThirteenWaterPlayerOpSelect = 6 // 预选牌
|
||||
)
|
||||
const (
|
||||
ThirteenWaterSceneWaitTimeout = time.Second * 2 //等待倒计时
|
||||
|
@ -53,9 +54,9 @@ const (
|
|||
)
|
||||
|
||||
func GetTimeout(param []int64, index int) time.Duration {
|
||||
//if index >= 0 && index < len(param) {
|
||||
// return time.Duration(param[index]) * time.Second
|
||||
//}
|
||||
if index >= 0 && index < len(param) {
|
||||
return time.Duration(param[index]) * time.Second
|
||||
}
|
||||
switch index {
|
||||
case TimeoutStart:
|
||||
return ThirteenWaterStartTimeout
|
||||
|
|
|
@ -105,7 +105,7 @@ type Group struct {
|
|||
Head [3]int
|
||||
Mid [5]int
|
||||
End [5]int
|
||||
PokerType int
|
||||
PokerType int // -1 无牌数据,0 有牌数据, 1-13 特殊牌型
|
||||
}
|
||||
|
||||
func (p *Group) String() string {
|
||||
|
@ -612,13 +612,19 @@ func (l *Logic) findAllCombine(cards [13]int) (pokers []*Group) {
|
|||
i++
|
||||
}
|
||||
} else if i == PokersTypeTwoPairs {
|
||||
// 6,7,8 对子
|
||||
// 4,5,6 两对
|
||||
al := len(copyCards)
|
||||
if al == 7 || al == 6 {
|
||||
if al == 8 || al == 7 {
|
||||
copy(poker.Mid[2:], card)
|
||||
} else if al == 5 || al == 4 {
|
||||
copy(poker.Mid[:], card)
|
||||
} else if al == 8 {
|
||||
} else if al == 6 {
|
||||
if poker.Mid[2] == -1 {
|
||||
copy(poker.Mid[2:], card)
|
||||
} else {
|
||||
copy(poker.Mid[:], card)
|
||||
}
|
||||
} else {
|
||||
copyCards = append(copyCards, card...)
|
||||
i++
|
||||
|
|
|
@ -87,6 +87,17 @@ func TestFindAllPokers(t *testing.T) {
|
|||
{46, 35, 30, 50, 34, 9, 25, 41, 3, 26, 2, 6, 45},
|
||||
}
|
||||
|
||||
//
|
||||
//牌序- A, K, Q, J,10, 9, 8, 7, 6, 5, 4, 3, 2
|
||||
//黑桃-51,50,49,48,47,46,45,44,43,42,41,40,39
|
||||
//红桃-38,37,36,35,34,33,32,31,30,29,28,27,26
|
||||
//梅花-25,24,23,22,21,20,19,18,17,16,15,14,13
|
||||
//方片-12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
|
||||
//data = [][13]int{
|
||||
// //{31, 42, 14, 49, 23, 25, 12, 6, 33, 20, 34, 21, 7},
|
||||
// {13, 23, 24, 36, 37, 38, 39, 51, 51, 50, 10, 11, 12},
|
||||
//}
|
||||
|
||||
for _, v := range data {
|
||||
cards := v
|
||||
fmt.Println(PokersShow(cards[:]))
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package base
|
||||
|
||||
// 提供税收和流水,根据代理需求后台进行分账
|
||||
func ProfitDistribution(p *Player, tax, taxex, validFlow int64) {
|
||||
//LogChannelSingleton.WriteMQData(model.GenerateTaxDivide(p.SnId, p.Platform, p.Channel, p.BeUnderAgentCode, p.PackageID, tax, taxex, validFlow, p.scene.GameId, p.scene.GameMode, p.scene.GetDBGameFree().GetId(), p.PromoterTree))
|
||||
}
|
|
@ -0,0 +1,255 @@
|
|||
package base
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/globalsign/mgo/bson"
|
||||
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/mq"
|
||||
)
|
||||
|
||||
/*
|
||||
记录游戏对局记录
|
||||
*/
|
||||
|
||||
type SaveGameDetailedParam struct {
|
||||
LogId string // 日志id
|
||||
Detail string // 游戏详细信息
|
||||
GameTime int64 // 游戏时长
|
||||
Trend20Lately string // 最近20局开奖结果
|
||||
CtrlType int // 调控类型 1控赢 2控输
|
||||
PlayerPool map[int]int // 个人水池分
|
||||
OnlyLog bool // 只返回日志,不保存
|
||||
}
|
||||
|
||||
// SaveGameDetailedLog 保存游戏详细记录
|
||||
func (this *Scene) SaveGameDetailedLog(param *SaveGameDetailedParam) *SaveGameDetailedCopy {
|
||||
if this == nil || param == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if param.GameTime <= 0 {
|
||||
param.GameTime = int64(time.Now().Sub(this.GameNowTime).Seconds())
|
||||
}
|
||||
|
||||
if param.GameTime < 0 {
|
||||
param.GameTime = 0
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
var ret SaveGameDetailedCopy
|
||||
ret.Param = param
|
||||
f := func(plt string) {
|
||||
log := &model.GameDetailedLog{
|
||||
Id: bson.NewObjectId(),
|
||||
LogId: param.LogId,
|
||||
GameId: this.GameId,
|
||||
Platform: plt,
|
||||
MatchId: this.GetMatch().GetMatchSortId(),
|
||||
SceneId: this.SceneId,
|
||||
GameMode: this.GameMode,
|
||||
GameFreeid: this.GetGameFreeId(),
|
||||
PlayerCount: int32(len(this.Players)),
|
||||
GameTiming: int32(param.GameTime),
|
||||
GameBaseBet: this.GetBaseScore(),
|
||||
GameDetailedNote: param.Detail,
|
||||
GameDetailVer: GameDetailedVer[int(this.GameId)],
|
||||
CpCtx: this.CpCtx,
|
||||
Time: now,
|
||||
Trend20Lately: param.Trend20Lately,
|
||||
Ts: now.Unix(),
|
||||
CtrlType: param.CtrlType,
|
||||
PlayerPool: make(map[int]int),
|
||||
CycleId: this.CycleID,
|
||||
}
|
||||
for k, v := range param.PlayerPool {
|
||||
log.PlayerPool[k] = v
|
||||
}
|
||||
if param.OnlyLog {
|
||||
ret.Log = append(ret.Log, log)
|
||||
} else {
|
||||
mq.Write(log)
|
||||
}
|
||||
}
|
||||
|
||||
switch {
|
||||
case this.IsCoinScene():
|
||||
mapPlatform := make(map[string]bool)
|
||||
for _, v := range this.Players {
|
||||
if v == nil {
|
||||
continue
|
||||
}
|
||||
if _, ok := mapPlatform[v.Platform]; ok {
|
||||
continue
|
||||
}
|
||||
mapPlatform[v.Platform] = true
|
||||
f(v.Platform)
|
||||
}
|
||||
default:
|
||||
f(this.Platform)
|
||||
}
|
||||
return &ret
|
||||
}
|
||||
|
||||
type SaveGamePlayerListLogParam struct {
|
||||
LogId string // 详情日志id
|
||||
Platform string // 平台
|
||||
Snid int32 // 玩家id
|
||||
PlayerName string // 玩家名字
|
||||
Channel string // 渠道
|
||||
ChannelId string // 推广渠道
|
||||
TotalIn int64 // 总投入
|
||||
TotalOut int64 // 总产出(税前)
|
||||
TaxCoin int64 // 总税收
|
||||
BetAmount int64 // 下注量
|
||||
WinAmountNoAnyTax int64 // 税后赢取额(净利润,正负值)
|
||||
IsFirstGame bool // 是否第一次游戏
|
||||
IsFree bool // 拉霸专用 是否免费
|
||||
WinSmallGame int64 // 拉霸专用 小游戏奖励
|
||||
WinTotal int64 // 拉霸专用 本局输赢
|
||||
GameTime int64 // 游戏时长
|
||||
OnlyLog bool // 只返回日志,不保存
|
||||
}
|
||||
|
||||
// SaveGamePlayerListLog 保存玩家对局记录
|
||||
func (this *Scene) SaveGamePlayerListLog(param *SaveGamePlayerListLogParam) *SaveGamePlayerListLogCopy {
|
||||
if this == nil {
|
||||
return nil
|
||||
}
|
||||
if param == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
p := this.GetPlayer(param.Snid)
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if param.PlayerName == "" {
|
||||
param.PlayerName = p.Name
|
||||
}
|
||||
|
||||
var ret SaveGamePlayerListLogCopy
|
||||
ret.Param = param
|
||||
|
||||
baseScore := this.GetBaseScore()
|
||||
|
||||
// 上报玩家游戏记录
|
||||
if !p.IsRob && (param.IsFree || param.TotalIn != 0 || param.TotalOut != 0) {
|
||||
e := p.ReportGameEvent(&ReportGameEventParam{
|
||||
Tax: param.TaxCoin,
|
||||
Change: param.WinAmountNoAnyTax,
|
||||
In: param.TotalIn,
|
||||
Out: param.TotalOut,
|
||||
GameTime: param.GameTime,
|
||||
OnlyLog: param.OnlyLog,
|
||||
})
|
||||
if e != nil {
|
||||
ret.UpLog = e
|
||||
}
|
||||
}
|
||||
|
||||
// 保存玩家游戏日志
|
||||
now := time.Now()
|
||||
log := &model.GamePlayerListLog{
|
||||
LogId: bson.NewObjectId(),
|
||||
SnId: p.SnId,
|
||||
Name: param.PlayerName,
|
||||
GameId: this.GameId,
|
||||
BaseScore: baseScore,
|
||||
TaxCoin: param.TaxCoin,
|
||||
Platform: param.Platform,
|
||||
Channel: param.Channel,
|
||||
SceneId: this.SceneId,
|
||||
GameMode: this.GameMode,
|
||||
GameFreeid: this.GetGameFreeId(),
|
||||
GameDetailedLogId: param.LogId,
|
||||
IsFirstGame: param.IsFirstGame,
|
||||
BetAmount: param.BetAmount,
|
||||
WinAmountNoAnyTax: param.WinAmountNoAnyTax,
|
||||
TotalIn: param.TotalIn,
|
||||
TotalOut: param.TotalOut,
|
||||
Time: now,
|
||||
RoomType: this.SceneMode,
|
||||
GameDif: this.GetDBGameFree().GetGameDif(),
|
||||
GameClass: this.GetDBGameFree().GetGameClass(),
|
||||
MatchId: this.GetMatch().GetMatchSortId(),
|
||||
MatchType: int64(this.GetMatch().GetMatchType()),
|
||||
Ts: now.Unix(),
|
||||
IsFree: param.IsFree,
|
||||
WinSmallGame: param.WinSmallGame,
|
||||
WinTotal: param.WinTotal,
|
||||
CycleId: this.CycleID,
|
||||
}
|
||||
if param.OnlyLog {
|
||||
ret.Log = append(ret.Log, log)
|
||||
} else {
|
||||
mq.Write(log)
|
||||
}
|
||||
return &ret
|
||||
}
|
||||
|
||||
// SaveGamePlayerListLogCopy 临时记录
|
||||
// 为了拉霸统计游戏时长,需要临时缓存游戏记录
|
||||
type SaveGamePlayerListLogCopy struct {
|
||||
Param *SaveGamePlayerListLogParam
|
||||
Log []*model.GamePlayerListLog
|
||||
UpLog *ReportGameEventOnly // mq上报数据
|
||||
}
|
||||
|
||||
func (s *SaveGamePlayerListLogCopy) Save() {
|
||||
for _, v := range s.Log {
|
||||
mq.Write(v)
|
||||
}
|
||||
if s.UpLog != nil {
|
||||
for _, v := range s.UpLog.Log {
|
||||
mq.Write(v, mq.BackGameRecord)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SaveGameDetailedCopy 临时记录
|
||||
// 为了拉霸统计游戏时长,需要临时缓存游戏记录
|
||||
type SaveGameDetailedCopy struct {
|
||||
Param *SaveGameDetailedParam
|
||||
Log []*model.GameDetailedLog
|
||||
}
|
||||
|
||||
func (s *SaveGameDetailedCopy) Save() {
|
||||
for _, v := range s.Log {
|
||||
mq.Write(v)
|
||||
}
|
||||
}
|
||||
|
||||
// LabaLog 拉霸缓存游戏记录
|
||||
type LabaLog struct {
|
||||
PlayerListLog *SaveGamePlayerListLogCopy
|
||||
GameDetailLog *SaveGameDetailedCopy
|
||||
}
|
||||
|
||||
// Cache 临时缓存
|
||||
func (l *LabaLog) Cache(s *Scene, detailLog *SaveGameDetailedParam, playerListLog *SaveGamePlayerListLogParam) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
detailLog.OnlyLog = true
|
||||
playerListLog.OnlyLog = true
|
||||
l.GameDetailLog = s.SaveGameDetailedLog(detailLog)
|
||||
l.PlayerListLog = s.SaveGamePlayerListLog(playerListLog)
|
||||
}
|
||||
|
||||
// Save 保存
|
||||
func (l *LabaLog) Save(f func(log *LabaLog)) {
|
||||
f(l)
|
||||
l.PlayerListLog.Save()
|
||||
l.GameDetailLog.Save()
|
||||
l.Clear()
|
||||
}
|
||||
|
||||
// Clear 清空
|
||||
func (l *LabaLog) Clear() {
|
||||
l.PlayerListLog = nil
|
||||
l.GameDetailLog = nil
|
||||
}
|
|
@ -68,27 +68,6 @@ func NewGameWarning(param string) {
|
|||
}), nil, "NewGameWarning").Start()
|
||||
}
|
||||
|
||||
// func WarningLoseCoin(gameFreeId int32, snid int32, loseCoin int64) {
|
||||
// if model.GameParamData.WarningLoseLimit == 0 {
|
||||
// return
|
||||
// }
|
||||
// if loseCoin < model.GameParamData.WarningLoseLimit {
|
||||
// return
|
||||
// }
|
||||
// NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningGame":%v,"WarningSnid":%v,"LoseCoin":%v}`,
|
||||
// Warning_LoseCoinLimit, gameFreeId, snid, loseCoin))
|
||||
//
|
||||
|
||||
//func WarningBetCoinCheck(sceneId, gameFreeId int32, snid int32, betCoin int64) {
|
||||
// if model.GameParamData.WarningBetMax == 0 {
|
||||
// return
|
||||
// }
|
||||
// if betCoin > model.GameParamData.WarningBetMax {
|
||||
// NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningSnid":%v,"WarningGame":%v,"WarningScene":%v}`,
|
||||
// Warning_BetCoinMax, snid, gameFreeId, sceneId))
|
||||
// }
|
||||
//}
|
||||
|
||||
func WarningCoinPool(warnType int, gameFreeId int32) {
|
||||
NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningGame":%v}`,
|
||||
warnType, gameFreeId))
|
||||
|
@ -97,24 +76,3 @@ func WarningBlackPlayer(snid, gameFreeId int32) {
|
|||
NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningSnid":%v,"WarningGame":%v}`,
|
||||
Warning_BlackPlayer, snid, gameFreeId))
|
||||
}
|
||||
|
||||
//func WarningWinnerRate(snid int32, winCoin, loseCoin int64) {
|
||||
// if model.GameParamData.WarningWinRate == 0 {
|
||||
// return
|
||||
// }
|
||||
// if (winCoin+1)/(loseCoin+1) < model.GameParamData.WarningWinRate {
|
||||
// return
|
||||
// }
|
||||
// NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningSnid":%v,"WarningRate":%v,"WinCoin":%v,"LoseCoin":%v}`,
|
||||
// Warning_WinRate, snid, (winCoin+1)/(loseCoin+1), winCoin, loseCoin))
|
||||
//}
|
||||
//func WarningWinnerCoin(snid int32, winCoin, loseCoin int64) {
|
||||
// if model.GameParamData.WarningWinMoney == 0 {
|
||||
// return
|
||||
// }
|
||||
// if (winCoin - loseCoin) < model.GameParamData.WarningWinMoney {
|
||||
// return
|
||||
// }
|
||||
// NewGameWarning(fmt.Sprintf(`{"WarningType":%v,"WarningSnid":%v,"WarningCoin":%v,"WinCoin":%v,"LoseCoin":%v}`,
|
||||
// Warning_WinCoin, snid, (winCoin - loseCoin), winCoin, loseCoin))
|
||||
//}
|
||||
|
|
|
@ -1,300 +0,0 @@
|
|||
package base
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"mongo.games.com/game/model"
|
||||
|
||||
"github.com/globalsign/mgo/bson"
|
||||
"mongo.games.com/goserver/core/basic"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
"mongo.games.com/goserver/core/task"
|
||||
)
|
||||
|
||||
// HundredJackListManager 排行榜 key: platform+gamefreeId
|
||||
type HundredJackListManager struct {
|
||||
HundredJackTsList map[string][]*HundredJackInfo
|
||||
HundredJackSortList map[string][]*HundredJackInfo
|
||||
}
|
||||
|
||||
// HundredJackListMgr 实例化
|
||||
var HundredJackListMgr = &HundredJackListManager{
|
||||
HundredJackTsList: make(map[string][]*HundredJackInfo),
|
||||
HundredJackSortList: make(map[string][]*HundredJackInfo),
|
||||
}
|
||||
|
||||
// HundredJackInfo 数据结构
|
||||
type HundredJackInfo struct {
|
||||
model.HundredjackpotLog
|
||||
linkSnids []int32 //点赞人数
|
||||
}
|
||||
|
||||
// ModuleName .
|
||||
func (hm *HundredJackListManager) ModuleName() string {
|
||||
return "HundredJackListManager"
|
||||
}
|
||||
|
||||
// Init .
|
||||
func (hm *HundredJackListManager) Init() {
|
||||
//data := model.
|
||||
}
|
||||
|
||||
// Update .
|
||||
func (hm *HundredJackListManager) Update() {
|
||||
}
|
||||
|
||||
// Shutdown .
|
||||
func (hm *HundredJackListManager) Shutdown() {
|
||||
module.UnregisteModule(hm)
|
||||
}
|
||||
|
||||
// ISInitJackInfo 仅初始化一次
|
||||
var ISInitJackInfo bool
|
||||
|
||||
// InitTsJackInfo 初始化TsJackInfo
|
||||
func (hm *HundredJackListManager) InitTsJackInfo(platform string, freeID int32) {
|
||||
key := fmt.Sprintf("%v-%v", platform, freeID)
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
datas, err := model.GetHundredjackpotLogTsByPlatformAndGameFreeID(platform, freeID)
|
||||
if err != nil {
|
||||
logger.Logger.Error("HundredJackListManager DelOneJackInfo ", err)
|
||||
return nil
|
||||
}
|
||||
return datas
|
||||
}), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
|
||||
datas := data.([]model.HundredjackpotLog)
|
||||
if data != nil && datas != nil {
|
||||
for i := range datas {
|
||||
if i == model.HundredjackpotLogMaxLimitPerQuery {
|
||||
break
|
||||
}
|
||||
data := &HundredJackInfo{
|
||||
HundredjackpotLog: datas[i],
|
||||
}
|
||||
strlikeSnids := strings.Split(datas[i].LinkeSnids, "|")
|
||||
for _, v := range strlikeSnids {
|
||||
if v == "" {
|
||||
break
|
||||
}
|
||||
snid, err := strconv.Atoi(v)
|
||||
if err == nil {
|
||||
data.linkSnids = append(data.linkSnids, int32(snid))
|
||||
}
|
||||
}
|
||||
hm.HundredJackTsList[key] = append(hm.HundredJackTsList[key], data)
|
||||
}
|
||||
// logger.Logger.Warnf("InitTsJackInfo data:%v", datas)
|
||||
} else {
|
||||
hm.HundredJackTsList[key] = []*HundredJackInfo{}
|
||||
}
|
||||
return
|
||||
}), "InitTsJackInfo").Start()
|
||||
}
|
||||
|
||||
// InitSortJackInfo 初始化SortJackInfo
|
||||
func (hm *HundredJackListManager) InitSortJackInfo(platform string, freeID int32) {
|
||||
|
||||
key := fmt.Sprintf("%v-%v", platform, freeID)
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
datas, err := model.GetHundredjackpotLogCoinByPlatformAndGameFreeID(platform, freeID)
|
||||
if err != nil {
|
||||
logger.Logger.Error("HundredJackListManager DelOneJackInfo ", err)
|
||||
return nil
|
||||
}
|
||||
return datas
|
||||
}), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
|
||||
datas := data.([]model.HundredjackpotLog)
|
||||
if data != nil && datas != nil {
|
||||
for i := range datas {
|
||||
if i == model.HundredjackpotLogMaxLimitPerQuery {
|
||||
break
|
||||
}
|
||||
data := &HundredJackInfo{
|
||||
HundredjackpotLog: datas[i],
|
||||
}
|
||||
strlikeSnids := strings.Split(datas[i].LinkeSnids, "|")
|
||||
for _, v := range strlikeSnids {
|
||||
snid, err := strconv.Atoi(v)
|
||||
if err == nil {
|
||||
data.linkSnids = append(data.linkSnids, int32(snid))
|
||||
}
|
||||
}
|
||||
hm.HundredJackSortList[key] = append(hm.HundredJackSortList[key], data)
|
||||
}
|
||||
// logger.Logger.Warnf("InitSortJackInfo data:%v", datas)
|
||||
} else {
|
||||
hm.HundredJackSortList[key] = []*HundredJackInfo{}
|
||||
}
|
||||
return
|
||||
}), "InitSortJackInfo").Start()
|
||||
}
|
||||
|
||||
// InitHundredJackListInfo 初始化 HundredJackListInfo
|
||||
func (hm *HundredJackListManager) InitHundredJackListInfo(platform string, freeID int32) {
|
||||
if ISInitJackInfo {
|
||||
return
|
||||
}
|
||||
key := fmt.Sprintf("%v-%v", platform, freeID)
|
||||
if _, exist := hm.HundredJackTsList[key]; !exist {
|
||||
hm.InitTsJackInfo(platform, freeID)
|
||||
}
|
||||
if _, exist := hm.HundredJackSortList[key]; !exist {
|
||||
hm.InitSortJackInfo(platform, freeID)
|
||||
}
|
||||
ISInitJackInfo = true
|
||||
return
|
||||
}
|
||||
|
||||
// GetJackTsInfo 返回TsInfo
|
||||
func (hm *HundredJackListManager) GetJackTsInfo(platform string, freeID int32) []*HundredJackInfo {
|
||||
key := fmt.Sprintf("%v-%v", platform, freeID)
|
||||
if _, exist := hm.HundredJackTsList[key]; !exist { // 玩家进入scene 已经初始化
|
||||
hm.InitTsJackInfo(platform, freeID)
|
||||
}
|
||||
return hm.HundredJackTsList[key]
|
||||
}
|
||||
|
||||
// GetJackSortInfo 返回SortInfo
|
||||
func (hm *HundredJackListManager) GetJackSortInfo(platform string, freeID int32) []*HundredJackInfo {
|
||||
key := fmt.Sprintf("%v-%v", platform, freeID)
|
||||
if _, exist := hm.HundredJackSortList[key]; !exist {
|
||||
hm.InitSortJackInfo(platform, freeID)
|
||||
}
|
||||
return hm.HundredJackSortList[key]
|
||||
}
|
||||
|
||||
// Insert 插入
|
||||
func (hm *HundredJackListManager) Insert(coin, turncoin int64, snid, roomid, jackType, inGame, vip int32, platform, channel, name string, gamedata []string) {
|
||||
key := fmt.Sprintf("%v-%v", platform, roomid)
|
||||
log := model.NewHundredjackpotLogEx(snid, coin, turncoin, roomid, jackType, inGame, vip, platform, channel, name, gamedata)
|
||||
///////////////////实际不走这里
|
||||
if _, exist := hm.HundredJackTsList[key]; !exist {
|
||||
hm.InitTsJackInfo(platform, roomid)
|
||||
}
|
||||
if _, exist := hm.HundredJackSortList[key]; !exist {
|
||||
hm.InitSortJackInfo(platform, roomid)
|
||||
}
|
||||
/////////////////////
|
||||
hm.InsertLog(log)
|
||||
data := &HundredJackInfo{
|
||||
HundredjackpotLog: *log,
|
||||
}
|
||||
/*logger.Logger.Trace("HundredJackListManager log 1 ", log.SnID, log.LogID, data.GameData)
|
||||
for _, v := range hm.HundredJackTsList[key] {
|
||||
logger.Logger.Trace("HundredJackListManager log 2 ", v.SnID, v.LogID, v.GameData)
|
||||
}*/
|
||||
for i, v := range hm.HundredJackSortList[key] { // 插入
|
||||
if v.Coin < log.Coin {
|
||||
d1 := append([]*HundredJackInfo{}, hm.HundredJackSortList[key][i:]...)
|
||||
hm.HundredJackSortList[key] = append(hm.HundredJackSortList[key][:i], data)
|
||||
hm.HundredJackSortList[key] = append(hm.HundredJackSortList[key], d1...)
|
||||
goto Exit
|
||||
}
|
||||
}
|
||||
if len(hm.HundredJackSortList[key]) < model.HundredjackpotLogMaxLimitPerQuery {
|
||||
hm.HundredJackSortList[key] = append(hm.HundredJackSortList[key], data)
|
||||
}
|
||||
Exit:
|
||||
d1 := append([]*HundredJackInfo{}, hm.HundredJackTsList[key][0:]...)
|
||||
hm.HundredJackTsList[key] = append(hm.HundredJackTsList[key][:0], data)
|
||||
hm.HundredJackTsList[key] = append(hm.HundredJackTsList[key], d1...)
|
||||
var delList []*HundredJackInfo
|
||||
if len(hm.HundredJackTsList[key]) > model.HundredjackpotLogMaxLimitPerQuery {
|
||||
delList = append(delList, hm.HundredJackTsList[key][model.HundredjackpotLogMaxLimitPerQuery:]...)
|
||||
hm.HundredJackTsList[key] = hm.HundredJackTsList[key][:model.HundredjackpotLogMaxLimitPerQuery]
|
||||
}
|
||||
if len(hm.HundredJackSortList[key]) > model.HundredjackpotLogMaxLimitPerQuery {
|
||||
delList = append(delList, hm.HundredJackSortList[key][model.HundredjackpotLogMaxLimitPerQuery:]...)
|
||||
hm.HundredJackSortList[key] = hm.HundredJackSortList[key][:model.HundredjackpotLogMaxLimitPerQuery]
|
||||
}
|
||||
/*for _, v := range hm.HundredJackTsList[key] {
|
||||
logger.Logger.Trace("HundredJackListManager log 3 ", v.SnID, v.LogID, v.GameData)
|
||||
}*/
|
||||
for _, v := range delList {
|
||||
if hm.IsCanDel(v, hm.HundredJackTsList[key], hm.HundredJackSortList[key]) { // 两个排行帮都不包含
|
||||
logger.Logger.Info("HundredJackListManager DelOneJackInfo ", v.LogID)
|
||||
hm.DelOneJackInfo(v.Platform, v.LogID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// IsCanDel 能否删除
|
||||
func (hm *HundredJackListManager) IsCanDel(deldata *HundredJackInfo, tsList, sortList []*HundredJackInfo) bool {
|
||||
for _, v := range tsList {
|
||||
if v.LogID == deldata.LogID {
|
||||
return false
|
||||
}
|
||||
}
|
||||
for _, v := range sortList {
|
||||
if v.LogID == deldata.LogID {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// InsertLog insert db
|
||||
func (hm *HundredJackListManager) InsertLog(log *model.HundredjackpotLog) {
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
err := model.InsertHundredjackpotLog(log)
|
||||
if err != nil {
|
||||
logger.Logger.Error("HundredJackListManager Insert ", err)
|
||||
}
|
||||
return err
|
||||
}), nil, "InsertHundredJack").Start()
|
||||
}
|
||||
|
||||
// UpdateLikeNum updata likenum
|
||||
func (hm *HundredJackListManager) UpdateLikeNum(plt string, gid bson.ObjectId, like int32, likesnids string) {
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
err := model.UpdateLikeNum(plt, gid, like, likesnids)
|
||||
if err != nil {
|
||||
logger.Logger.Error("HundredJackListManager UpdateHundredLikeNum ", err)
|
||||
}
|
||||
return err
|
||||
}), nil, "UpdateHundredLikeNum").Start()
|
||||
}
|
||||
|
||||
// UpdatePlayBlackNum updata playblacknum
|
||||
func (hm *HundredJackListManager) UpdatePlayBlackNum(plt string, gid bson.ObjectId, playblack int32) []string {
|
||||
var ret []string
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
data, err := model.UpdatePlayBlackNum(plt, gid, playblack)
|
||||
if err != nil {
|
||||
logger.Logger.Error("HundredJackListManager DelOneJackInfo ", err)
|
||||
return nil
|
||||
}
|
||||
return data
|
||||
}), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
|
||||
if data != nil {
|
||||
ret = data.([]string)
|
||||
logger.Logger.Warnf("UpdatePlayBlackNum data:%v", ret)
|
||||
}
|
||||
return
|
||||
}), "UpdatePlayBlackNum").Start()
|
||||
|
||||
logger.Logger.Error("HundredJackListManager UpdatePlayBlackNum ", ret)
|
||||
if len(ret) == 0 {
|
||||
return ret
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DelOneJackInfo del
|
||||
func (hm *HundredJackListManager) DelOneJackInfo(plt string, gid bson.ObjectId) {
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
err := model.RemoveHundredjackpotLogOne(plt, gid)
|
||||
if err != nil {
|
||||
logger.Logger.Error("HundredJackListManager DelOneJackInfo ", err)
|
||||
}
|
||||
return err
|
||||
}), nil, "DelOneJackInfo").Start()
|
||||
}
|
||||
|
||||
func init() {
|
||||
module.RegisteModule(HundredJackListMgr, time.Hour, 0)
|
||||
}
|
|
@ -627,9 +627,15 @@ type ReportGameEventParam struct {
|
|||
Change int64 // 净输赢,正负值,不带税收
|
||||
In, Out int64 // 投入,产出(税前)
|
||||
GameTime int64 // 游戏时长,秒
|
||||
OnlyLog bool // 只返回数据,不上报
|
||||
}
|
||||
|
||||
func (this *Player) ReportGameEvent(param *ReportGameEventParam) {
|
||||
type ReportGameEventOnly struct {
|
||||
Param *ReportGameEventParam
|
||||
Log []*model.PlayerGameRecEvent
|
||||
}
|
||||
|
||||
func (this *Player) ReportGameEvent(param *ReportGameEventParam) *ReportGameEventOnly {
|
||||
// 记录玩家 首次参与该场次的游戏时间 游戏次数
|
||||
var gameFirstTime, gameFreeFirstTime time.Time
|
||||
var gameTimes, gameFreeTimes int64
|
||||
|
@ -659,6 +665,8 @@ func (this *Player) ReportGameEvent(param *ReportGameEventParam) {
|
|||
param.GameTime = 0
|
||||
}
|
||||
|
||||
var ret ReportGameEventOnly
|
||||
ret.Param = param
|
||||
log := &model.PlayerGameRecEvent{
|
||||
Platform: this.Platform,
|
||||
RecordId: this.scene.GetRecordId(),
|
||||
|
@ -685,8 +693,13 @@ func (this *Player) ReportGameEvent(param *ReportGameEventParam) {
|
|||
LastLoginTime: this.LastLoginTime.Unix(),
|
||||
DeviceId: this.DeviceId,
|
||||
}
|
||||
if param.OnlyLog {
|
||||
ret.Log = append(ret.Log, log)
|
||||
} else {
|
||||
mq.Write(log, mq.BackGameRecord)
|
||||
}
|
||||
return &ret
|
||||
}
|
||||
|
||||
// 汇总玩家该次游戏总产生的税收
|
||||
// 数据用途: 平台和推广间分账用,确保数据计算无误,
|
||||
|
|
|
@ -2,7 +2,6 @@ package base
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/globalsign/mgo/bson"
|
||||
"math"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
|
@ -1457,162 +1456,6 @@ func (this *Scene) SaveFriendRecord(snid int32, isWin int32, billCoin int64, bas
|
|||
}
|
||||
}
|
||||
|
||||
type SaveGameDetailedParam struct {
|
||||
LogId string // 日志id
|
||||
Detail string // 游戏详细信息
|
||||
GameTime int64 // 游戏时长
|
||||
Trend20Lately string // 最近20局开奖结果
|
||||
CtrlType int // 调控类型 1控赢 2控输
|
||||
PlayerPool map[int]int // 个人水池分
|
||||
}
|
||||
|
||||
func (this *Scene) SaveGameDetailedLog(param *SaveGameDetailedParam) {
|
||||
if this == nil || param == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if param.GameTime <= 0 {
|
||||
param.GameTime = int64(time.Now().Sub(this.GameNowTime).Seconds())
|
||||
}
|
||||
|
||||
if param.GameTime < 0 {
|
||||
param.GameTime = 0
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
|
||||
f := func(plt string) {
|
||||
log := &model.GameDetailedLog{
|
||||
Id: bson.NewObjectId(),
|
||||
LogId: param.LogId,
|
||||
GameId: this.GameId,
|
||||
Platform: plt,
|
||||
MatchId: this.GetMatch().GetMatchSortId(),
|
||||
SceneId: this.SceneId,
|
||||
GameMode: this.GameMode,
|
||||
GameFreeid: this.GetGameFreeId(),
|
||||
PlayerCount: int32(len(this.Players)),
|
||||
GameTiming: int32(param.GameTime),
|
||||
GameBaseBet: this.GetBaseScore(),
|
||||
GameDetailedNote: param.Detail,
|
||||
GameDetailVer: GameDetailedVer[int(this.GameId)],
|
||||
CpCtx: this.CpCtx,
|
||||
Time: now,
|
||||
Trend20Lately: param.Trend20Lately,
|
||||
Ts: now.Unix(),
|
||||
CtrlType: param.CtrlType,
|
||||
PlayerPool: make(map[int]int),
|
||||
CycleId: this.CycleID,
|
||||
}
|
||||
for k, v := range param.PlayerPool {
|
||||
log.PlayerPool[k] = v
|
||||
}
|
||||
mq.Write(log)
|
||||
}
|
||||
|
||||
switch {
|
||||
case this.IsCoinScene():
|
||||
mapPlatform := make(map[string]bool)
|
||||
for _, v := range this.Players {
|
||||
if v == nil {
|
||||
continue
|
||||
}
|
||||
if _, ok := mapPlatform[v.Platform]; ok {
|
||||
continue
|
||||
}
|
||||
mapPlatform[v.Platform] = true
|
||||
f(v.Platform)
|
||||
}
|
||||
default:
|
||||
f(this.Platform)
|
||||
}
|
||||
}
|
||||
|
||||
type SaveGamePlayerListLogParam struct {
|
||||
LogId string // 详情日志id
|
||||
Platform string // 平台
|
||||
Snid int32 // 玩家id
|
||||
PlayerName string // 玩家名字
|
||||
Channel string // 渠道
|
||||
ChannelId string // 推广渠道
|
||||
TotalIn int64 // 总投入
|
||||
TotalOut int64 // 总产出(税前)
|
||||
TaxCoin int64 // 总税收
|
||||
BetAmount int64 // 下注量
|
||||
WinAmountNoAnyTax int64 // 税后赢取额(净利润,正负值)
|
||||
IsFirstGame bool // 是否第一次游戏
|
||||
IsFree bool // 拉霸专用 是否免费
|
||||
WinSmallGame int64 // 拉霸专用 小游戏奖励
|
||||
WinTotal int64 // 拉霸专用 本局输赢
|
||||
GameTime int64 // 游戏时长
|
||||
}
|
||||
|
||||
// SaveGamePlayerListLog 保存玩家对局记录
|
||||
func (this *Scene) SaveGamePlayerListLog(param *SaveGamePlayerListLogParam) {
|
||||
if this == nil {
|
||||
return
|
||||
}
|
||||
if param == nil {
|
||||
return
|
||||
}
|
||||
|
||||
p := this.GetPlayer(param.Snid)
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if param.PlayerName == "" {
|
||||
param.PlayerName = p.Name
|
||||
}
|
||||
|
||||
baseScore := this.GetBaseScore()
|
||||
|
||||
// 上报玩家游戏记录
|
||||
if !p.IsRob && (param.IsFree || param.TotalIn != 0 || param.TotalOut != 0) {
|
||||
p.ReportGameEvent(&ReportGameEventParam{
|
||||
Tax: param.TaxCoin,
|
||||
Change: param.WinAmountNoAnyTax,
|
||||
In: param.TotalIn,
|
||||
Out: param.TotalOut,
|
||||
GameTime: param.GameTime,
|
||||
})
|
||||
}
|
||||
|
||||
// 保存玩家游戏日志
|
||||
now := time.Now()
|
||||
log := &model.GamePlayerListLog{
|
||||
LogId: bson.NewObjectId(),
|
||||
SnId: p.SnId,
|
||||
Name: param.PlayerName,
|
||||
GameId: this.GameId,
|
||||
BaseScore: baseScore,
|
||||
TaxCoin: param.TaxCoin,
|
||||
Platform: param.Platform,
|
||||
Channel: param.Channel,
|
||||
SceneId: this.SceneId,
|
||||
GameMode: this.GameMode,
|
||||
GameFreeid: this.GetGameFreeId(),
|
||||
GameDetailedLogId: param.LogId,
|
||||
IsFirstGame: param.IsFirstGame,
|
||||
BetAmount: param.BetAmount,
|
||||
WinAmountNoAnyTax: param.WinAmountNoAnyTax,
|
||||
TotalIn: param.TotalIn,
|
||||
TotalOut: param.TotalOut,
|
||||
Time: now,
|
||||
RoomType: this.SceneMode,
|
||||
GameDif: this.GetDBGameFree().GetGameDif(),
|
||||
GameClass: this.GetDBGameFree().GetGameClass(),
|
||||
MatchId: this.GetMatch().GetMatchSortId(),
|
||||
MatchType: int64(this.GetMatch().GetMatchType()),
|
||||
Ts: now.Unix(),
|
||||
IsFree: param.IsFree,
|
||||
WinSmallGame: param.WinSmallGame,
|
||||
WinTotal: param.WinTotal,
|
||||
CycleId: this.CycleID,
|
||||
}
|
||||
mq.Write(log)
|
||||
}
|
||||
|
||||
func (this *Scene) IsPlayerFirst(p *Player) bool {
|
||||
if p == nil {
|
||||
return false
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package fortunemouse
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/protocol/fortunemouse"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/netlib"
|
||||
)
|
||||
|
||||
type CSFortuneMouseOpPacketFactory struct {
|
||||
}
|
||||
type CSFortuneMouseOpHandler struct {
|
||||
}
|
||||
|
||||
func (this *CSFortuneMouseOpPacketFactory) CreatePacket() interface{} {
|
||||
pack := &fortunemouse.CSFortuneMouseOp{}
|
||||
return pack
|
||||
}
|
||||
|
||||
func (this *CSFortuneMouseOpHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||
if op, ok := data.(*fortunemouse.CSFortuneMouseOp); ok {
|
||||
p := base.PlayerMgrSington.GetPlayer(sid)
|
||||
if p == nil {
|
||||
logger.Logger.Warn("CSFortuneMouseOpHandler p == nil")
|
||||
return nil
|
||||
}
|
||||
scene := p.GetScene()
|
||||
if scene == nil {
|
||||
logger.Logger.Warn("CSFortuneMouseOpHandler p.scene == nil")
|
||||
return nil
|
||||
}
|
||||
if !scene.HasPlayer(p) {
|
||||
return nil
|
||||
}
|
||||
if scene.GetScenePolicy() != nil {
|
||||
scene.GetScenePolicy().OnPlayerOp(scene, p, int(op.GetOpCode()), op.GetParams())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func init() {
|
||||
common.RegisterHandler(int(fortunemouse.FortuneMousePID_PACKET_FORTUNEMOUSE_CSFORTUNEMOUSEOP), &CSFortuneMouseOpHandler{})
|
||||
netlib.RegisterFactory(int(fortunemouse.FortuneMousePID_PACKET_FORTUNEMOUSE_CSFORTUNEMOUSEOP), &CSFortuneMouseOpPacketFactory{})
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package fortunemouse
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamerule/fortunemouse"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots"
|
||||
)
|
||||
|
||||
type FortuneMousePlayerData struct {
|
||||
*base.Player
|
||||
leaveTime int32 //离开时间
|
||||
SlotsSession *base.SlotsSession
|
||||
|
||||
BetSizeIndex int64 `json:"bsi"` //选中的单注下标
|
||||
BetLevelIndex int64 `json:"bli"` //选中的等级下标
|
||||
BetLineIndex int64 `json:"bii"` //选中的线数下标
|
||||
BetMode int64 `json:"bm,optional"` //0.常规 1.必中
|
||||
|
||||
taxCoin int64
|
||||
winCoin int64
|
||||
currentLogId string
|
||||
totalBet int64
|
||||
|
||||
isRespin bool //只用于判断是否可以离开
|
||||
}
|
||||
|
||||
type SpinLock struct {
|
||||
ReSpinStatus int `json:"rs,omitempty"` //0.默认 1.第一次触发 2.进行中 3.结束
|
||||
//OXSpecial
|
||||
NewSuperStack []int64 `json:"nss,omitempty"`
|
||||
}
|
||||
|
||||
func (p *FortuneMousePlayerData) init() {
|
||||
p.SlotsSession = base.NewSession(uint64(p.SnId), p.Coin*fortunemouse.NowByte)
|
||||
}
|
||||
func (p *FortuneMousePlayerData) Clear() {
|
||||
p.taxCoin = 0
|
||||
p.winCoin = 0
|
||||
p.currentLogId = ""
|
||||
}
|
||||
|
||||
// 需要带到world上进行数据处理
|
||||
func (p *FortuneMousePlayerData) PushPlayer() map[string]string {
|
||||
cache := slots.SlotsMgrSington.PushPlayer(p.SlotsSession)
|
||||
return cache
|
||||
}
|
||||
|
||||
// 进房的时候需要带进来
|
||||
func (p *FortuneMousePlayerData) PullPlayer(data map[string]string) {
|
||||
slots.SlotsMgrSington.PullPlayer(p.SlotsSession, data)
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package fortunemouse
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/assemble"
|
||||
)
|
||||
|
||||
type FortuneMouseSceneData struct {
|
||||
*base.Scene //场景
|
||||
players map[int32]*FortuneMousePlayerData //玩家信息
|
||||
BetConfig *assemble.BetConfig
|
||||
}
|
||||
|
||||
func NewFortuneMouseSceneData(s *base.Scene) *FortuneMouseSceneData {
|
||||
sceneEx := &FortuneMouseSceneData{
|
||||
Scene: s,
|
||||
players: make(map[int32]*FortuneMousePlayerData),
|
||||
}
|
||||
sceneEx.Init()
|
||||
return sceneEx
|
||||
}
|
||||
func (s *FortuneMouseSceneData) Init() {
|
||||
|
||||
}
|
||||
|
||||
func (s *FortuneMouseSceneData) Clear() {
|
||||
//应该是水池变一次就判断修改一次
|
||||
//s.slotRateWeight = s.slotRateWeightTotal[0]
|
||||
}
|
||||
func (s *FortuneMouseSceneData) SceneDestroy(force bool) {
|
||||
//销毁房间
|
||||
s.Scene.Destroy(force)
|
||||
}
|
||||
|
||||
func (s *FortuneMouseSceneData) delPlayer(SnId int32) {
|
||||
if _, exist := s.players[SnId]; exist {
|
||||
delete(s.players, SnId)
|
||||
}
|
||||
}
|
||||
func (s *FortuneMouseSceneData) OnPlayerLeave(p *base.Player, reason int) {
|
||||
if /*playerEx*/ _, ok := p.ExtraData.(*FortuneMousePlayerData); ok {
|
||||
|
||||
}
|
||||
s.delPlayer(p.SnId)
|
||||
}
|
|
@ -0,0 +1,594 @@
|
|||
package fortunemouse
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/gamerule/fortunemouse"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/assemble"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/proto"
|
||||
protocol "mongo.games.com/game/protocol/fortunemouse"
|
||||
"mongo.games.com/game/protocol/server"
|
||||
"mongo.games.com/goserver/core"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
var ScenePolicyFortuneMouseSington = &ScenePolicyFortuneMouse{}
|
||||
|
||||
type ScenePolicyFortuneMouse struct {
|
||||
base.BaseScenePolicy
|
||||
states [fortunemouse.FortuneMouseStateMax]base.SceneState
|
||||
}
|
||||
|
||||
// 创建场景扩展数据
|
||||
func (this *ScenePolicyFortuneMouse) CreateSceneExData(s *base.Scene) interface{} {
|
||||
sceneEx := NewFortuneMouseSceneData(s)
|
||||
if sceneEx != nil {
|
||||
if sceneEx.GetInit() {
|
||||
s.SetExtraData(sceneEx)
|
||||
}
|
||||
}
|
||||
return sceneEx
|
||||
}
|
||||
|
||||
// 创建玩家扩展数据
|
||||
func (this *ScenePolicyFortuneMouse) CreatePlayerExData(s *base.Scene, p *base.Player) interface{} {
|
||||
playerEx := &FortuneMousePlayerData{Player: p}
|
||||
p.SetExtraData(playerEx)
|
||||
return playerEx
|
||||
}
|
||||
|
||||
// 场景开启事件
|
||||
func (this *ScenePolicyFortuneMouse) OnStart(s *base.Scene) {
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneMouse) OnStart, sceneId=", s.GetSceneId())
|
||||
sceneEx := NewFortuneMouseSceneData(s)
|
||||
if sceneEx != nil {
|
||||
if sceneEx.GetInit() {
|
||||
s.SetExtraData(sceneEx)
|
||||
s.ChangeSceneState(fortunemouse.FortuneMouseStateStart)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 场景关闭事件
|
||||
func (this *ScenePolicyFortuneMouse) OnStop(s *base.Scene) {
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneMouse) OnStop , sceneId=", s.GetSceneId())
|
||||
}
|
||||
|
||||
// 场景心跳事件
|
||||
func (this *ScenePolicyFortuneMouse) OnTick(s *base.Scene) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
if s.GetSceneState() != nil {
|
||||
s.GetSceneState().OnTick(s)
|
||||
}
|
||||
}
|
||||
|
||||
// 玩家进入事件
|
||||
func (this *ScenePolicyFortuneMouse) OnPlayerEnter(s *base.Scene, p *base.Player) {
|
||||
if s == nil || p == nil {
|
||||
return
|
||||
}
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneMouse) OnPlayerEnter, sceneId=", s.GetSceneId(), " player=", p.Name)
|
||||
if sceneEx, ok := s.GetExtraData().(*FortuneMouseSceneData); ok {
|
||||
playerEx := &FortuneMousePlayerData{Player: p}
|
||||
|
||||
playerEx.init()
|
||||
|
||||
d := p.GameData[fortunemouse.GameDataKey]
|
||||
if d != nil {
|
||||
m := make(map[string]string)
|
||||
json.Unmarshal(d.Data.([]byte), &m)
|
||||
playerEx.PullPlayer(m)
|
||||
} else {
|
||||
m := make(map[string]string)
|
||||
//json.Unmarshal(d.Data.([]byte), &m)
|
||||
playerEx.PullPlayer(m)
|
||||
}
|
||||
|
||||
playerEx.SlotsSession.SetCoin(playerEx.Coin * fortunemouse.NowByte)
|
||||
|
||||
playerEx.Clear()
|
||||
|
||||
sceneEx.players[p.SnId] = playerEx
|
||||
|
||||
p.SetExtraData(playerEx)
|
||||
FortuneMouseSendRoomInfo(s, sceneEx, playerEx)
|
||||
|
||||
s.FirePlayerEvent(p, base.PlayerEventEnter, nil)
|
||||
}
|
||||
}
|
||||
|
||||
// 玩家离开事件
|
||||
func (this *ScenePolicyFortuneMouse) OnPlayerLeave(s *base.Scene, p *base.Player, reason int) {
|
||||
if s == nil || p == nil {
|
||||
return
|
||||
}
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneMouse) OnPlayerLeave, sceneId=", s.GetSceneId(), " player=", p.SnId)
|
||||
if playerEx, ok := p.ExtraData.(*FortuneMousePlayerData); ok {
|
||||
m := playerEx.PushPlayer()
|
||||
if m != nil && len(m) > 0 {
|
||||
b, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
logger.Logger.Error("OnPlayerLeave, json.Marshal error:", err)
|
||||
} else {
|
||||
p.GameData[fortunemouse.GameDataKey] = &model.PlayerGameData{
|
||||
Platform: p.Platform,
|
||||
SnId: p.SnId,
|
||||
Id: fortunemouse.GameDataKey,
|
||||
Data: b,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if sceneEx, ok := s.ExtraData.(*FortuneMouseSceneData); ok {
|
||||
s.FirePlayerEvent(p, base.PlayerEventLeave, nil)
|
||||
sceneEx.OnPlayerLeave(p, reason)
|
||||
}
|
||||
}
|
||||
|
||||
// 玩家掉线
|
||||
func (this *ScenePolicyFortuneMouse) OnPlayerDropLine(s *base.Scene, p *base.Player) {
|
||||
if s == nil || p == nil {
|
||||
return
|
||||
}
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneMouse) OnPlayerDropLine, sceneId=", s.GetSceneId(), " player=", p.SnId)
|
||||
s.FirePlayerEvent(p, base.PlayerEventDropLine, nil)
|
||||
}
|
||||
|
||||
// 玩家重连
|
||||
func (this *ScenePolicyFortuneMouse) OnPlayerRehold(s *base.Scene, p *base.Player) {
|
||||
if s == nil || p == nil {
|
||||
return
|
||||
}
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneMouse) OnPlayerRehold, sceneId=", s.GetSceneId(), " player=", p.SnId)
|
||||
if sceneEx, ok := s.GetExtraData().(*FortuneMouseSceneData); ok {
|
||||
if playerEx, ok := p.GetExtraData().(*FortuneMousePlayerData); ok {
|
||||
FortuneMouseSendRoomInfo(s, sceneEx, playerEx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 返回房间
|
||||
func (this *ScenePolicyFortuneMouse) OnPlayerReturn(s *base.Scene, p *base.Player) {
|
||||
if s == nil || p == nil {
|
||||
return
|
||||
}
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneMouse) OnPlayerReturn, GetSceneId()=", s.GetSceneId(), " player=", p.Name)
|
||||
if sceneEx, ok := s.GetExtraData().(*FortuneMouseSceneData); ok {
|
||||
if playerEx, ok := p.GetExtraData().(*FortuneMousePlayerData); ok {
|
||||
//if p.IsMarkFlag(base.PlayerState_Auto) {
|
||||
// p.UnmarkFlag(base.PlayerState_Auto)
|
||||
// p.SyncFlag()
|
||||
//}
|
||||
//发送房间信息给自己
|
||||
FortuneMouseSendRoomInfo(s, sceneEx, playerEx)
|
||||
s.FirePlayerEvent(p, base.PlayerEventReturn, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func FortuneMouseSendRoomInfo(s *base.Scene, sceneEx *FortuneMouseSceneData, playerEx *FortuneMousePlayerData) {
|
||||
pack := FortuneMouseCreateRoomInfoPacket(s, sceneEx, playerEx)
|
||||
logger.Logger.Trace("RoomInfo: ", pack)
|
||||
playerEx.SendToClient(int(protocol.FortuneMousePID_PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEROOMINFO), pack)
|
||||
}
|
||||
func FortuneMouseCreateRoomInfoPacket(s *base.Scene, sceneEx *FortuneMouseSceneData, playerEx *FortuneMousePlayerData) interface{} {
|
||||
//房间信息
|
||||
pack := &protocol.SCFortuneMouseRoomInfo{
|
||||
RoomId: s.SceneId,
|
||||
GameId: s.GameId,
|
||||
RoomMode: s.SceneMode,
|
||||
SceneType: s.GetSceneType(),
|
||||
Params: common.CopySliceInt64ToInt32(s.Params),
|
||||
NumOfGames: proto.Int(sceneEx.NumOfGames),
|
||||
State: proto.Int(s.SceneState.GetState()),
|
||||
ParamsEx: s.GetDBGameFree().OtherIntParams,
|
||||
GameFreeId: proto.Int32(s.GetDBGameFree().Id),
|
||||
//BetLimit: s.GetDBGameFree().BetLimit,
|
||||
}
|
||||
|
||||
//自己的信息
|
||||
if playerEx != nil {
|
||||
pd := &protocol.FortuneMousePlayerData{
|
||||
SnId: proto.Int32(playerEx.SnId),
|
||||
Name: proto.String(playerEx.Name),
|
||||
Head: proto.Int32(playerEx.Head),
|
||||
Sex: proto.Int32(playerEx.Sex),
|
||||
Coin: proto.Int64(playerEx.Coin),
|
||||
Pos: proto.Int(playerEx.Pos),
|
||||
Flag: proto.Int(playerEx.GetFlag()),
|
||||
City: proto.String(playerEx.City),
|
||||
HeadOutLine: proto.Int32(playerEx.HeadOutLine),
|
||||
VIP: proto.Int32(playerEx.VIP),
|
||||
}
|
||||
pack.Player = pd
|
||||
}
|
||||
|
||||
//get data
|
||||
Response, err := slots.SlotsMgrSington.Enter(playerEx.SlotsSession, int64(s.GameId))
|
||||
if err == nil {
|
||||
data := assemble.DataToCli(Response).(assemble.TableInfo)
|
||||
pi, _ := json.Marshal(data)
|
||||
pack.PlayerInfo = string(pi)
|
||||
if sceneEx.BetConfig == nil {
|
||||
sceneEx.BetConfig = &data.BetConfig
|
||||
}
|
||||
} else {
|
||||
logger.Logger.Error("slots enter err:", err)
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
return pack
|
||||
}
|
||||
func (this *ScenePolicyFortuneMouse) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, params []int64) bool {
|
||||
if s == nil || p == nil {
|
||||
return false
|
||||
}
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneMouse) OnPlayerOp, sceneId=", s.GetSceneId(), " player=", p.SnId, " opcode=", opcode, " params=", params)
|
||||
if s.GetSceneState() != nil {
|
||||
if s.GetSceneState().OnPlayerOp(s, p, opcode, params) {
|
||||
p.SetLastOPTimer(time.Now())
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *ScenePolicyFortuneMouse) OnPlayerEvent(s *base.Scene, p *base.Player, evtcode int, params []int64) {
|
||||
if s == nil || p == nil {
|
||||
return
|
||||
}
|
||||
logger.Logger.Trace("(this *ScenePolicyFortuneMouse) OnPlayerEvent, sceneId=", s.GetSceneId(), " player=", p.SnId, " eventcode=", evtcode, " params=", params)
|
||||
if s.GetSceneState() != nil {
|
||||
s.GetSceneState().OnPlayerEvent(s, p, evtcode, params)
|
||||
}
|
||||
}
|
||||
|
||||
// 当前状态能否换桌
|
||||
func (this *ScenePolicyFortuneMouse) CanChangeCoinScene(s *base.Scene, p *base.Player) bool {
|
||||
if s == nil || p == nil {
|
||||
return false
|
||||
}
|
||||
if s.GetSceneState() != nil {
|
||||
return s.GetSceneState().CanChangeCoinScene(s, p)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 状态基类
|
||||
type SceneBaseStateFortuneMouse struct {
|
||||
}
|
||||
|
||||
func (this *SceneBaseStateFortuneMouse) GetTimeout(s *base.Scene) int {
|
||||
if sceneEx, ok := s.GetExtraData().(*FortuneMouseSceneData); ok {
|
||||
return int(time.Now().Sub(sceneEx.GetStateStartTime()) / time.Second)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (this *SceneBaseStateFortuneMouse) CanChangeTo(s base.SceneState) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// 当前状态能否换桌
|
||||
func (this *SceneBaseStateFortuneMouse) CanChangeCoinScene(s *base.Scene, p *base.Player) bool {
|
||||
return true
|
||||
}
|
||||
func (this *SceneBaseStateFortuneMouse) OnEnter(s *base.Scene) {
|
||||
if sceneEx, ok := s.GetExtraData().(*FortuneMouseSceneData); ok {
|
||||
sceneEx.SetStateStartTime(time.Now())
|
||||
}
|
||||
}
|
||||
|
||||
func (this *SceneBaseStateFortuneMouse) OnLeave(s *base.Scene) {}
|
||||
func (this *SceneBaseStateFortuneMouse) OnTick(s *base.Scene) {
|
||||
if time.Now().Sub(s.GameStartTime) > time.Second*3 {
|
||||
if sceneEx, ok := s.ExtraData.(*FortuneMouseSceneData); ok {
|
||||
for _, p := range sceneEx.players {
|
||||
if p.IsOnLine() {
|
||||
p.leaveTime = 0
|
||||
continue
|
||||
}
|
||||
p.leaveTime++
|
||||
if p.leaveTime < 60*2 {
|
||||
continue
|
||||
}
|
||||
//踢出玩家
|
||||
sceneEx.PlayerLeave(p.Player, common.PlayerLeaveReason_LongTimeNoOp, true)
|
||||
}
|
||||
}
|
||||
s.GameStartTime = time.Now()
|
||||
}
|
||||
}
|
||||
func (this *SceneBaseStateFortuneMouse) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, params []int64) bool {
|
||||
return false
|
||||
}
|
||||
func (this *SceneBaseStateFortuneMouse) OnPlayerEvent(s *base.Scene, p *base.Player, evtcode int, params []int64) {
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////
|
||||
// 开始状态
|
||||
// ////////////////////////////////////////////////////////////
|
||||
type SceneStateStartFortuneMouse struct {
|
||||
SceneBaseStateFortuneMouse
|
||||
}
|
||||
|
||||
func (this *SceneStateStartFortuneMouse) GetState() int {
|
||||
return fortunemouse.FortuneMouseStateStart
|
||||
}
|
||||
|
||||
func (this *SceneStateStartFortuneMouse) CanChangeTo(s base.SceneState) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// 当前状态能否换桌
|
||||
func (this *SceneStateStartFortuneMouse) CanChangeCoinScene(s *base.Scene, p *base.Player) bool {
|
||||
if playerEx, ok := p.GetExtraData().(*FortuneMousePlayerData); ok {
|
||||
if playerEx.isRespin {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *SceneStateStartFortuneMouse) GetTimeout(s *base.Scene) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (this *SceneStateStartFortuneMouse) OnEnter(s *base.Scene) {
|
||||
this.SceneBaseStateFortuneMouse.OnEnter(s)
|
||||
if sceneEx, ok := s.GetExtraData().(*FortuneMouseSceneData); ok {
|
||||
sceneEx.SetGameNowTime(time.Now())
|
||||
}
|
||||
}
|
||||
|
||||
// 状态离开时
|
||||
func (this *SceneStateStartFortuneMouse) OnLeave(s *base.Scene) {
|
||||
this.SceneBaseStateFortuneMouse.OnLeave(s)
|
||||
logger.Logger.Tracef("(this *SceneStateStartFortuneMouse) OnLeave, sceneid=%v", s.GetSceneId())
|
||||
}
|
||||
|
||||
// 玩家操作
|
||||
func (this *SceneStateStartFortuneMouse) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, params []int64) bool {
|
||||
logger.Logger.Tracef("(this *SceneStateStartFortuneMouse) OnPlayerOp, sceneid=%v params=%v", s.GetSceneId(), params)
|
||||
if this.SceneBaseStateFortuneMouse.OnPlayerOp(s, p, opcode, params) {
|
||||
return true
|
||||
}
|
||||
if sceneEx, ok := s.GetExtraData().(*FortuneMouseSceneData); ok {
|
||||
if playerEx, ok := p.GetExtraData().(*FortuneMousePlayerData); ok {
|
||||
switch opcode {
|
||||
case fortunemouse.FortuneMousePlayerOpStart:
|
||||
playerEx.Clear()
|
||||
if len(params) < 3 {
|
||||
pack := &protocol.SCFortuneMouseBilled{
|
||||
OpRetCode: proto.Int32(1),
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
logger.Logger.Trace("SCFortuneMouseBilled", pack.String())
|
||||
playerEx.SendToClient(int(protocol.FortuneMousePID_PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEBILLED), pack)
|
||||
return true
|
||||
}
|
||||
playerEx.BetSizeIndex = params[0]
|
||||
playerEx.BetLevelIndex = params[1]
|
||||
playerEx.BetLineIndex = params[2]
|
||||
//playerEx.BetMode = params[3]
|
||||
needCoin := sceneEx.BetConfig.BetSize[params[0]] * float64(sceneEx.BetConfig.BetLevel[params[1]]) *
|
||||
float64(sceneEx.BetConfig.BetLines[params[2]])
|
||||
if needCoin > float64(playerEx.Coin) {
|
||||
pack := &protocol.SCFortuneMouseBilled{
|
||||
OpRetCode: proto.Int32(1),
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
logger.Logger.Trace("SCFortuneMouseBilled:", pack.String())
|
||||
playerEx.SendToClient(int(protocol.FortuneMousePID_PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEBILLED), pack)
|
||||
return true
|
||||
}
|
||||
|
||||
//playerEx.SlotsSession.SetCoin(playerEx.Coin * fortunemouse.NowByte)
|
||||
//logger.Logger.Trace("=============init dif coin", playerEx.Coin-playerEx.SlotsSession.Coin()/fortunemouse.NowByte)
|
||||
|
||||
//get data
|
||||
Response, err := slots.SlotsMgrSington.Play(playerEx.SlotsSession, &base.SpinReq{
|
||||
GameId: int64(sceneEx.GameId),
|
||||
BetSizeIndex: playerEx.BetSizeIndex,
|
||||
BetLevelIndex: playerEx.BetLevelIndex,
|
||||
BetLineIndex: playerEx.BetLineIndex,
|
||||
BetMode: playerEx.BetMode,
|
||||
Ts: time.Now().Unix(),
|
||||
})
|
||||
var gameEndStr string
|
||||
var data assemble.GameEnd
|
||||
if err == nil {
|
||||
s.SetGameNowTime(time.Now())
|
||||
data = assemble.DataToCli(Response).(assemble.GameEnd)
|
||||
var respinStatus int
|
||||
if data.Results[0].ArrSpins[0].Special != nil {
|
||||
sp, _ := json.Marshal(data.Results[0].ArrSpins[0].Special)
|
||||
var spinLock SpinLock
|
||||
json.Unmarshal(sp, &spinLock)
|
||||
respinStatus = spinLock.ReSpinStatus
|
||||
}
|
||||
if respinStatus == 0 || respinStatus == 1 {
|
||||
//第一次触发或者正常模式
|
||||
//logger.Logger.Trace("=============addcoin1111 ", -data.TotalBet)
|
||||
playerEx.AddCoin(int64(-data.TotalBet), common.GainWay_HundredSceneLost, base.SyncFlag_ToClient, "system", s.GetSceneName())
|
||||
playerEx.totalBet = int64(data.TotalBet)
|
||||
//logger.Logger.Trace("=======bet======dif++++ ", float64(playerEx.Coin)-data.BetAfterCoin)
|
||||
}
|
||||
var taxCoin float64
|
||||
if data.RoundReward > 0 {
|
||||
//税收比例
|
||||
taxRate := sceneEx.GetDBGameFree().GetTaxRate()
|
||||
if taxRate < 0 || taxRate > 10000 {
|
||||
taxRate = 500
|
||||
}
|
||||
taxCoin = data.RoundReward * float64(taxRate) / 10000
|
||||
data.RoundReward = data.RoundReward - taxCoin
|
||||
playerEx.AddServiceFee(int64(taxCoin))
|
||||
playerEx.taxCoin = int64(taxCoin)
|
||||
playerEx.winCoin = int64(data.RoundReward)
|
||||
}
|
||||
pi, _ := json.Marshal(data)
|
||||
gameEndStr = string(pi)
|
||||
if respinStatus == 0 || respinStatus == 3 {
|
||||
//logger.Logger.Trace("===win==========addcoin222 ", data.RoundReward)
|
||||
playerEx.AddCoin(int64(data.RoundReward), common.GainWay_HundredSceneWin, 0, "system", s.GetSceneName())
|
||||
//logger.Logger.Trace("=======win======dif++++ ", float64(playerEx.Coin)-data.FinalCoin)
|
||||
//免费游戏结束或者正常模式
|
||||
sceneEx.StaticsLaba(&base.StaticLabaParam{
|
||||
SnId: playerEx.SnId,
|
||||
Gain: int64(data.RoundReward - data.TotalBet),
|
||||
GainTax: int64(taxCoin),
|
||||
IsAddTimes: true,
|
||||
})
|
||||
}
|
||||
if respinStatus == 0 || respinStatus == 3 {
|
||||
playerEx.isRespin = false
|
||||
} else {
|
||||
playerEx.isRespin = true
|
||||
}
|
||||
} else {
|
||||
logger.Logger.Error("slots Play err:", err)
|
||||
}
|
||||
|
||||
playerEx.SlotsSession.SetCoin(int64(data.FinalCoin) * fortunemouse.NowByte)
|
||||
|
||||
//logger.Logger.Trace("======end=======init dif coin", playerEx.Coin-playerEx.SlotsSession.Coin()/fortunemouse.NowByte)
|
||||
|
||||
if playerEx.Coin != int64(data.FinalCoin) {
|
||||
logger.Logger.Error("==========playerEx.Coin != data.FinalCoin==============", (float64(playerEx.Coin)-data.FinalCoin)/10000)
|
||||
}
|
||||
pack := &protocol.SCFortuneMouseBilled{
|
||||
OpRetCode: proto.Int32(0),
|
||||
GameEndStr: proto.String(gameEndStr),
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
logger.Logger.Trace("SCFortuneMouseBilled", pack.String())
|
||||
playerEx.SendToClient(int(protocol.FortuneMousePID_PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEBILLED), pack)
|
||||
|
||||
// 记录本次操作
|
||||
FortuneMouseAndSaveLog(sceneEx, playerEx, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 玩家事件
|
||||
func (this *SceneStateStartFortuneMouse) OnPlayerEvent(s *base.Scene, p *base.Player, evtcode int, params []int64) {
|
||||
logger.Logger.Trace("(this *SceneStateStartFortuneMouse) OnPlayerEvent, sceneId=", s.GetSceneId(), " player=", p.SnId, " evtcode=", evtcode)
|
||||
this.SceneBaseStateFortuneMouse.OnPlayerEvent(s, p, evtcode, params)
|
||||
}
|
||||
|
||||
func (this *SceneStateStartFortuneMouse) OnTick(s *base.Scene) {
|
||||
this.SceneBaseStateFortuneMouse.OnTick(s)
|
||||
}
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
func (this *ScenePolicyFortuneMouse) RegisteSceneState(state base.SceneState) {
|
||||
if state == nil {
|
||||
return
|
||||
}
|
||||
stateid := state.GetState()
|
||||
if stateid < 0 || stateid >= fortunemouse.FortuneMouseStateMax {
|
||||
return
|
||||
}
|
||||
this.states[stateid] = state
|
||||
}
|
||||
|
||||
func (this *ScenePolicyFortuneMouse) GetSceneState(s *base.Scene, stateid int) base.SceneState {
|
||||
if stateid >= 0 && stateid < fortunemouse.FortuneMouseStateMax {
|
||||
return this.states[stateid]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func FortuneMouseAndSaveLog(sceneEx *FortuneMouseSceneData, playerEx *FortuneMousePlayerData, data assemble.GameEnd) {
|
||||
if !playerEx.IsRob {
|
||||
data.SnId = playerEx.SnId
|
||||
var respinStatus int
|
||||
if data.Results[0].ArrSpins[0].Special != nil {
|
||||
sp, _ := json.Marshal(data.Results[0].ArrSpins[0].Special)
|
||||
var spinLock SpinLock
|
||||
json.Unmarshal(sp, &spinLock)
|
||||
respinStatus = spinLock.ReSpinStatus
|
||||
}
|
||||
if respinStatus == 0 || respinStatus == 1 {
|
||||
data.TotalBet = 0
|
||||
}
|
||||
info, err := model.MarshalGameNoteByROLL(data)
|
||||
if err == nil {
|
||||
logid, _ := model.AutoIncGameLogId()
|
||||
playerEx.currentLogId = logid
|
||||
sceneEx.SaveGameDetailedLog(&base.SaveGameDetailedParam{
|
||||
LogId: logid,
|
||||
Detail: info,
|
||||
GameTime: 2,
|
||||
})
|
||||
var totalin, totalout int64
|
||||
if respinStatus == 0 || respinStatus == 1 {
|
||||
totalin = playerEx.totalBet
|
||||
}
|
||||
if respinStatus == 0 || respinStatus == 3 {
|
||||
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
||||
}
|
||||
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
|
||||
LogId: logid,
|
||||
Platform: playerEx.Platform,
|
||||
Snid: playerEx.SnId,
|
||||
PlayerName: playerEx.Name,
|
||||
Channel: playerEx.Channel,
|
||||
ChannelId: playerEx.ChannelId,
|
||||
TotalIn: totalin,
|
||||
TotalOut: totalout,
|
||||
TaxCoin: playerEx.taxCoin,
|
||||
BetAmount: playerEx.totalBet,
|
||||
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
|
||||
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
|
||||
IsFree: totalin == 0,
|
||||
GameTime: 2,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//统计输下注金币数
|
||||
if !sceneEx.Testing && !playerEx.IsRob {
|
||||
playerBet := &server.PlayerData{
|
||||
SnId: proto.Int32(playerEx.SnId),
|
||||
Bet: proto.Int64(playerEx.CurrentBet),
|
||||
Gain: proto.Int64(int64(data.RoundReward) + playerEx.taxCoin),
|
||||
Tax: proto.Int64(playerEx.taxCoin),
|
||||
Coin: proto.Int64(playerEx.GetCoin()),
|
||||
GameCoinTs: proto.Int64(playerEx.GameCoinTs),
|
||||
}
|
||||
gwPlayerBet := &server.GWPlayerData{
|
||||
SceneId: sceneEx.SceneId,
|
||||
GameFreeId: proto.Int32(sceneEx.GetDBGameFree().GetId()),
|
||||
}
|
||||
gwPlayerBet.Datas = append(gwPlayerBet.Datas, playerBet)
|
||||
sceneEx.SyncPlayerDatas(&base.PlayerDataParam{
|
||||
HasRobotGaming: false,
|
||||
Data: gwPlayerBet,
|
||||
})
|
||||
}
|
||||
|
||||
playerEx.taxCoin = 0
|
||||
playerEx.winCoin = 0
|
||||
|
||||
if sceneEx.CheckNeedDestroy() && data.Results[0].FreeNum <= 0 {
|
||||
sceneEx.SceneDestroy(true)
|
||||
}
|
||||
}
|
||||
func init() {
|
||||
//主状态
|
||||
ScenePolicyFortuneMouseSington.RegisteSceneState(&SceneStateStartFortuneMouse{})
|
||||
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
||||
base.RegisteScenePolicy(common.GameId_FortuneMouse, fortunemouse.RoomMode_Classic, ScenePolicyFortuneMouseSington)
|
||||
return nil
|
||||
})
|
||||
}
|
|
@ -511,9 +511,17 @@ func (this *ScenePolicyFortuneOx) GetSceneState(s *base.Scene, stateid int) base
|
|||
func FortuneOxAndSaveLog(sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerData, data assemble.GameEnd) {
|
||||
if !playerEx.IsRob {
|
||||
data.SnId = playerEx.SnId
|
||||
if data.Results[0].FreeStatus != 1 && data.Results[0].FreeNumMax != 0 {
|
||||
var respinStatus int
|
||||
if data.Results[0].ArrSpins[0].Special != nil {
|
||||
sp, _ := json.Marshal(data.Results[0].ArrSpins[0].Special)
|
||||
var spinLock SpinLock
|
||||
json.Unmarshal(sp, &spinLock)
|
||||
respinStatus = spinLock.ReSpinStatus
|
||||
}
|
||||
if respinStatus == 0 || respinStatus == 1 {
|
||||
data.TotalBet = 0
|
||||
}
|
||||
|
||||
info, err := model.MarshalGameNoteByROLL(data)
|
||||
if err == nil {
|
||||
logid, _ := model.AutoIncGameLogId()
|
||||
|
@ -524,10 +532,10 @@ func FortuneOxAndSaveLog(sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerD
|
|||
GameTime: 2,
|
||||
})
|
||||
var totalin, totalout int64
|
||||
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
|
||||
if respinStatus == 0 || respinStatus == 1 {
|
||||
totalin = playerEx.totalBet
|
||||
}
|
||||
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
|
||||
if respinStatus == 0 || respinStatus == 3 {
|
||||
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
||||
}
|
||||
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
|
||||
|
|
|
@ -409,7 +409,10 @@ func (this *SceneStateStartFortuneTiger) OnPlayerOp(s *base.Scene, p *base.Playe
|
|||
data = assemble.DataToCli(Response).(assemble.GameEnd)
|
||||
var respinStatus int
|
||||
if data.Results[0].ArrSpins[0].Special != nil {
|
||||
respinStatus = data.Results[0].ArrSpins[0].Special.(SpinLock).ReSpinStatus
|
||||
sp, _ := json.Marshal(data.Results[0].ArrSpins[0].Special)
|
||||
var spinLock SpinLock
|
||||
json.Unmarshal(sp, &spinLock)
|
||||
respinStatus = spinLock.ReSpinStatus
|
||||
}
|
||||
if respinStatus == 0 || respinStatus == 1 {
|
||||
//第一次触发或者正常模式
|
||||
|
|
|
@ -31,6 +31,7 @@ import (
|
|||
_ "mongo.games.com/game/gamesrv/caishen"
|
||||
_ "mongo.games.com/game/gamesrv/easterisland"
|
||||
_ "mongo.games.com/game/gamesrv/fortunedragon"
|
||||
_ "mongo.games.com/game/gamesrv/fortunemouse"
|
||||
_ "mongo.games.com/game/gamesrv/fortuneox"
|
||||
_ "mongo.games.com/game/gamesrv/fortunerabbit"
|
||||
_ "mongo.games.com/game/gamesrv/fortunetiger"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package errors
|
||||
|
||||
import "github.com/idealeak/goserver/core/logger"
|
||||
import "mongo.games.com/goserver/core/logger"
|
||||
|
||||
var (
|
||||
begins = []Code{ErrorBegin}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package slots
|
||||
|
||||
import (
|
||||
"github.com/idealeak/goserver/core/logger"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/global"
|
||||
|
@ -10,6 +9,7 @@ import (
|
|||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/machine"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/types/cli"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
)
|
||||
|
||||
func (sm *SlotsMgr) Enter(s *base.SlotsSession, gameId int64) (*cli.SlotsEnterResponse, error) {
|
||||
|
|
|
@ -12,6 +12,7 @@ type PlayerEx struct {
|
|||
cards [13]int //手牌信息
|
||||
allGroup map[int]*thirteen.Group //玩家所有牌型
|
||||
cardsO *thirteen.Group //确定的牌型信息
|
||||
preCardsO *thirteen.Group //预确定的牌型
|
||||
isDP bool // 是否倒排
|
||||
gainCoin int64 //本局赢的金币
|
||||
taxCoin int64 //本局税收
|
||||
|
@ -36,6 +37,7 @@ func (this *PlayerEx) Clear() {
|
|||
}
|
||||
this.allGroup = make(map[int]*thirteen.Group)
|
||||
this.cardsO = &thirteen.Group{Head: [3]int{-1, -1, -1}, Mid: [5]int{-1, -1, -1, -1, -1}, End: [5]int{-1, -1, -1, -1, -1}, PokerType: -1}
|
||||
this.preCardsO = &thirteen.Group{Head: [3]int{-1, -1, -1}, Mid: [5]int{-1, -1, -1, -1, -1}, End: [5]int{-1, -1, -1, -1, -1}, PokerType: -1}
|
||||
this.isDP = false
|
||||
this.gainCoin = 0
|
||||
this.taxCoin = 0
|
||||
|
|
|
@ -185,11 +185,14 @@ func (this *SceneEx) ThirteenWaterCreateRoomInfoPacket(s *base.Scene, p *base.Pl
|
|||
LeaveDeduct: this.GetDBGameFree().GetLeaveDeduct(),
|
||||
LeaveCombat: this.GetDBGameFree().GetLeaveCombat(),
|
||||
Params: common.CopySliceInt64ToInt32(s.Params),
|
||||
TimeOuts: this.GetDBGameFree().GetOtherIntParams(),
|
||||
}
|
||||
if len(pack.TimeOuts) > rule.TimeoutOp {
|
||||
pack.TimeOuts[rule.TimeoutOp] = int64(this.GetBaiPai().Seconds())
|
||||
}
|
||||
|
||||
pack.TimeOuts = make([]int64, 4)
|
||||
pack.TimeOuts[rule.TimeoutStart] = int64(rule.GetTimeout(this.GetDBGameFree().GetOtherIntParams(), rule.TimeoutStart).Seconds())
|
||||
pack.TimeOuts[rule.TimeoutSendCards] = int64(rule.GetTimeout(this.GetDBGameFree().GetOtherIntParams(), rule.TimeoutSendCards).Seconds())
|
||||
pack.TimeOuts[rule.TimeoutOp] = int64(rule.GetTimeout(this.GetDBGameFree().GetOtherIntParams(), rule.TimeoutOp).Seconds())
|
||||
pack.TimeOuts[rule.TimeoutBill] = int64(rule.GetTimeout(this.GetDBGameFree().GetOtherIntParams(), rule.TimeoutBill).Seconds())
|
||||
|
||||
// 玩家信息
|
||||
for _, playerEx := range this.players {
|
||||
pd := &thirteen.ThirteenPlayerData{
|
||||
|
@ -484,6 +487,7 @@ func (this *SceneEx) GetScore(player *PlayerEx) {
|
|||
player.winAllPlayers[p.Pos] += rate
|
||||
p.winAllPlayers[player.Pos] -= rate
|
||||
player.tableScore[3] += rate - 1
|
||||
p.tableScore[3] -= rate - 1
|
||||
}
|
||||
//中墩
|
||||
rate = int64(1)
|
||||
|
@ -506,6 +510,7 @@ func (this *SceneEx) GetScore(player *PlayerEx) {
|
|||
player.winAllPlayers[p.Pos] += rate
|
||||
p.winAllPlayers[player.Pos] -= rate
|
||||
player.tableScore[4] += rate - 1
|
||||
p.tableScore[4] -= rate - 1
|
||||
}
|
||||
//尾墩
|
||||
rate = int64(1)
|
||||
|
@ -526,6 +531,7 @@ func (this *SceneEx) GetScore(player *PlayerEx) {
|
|||
player.winAllPlayers[p.Pos] += rate
|
||||
p.winAllPlayers[player.Pos] -= rate
|
||||
player.tableScore[5] += rate - 1
|
||||
p.tableScore[5] -= rate - 1
|
||||
}
|
||||
if s == 3 {
|
||||
player.winThreePos[p.Pos] = score
|
||||
|
|
|
@ -507,6 +507,7 @@ func (this *BaseState) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, par
|
|||
if len(sceneEx.cardsArr) > 0 && playerEx.cards[0] == -1 {
|
||||
playerEx.MarkFlag(base.PlayerState_Ready)
|
||||
playerEx.UnmarkFlag(base.PlayerState_WaitNext)
|
||||
p.SyncFlag()
|
||||
playerEx.cards = sceneEx.cardsArr[0]
|
||||
playerEx.allGroup = sceneEx.cardsGroup[0]
|
||||
sceneEx.cardsArr = sceneEx.cardsArr[1:]
|
||||
|
@ -865,10 +866,15 @@ func (this *StateOp) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, param
|
|||
copy(playerEx.cardsO.Mid[:], common.Int64Toint(params[3:8]))
|
||||
copy(playerEx.cardsO.End[:], common.Int64Toint(params[8:]))
|
||||
playerEx.cardsO.PokerType = 0
|
||||
tp := sceneEx.logic.GetSpecialType(playerEx.cards)
|
||||
if tp > 0 {
|
||||
playerEx.cardsO.PokerType = tp
|
||||
}
|
||||
sceneEx.SendSelectCards(playerEx, 0, int64(opcode))
|
||||
} else {
|
||||
sceneEx.SendSelectCards(playerEx, int(params[0]), int64(opcode))
|
||||
}
|
||||
playerEx.preCardsO = &rule.Group{Head: [3]int{-1, -1, -1}, Mid: [5]int{-1, -1, -1, -1, -1}, End: [5]int{-1, -1, -1, -1, -1}, PokerType: -1}
|
||||
playerEx.Trusteeship = 0
|
||||
playerEx.UnmarkFlag(base.PlayerState_Auto)
|
||||
playerEx.deterMine = true
|
||||
|
@ -885,6 +891,38 @@ func (this *StateOp) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, param
|
|||
//提前进入亮牌阶段
|
||||
s.ChangeSceneState(rule.ThirteenWaterSceneStateShowCards)
|
||||
}
|
||||
|
||||
case rule.ThirteenWaterPlayerOpSelect:
|
||||
playerEx.deterMine = false
|
||||
playerEx.cardsO = &rule.Group{Head: [3]int{-1, -1, -1}, Mid: [5]int{-1, -1, -1, -1, -1}, End: [5]int{-1, -1, -1, -1, -1}, PokerType: -1}
|
||||
playerEx.Trusteeship = 0
|
||||
playerEx.UnmarkFlag(base.PlayerState_Auto)
|
||||
pack := &thirteen.SCThirteenPlayerOp{
|
||||
OpRetCode: thirteen.OpResultCode_OPRC_Sucess,
|
||||
OpCode: int32(opcode),
|
||||
OpParam: params,
|
||||
Pos: int32(playerEx.GetPos()),
|
||||
}
|
||||
if len(params) == 13 {
|
||||
//校验牌
|
||||
a := rule.DelCards(playerEx.cards[:], common.Int64Toint(params))
|
||||
if len(a) != 0 {
|
||||
logger.Logger.Error("the cards is error.")
|
||||
returnFunc(thirteen.OpResultCode_OPRC_Error)
|
||||
return true
|
||||
}
|
||||
//牌赋值
|
||||
copy(playerEx.preCardsO.Head[:], common.Int64Toint(params[:3]))
|
||||
copy(playerEx.preCardsO.Mid[:], common.Int64Toint(params[3:8]))
|
||||
copy(playerEx.preCardsO.End[:], common.Int64Toint(params[8:]))
|
||||
playerEx.preCardsO.PokerType = 0
|
||||
tp := sceneEx.logic.GetSpecialType(playerEx.cards)
|
||||
if tp > 0 {
|
||||
playerEx.preCardsO.PokerType = tp
|
||||
}
|
||||
}
|
||||
playerEx.SendToClient(int(thirteen.TWMmoPacketID_PACKET_SCThirteenPlayerOp), pack)
|
||||
|
||||
case rule.ThirteenWaterPlayerOpReset:
|
||||
// 取消确认
|
||||
playerEx.deterMine = false
|
||||
|
@ -912,8 +950,13 @@ func (this *StateOp) OnLeave(s *base.Scene) {
|
|||
|
||||
for _, player := range sceneEx.players {
|
||||
if player != nil && player.IsGameing() {
|
||||
// 使用预选牌
|
||||
if player.preCardsO != nil && player.preCardsO.PokerType != -1 && (player.cardsO == nil || player.cardsO.PokerType == -1) {
|
||||
player.cardsO = player.preCardsO
|
||||
}
|
||||
// 判断是否倒水
|
||||
if player.cardsO != nil && player.cardsO.PokerType != -1 {
|
||||
if player.cardsO.PokerType < 1000000 {
|
||||
if player.cardsO.PokerType == 0 {
|
||||
player.isDP = sceneEx.logic.IsDP(player.cardsO.Head, player.cardsO.Mid, player.cardsO.End)
|
||||
}
|
||||
continue
|
||||
|
@ -1120,21 +1163,55 @@ func (this *StateShow) OnEnter(s *base.Scene) {
|
|||
logger.Logger.Tracef("(this *StateShow) OnEnter, sceneid=%v currpos:%v", s.GetSceneId(), sceneEx.currOpPos)
|
||||
sceneEx.ShowCards()
|
||||
// 每人看牌5秒,特殊牌型不算;
|
||||
var n int
|
||||
var has bool
|
||||
//var n int
|
||||
//var has bool
|
||||
//for _, v := range sceneEx.players {
|
||||
// if v != nil && v.IsGameing() && v.cardsO != nil {
|
||||
// n++
|
||||
// if v.cardsO.PokerType == 1 { // 有青龙
|
||||
// has = true
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//n -= sceneEx.specialTypeNum
|
||||
//sceneEx.specialTime = time.Second * time.Duration(n*5)
|
||||
//// pk动画 2秒
|
||||
//sceneEx.specialTime += time.Second * 2
|
||||
//// 特殊牌型 4.5秒;至尊青龙5.5秒
|
||||
//if sceneEx.specialTypeNum > 0 {
|
||||
// if has {
|
||||
// sceneEx.specialTime += time.Millisecond * 5500
|
||||
// } else {
|
||||
// sceneEx.specialTime += time.Millisecond * 4500
|
||||
// }
|
||||
//}
|
||||
|
||||
sceneEx.specialTime = 0
|
||||
// pk动画 2秒
|
||||
sceneEx.specialTime += time.Second * 2
|
||||
// 2人且有特殊牌型,直接播放特殊牌型动画
|
||||
var n int // 玩家数量
|
||||
var has bool // 是否有青龙
|
||||
var hasDP bool // 是否有倒水
|
||||
for _, v := range sceneEx.players {
|
||||
if v != nil && v.IsGameing() && v.cardsO != nil {
|
||||
n++
|
||||
if v.cardsO.PokerType == 1 { // 有青龙
|
||||
has = true
|
||||
}
|
||||
if v.isDP {
|
||||
hasDP = true
|
||||
}
|
||||
}
|
||||
n -= sceneEx.specialTypeNum
|
||||
sceneEx.specialTime = time.Second * time.Duration(n*5)
|
||||
// pk动画 2秒
|
||||
sceneEx.specialTime += time.Second * 2
|
||||
// 特殊牌型 4.5秒;至尊青龙5.5秒
|
||||
}
|
||||
|
||||
normalNum := n - sceneEx.specialTypeNum
|
||||
if hasDP {
|
||||
sceneEx.specialTime += time.Second
|
||||
}
|
||||
if normalNum > 1 {
|
||||
sceneEx.specialTime += time.Second * time.Duration(5)
|
||||
}
|
||||
if sceneEx.specialTypeNum > 0 {
|
||||
if has {
|
||||
sceneEx.specialTime += time.Millisecond * 5500
|
||||
|
@ -1142,6 +1219,7 @@ func (this *StateShow) OnEnter(s *base.Scene) {
|
|||
sceneEx.specialTime += time.Millisecond * 4500
|
||||
}
|
||||
}
|
||||
|
||||
logger.Logger.Tracef("show cards: %v %v", n, sceneEx.specialTime)
|
||||
if sceneEx.specialTime <= 0 {
|
||||
sceneEx.specialTime = time.Second
|
||||
|
@ -1198,11 +1276,8 @@ func (this *StateHit) OnEnter(s *base.Scene) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if sceneEx.isCanAllHitPos != -1 {
|
||||
hitNum++
|
||||
}
|
||||
// 每个打枪加1秒,全垒打再加1秒
|
||||
sceneEx.hitTime += time.Second * (time.Duration(hitNum))
|
||||
// 每个打枪加2秒,全垒打再加2秒
|
||||
sceneEx.hitTime += time.Second * 2 * (time.Duration(hitNum))
|
||||
sceneEx.ShowCards()
|
||||
}
|
||||
}
|
||||
|
|
11
go.mod
11
go.mod
|
@ -16,7 +16,6 @@ require (
|
|||
github.com/golang-jwt/jwt/v4 v4.5.1
|
||||
github.com/google/go-querystring v1.1.0
|
||||
github.com/howeyc/fsnotify v0.9.0
|
||||
github.com/idealeak/goserver v0.0.0-20201014040547-b8f686262078
|
||||
github.com/jinzhu/now v1.1.5
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
|
||||
github.com/mojocn/base64Captcha v1.3.6
|
||||
|
@ -26,13 +25,13 @@ require (
|
|||
github.com/tomas-qstarrs/boost v1.0.3
|
||||
github.com/tomas-qstarrs/excel-converter v1.0.2
|
||||
github.com/wendal/errors v0.0.0-20181209125328-7f31f4b264ec
|
||||
github.com/xuri/excelize/v2 v2.9.0
|
||||
github.com/zegoim/zego_server_assistant/token/go/src v0.0.0-20231013093807-4e80bab42ec3
|
||||
github.com/zeromicro/go-zero v1.7.3
|
||||
go.etcd.io/etcd/client/v3 v3.5.16
|
||||
go.mongodb.org/mongo-driver v1.17.1
|
||||
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
|
||||
google.golang.org/protobuf v1.35.1
|
||||
gorm.io/driver/mysql v1.5.7
|
||||
gorm.io/gorm v1.25.12
|
||||
mongo.games.com/goserver v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
|
@ -70,7 +69,7 @@ require (
|
|||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/richardlehane/mscfb v1.0.4 // indirect
|
||||
github.com/richardlehane/msoleps v1.0.3 // indirect
|
||||
github.com/richardlehane/msoleps v1.0.4 // indirect
|
||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/shopspring/decimal v1.3.1 // indirect
|
||||
|
@ -92,7 +91,8 @@ require (
|
|||
github.com/xdg-go/scram v1.1.2 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.4 // indirect
|
||||
github.com/xtaci/kcp-go v5.4.20+incompatible // indirect
|
||||
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect
|
||||
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d // indirect
|
||||
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.16 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.16 // indirect
|
||||
|
@ -103,7 +103,7 @@ require (
|
|||
go.uber.org/multierr v1.9.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.28.0 // indirect
|
||||
golang.org/x/image v0.13.0 // indirect
|
||||
golang.org/x/image v0.18.0 // indirect
|
||||
golang.org/x/net v0.30.0 // indirect
|
||||
golang.org/x/sync v0.8.0 // indirect
|
||||
golang.org/x/sys v0.26.0 // indirect
|
||||
|
@ -115,4 +115,5 @@ require (
|
|||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/driver/mysql v1.5.7 // indirect
|
||||
)
|
||||
|
|
17
go.sum
17
go.sum
|
@ -157,8 +157,6 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T
|
|||
github.com/howeyc/fsnotify v0.9.0 h1:0gtV5JmOKH4A8SsFxG2BczSeXWWPvcMT0euZt5gDAxY=
|
||||
github.com/howeyc/fsnotify v0.9.0/go.mod h1:41HzSPxBGeFRQKEEwgh49TRw/nKBsYZ2cF1OzPjSJsA=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/idealeak/goserver v0.0.0-20201014040547-b8f686262078 h1:0Z5Im7EJiMKEiIQPPApdK0uOtyV5Ylo9wA3N9jWrfsU=
|
||||
github.com/idealeak/goserver v0.0.0-20201014040547-b8f686262078/go.mod h1:ozCWDPw33jhq/GX7nsWS0cFCm5Jyag/Fy0LSQpKXT1I=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/innopals/sls-logrus-hook v0.0.0-20190808032145-2fe1d6f7ce00 h1:QfdUfoZWIzBZ/FMtdUE/3wUwzsMU+PGTld17NDBld3k=
|
||||
github.com/innopals/sls-logrus-hook v0.0.0-20190808032145-2fe1d6f7ce00/go.mod h1:Q24O6QMGImDU3WY71P4YAxNb36NNn5qaznCfMUoXVfc=
|
||||
|
@ -279,8 +277,8 @@ github.com/richardlehane/mscfb v1.0.3/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7
|
|||
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
|
||||
github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
|
||||
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
|
||||
github.com/richardlehane/msoleps v1.0.3 h1:aznSZzrwYRl3rLKRT3gUk9am7T/mLNSnJINvN0AQoVM=
|
||||
github.com/richardlehane/msoleps v1.0.3/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
|
||||
github.com/richardlehane/msoleps v1.0.4 h1:WuESlvhX3gH2IHcd8UqyCuFY5yiq/GR/yqaSM/9/g00=
|
||||
github.com/richardlehane/msoleps v1.0.4/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
|
@ -386,8 +384,12 @@ github.com/xtaci/kcp-go v5.4.20+incompatible/go.mod h1:bN6vIwHQbfHaHtFpEssmWsN45
|
|||
github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37 h1:EWU6Pktpas0n8lLQwDsRyZfmkPeRbdgPtW609es+/9E=
|
||||
github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37/go.mod h1:HpMP7DB2CyokmAh4lp0EQnnWhmycP/TvwBGzvuie+H0=
|
||||
github.com/xuri/efp v0.0.0-20200605144744-ba689101faaf/go.mod h1:uBiSUepVYMhGTfDeBKKasV4GpgBlzJ46gXUBAqV8qLk=
|
||||
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 h1:6932x8ltq1w4utjmfMPVj09jdMlkY0aiA6+Skbtl3/c=
|
||||
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
|
||||
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d h1:llb0neMWDQe87IzJLS4Ci7psK/lVsjIS2otl+1WyRyY=
|
||||
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
|
||||
github.com/xuri/excelize/v2 v2.9.0 h1:1tgOaEq92IOEumR1/JfYS/eR0KHOCsRv/rYXXh6YJQE=
|
||||
github.com/xuri/excelize/v2 v2.9.0/go.mod h1:uqey4QBZ9gdMeWApPLdhm9x+9o2lq4iVmjiLfBS5hdE=
|
||||
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 h1:hPVCafDV85blFTabnqKgNhDCkJX25eik94Si9cTER4A=
|
||||
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
|
||||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
|
||||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
|
@ -441,8 +443,9 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL
|
|||
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
|
||||
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
|
||||
golang.org/x/image v0.0.0-20200922025426-e59bae62ef32/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.13.0 h1:3cge/F/QTkNLauhf2QoE9zp+7sr+ZcL4HnoZmdwg9sg=
|
||||
golang.org/x/image v0.13.0/go.mod h1:6mmbMOeV28HuMTgA6OSRkdXKYw/t5W9Uwn2Yv1r3Yxk=
|
||||
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
|
||||
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
|
|
|
@ -108,7 +108,7 @@ func (c *MessageMgr) RegisterHandler(param *RegisterHandlerParam) {
|
|||
logger.Logger.Errorf("RabbitMQ Unmarshal error: %v", err)
|
||||
return
|
||||
}
|
||||
logger.Logger.Tracef("==> Receive RabbitMQ(%v): %#v", param.Name, log)
|
||||
logger.Logger.Tracef("MQ Receive[%v]: %#v", param.Name, log)
|
||||
|
||||
return c.handler[param.Name].F(log)
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ func StopPublisher() {
|
|||
|
||||
func Send(topic string, msg interface{}, opts ...broker.PublishOption) (err error) {
|
||||
if globalPublisher != nil {
|
||||
logger.Logger.Tracef("==> RabbitMQ(%v): %#v", topic, msg)
|
||||
logger.Logger.Tracef("MQ Send[%v]: %#v", topic, msg)
|
||||
return globalPublisher.Send(topic, msg, opts...)
|
||||
}
|
||||
logger.Logger.Errorf("RabbitMQPublisher not start!")
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"mongo.games.com/game/mysql/internal"
|
||||
)
|
||||
|
||||
var NotInitError = errors.New("mysql manager is nil, please call Init() first")
|
||||
|
||||
type Config = internal.Config
|
||||
type DatabaseConfig = internal.DatabaseConfig
|
||||
type Database = internal.Database
|
||||
|
||||
var manager *internal.Manager
|
||||
|
||||
func Init(conf *Config) error {
|
||||
manager = internal.NewManager(conf)
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetAutoMigrateTables(tables []interface{}) {
|
||||
if manager == nil {
|
||||
return
|
||||
}
|
||||
manager.SetAutoMigrateTables(tables)
|
||||
}
|
||||
|
||||
func GetConfig() *Config {
|
||||
if manager == nil {
|
||||
return nil
|
||||
}
|
||||
return manager.GetConfig()
|
||||
}
|
||||
|
||||
func Close() {
|
||||
if manager == nil {
|
||||
return
|
||||
}
|
||||
manager.Close()
|
||||
}
|
||||
|
||||
func GetDatabase(platform string) (*Database, error) {
|
||||
if manager == nil {
|
||||
return nil, NotInitError
|
||||
}
|
||||
return manager.GetDatabase(platform)
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Platforms map[string]*DatabaseConfig
|
||||
MaxIdleConns int
|
||||
MaxOpenConns int
|
||||
ConnMaxLifetime int
|
||||
ConnMaxIdletime int
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
HostName string
|
||||
HostPort int32
|
||||
Database string
|
||||
Username string
|
||||
Password string
|
||||
Options string
|
||||
}
|
||||
|
||||
type Database struct {
|
||||
*Manager
|
||||
*Config
|
||||
*DatabaseConfig
|
||||
*gorm.DB
|
||||
}
|
||||
|
||||
func (d *Database) Connect() error {
|
||||
if d.DatabaseConfig == nil {
|
||||
err := fmt.Errorf("mysql Connect error, DatabaseConifg not found")
|
||||
logger.Logger.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
login := ""
|
||||
if d.DatabaseConfig.Username != "" {
|
||||
login = d.DatabaseConfig.Username + ":" + d.DatabaseConfig.Password + "@"
|
||||
}
|
||||
host := d.DatabaseConfig.HostName
|
||||
if d.DatabaseConfig.HostName == "" {
|
||||
host = "127.0.0.1"
|
||||
}
|
||||
port := d.DatabaseConfig.HostPort
|
||||
if d.DatabaseConfig.HostPort == 0 {
|
||||
port = 3306
|
||||
}
|
||||
database := d.DatabaseConfig.Database
|
||||
if database == "" {
|
||||
database = "mysql"
|
||||
}
|
||||
myOptions := d.DatabaseConfig.Options
|
||||
if myOptions != "" {
|
||||
myOptions = "?" + myOptions
|
||||
}
|
||||
|
||||
// [username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN]
|
||||
s := fmt.Sprintf("%stcp(%s:%d)/%s%s", login, host, port, "mysql", myOptions)
|
||||
db, err := gorm.Open(mysql.Open(s), &gorm.Config{})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql Connect %v error: %v config:%+v", s, err, *d.DatabaseConfig)
|
||||
return err
|
||||
}
|
||||
logger.Logger.Tracef("mysql connect success %+v", *d.DatabaseConfig)
|
||||
|
||||
err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci", d.DatabaseConfig.Database)).Error
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql create database %s error: %v", d.DatabaseConfig.Database, err)
|
||||
return err
|
||||
}
|
||||
|
||||
s = fmt.Sprintf("%stcp(%s:%d)/%s%s", login, host, port, d.DatabaseConfig.Database, myOptions)
|
||||
db, err = gorm.Open(mysql.Open(s), &gorm.Config{SkipDefaultTransaction: true})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql Connect %v error: %v config:%+v", s, err, *d.DatabaseConfig)
|
||||
return err
|
||||
}
|
||||
|
||||
sqlDB, err := db.DB()
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql get DB error: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if len(d.tables) > 0 {
|
||||
if err := db.AutoMigrate(d.tables...); err != nil {
|
||||
logger.Logger.Warnf("mysql migrate error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
sqlDB.SetMaxIdleConns(d.MaxIdleConns)
|
||||
sqlDB.SetMaxOpenConns(d.MaxOpenConns)
|
||||
sqlDB.SetConnMaxLifetime(time.Duration(d.ConnMaxLifetime))
|
||||
sqlDB.SetConnMaxIdleTime(time.Duration(d.ConnMaxIdletime))
|
||||
|
||||
d.DB = db.Session(&gorm.Session{SkipDefaultTransaction: true})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Manager struct {
|
||||
conf *Config
|
||||
platforms sync.Map // 平台id:Database
|
||||
tables []interface{}
|
||||
}
|
||||
|
||||
func (m *Manager) GetConfig() *Config {
|
||||
return m.conf
|
||||
}
|
||||
|
||||
func (m *Manager) SetAutoMigrateTables(tables []interface{}) {
|
||||
m.tables = tables
|
||||
}
|
||||
|
||||
func (m *Manager) GetDatabase(key string) (*Database, error) {
|
||||
v, ok := m.platforms.Load(key) // 平台id
|
||||
if !ok {
|
||||
db := &Database{
|
||||
Manager: m,
|
||||
Config: m.conf,
|
||||
DatabaseConfig: m.conf.Platforms[key],
|
||||
}
|
||||
if err := db.Connect(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v = db
|
||||
m.platforms.Store(key, v)
|
||||
}
|
||||
d, _ := v.(*Database)
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (m *Manager) Close() {
|
||||
|
||||
}
|
||||
|
||||
func NewManager(conf *Config) *Manager {
|
||||
return &Manager{
|
||||
conf: conf,
|
||||
platforms: sync.Map{},
|
||||
}
|
||||
}
|
|
@ -0,0 +1,799 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1-devel
|
||||
// protoc v3.19.4
|
||||
// source: protocol/cashmania/cashmania.proto
|
||||
|
||||
package cashmania
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
//cashmania
|
||||
//龙
|
||||
type CashManiaPID int32
|
||||
|
||||
const (
|
||||
CashManiaPID_PACKET_CASHMANIA_ZERO CashManiaPID = 0 // 弃用消息号
|
||||
CashManiaPID_PACKET_CASHMANIA_SCCASHMANIAROOMINFO CashManiaPID = 5650 //房间信息
|
||||
CashManiaPID_PACKET_CASHMANIA_CSCASHMANIAOP CashManiaPID = 5651
|
||||
CashManiaPID_PACKET_CASHMANIA_SCCASHMANIAOP CashManiaPID = 5652
|
||||
CashManiaPID_PACKET_CASHMANIA_SCCASHMANIAROOMSTATE CashManiaPID = 5653
|
||||
CashManiaPID_PACKET_CASHMANIA_SCCASHMANIABILLED CashManiaPID = 5654
|
||||
)
|
||||
|
||||
// Enum value maps for CashManiaPID.
|
||||
var (
|
||||
CashManiaPID_name = map[int32]string{
|
||||
0: "PACKET_CASHMANIA_ZERO",
|
||||
5650: "PACKET_CASHMANIA_SCCASHMANIAROOMINFO",
|
||||
5651: "PACKET_CASHMANIA_CSCASHMANIAOP",
|
||||
5652: "PACKET_CASHMANIA_SCCASHMANIAOP",
|
||||
5653: "PACKET_CASHMANIA_SCCASHMANIAROOMSTATE",
|
||||
5654: "PACKET_CASHMANIA_SCCASHMANIABILLED",
|
||||
}
|
||||
CashManiaPID_value = map[string]int32{
|
||||
"PACKET_CASHMANIA_ZERO": 0,
|
||||
"PACKET_CASHMANIA_SCCASHMANIAROOMINFO": 5650,
|
||||
"PACKET_CASHMANIA_CSCASHMANIAOP": 5651,
|
||||
"PACKET_CASHMANIA_SCCASHMANIAOP": 5652,
|
||||
"PACKET_CASHMANIA_SCCASHMANIAROOMSTATE": 5653,
|
||||
"PACKET_CASHMANIA_SCCASHMANIABILLED": 5654,
|
||||
}
|
||||
)
|
||||
|
||||
func (x CashManiaPID) Enum() *CashManiaPID {
|
||||
p := new(CashManiaPID)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x CashManiaPID) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (CashManiaPID) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_protocol_cashmania_cashmania_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (CashManiaPID) Type() protoreflect.EnumType {
|
||||
return &file_protocol_cashmania_cashmania_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x CashManiaPID) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CashManiaPID.Descriptor instead.
|
||||
func (CashManiaPID) EnumDescriptor() ([]byte, []int) {
|
||||
return file_protocol_cashmania_cashmania_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type CashManiaPlayerData struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` //名字
|
||||
SnId int32 `protobuf:"varint,2,opt,name=SnId,proto3" json:"SnId,omitempty"` //账号
|
||||
Head int32 `protobuf:"varint,3,opt,name=Head,proto3" json:"Head,omitempty"` //头像
|
||||
Sex int32 `protobuf:"varint,4,opt,name=Sex,proto3" json:"Sex,omitempty"` //性别
|
||||
Coin int64 `protobuf:"varint,5,opt,name=Coin,proto3" json:"Coin,omitempty"` //金币
|
||||
Pos int32 `protobuf:"varint,6,opt,name=Pos,proto3" json:"Pos,omitempty"` //座位位置
|
||||
Flag int32 `protobuf:"varint,7,opt,name=Flag,proto3" json:"Flag,omitempty"` //二进制标记
|
||||
Params []string `protobuf:"bytes,8,rep,name=Params,proto3" json:"Params,omitempty"` //其他数据 如:ip 等
|
||||
City string `protobuf:"bytes,9,opt,name=City,proto3" json:"City,omitempty"` //城市
|
||||
HeadOutLine int32 `protobuf:"varint,10,opt,name=HeadOutLine,proto3" json:"HeadOutLine,omitempty"` //头像框
|
||||
VIP int32 `protobuf:"varint,11,opt,name=VIP,proto3" json:"VIP,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) Reset() {
|
||||
*x = CashManiaPlayerData{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_protocol_cashmania_cashmania_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CashManiaPlayerData) ProtoMessage() {}
|
||||
|
||||
func (x *CashManiaPlayerData) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protocol_cashmania_cashmania_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CashManiaPlayerData.ProtoReflect.Descriptor instead.
|
||||
func (*CashManiaPlayerData) Descriptor() ([]byte, []int) {
|
||||
return file_protocol_cashmania_cashmania_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) GetSnId() int32 {
|
||||
if x != nil {
|
||||
return x.SnId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) GetHead() int32 {
|
||||
if x != nil {
|
||||
return x.Head
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) GetSex() int32 {
|
||||
if x != nil {
|
||||
return x.Sex
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) GetCoin() int64 {
|
||||
if x != nil {
|
||||
return x.Coin
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) GetPos() int32 {
|
||||
if x != nil {
|
||||
return x.Pos
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) GetFlag() int32 {
|
||||
if x != nil {
|
||||
return x.Flag
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) GetParams() []string {
|
||||
if x != nil {
|
||||
return x.Params
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) GetCity() string {
|
||||
if x != nil {
|
||||
return x.City
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) GetHeadOutLine() int32 {
|
||||
if x != nil {
|
||||
return x.HeadOutLine
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CashManiaPlayerData) GetVIP() int32 {
|
||||
if x != nil {
|
||||
return x.VIP
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
//房间信息
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEROOMINFO
|
||||
type SCCashManiaRoomInfo struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
RoomId int32 `protobuf:"varint,1,opt,name=RoomId,proto3" json:"RoomId,omitempty"` //房间id
|
||||
GameFreeId int32 `protobuf:"varint,2,opt,name=GameFreeId,proto3" json:"GameFreeId,omitempty"`
|
||||
GameId int32 `protobuf:"varint,3,opt,name=GameId,proto3" json:"GameId,omitempty"` //游戏id
|
||||
RoomMode int32 `protobuf:"varint,4,opt,name=RoomMode,proto3" json:"RoomMode,omitempty"` //游戏模式
|
||||
Params []int32 `protobuf:"varint,5,rep,packed,name=Params,proto3" json:"Params,omitempty"` //规则参数
|
||||
NumOfGames int32 `protobuf:"varint,6,opt,name=NumOfGames,proto3" json:"NumOfGames,omitempty"` //当前第几局
|
||||
State int32 `protobuf:"varint,7,opt,name=State,proto3" json:"State,omitempty"` //房间当前状态
|
||||
ParamsEx []int64 `protobuf:"varint,8,rep,packed,name=ParamsEx,proto3" json:"ParamsEx,omitempty"` //其他参数
|
||||
SceneType int32 `protobuf:"varint,9,opt,name=SceneType,proto3" json:"SceneType,omitempty"` //房间模式
|
||||
Player *CashManiaPlayerData `protobuf:"bytes,10,opt,name=Player,proto3" json:"Player,omitempty"` //房间内的玩家信息
|
||||
PlayerInfo string `protobuf:"bytes,11,opt,name=PlayerInfo,proto3" json:"PlayerInfo,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) Reset() {
|
||||
*x = SCCashManiaRoomInfo{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_protocol_cashmania_cashmania_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SCCashManiaRoomInfo) ProtoMessage() {}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protocol_cashmania_cashmania_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SCCashManiaRoomInfo.ProtoReflect.Descriptor instead.
|
||||
func (*SCCashManiaRoomInfo) Descriptor() ([]byte, []int) {
|
||||
return file_protocol_cashmania_cashmania_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) GetRoomId() int32 {
|
||||
if x != nil {
|
||||
return x.RoomId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) GetGameFreeId() int32 {
|
||||
if x != nil {
|
||||
return x.GameFreeId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) GetGameId() int32 {
|
||||
if x != nil {
|
||||
return x.GameId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) GetRoomMode() int32 {
|
||||
if x != nil {
|
||||
return x.RoomMode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) GetParams() []int32 {
|
||||
if x != nil {
|
||||
return x.Params
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) GetNumOfGames() int32 {
|
||||
if x != nil {
|
||||
return x.NumOfGames
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) GetState() int32 {
|
||||
if x != nil {
|
||||
return x.State
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) GetParamsEx() []int64 {
|
||||
if x != nil {
|
||||
return x.ParamsEx
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) GetSceneType() int32 {
|
||||
if x != nil {
|
||||
return x.SceneType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) GetPlayer() *CashManiaPlayerData {
|
||||
if x != nil {
|
||||
return x.Player
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomInfo) GetPlayerInfo() string {
|
||||
if x != nil {
|
||||
return x.PlayerInfo
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
//玩家操作
|
||||
//PACKET_FORTUNEMOUSE_CSFORTUNEMOUSEOP
|
||||
type CSCashManiaOp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
OpCode int32 `protobuf:"varint,1,opt,name=OpCode,proto3" json:"OpCode,omitempty"` //操作码 0.spin
|
||||
Params []int64 `protobuf:"varint,2,rep,packed,name=Params,proto3" json:"Params,omitempty"` //操作参数 下注索引编号
|
||||
}
|
||||
|
||||
func (x *CSCashManiaOp) Reset() {
|
||||
*x = CSCashManiaOp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_protocol_cashmania_cashmania_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CSCashManiaOp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CSCashManiaOp) ProtoMessage() {}
|
||||
|
||||
func (x *CSCashManiaOp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protocol_cashmania_cashmania_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CSCashManiaOp.ProtoReflect.Descriptor instead.
|
||||
func (*CSCashManiaOp) Descriptor() ([]byte, []int) {
|
||||
return file_protocol_cashmania_cashmania_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *CSCashManiaOp) GetOpCode() int32 {
|
||||
if x != nil {
|
||||
return x.OpCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CSCashManiaOp) GetParams() []int64 {
|
||||
if x != nil {
|
||||
return x.Params
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//玩家操作返回
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEOP
|
||||
type SCCashManiaOp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
OpCode int32 `protobuf:"varint,1,opt,name=OpCode,proto3" json:"OpCode,omitempty"` //操作码
|
||||
OpRetCode int32 `protobuf:"varint,2,opt,name=OpRetCode,proto3" json:"OpRetCode,omitempty"` //操作结果 1.金币不足 2.低于该值不能押注
|
||||
Params []int64 `protobuf:"varint,3,rep,packed,name=Params,proto3" json:"Params,omitempty"` //操作参数
|
||||
}
|
||||
|
||||
func (x *SCCashManiaOp) Reset() {
|
||||
*x = SCCashManiaOp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_protocol_cashmania_cashmania_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SCCashManiaOp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SCCashManiaOp) ProtoMessage() {}
|
||||
|
||||
func (x *SCCashManiaOp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protocol_cashmania_cashmania_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SCCashManiaOp.ProtoReflect.Descriptor instead.
|
||||
func (*SCCashManiaOp) Descriptor() ([]byte, []int) {
|
||||
return file_protocol_cashmania_cashmania_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *SCCashManiaOp) GetOpCode() int32 {
|
||||
if x != nil {
|
||||
return x.OpCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCCashManiaOp) GetOpRetCode() int32 {
|
||||
if x != nil {
|
||||
return x.OpRetCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCCashManiaOp) GetParams() []int64 {
|
||||
if x != nil {
|
||||
return x.Params
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//房间状态
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEROOMSTATE
|
||||
type SCCashManiaRoomState struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
State int32 `protobuf:"varint,1,opt,name=State,proto3" json:"State,omitempty"` //房间当前状态
|
||||
SubState int32 `protobuf:"varint,2,opt,name=SubState,proto3" json:"SubState,omitempty"` //房间当前子状态
|
||||
Params []int32 `protobuf:"varint,3,rep,packed,name=Params,proto3" json:"Params,omitempty"` //状态参数
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomState) Reset() {
|
||||
*x = SCCashManiaRoomState{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_protocol_cashmania_cashmania_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomState) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SCCashManiaRoomState) ProtoMessage() {}
|
||||
|
||||
func (x *SCCashManiaRoomState) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protocol_cashmania_cashmania_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SCCashManiaRoomState.ProtoReflect.Descriptor instead.
|
||||
func (*SCCashManiaRoomState) Descriptor() ([]byte, []int) {
|
||||
return file_protocol_cashmania_cashmania_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomState) GetState() int32 {
|
||||
if x != nil {
|
||||
return x.State
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomState) GetSubState() int32 {
|
||||
if x != nil {
|
||||
return x.SubState
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCCashManiaRoomState) GetParams() []int32 {
|
||||
if x != nil {
|
||||
return x.Params
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEBILLED
|
||||
type SCCashManiaBilled struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
OpRetCode int32 `protobuf:"varint,1,opt,name=OpRetCode,proto3" json:"OpRetCode,omitempty"` //0.spin成功 1.spin失败
|
||||
GameEndStr string `protobuf:"bytes,2,opt,name=GameEndStr,proto3" json:"GameEndStr,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SCCashManiaBilled) Reset() {
|
||||
*x = SCCashManiaBilled{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_protocol_cashmania_cashmania_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SCCashManiaBilled) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SCCashManiaBilled) ProtoMessage() {}
|
||||
|
||||
func (x *SCCashManiaBilled) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protocol_cashmania_cashmania_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SCCashManiaBilled.ProtoReflect.Descriptor instead.
|
||||
func (*SCCashManiaBilled) Descriptor() ([]byte, []int) {
|
||||
return file_protocol_cashmania_cashmania_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *SCCashManiaBilled) GetOpRetCode() int32 {
|
||||
if x != nil {
|
||||
return x.OpRetCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCCashManiaBilled) GetGameEndStr() string {
|
||||
if x != nil {
|
||||
return x.GameEndStr
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_protocol_cashmania_cashmania_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_protocol_cashmania_cashmania_proto_rawDesc = []byte{
|
||||
0x0a, 0x22, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x63, 0x61, 0x73, 0x68, 0x6d,
|
||||
0x61, 0x6e, 0x69, 0x61, 0x2f, 0x63, 0x61, 0x73, 0x68, 0x6d, 0x61, 0x6e, 0x69, 0x61, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x63, 0x61, 0x73, 0x68, 0x6d, 0x61, 0x6e, 0x69, 0x61, 0x22,
|
||||
0xfd, 0x01, 0x0a, 0x13, 0x43, 0x61, 0x73, 0x68, 0x4d, 0x61, 0x6e, 0x69, 0x61, 0x50, 0x6c, 0x61,
|
||||
0x79, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x53,
|
||||
0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x6e, 0x49, 0x64, 0x12,
|
||||
0x12, 0x0a, 0x04, 0x48, 0x65, 0x61, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x48,
|
||||
0x65, 0x61, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x03, 0x53, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x69, 0x6e, 0x18, 0x05, 0x20,
|
||||
0x01, 0x28, 0x03, 0x52, 0x04, 0x43, 0x6f, 0x69, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x50, 0x6f, 0x73,
|
||||
0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x50, 0x6f, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x46,
|
||||
0x6c, 0x61, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x46, 0x6c, 0x61, 0x67, 0x12,
|
||||
0x16, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52,
|
||||
0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x69, 0x74, 0x79, 0x18,
|
||||
0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x43, 0x69, 0x74, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x48,
|
||||
0x65, 0x61, 0x64, 0x4f, 0x75, 0x74, 0x4c, 0x69, 0x6e, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x4f, 0x75, 0x74, 0x4c, 0x69, 0x6e, 0x65, 0x12, 0x10, 0x0a,
|
||||
0x03, 0x56, 0x49, 0x50, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x56, 0x49, 0x50, 0x22,
|
||||
0xe1, 0x02, 0x0a, 0x13, 0x53, 0x43, 0x43, 0x61, 0x73, 0x68, 0x4d, 0x61, 0x6e, 0x69, 0x61, 0x52,
|
||||
0x6f, 0x6f, 0x6d, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x52, 0x6f, 0x6f, 0x6d, 0x49,
|
||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x12,
|
||||
0x1e, 0x0a, 0x0a, 0x47, 0x61, 0x6d, 0x65, 0x46, 0x72, 0x65, 0x65, 0x49, 0x64, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x0a, 0x47, 0x61, 0x6d, 0x65, 0x46, 0x72, 0x65, 0x65, 0x49, 0x64, 0x12,
|
||||
0x16, 0x0a, 0x06, 0x47, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x06, 0x47, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x52, 0x6f, 0x6f, 0x6d, 0x4d,
|
||||
0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x52, 0x6f, 0x6f, 0x6d, 0x4d,
|
||||
0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x05, 0x20,
|
||||
0x03, 0x28, 0x05, 0x52, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x4e,
|
||||
0x75, 0x6d, 0x4f, 0x66, 0x47, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x0a, 0x4e, 0x75, 0x6d, 0x4f, 0x66, 0x47, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x53,
|
||||
0x74, 0x61, 0x74, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x53, 0x74, 0x61, 0x74,
|
||||
0x65, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x45, 0x78, 0x18, 0x08, 0x20,
|
||||
0x03, 0x28, 0x03, 0x52, 0x08, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x45, 0x78, 0x12, 0x1c, 0x0a,
|
||||
0x09, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x09, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x36, 0x0a, 0x06, 0x50,
|
||||
0x6c, 0x61, 0x79, 0x65, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x61,
|
||||
0x73, 0x68, 0x6d, 0x61, 0x6e, 0x69, 0x61, 0x2e, 0x43, 0x61, 0x73, 0x68, 0x4d, 0x61, 0x6e, 0x69,
|
||||
0x61, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x06, 0x50, 0x6c, 0x61,
|
||||
0x79, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x6e, 0x66,
|
||||
0x6f, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49,
|
||||
0x6e, 0x66, 0x6f, 0x22, 0x3f, 0x0a, 0x0d, 0x43, 0x53, 0x43, 0x61, 0x73, 0x68, 0x4d, 0x61, 0x6e,
|
||||
0x69, 0x61, 0x4f, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x4f, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x4f, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x03, 0x52, 0x06, 0x50, 0x61,
|
||||
0x72, 0x61, 0x6d, 0x73, 0x22, 0x5d, 0x0a, 0x0d, 0x53, 0x43, 0x43, 0x61, 0x73, 0x68, 0x4d, 0x61,
|
||||
0x6e, 0x69, 0x61, 0x4f, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x4f, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x4f, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1c, 0x0a,
|
||||
0x09, 0x4f, 0x70, 0x52, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x09, 0x4f, 0x70, 0x52, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x50,
|
||||
0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x03, 0x52, 0x06, 0x50, 0x61, 0x72,
|
||||
0x61, 0x6d, 0x73, 0x22, 0x60, 0x0a, 0x14, 0x53, 0x43, 0x43, 0x61, 0x73, 0x68, 0x4d, 0x61, 0x6e,
|
||||
0x69, 0x61, 0x52, 0x6f, 0x6f, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x53,
|
||||
0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x53, 0x74, 0x61, 0x74,
|
||||
0x65, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x75, 0x62, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x08, 0x53, 0x75, 0x62, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x05, 0x52, 0x06, 0x50,
|
||||
0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x51, 0x0a, 0x11, 0x53, 0x43, 0x43, 0x61, 0x73, 0x68, 0x4d,
|
||||
0x61, 0x6e, 0x69, 0x61, 0x42, 0x69, 0x6c, 0x6c, 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x4f, 0x70,
|
||||
0x52, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x4f,
|
||||
0x70, 0x52, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x47, 0x61, 0x6d, 0x65,
|
||||
0x45, 0x6e, 0x64, 0x53, 0x74, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x47, 0x61,
|
||||
0x6d, 0x65, 0x45, 0x6e, 0x64, 0x53, 0x74, 0x72, 0x2a, 0xf3, 0x01, 0x0a, 0x0c, 0x43, 0x61, 0x73,
|
||||
0x68, 0x4d, 0x61, 0x6e, 0x69, 0x61, 0x50, 0x49, 0x44, 0x12, 0x19, 0x0a, 0x15, 0x50, 0x41, 0x43,
|
||||
0x4b, 0x45, 0x54, 0x5f, 0x43, 0x41, 0x53, 0x48, 0x4d, 0x41, 0x4e, 0x49, 0x41, 0x5f, 0x5a, 0x45,
|
||||
0x52, 0x4f, 0x10, 0x00, 0x12, 0x29, 0x0a, 0x24, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x43,
|
||||
0x41, 0x53, 0x48, 0x4d, 0x41, 0x4e, 0x49, 0x41, 0x5f, 0x53, 0x43, 0x43, 0x41, 0x53, 0x48, 0x4d,
|
||||
0x41, 0x4e, 0x49, 0x41, 0x52, 0x4f, 0x4f, 0x4d, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x92, 0x2c, 0x12,
|
||||
0x23, 0x0a, 0x1e, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x43, 0x41, 0x53, 0x48, 0x4d, 0x41,
|
||||
0x4e, 0x49, 0x41, 0x5f, 0x43, 0x53, 0x43, 0x41, 0x53, 0x48, 0x4d, 0x41, 0x4e, 0x49, 0x41, 0x4f,
|
||||
0x50, 0x10, 0x93, 0x2c, 0x12, 0x23, 0x0a, 0x1e, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x43,
|
||||
0x41, 0x53, 0x48, 0x4d, 0x41, 0x4e, 0x49, 0x41, 0x5f, 0x53, 0x43, 0x43, 0x41, 0x53, 0x48, 0x4d,
|
||||
0x41, 0x4e, 0x49, 0x41, 0x4f, 0x50, 0x10, 0x94, 0x2c, 0x12, 0x2a, 0x0a, 0x25, 0x50, 0x41, 0x43,
|
||||
0x4b, 0x45, 0x54, 0x5f, 0x43, 0x41, 0x53, 0x48, 0x4d, 0x41, 0x4e, 0x49, 0x41, 0x5f, 0x53, 0x43,
|
||||
0x43, 0x41, 0x53, 0x48, 0x4d, 0x41, 0x4e, 0x49, 0x41, 0x52, 0x4f, 0x4f, 0x4d, 0x53, 0x54, 0x41,
|
||||
0x54, 0x45, 0x10, 0x95, 0x2c, 0x12, 0x27, 0x0a, 0x22, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f,
|
||||
0x43, 0x41, 0x53, 0x48, 0x4d, 0x41, 0x4e, 0x49, 0x41, 0x5f, 0x53, 0x43, 0x43, 0x41, 0x53, 0x48,
|
||||
0x4d, 0x41, 0x4e, 0x49, 0x41, 0x42, 0x49, 0x4c, 0x4c, 0x45, 0x44, 0x10, 0x96, 0x2c, 0x42, 0x29,
|
||||
0x5a, 0x27, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f,
|
||||
0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f,
|
||||
0x63, 0x61, 0x73, 0x68, 0x6d, 0x61, 0x6e, 0x69, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_protocol_cashmania_cashmania_proto_rawDescOnce sync.Once
|
||||
file_protocol_cashmania_cashmania_proto_rawDescData = file_protocol_cashmania_cashmania_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_protocol_cashmania_cashmania_proto_rawDescGZIP() []byte {
|
||||
file_protocol_cashmania_cashmania_proto_rawDescOnce.Do(func() {
|
||||
file_protocol_cashmania_cashmania_proto_rawDescData = protoimpl.X.CompressGZIP(file_protocol_cashmania_cashmania_proto_rawDescData)
|
||||
})
|
||||
return file_protocol_cashmania_cashmania_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_protocol_cashmania_cashmania_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_protocol_cashmania_cashmania_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_protocol_cashmania_cashmania_proto_goTypes = []interface{}{
|
||||
(CashManiaPID)(0), // 0: cashmania.CashManiaPID
|
||||
(*CashManiaPlayerData)(nil), // 1: cashmania.CashManiaPlayerData
|
||||
(*SCCashManiaRoomInfo)(nil), // 2: cashmania.SCCashManiaRoomInfo
|
||||
(*CSCashManiaOp)(nil), // 3: cashmania.CSCashManiaOp
|
||||
(*SCCashManiaOp)(nil), // 4: cashmania.SCCashManiaOp
|
||||
(*SCCashManiaRoomState)(nil), // 5: cashmania.SCCashManiaRoomState
|
||||
(*SCCashManiaBilled)(nil), // 6: cashmania.SCCashManiaBilled
|
||||
}
|
||||
var file_protocol_cashmania_cashmania_proto_depIdxs = []int32{
|
||||
1, // 0: cashmania.SCCashManiaRoomInfo.Player:type_name -> cashmania.CashManiaPlayerData
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_protocol_cashmania_cashmania_proto_init() }
|
||||
func file_protocol_cashmania_cashmania_proto_init() {
|
||||
if File_protocol_cashmania_cashmania_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_protocol_cashmania_cashmania_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CashManiaPlayerData); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_protocol_cashmania_cashmania_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SCCashManiaRoomInfo); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_protocol_cashmania_cashmania_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CSCashManiaOp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_protocol_cashmania_cashmania_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SCCashManiaOp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_protocol_cashmania_cashmania_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SCCashManiaRoomState); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_protocol_cashmania_cashmania_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SCCashManiaBilled); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_protocol_cashmania_cashmania_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 6,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_protocol_cashmania_cashmania_proto_goTypes,
|
||||
DependencyIndexes: file_protocol_cashmania_cashmania_proto_depIdxs,
|
||||
EnumInfos: file_protocol_cashmania_cashmania_proto_enumTypes,
|
||||
MessageInfos: file_protocol_cashmania_cashmania_proto_msgTypes,
|
||||
}.Build()
|
||||
File_protocol_cashmania_cashmania_proto = out.File
|
||||
file_protocol_cashmania_cashmania_proto_rawDesc = nil
|
||||
file_protocol_cashmania_cashmania_proto_goTypes = nil
|
||||
file_protocol_cashmania_cashmania_proto_depIdxs = nil
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
syntax = "proto3";
|
||||
package cashmania;
|
||||
option go_package = "mongo.games.com/game/protocol/cashmania";
|
||||
|
||||
//cashmania
|
||||
//龙
|
||||
enum CashManiaPID {
|
||||
PACKET_CASHMANIA_ZERO = 0;// 弃用消息号
|
||||
PACKET_CASHMANIA_SCCASHMANIAROOMINFO = 5650; //房间信息
|
||||
PACKET_CASHMANIA_CSCASHMANIAOP = 5651;
|
||||
PACKET_CASHMANIA_SCCASHMANIAOP = 5652;
|
||||
PACKET_CASHMANIA_SCCASHMANIAROOMSTATE = 5653;
|
||||
PACKET_CASHMANIA_SCCASHMANIABILLED = 5654;
|
||||
}
|
||||
|
||||
message CashManiaPlayerData {
|
||||
string Name = 1; //名字
|
||||
int32 SnId = 2; //账号
|
||||
int32 Head = 3; //头像
|
||||
int32 Sex = 4; //性别
|
||||
int64 Coin = 5; //金币
|
||||
int32 Pos = 6; //座位位置
|
||||
int32 Flag = 7; //二进制标记
|
||||
repeated string Params = 8; //其他数据 如:ip 等
|
||||
string City = 9; //城市
|
||||
int32 HeadOutLine = 10; //头像框
|
||||
int32 VIP = 11;
|
||||
}
|
||||
//房间信息
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEROOMINFO
|
||||
message SCCashManiaRoomInfo {
|
||||
int32 RoomId = 1; //房间id
|
||||
int32 GameFreeId = 2;
|
||||
int32 GameId = 3; //游戏id
|
||||
int32 RoomMode = 4; //游戏模式
|
||||
repeated int32 Params = 5; //规则参数
|
||||
int32 NumOfGames = 6; //当前第几局
|
||||
int32 State = 7; //房间当前状态
|
||||
repeated int64 ParamsEx = 8; //其他参数
|
||||
int32 SceneType = 9; //房间模式
|
||||
CashManiaPlayerData Player = 10; //房间内的玩家信息
|
||||
string PlayerInfo = 11;
|
||||
}
|
||||
//玩家操作
|
||||
//PACKET_FORTUNEMOUSE_CSFORTUNEMOUSEOP
|
||||
message CSCashManiaOp {
|
||||
int32 OpCode = 1; //操作码 0.spin
|
||||
repeated int64 Params = 2; //操作参数 下注索引编号
|
||||
}
|
||||
//玩家操作返回
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEOP
|
||||
message SCCashManiaOp {
|
||||
int32 OpCode = 1; //操作码
|
||||
int32 OpRetCode = 2; //操作结果 1.金币不足 2.低于该值不能押注
|
||||
repeated int64 Params = 3; //操作参数
|
||||
}
|
||||
//房间状态
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEROOMSTATE
|
||||
message SCCashManiaRoomState {
|
||||
int32 State = 1; //房间当前状态
|
||||
int32 SubState = 2; //房间当前子状态
|
||||
repeated int32 Params = 3; //状态参数
|
||||
}
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEBILLED
|
||||
message SCCashManiaBilled{
|
||||
int32 OpRetCode = 1;//0.spin成功 1.spin失败
|
||||
string GameEndStr = 2;
|
||||
}
|
|
@ -159,31 +159,39 @@
|
|||
### samloc.proto
|
||||
- 5550~5569
|
||||
|
||||
### thirteen.protp
|
||||
### thirteen.proto
|
||||
- 5570~5580
|
||||
|
||||
### smallrocket.protp
|
||||
### smallrocket.proto
|
||||
- 5581~5599
|
||||
|
||||
### fortunedragon.prot
|
||||
### fortunedragon.proto
|
||||
|
||||
- 5600~5609
|
||||
|
||||
### fortunerabbit.prot
|
||||
### fortunerabbit.proto
|
||||
|
||||
- 5610~5619
|
||||
|
||||
### fortuneox.prot
|
||||
### fortuneox.proto
|
||||
|
||||
- 5620~5629
|
||||
|
||||
### fortunetiger.prot
|
||||
### fortunetiger.proto
|
||||
|
||||
- 5630~5639
|
||||
|
||||
### fortunemouse.prot
|
||||
### fortunemouse.proto
|
||||
|
||||
- 5640~5649
|
||||
|
||||
### cashmania.proto
|
||||
|
||||
- 5650~5659
|
||||
|
||||
### gatesofolympus.proto
|
||||
|
||||
- 5660~5669
|
||||
|
||||
### game.proto(玩家离开)
|
||||
- 8000~8099
|
|
@ -0,0 +1,806 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1-devel
|
||||
// protoc v3.19.4
|
||||
// source: protocol/gatesofolympus/gatesofolympus.proto
|
||||
|
||||
package gatesofolympus
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
//gatesofolympus
|
||||
//龙
|
||||
type GatesOfOlympusPID int32
|
||||
|
||||
const (
|
||||
GatesOfOlympusPID_PACKET_GATESOFOLYMPUS_ZERO GatesOfOlympusPID = 0 // 弃用消息号
|
||||
GatesOfOlympusPID_PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSROOMINFO GatesOfOlympusPID = 5660 //房间信息
|
||||
GatesOfOlympusPID_PACKET_GATESOFOLYMPUS_CSGATESOFOLYMPUSOP GatesOfOlympusPID = 5661
|
||||
GatesOfOlympusPID_PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSOP GatesOfOlympusPID = 5662
|
||||
GatesOfOlympusPID_PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSROOMSTATE GatesOfOlympusPID = 5663
|
||||
GatesOfOlympusPID_PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSBILLED GatesOfOlympusPID = 5664
|
||||
)
|
||||
|
||||
// Enum value maps for GatesOfOlympusPID.
|
||||
var (
|
||||
GatesOfOlympusPID_name = map[int32]string{
|
||||
0: "PACKET_GATESOFOLYMPUS_ZERO",
|
||||
5660: "PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSROOMINFO",
|
||||
5661: "PACKET_GATESOFOLYMPUS_CSGATESOFOLYMPUSOP",
|
||||
5662: "PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSOP",
|
||||
5663: "PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSROOMSTATE",
|
||||
5664: "PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSBILLED",
|
||||
}
|
||||
GatesOfOlympusPID_value = map[string]int32{
|
||||
"PACKET_GATESOFOLYMPUS_ZERO": 0,
|
||||
"PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSROOMINFO": 5660,
|
||||
"PACKET_GATESOFOLYMPUS_CSGATESOFOLYMPUSOP": 5661,
|
||||
"PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSOP": 5662,
|
||||
"PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSROOMSTATE": 5663,
|
||||
"PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSBILLED": 5664,
|
||||
}
|
||||
)
|
||||
|
||||
func (x GatesOfOlympusPID) Enum() *GatesOfOlympusPID {
|
||||
p := new(GatesOfOlympusPID)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x GatesOfOlympusPID) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (GatesOfOlympusPID) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_protocol_gatesofolympus_gatesofolympus_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (GatesOfOlympusPID) Type() protoreflect.EnumType {
|
||||
return &file_protocol_gatesofolympus_gatesofolympus_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x GatesOfOlympusPID) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GatesOfOlympusPID.Descriptor instead.
|
||||
func (GatesOfOlympusPID) EnumDescriptor() ([]byte, []int) {
|
||||
return file_protocol_gatesofolympus_gatesofolympus_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type GatesOfOlympusPlayerData struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` //名字
|
||||
SnId int32 `protobuf:"varint,2,opt,name=SnId,proto3" json:"SnId,omitempty"` //账号
|
||||
Head int32 `protobuf:"varint,3,opt,name=Head,proto3" json:"Head,omitempty"` //头像
|
||||
Sex int32 `protobuf:"varint,4,opt,name=Sex,proto3" json:"Sex,omitempty"` //性别
|
||||
Coin int64 `protobuf:"varint,5,opt,name=Coin,proto3" json:"Coin,omitempty"` //金币
|
||||
Pos int32 `protobuf:"varint,6,opt,name=Pos,proto3" json:"Pos,omitempty"` //座位位置
|
||||
Flag int32 `protobuf:"varint,7,opt,name=Flag,proto3" json:"Flag,omitempty"` //二进制标记
|
||||
Params []string `protobuf:"bytes,8,rep,name=Params,proto3" json:"Params,omitempty"` //其他数据 如:ip 等
|
||||
City string `protobuf:"bytes,9,opt,name=City,proto3" json:"City,omitempty"` //城市
|
||||
HeadOutLine int32 `protobuf:"varint,10,opt,name=HeadOutLine,proto3" json:"HeadOutLine,omitempty"` //头像框
|
||||
VIP int32 `protobuf:"varint,11,opt,name=VIP,proto3" json:"VIP,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) Reset() {
|
||||
*x = GatesOfOlympusPlayerData{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GatesOfOlympusPlayerData) ProtoMessage() {}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GatesOfOlympusPlayerData.ProtoReflect.Descriptor instead.
|
||||
func (*GatesOfOlympusPlayerData) Descriptor() ([]byte, []int) {
|
||||
return file_protocol_gatesofolympus_gatesofolympus_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) GetSnId() int32 {
|
||||
if x != nil {
|
||||
return x.SnId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) GetHead() int32 {
|
||||
if x != nil {
|
||||
return x.Head
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) GetSex() int32 {
|
||||
if x != nil {
|
||||
return x.Sex
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) GetCoin() int64 {
|
||||
if x != nil {
|
||||
return x.Coin
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) GetPos() int32 {
|
||||
if x != nil {
|
||||
return x.Pos
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) GetFlag() int32 {
|
||||
if x != nil {
|
||||
return x.Flag
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) GetParams() []string {
|
||||
if x != nil {
|
||||
return x.Params
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) GetCity() string {
|
||||
if x != nil {
|
||||
return x.City
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) GetHeadOutLine() int32 {
|
||||
if x != nil {
|
||||
return x.HeadOutLine
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GatesOfOlympusPlayerData) GetVIP() int32 {
|
||||
if x != nil {
|
||||
return x.VIP
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
//房间信息
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEROOMINFO
|
||||
type SCGatesOfOlympusRoomInfo struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
RoomId int32 `protobuf:"varint,1,opt,name=RoomId,proto3" json:"RoomId,omitempty"` //房间id
|
||||
GameFreeId int32 `protobuf:"varint,2,opt,name=GameFreeId,proto3" json:"GameFreeId,omitempty"`
|
||||
GameId int32 `protobuf:"varint,3,opt,name=GameId,proto3" json:"GameId,omitempty"` //游戏id
|
||||
RoomMode int32 `protobuf:"varint,4,opt,name=RoomMode,proto3" json:"RoomMode,omitempty"` //游戏模式
|
||||
Params []int32 `protobuf:"varint,5,rep,packed,name=Params,proto3" json:"Params,omitempty"` //规则参数
|
||||
NumOfGames int32 `protobuf:"varint,6,opt,name=NumOfGames,proto3" json:"NumOfGames,omitempty"` //当前第几局
|
||||
State int32 `protobuf:"varint,7,opt,name=State,proto3" json:"State,omitempty"` //房间当前状态
|
||||
ParamsEx []int64 `protobuf:"varint,8,rep,packed,name=ParamsEx,proto3" json:"ParamsEx,omitempty"` //其他参数
|
||||
SceneType int32 `protobuf:"varint,9,opt,name=SceneType,proto3" json:"SceneType,omitempty"` //房间模式
|
||||
Player *GatesOfOlympusPlayerData `protobuf:"bytes,10,opt,name=Player,proto3" json:"Player,omitempty"` //房间内的玩家信息
|
||||
PlayerInfo string `protobuf:"bytes,11,opt,name=PlayerInfo,proto3" json:"PlayerInfo,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) Reset() {
|
||||
*x = SCGatesOfOlympusRoomInfo{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SCGatesOfOlympusRoomInfo) ProtoMessage() {}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SCGatesOfOlympusRoomInfo.ProtoReflect.Descriptor instead.
|
||||
func (*SCGatesOfOlympusRoomInfo) Descriptor() ([]byte, []int) {
|
||||
return file_protocol_gatesofolympus_gatesofolympus_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) GetRoomId() int32 {
|
||||
if x != nil {
|
||||
return x.RoomId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) GetGameFreeId() int32 {
|
||||
if x != nil {
|
||||
return x.GameFreeId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) GetGameId() int32 {
|
||||
if x != nil {
|
||||
return x.GameId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) GetRoomMode() int32 {
|
||||
if x != nil {
|
||||
return x.RoomMode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) GetParams() []int32 {
|
||||
if x != nil {
|
||||
return x.Params
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) GetNumOfGames() int32 {
|
||||
if x != nil {
|
||||
return x.NumOfGames
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) GetState() int32 {
|
||||
if x != nil {
|
||||
return x.State
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) GetParamsEx() []int64 {
|
||||
if x != nil {
|
||||
return x.ParamsEx
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) GetSceneType() int32 {
|
||||
if x != nil {
|
||||
return x.SceneType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) GetPlayer() *GatesOfOlympusPlayerData {
|
||||
if x != nil {
|
||||
return x.Player
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomInfo) GetPlayerInfo() string {
|
||||
if x != nil {
|
||||
return x.PlayerInfo
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
//玩家操作
|
||||
//PACKET_FORTUNEMOUSE_CSFORTUNEMOUSEOP
|
||||
type CSGatesOfOlympusOp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
OpCode int32 `protobuf:"varint,1,opt,name=OpCode,proto3" json:"OpCode,omitempty"` //操作码 0.spin
|
||||
Params []int64 `protobuf:"varint,2,rep,packed,name=Params,proto3" json:"Params,omitempty"` //操作参数 下注索引编号
|
||||
}
|
||||
|
||||
func (x *CSGatesOfOlympusOp) Reset() {
|
||||
*x = CSGatesOfOlympusOp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CSGatesOfOlympusOp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CSGatesOfOlympusOp) ProtoMessage() {}
|
||||
|
||||
func (x *CSGatesOfOlympusOp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CSGatesOfOlympusOp.ProtoReflect.Descriptor instead.
|
||||
func (*CSGatesOfOlympusOp) Descriptor() ([]byte, []int) {
|
||||
return file_protocol_gatesofolympus_gatesofolympus_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *CSGatesOfOlympusOp) GetOpCode() int32 {
|
||||
if x != nil {
|
||||
return x.OpCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CSGatesOfOlympusOp) GetParams() []int64 {
|
||||
if x != nil {
|
||||
return x.Params
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//玩家操作返回
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEOP
|
||||
type SCGatesOfOlympusOp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
OpCode int32 `protobuf:"varint,1,opt,name=OpCode,proto3" json:"OpCode,omitempty"` //操作码
|
||||
OpRetCode int32 `protobuf:"varint,2,opt,name=OpRetCode,proto3" json:"OpRetCode,omitempty"` //操作结果 1.金币不足 2.低于该值不能押注
|
||||
Params []int64 `protobuf:"varint,3,rep,packed,name=Params,proto3" json:"Params,omitempty"` //操作参数
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusOp) Reset() {
|
||||
*x = SCGatesOfOlympusOp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusOp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SCGatesOfOlympusOp) ProtoMessage() {}
|
||||
|
||||
func (x *SCGatesOfOlympusOp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SCGatesOfOlympusOp.ProtoReflect.Descriptor instead.
|
||||
func (*SCGatesOfOlympusOp) Descriptor() ([]byte, []int) {
|
||||
return file_protocol_gatesofolympus_gatesofolympus_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusOp) GetOpCode() int32 {
|
||||
if x != nil {
|
||||
return x.OpCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusOp) GetOpRetCode() int32 {
|
||||
if x != nil {
|
||||
return x.OpRetCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusOp) GetParams() []int64 {
|
||||
if x != nil {
|
||||
return x.Params
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//房间状态
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEROOMSTATE
|
||||
type SCGatesOfOlympusRoomState struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
State int32 `protobuf:"varint,1,opt,name=State,proto3" json:"State,omitempty"` //房间当前状态
|
||||
SubState int32 `protobuf:"varint,2,opt,name=SubState,proto3" json:"SubState,omitempty"` //房间当前子状态
|
||||
Params []int32 `protobuf:"varint,3,rep,packed,name=Params,proto3" json:"Params,omitempty"` //状态参数
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomState) Reset() {
|
||||
*x = SCGatesOfOlympusRoomState{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomState) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SCGatesOfOlympusRoomState) ProtoMessage() {}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomState) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SCGatesOfOlympusRoomState.ProtoReflect.Descriptor instead.
|
||||
func (*SCGatesOfOlympusRoomState) Descriptor() ([]byte, []int) {
|
||||
return file_protocol_gatesofolympus_gatesofolympus_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomState) GetState() int32 {
|
||||
if x != nil {
|
||||
return x.State
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomState) GetSubState() int32 {
|
||||
if x != nil {
|
||||
return x.SubState
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusRoomState) GetParams() []int32 {
|
||||
if x != nil {
|
||||
return x.Params
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEBILLED
|
||||
type SCGatesOfOlympusBilled struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
OpRetCode int32 `protobuf:"varint,1,opt,name=OpRetCode,proto3" json:"OpRetCode,omitempty"` //0.spin成功 1.spin失败
|
||||
GameEndStr string `protobuf:"bytes,2,opt,name=GameEndStr,proto3" json:"GameEndStr,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusBilled) Reset() {
|
||||
*x = SCGatesOfOlympusBilled{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusBilled) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SCGatesOfOlympusBilled) ProtoMessage() {}
|
||||
|
||||
func (x *SCGatesOfOlympusBilled) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SCGatesOfOlympusBilled.ProtoReflect.Descriptor instead.
|
||||
func (*SCGatesOfOlympusBilled) Descriptor() ([]byte, []int) {
|
||||
return file_protocol_gatesofolympus_gatesofolympus_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusBilled) GetOpRetCode() int32 {
|
||||
if x != nil {
|
||||
return x.OpRetCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SCGatesOfOlympusBilled) GetGameEndStr() string {
|
||||
if x != nil {
|
||||
return x.GameEndStr
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_protocol_gatesofolympus_gatesofolympus_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_protocol_gatesofolympus_gatesofolympus_proto_rawDesc = []byte{
|
||||
0x0a, 0x2c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x67, 0x61, 0x74, 0x65, 0x73,
|
||||
0x6f, 0x66, 0x6f, 0x6c, 0x79, 0x6d, 0x70, 0x75, 0x73, 0x2f, 0x67, 0x61, 0x74, 0x65, 0x73, 0x6f,
|
||||
0x66, 0x6f, 0x6c, 0x79, 0x6d, 0x70, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e,
|
||||
0x67, 0x61, 0x74, 0x65, 0x73, 0x6f, 0x66, 0x6f, 0x6c, 0x79, 0x6d, 0x70, 0x75, 0x73, 0x22, 0x82,
|
||||
0x02, 0x0a, 0x18, 0x47, 0x61, 0x74, 0x65, 0x73, 0x4f, 0x66, 0x4f, 0x6c, 0x79, 0x6d, 0x70, 0x75,
|
||||
0x73, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x4e,
|
||||
0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12,
|
||||
0x12, 0x0a, 0x04, 0x53, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53,
|
||||
0x6e, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x48, 0x65, 0x61, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28,
|
||||
0x05, 0x52, 0x04, 0x48, 0x65, 0x61, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x65, 0x78, 0x18, 0x04,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x53, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x69,
|
||||
0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x43, 0x6f, 0x69, 0x6e, 0x12, 0x10, 0x0a,
|
||||
0x03, 0x50, 0x6f, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x50, 0x6f, 0x73, 0x12,
|
||||
0x12, 0x0a, 0x04, 0x46, 0x6c, 0x61, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x46,
|
||||
0x6c, 0x61, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x08, 0x20,
|
||||
0x03, 0x28, 0x09, 0x52, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x43,
|
||||
0x69, 0x74, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x43, 0x69, 0x74, 0x79, 0x12,
|
||||
0x20, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x4f, 0x75, 0x74, 0x4c, 0x69, 0x6e, 0x65, 0x18, 0x0a,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x4f, 0x75, 0x74, 0x4c, 0x69, 0x6e,
|
||||
0x65, 0x12, 0x10, 0x0a, 0x03, 0x56, 0x49, 0x50, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03,
|
||||
0x56, 0x49, 0x50, 0x22, 0xf0, 0x02, 0x0a, 0x18, 0x53, 0x43, 0x47, 0x61, 0x74, 0x65, 0x73, 0x4f,
|
||||
0x66, 0x4f, 0x6c, 0x79, 0x6d, 0x70, 0x75, 0x73, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x6e, 0x66, 0x6f,
|
||||
0x12, 0x16, 0x0a, 0x06, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x06, 0x52, 0x6f, 0x6f, 0x6d, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x47, 0x61, 0x6d, 0x65,
|
||||
0x46, 0x72, 0x65, 0x65, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x47, 0x61,
|
||||
0x6d, 0x65, 0x46, 0x72, 0x65, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x61, 0x6d, 0x65,
|
||||
0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x47, 0x61, 0x6d, 0x65, 0x49, 0x64,
|
||||
0x12, 0x1a, 0x0a, 0x08, 0x52, 0x6f, 0x6f, 0x6d, 0x4d, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x08, 0x52, 0x6f, 0x6f, 0x6d, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x05, 0x52, 0x06, 0x50, 0x61,
|
||||
0x72, 0x61, 0x6d, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x4e, 0x75, 0x6d, 0x4f, 0x66, 0x47, 0x61, 0x6d,
|
||||
0x65, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x4e, 0x75, 0x6d, 0x4f, 0x66, 0x47,
|
||||
0x61, 0x6d, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x07, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61,
|
||||
0x72, 0x61, 0x6d, 0x73, 0x45, 0x78, 0x18, 0x08, 0x20, 0x03, 0x28, 0x03, 0x52, 0x08, 0x50, 0x61,
|
||||
0x72, 0x61, 0x6d, 0x73, 0x45, 0x78, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x54,
|
||||
0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x53, 0x63, 0x65, 0x6e, 0x65,
|
||||
0x54, 0x79, 0x70, 0x65, 0x12, 0x40, 0x0a, 0x06, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x18, 0x0a,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x73, 0x6f, 0x66, 0x6f, 0x6c,
|
||||
0x79, 0x6d, 0x70, 0x75, 0x73, 0x2e, 0x47, 0x61, 0x74, 0x65, 0x73, 0x4f, 0x66, 0x4f, 0x6c, 0x79,
|
||||
0x6d, 0x70, 0x75, 0x73, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x06,
|
||||
0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72,
|
||||
0x49, 0x6e, 0x66, 0x6f, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x50, 0x6c, 0x61, 0x79,
|
||||
0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x44, 0x0a, 0x12, 0x43, 0x53, 0x47, 0x61, 0x74, 0x65,
|
||||
0x73, 0x4f, 0x66, 0x4f, 0x6c, 0x79, 0x6d, 0x70, 0x75, 0x73, 0x4f, 0x70, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x4f, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x4f, 0x70,
|
||||
0x43, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02,
|
||||
0x20, 0x03, 0x28, 0x03, 0x52, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x62, 0x0a, 0x12,
|
||||
0x53, 0x43, 0x47, 0x61, 0x74, 0x65, 0x73, 0x4f, 0x66, 0x4f, 0x6c, 0x79, 0x6d, 0x70, 0x75, 0x73,
|
||||
0x4f, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x4f, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x06, 0x4f, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x4f, 0x70,
|
||||
0x52, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x4f,
|
||||
0x70, 0x52, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61,
|
||||
0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x03, 0x52, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73,
|
||||
0x22, 0x65, 0x0a, 0x19, 0x53, 0x43, 0x47, 0x61, 0x74, 0x65, 0x73, 0x4f, 0x66, 0x4f, 0x6c, 0x79,
|
||||
0x6d, 0x70, 0x75, 0x73, 0x52, 0x6f, 0x6f, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a,
|
||||
0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x53, 0x74,
|
||||
0x61, 0x74, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x75, 0x62, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x53, 0x75, 0x62, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12,
|
||||
0x16, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x05, 0x52,
|
||||
0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x56, 0x0a, 0x16, 0x53, 0x43, 0x47, 0x61, 0x74,
|
||||
0x65, 0x73, 0x4f, 0x66, 0x4f, 0x6c, 0x79, 0x6d, 0x70, 0x75, 0x73, 0x42, 0x69, 0x6c, 0x6c, 0x65,
|
||||
0x64, 0x12, 0x1c, 0x0a, 0x09, 0x4f, 0x70, 0x52, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x4f, 0x70, 0x52, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
||||
0x1e, 0x0a, 0x0a, 0x47, 0x61, 0x6d, 0x65, 0x45, 0x6e, 0x64, 0x53, 0x74, 0x72, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x0a, 0x47, 0x61, 0x6d, 0x65, 0x45, 0x6e, 0x64, 0x53, 0x74, 0x72, 0x2a,
|
||||
0xaf, 0x02, 0x0a, 0x11, 0x47, 0x61, 0x74, 0x65, 0x73, 0x4f, 0x66, 0x4f, 0x6c, 0x79, 0x6d, 0x70,
|
||||
0x75, 0x73, 0x50, 0x49, 0x44, 0x12, 0x1e, 0x0a, 0x1a, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f,
|
||||
0x47, 0x41, 0x54, 0x45, 0x53, 0x4f, 0x46, 0x4f, 0x4c, 0x59, 0x4d, 0x50, 0x55, 0x53, 0x5f, 0x5a,
|
||||
0x45, 0x52, 0x4f, 0x10, 0x00, 0x12, 0x33, 0x0a, 0x2e, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f,
|
||||
0x47, 0x41, 0x54, 0x45, 0x53, 0x4f, 0x46, 0x4f, 0x4c, 0x59, 0x4d, 0x50, 0x55, 0x53, 0x5f, 0x53,
|
||||
0x43, 0x47, 0x41, 0x54, 0x45, 0x53, 0x4f, 0x46, 0x4f, 0x4c, 0x59, 0x4d, 0x50, 0x55, 0x53, 0x52,
|
||||
0x4f, 0x4f, 0x4d, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x9c, 0x2c, 0x12, 0x2d, 0x0a, 0x28, 0x50, 0x41,
|
||||
0x43, 0x4b, 0x45, 0x54, 0x5f, 0x47, 0x41, 0x54, 0x45, 0x53, 0x4f, 0x46, 0x4f, 0x4c, 0x59, 0x4d,
|
||||
0x50, 0x55, 0x53, 0x5f, 0x43, 0x53, 0x47, 0x41, 0x54, 0x45, 0x53, 0x4f, 0x46, 0x4f, 0x4c, 0x59,
|
||||
0x4d, 0x50, 0x55, 0x53, 0x4f, 0x50, 0x10, 0x9d, 0x2c, 0x12, 0x2d, 0x0a, 0x28, 0x50, 0x41, 0x43,
|
||||
0x4b, 0x45, 0x54, 0x5f, 0x47, 0x41, 0x54, 0x45, 0x53, 0x4f, 0x46, 0x4f, 0x4c, 0x59, 0x4d, 0x50,
|
||||
0x55, 0x53, 0x5f, 0x53, 0x43, 0x47, 0x41, 0x54, 0x45, 0x53, 0x4f, 0x46, 0x4f, 0x4c, 0x59, 0x4d,
|
||||
0x50, 0x55, 0x53, 0x4f, 0x50, 0x10, 0x9e, 0x2c, 0x12, 0x34, 0x0a, 0x2f, 0x50, 0x41, 0x43, 0x4b,
|
||||
0x45, 0x54, 0x5f, 0x47, 0x41, 0x54, 0x45, 0x53, 0x4f, 0x46, 0x4f, 0x4c, 0x59, 0x4d, 0x50, 0x55,
|
||||
0x53, 0x5f, 0x53, 0x43, 0x47, 0x41, 0x54, 0x45, 0x53, 0x4f, 0x46, 0x4f, 0x4c, 0x59, 0x4d, 0x50,
|
||||
0x55, 0x53, 0x52, 0x4f, 0x4f, 0x4d, 0x53, 0x54, 0x41, 0x54, 0x45, 0x10, 0x9f, 0x2c, 0x12, 0x31,
|
||||
0x0a, 0x2c, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x47, 0x41, 0x54, 0x45, 0x53, 0x4f, 0x46,
|
||||
0x4f, 0x4c, 0x59, 0x4d, 0x50, 0x55, 0x53, 0x5f, 0x53, 0x43, 0x47, 0x41, 0x54, 0x45, 0x53, 0x4f,
|
||||
0x46, 0x4f, 0x4c, 0x59, 0x4d, 0x50, 0x55, 0x53, 0x42, 0x49, 0x4c, 0x4c, 0x45, 0x44, 0x10, 0xa0,
|
||||
0x2c, 0x42, 0x2e, 0x5a, 0x2c, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73,
|
||||
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63,
|
||||
0x6f, 0x6c, 0x2f, 0x67, 0x61, 0x74, 0x65, 0x73, 0x6f, 0x66, 0x6f, 0x6c, 0x79, 0x6d, 0x70, 0x75,
|
||||
0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_rawDescOnce sync.Once
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_rawDescData = file_protocol_gatesofolympus_gatesofolympus_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_protocol_gatesofolympus_gatesofolympus_proto_rawDescGZIP() []byte {
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_rawDescOnce.Do(func() {
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_rawDescData = protoimpl.X.CompressGZIP(file_protocol_gatesofolympus_gatesofolympus_proto_rawDescData)
|
||||
})
|
||||
return file_protocol_gatesofolympus_gatesofolympus_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_protocol_gatesofolympus_gatesofolympus_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_protocol_gatesofolympus_gatesofolympus_proto_goTypes = []interface{}{
|
||||
(GatesOfOlympusPID)(0), // 0: gatesofolympus.GatesOfOlympusPID
|
||||
(*GatesOfOlympusPlayerData)(nil), // 1: gatesofolympus.GatesOfOlympusPlayerData
|
||||
(*SCGatesOfOlympusRoomInfo)(nil), // 2: gatesofolympus.SCGatesOfOlympusRoomInfo
|
||||
(*CSGatesOfOlympusOp)(nil), // 3: gatesofolympus.CSGatesOfOlympusOp
|
||||
(*SCGatesOfOlympusOp)(nil), // 4: gatesofolympus.SCGatesOfOlympusOp
|
||||
(*SCGatesOfOlympusRoomState)(nil), // 5: gatesofolympus.SCGatesOfOlympusRoomState
|
||||
(*SCGatesOfOlympusBilled)(nil), // 6: gatesofolympus.SCGatesOfOlympusBilled
|
||||
}
|
||||
var file_protocol_gatesofolympus_gatesofolympus_proto_depIdxs = []int32{
|
||||
1, // 0: gatesofolympus.SCGatesOfOlympusRoomInfo.Player:type_name -> gatesofolympus.GatesOfOlympusPlayerData
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_protocol_gatesofolympus_gatesofolympus_proto_init() }
|
||||
func file_protocol_gatesofolympus_gatesofolympus_proto_init() {
|
||||
if File_protocol_gatesofolympus_gatesofolympus_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GatesOfOlympusPlayerData); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SCGatesOfOlympusRoomInfo); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CSGatesOfOlympusOp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SCGatesOfOlympusOp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SCGatesOfOlympusRoomState); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SCGatesOfOlympusBilled); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_protocol_gatesofolympus_gatesofolympus_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 6,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_protocol_gatesofolympus_gatesofolympus_proto_goTypes,
|
||||
DependencyIndexes: file_protocol_gatesofolympus_gatesofolympus_proto_depIdxs,
|
||||
EnumInfos: file_protocol_gatesofolympus_gatesofolympus_proto_enumTypes,
|
||||
MessageInfos: file_protocol_gatesofolympus_gatesofolympus_proto_msgTypes,
|
||||
}.Build()
|
||||
File_protocol_gatesofolympus_gatesofolympus_proto = out.File
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_rawDesc = nil
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_goTypes = nil
|
||||
file_protocol_gatesofolympus_gatesofolympus_proto_depIdxs = nil
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
syntax = "proto3";
|
||||
package gatesofolympus;
|
||||
option go_package = "mongo.games.com/game/protocol/gatesofolympus";
|
||||
|
||||
//gatesofolympus
|
||||
//龙
|
||||
enum GatesOfOlympusPID {
|
||||
PACKET_GATESOFOLYMPUS_ZERO = 0;// 弃用消息号
|
||||
PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSROOMINFO = 5660; //房间信息
|
||||
PACKET_GATESOFOLYMPUS_CSGATESOFOLYMPUSOP = 5661;
|
||||
PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSOP = 5662;
|
||||
PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSROOMSTATE = 5663;
|
||||
PACKET_GATESOFOLYMPUS_SCGATESOFOLYMPUSBILLED = 5664;
|
||||
}
|
||||
|
||||
message GatesOfOlympusPlayerData {
|
||||
string Name = 1; //名字
|
||||
int32 SnId = 2; //账号
|
||||
int32 Head = 3; //头像
|
||||
int32 Sex = 4; //性别
|
||||
int64 Coin = 5; //金币
|
||||
int32 Pos = 6; //座位位置
|
||||
int32 Flag = 7; //二进制标记
|
||||
repeated string Params = 8; //其他数据 如:ip 等
|
||||
string City = 9; //城市
|
||||
int32 HeadOutLine = 10; //头像框
|
||||
int32 VIP = 11;
|
||||
}
|
||||
//房间信息
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEROOMINFO
|
||||
message SCGatesOfOlympusRoomInfo {
|
||||
int32 RoomId = 1; //房间id
|
||||
int32 GameFreeId = 2;
|
||||
int32 GameId = 3; //游戏id
|
||||
int32 RoomMode = 4; //游戏模式
|
||||
repeated int32 Params = 5; //规则参数
|
||||
int32 NumOfGames = 6; //当前第几局
|
||||
int32 State = 7; //房间当前状态
|
||||
repeated int64 ParamsEx = 8; //其他参数
|
||||
int32 SceneType = 9; //房间模式
|
||||
GatesOfOlympusPlayerData Player = 10; //房间内的玩家信息
|
||||
string PlayerInfo = 11;
|
||||
}
|
||||
//玩家操作
|
||||
//PACKET_FORTUNEMOUSE_CSFORTUNEMOUSEOP
|
||||
message CSGatesOfOlympusOp {
|
||||
int32 OpCode = 1; //操作码 0.spin
|
||||
repeated int64 Params = 2; //操作参数 下注索引编号
|
||||
}
|
||||
//玩家操作返回
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEOP
|
||||
message SCGatesOfOlympusOp {
|
||||
int32 OpCode = 1; //操作码
|
||||
int32 OpRetCode = 2; //操作结果 1.金币不足 2.低于该值不能押注
|
||||
repeated int64 Params = 3; //操作参数
|
||||
}
|
||||
//房间状态
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEROOMSTATE
|
||||
message SCGatesOfOlympusRoomState {
|
||||
int32 State = 1; //房间当前状态
|
||||
int32 SubState = 2; //房间当前子状态
|
||||
repeated int32 Params = 3; //状态参数
|
||||
}
|
||||
//PACKET_FORTUNEMOUSE_SCFORTUNEMOUSEBILLED
|
||||
message SCGatesOfOlympusBilled{
|
||||
int32 OpRetCode = 1;//0.spin成功 1.spin失败
|
||||
string GameEndStr = 2;
|
||||
}
|
|
@ -4238,10 +4238,10 @@ type DB_GameFree struct {
|
|||
FreeMode int32 `protobuf:"varint,6,opt,name=FreeMode,proto3" json:"FreeMode,omitempty"`
|
||||
GameRule int32 `protobuf:"varint,7,opt,name=GameRule,proto3" json:"GameRule,omitempty"`
|
||||
GameType int32 `protobuf:"varint,8,opt,name=GameType,proto3" json:"GameType,omitempty"`
|
||||
SceneType int32 `protobuf:"varint,9,opt,name=SceneType,proto3" json:"SceneType,omitempty"`
|
||||
RankType int32 `protobuf:"varint,10,opt,name=RankType,proto3" json:"RankType,omitempty"`
|
||||
SceneAdd int32 `protobuf:"varint,11,opt,name=SceneAdd,proto3" json:"SceneAdd,omitempty"`
|
||||
Desc string `protobuf:"bytes,12,opt,name=Desc,proto3" json:"Desc,omitempty"`
|
||||
Desc string `protobuf:"bytes,9,opt,name=Desc,proto3" json:"Desc,omitempty"`
|
||||
SceneType int32 `protobuf:"varint,10,opt,name=SceneType,proto3" json:"SceneType,omitempty"`
|
||||
RankType int32 `protobuf:"varint,11,opt,name=RankType,proto3" json:"RankType,omitempty"`
|
||||
SceneAdd int32 `protobuf:"varint,12,opt,name=SceneAdd,proto3" json:"SceneAdd,omitempty"`
|
||||
ShowType int32 `protobuf:"varint,13,opt,name=ShowType,proto3" json:"ShowType,omitempty"`
|
||||
SubShowType int32 `protobuf:"varint,14,opt,name=SubShowType,proto3" json:"SubShowType,omitempty"`
|
||||
Flag int32 `protobuf:"varint,15,opt,name=Flag,proto3" json:"Flag,omitempty"`
|
||||
|
@ -4393,6 +4393,13 @@ func (x *DB_GameFree) GetGameType() int32 {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (x *DB_GameFree) GetDesc() string {
|
||||
if x != nil {
|
||||
return x.Desc
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_GameFree) GetSceneType() int32 {
|
||||
if x != nil {
|
||||
return x.SceneType
|
||||
|
@ -4414,13 +4421,6 @@ func (x *DB_GameFree) GetSceneAdd() int32 {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (x *DB_GameFree) GetDesc() string {
|
||||
if x != nil {
|
||||
return x.Desc
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_GameFree) GetShowType() int32 {
|
||||
if x != nil {
|
||||
return x.ShowType
|
||||
|
@ -11426,14 +11426,14 @@ var file_protocol_server_pbdata_proto_rawDesc = []byte{
|
|||
0x65, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x47, 0x61, 0x6d, 0x65, 0x52, 0x75,
|
||||
0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x47, 0x61, 0x6d, 0x65, 0x52, 0x75,
|
||||
0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x47, 0x61, 0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x08,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x47, 0x61, 0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c,
|
||||
0x0a, 0x09, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28,
|
||||
0x05, 0x52, 0x09, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x52, 0x61, 0x6e, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08,
|
||||
0x52, 0x61, 0x6e, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x63, 0x65, 0x6e,
|
||||
0x65, 0x41, 0x64, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x53, 0x63, 0x65, 0x6e,
|
||||
0x65, 0x41, 0x64, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x65, 0x73, 0x63, 0x18, 0x0c, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x04, 0x44, 0x65, 0x73, 0x63, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x68, 0x6f, 0x77,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x47, 0x61, 0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12,
|
||||
0x0a, 0x04, 0x44, 0x65, 0x73, 0x63, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x44, 0x65,
|
||||
0x73, 0x63, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18,
|
||||
0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x54, 0x79, 0x70, 0x65,
|
||||
0x12, 0x1a, 0x0a, 0x08, 0x52, 0x61, 0x6e, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x0b, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x08, 0x52, 0x61, 0x6e, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x53, 0x63, 0x65, 0x6e, 0x65, 0x41, 0x64, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08,
|
||||
0x53, 0x63, 0x65, 0x6e, 0x65, 0x41, 0x64, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x68, 0x6f, 0x77,
|
||||
0x54, 0x79, 0x70, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x53, 0x68, 0x6f, 0x77,
|
||||
0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x53, 0x75, 0x62, 0x53, 0x68, 0x6f, 0x77, 0x54,
|
||||
0x79, 0x70, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x53, 0x75, 0x62, 0x53, 0x68,
|
||||
|
|
|
@ -709,13 +709,13 @@ message DB_GameFree {
|
|||
|
||||
int32 GameType = 8;
|
||||
|
||||
int32 SceneType = 9;
|
||||
string Desc = 9;
|
||||
|
||||
int32 RankType = 10;
|
||||
int32 SceneType = 10;
|
||||
|
||||
int32 SceneAdd = 11;
|
||||
int32 RankType = 11;
|
||||
|
||||
string Desc = 12;
|
||||
int32 SceneAdd = 12;
|
||||
|
||||
int32 ShowType = 13;
|
||||
|
||||
|
|
|
@ -386,7 +386,7 @@ type CSThirteenPlayerOp struct {
|
|||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
OpCode int32 `protobuf:"varint,1,opt,name=OpCode,proto3" json:"OpCode,omitempty"` // 1:确定牌 2站起状态 3test 4重新选牌 5加入游戏
|
||||
OpCode int32 `protobuf:"varint,1,opt,name=OpCode,proto3" json:"OpCode,omitempty"` // 1:确定牌 2站起状态 3test 4重新选牌 5加入游戏 6预选
|
||||
// 确定牌时,两种参数规则,都可以
|
||||
// 第一种:玩家从推荐牌型中选择一个,把Poker.IndexType发过来(减少数据传输)
|
||||
// 第二种:按头墩中墩尾墩顺序把牌发过来
|
||||
|
|
|
@ -73,7 +73,7 @@ message SCThirteenPlayerCards {
|
|||
//玩家操作
|
||||
//PACKET_CSThirteenPlayerOp
|
||||
message CSThirteenPlayerOp {
|
||||
int32 OpCode = 1; // 1:确定牌 2站起状态 3test 4重新选牌 5加入游戏
|
||||
int32 OpCode = 1; // 1:确定牌 2站起状态 3test 4重新选牌 5加入游戏 6预选
|
||||
|
||||
// 确定牌时,两种参数规则,都可以
|
||||
// 第一种:玩家从推荐牌型中选择一个,把Poker.IndexType发过来(减少数据传输)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
# ---> Go
|
||||
# If you prefer the allow list template instead of the deny list, see community template:
|
||||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||
#
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
*.xlsx
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
local_test.go
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
|
||||
.idea
|
||||
.vscode
|
||||
log
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# statistics
|
||||
|
||||
数据分析服务
|
||||
* mongodb同步到mysql
|
||||
* 接收消息队列数据
|
||||
* 历史数据查询
|
||||
* 数据统计
|
|
@ -0,0 +1,8 @@
|
|||
set GOPATH=D:\godev
|
||||
go env -w GO111MODULE=on
|
||||
|
||||
set CGO_ENABLED=0
|
||||
set GOOS=linux
|
||||
set GOARCH=amd64
|
||||
go build
|
||||
pause
|
|
@ -0,0 +1,8 @@
|
|||
package constant
|
||||
|
||||
const (
|
||||
InviteScoreTypeBind = 1 // 绑定邀请码
|
||||
InviteScoreTypePay = 2 // 充值返佣
|
||||
InviteScoreTypeRecharge = 3 // 充值完成
|
||||
InviteScoreTypePayMe = 4 // 充值(自己)
|
||||
)
|
|
@ -0,0 +1,27 @@
|
|||
# 平台id
|
||||
platforms:
|
||||
- 1
|
||||
|
||||
# 几秒同步一次数据
|
||||
# 注册表,登录日志表
|
||||
update_second: 60
|
||||
# 注册表每次同步多少条数据
|
||||
update_account_num: 100
|
||||
# 登录日志每次同步多少条数据
|
||||
update_login_num: 100
|
||||
# 几秒读取一次玩家id列表
|
||||
update_second_snid: 30
|
||||
# 最多触发几个玩家数据更新
|
||||
update_snid_num: 100
|
||||
|
||||
# 邀请数据统计
|
||||
# 几秒读取一次邀请记录
|
||||
update_second_invite: 10
|
||||
# 一次最多读取多少条邀请记录
|
||||
update_invite_num: 30
|
||||
|
||||
# 道具获得数量统计
|
||||
# 几秒读取一次道具日志
|
||||
update_second_item: 10
|
||||
# 一次最多读取多少道具日志
|
||||
update_item_num: 100
|
|
@ -0,0 +1,53 @@
|
|||
global:
|
||||
user:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_global
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
||||
log:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_log
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
||||
monitor:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_monitor
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
||||
platforms:
|
||||
0:
|
||||
user:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_user_plt_000
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
||||
log:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_log_plt_000
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
||||
1:
|
||||
user:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_user_plt_001
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
||||
log:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_log_plt_001
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
|
@ -0,0 +1,38 @@
|
|||
platforms:
|
||||
global:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 3306
|
||||
Database: win88_user
|
||||
Username: root
|
||||
Password: 123456
|
||||
Options: charset=utf8mb4&parseTime=True&loc=Local
|
||||
0:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 3306
|
||||
Database: win88_plt_000
|
||||
Username: root
|
||||
Password: 123456
|
||||
Options: charset=utf8mb4&parseTime=True&loc=Local
|
||||
1:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 3306
|
||||
Database: win88_plt_001
|
||||
Username: root
|
||||
Password: 123456
|
||||
Options: charset=utf8mb4&parseTime=True&loc=Local
|
||||
count: # 破产日志库
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 3306
|
||||
Database: dbmis_count
|
||||
Username: root
|
||||
Password: 123456
|
||||
Options: charset=utf8mb4&parseTime=True&loc=Local
|
||||
|
||||
# 最大空闲连接数
|
||||
MaxIdleConns: 10
|
||||
# 最大连接数
|
||||
MaxOpenConns: 100
|
||||
# 连接可复用的最大时间
|
||||
ConnMaxLifetime: 3600
|
||||
# 连接最大空闲时间
|
||||
ConnMaxIdletime: 0
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<seelog type="adaptive" mininterval="2000000" maxinterval="100000000" critmsgcount="500" minlevel="trace">
|
||||
<exceptions>
|
||||
<exception filepattern="test*" minlevel="error"/>
|
||||
</exceptions>
|
||||
<outputs formatid="all">
|
||||
<rollingfile formatid="all" type="size" filename="./all.log" maxsize="50000000" maxrolls="5" />
|
||||
<filter levels="info,trace,warn">
|
||||
<console formatid="fmtinfo"/>
|
||||
</filter>
|
||||
<filter levels="error,critical" formatid="fmterror">
|
||||
<console/>
|
||||
<file path="errors.log"/>
|
||||
</filter>
|
||||
</outputs>
|
||||
<formats>
|
||||
<format id="fmtinfo" format="[%Date][%Time] [%Level] %Msg%n"/>
|
||||
<format id="fmterror" format="[%Date][%Time] [%LEVEL] [%FuncShort @ %File.%Line] %Msg%n"/>
|
||||
<format id="all" format="[%Date][%Time] [%Level] [@ %File.%Line] %Msg%n"/>
|
||||
<format id="criticalemail" format="Critical error on our server!\n %Time %Date %RelFile %Func %Msg \nSent by Seelog"/>
|
||||
</formats>
|
||||
</seelog>
|
|
@ -0,0 +1,212 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/mongox"
|
||||
"mongo.games.com/goserver/core/mysqlx"
|
||||
"mongo.games.com/goserver/core/utils"
|
||||
"mongo.games.com/goserver/core/viperx"
|
||||
|
||||
mongomodel "mongo.games.com/game/statistics/modelmongo"
|
||||
mysqlmodel "mongo.games.com/game/statistics/modelmysql"
|
||||
"mongo.games.com/game/statistics/static"
|
||||
"mongo.games.com/game/statistics/syn"
|
||||
)
|
||||
|
||||
var VP *viper.Viper
|
||||
|
||||
// DoTick 定时执行
|
||||
func DoTick(ctx context.Context, wg *sync.WaitGroup, duration time.Duration, fu func(ctx context.Context)) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-time.After(duration):
|
||||
utils.RecoverPanicFunc() // 捕获异常
|
||||
fu(ctx)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// DoTickPlatform 定时执行,根据platform执行
|
||||
func DoTickPlatform(ctx context.Context, wg *sync.WaitGroup, duration time.Duration, batchSize int,
|
||||
fu func(ctx context.Context, platform string, batchSize int)) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-time.After(duration):
|
||||
utils.RecoverPanicFunc() // 捕获异常
|
||||
wg := new(sync.WaitGroup)
|
||||
for _, v := range VP.GetStringSlice("platforms") {
|
||||
platform := v
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
fu(ctx, platform, batchSize)
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func main() {
|
||||
VP = viperx.GetViper("config", "yaml")
|
||||
// mongo
|
||||
vp := viperx.GetViper("mongo", "yaml")
|
||||
// mongo初始化
|
||||
conf := &mongox.Config{}
|
||||
err := vp.Unmarshal(conf)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("mongo config error: %v", err))
|
||||
}
|
||||
mongox.Init(conf)
|
||||
defer mongox.Close()
|
||||
|
||||
// mysql
|
||||
vp = viperx.GetViper("mysql", "yaml")
|
||||
myConf := &mysqlx.Config{}
|
||||
err = vp.Unmarshal(myConf)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("mysql config error: %v", err))
|
||||
}
|
||||
mysqlx.Init(myConf)
|
||||
defer mysqlx.Close()
|
||||
|
||||
mysqlx.SetAutoMigrateTables(mysqlmodel.Tables)
|
||||
|
||||
wg := &sync.WaitGroup{}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
DoTick(ctx, wg, time.Duration(VP.GetInt64("update_second"))*time.Second, SyncSnId)
|
||||
|
||||
DoTick(ctx, wg, time.Duration(VP.GetInt64("update_second_snid"))*time.Second, func(ctx context.Context) {
|
||||
wg := new(sync.WaitGroup)
|
||||
for _, v := range VP.GetStringSlice("platforms") {
|
||||
platform := v
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
Static(platform)
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
})
|
||||
|
||||
DoTick(ctx, wg, time.Duration(VP.GetInt64("update_second_invite"))*time.Second, SyncInvite)
|
||||
|
||||
DoTickPlatform(ctx, wg, time.Duration(VP.GetInt64("update_second_item"))*time.Second, VP.GetInt("update_item_num"),
|
||||
func(ctx context.Context, platform string, batchSize int) {
|
||||
err := syn.ItemGainDone(&syn.Data[mongomodel.ItemLog]{
|
||||
Platform: platform,
|
||||
BatchSize: batchSize,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("SyncItem error:%v", err)
|
||||
}
|
||||
})
|
||||
|
||||
logger.Logger.Info("start")
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt, os.Kill)
|
||||
sig := <-c
|
||||
logger.Logger.Infof("closing down (signal: %v)", sig)
|
||||
|
||||
// release
|
||||
cancel()
|
||||
wg.Wait()
|
||||
|
||||
logger.Logger.Info("closed")
|
||||
}
|
||||
|
||||
// SyncSnId 同步注册和登录日志
|
||||
func SyncSnId(ctx context.Context) {
|
||||
wg := new(sync.WaitGroup)
|
||||
for _, v := range VP.GetStringSlice("platforms") {
|
||||
platform := v
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
_, err := syn.UserAccount(platform, VP.GetInt("update_account_num"))
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("SyncUserAccount error: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = syn.LogLogin(platform, VP.GetInt("update_login_num"))
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("SyncLogLogin error: %v", err)
|
||||
return
|
||||
}
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
// Static 玩家id触发数据统计
|
||||
func Static(platform string) {
|
||||
// 查询需要更新的玩家id
|
||||
var ids []*mysqlmodel.UserID
|
||||
db, err := mysqlx.GetDatabase(platform)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("GetDatabase error: %v", err)
|
||||
return
|
||||
}
|
||||
if err := db.Limit(VP.GetInt("update_snid_num")).Find(&ids).Error; err != nil {
|
||||
logger.Logger.Warnf("Get UserID error: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if len(ids) == 0 {
|
||||
logger.Logger.Tracef("Static: no need to update")
|
||||
return
|
||||
}
|
||||
|
||||
// 统计玩家跳出记录
|
||||
if err := static.UserLogin(platform, ids); err != nil {
|
||||
logger.Logger.Errorf("StaticUserLogin error: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// 删除更新过的玩家id
|
||||
if err := db.Delete(ids).Error; err != nil {
|
||||
logger.Logger.Errorf("Delete error: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// SyncInvite 同步邀请数据
|
||||
func SyncInvite(ctx context.Context) {
|
||||
wg := new(sync.WaitGroup)
|
||||
for _, v := range VP.GetStringSlice("platforms") {
|
||||
platform := v
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
err := syn.SyncInviteScore(platform, VP.GetInt("update_invite_num"))
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("SyncInviteScore error: %v", err)
|
||||
return
|
||||
}
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package modelmongo
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
const LogGamePlayerListLog = "log_gameplayerlistlog"
|
||||
|
||||
type GamePlayerListLog struct {
|
||||
LogId primitive.ObjectID `bson:"_id"`
|
||||
SnId int32 //用户Id
|
||||
Name string //名称
|
||||
GameId int32 //游戏id
|
||||
BaseScore int32 //游戏底注
|
||||
ClubId int32 //俱乐部Id
|
||||
ClubRoom string //俱乐部包间
|
||||
TaxCoin int64 //税收
|
||||
ClubPumpCoin int64 //俱乐部额外抽水
|
||||
Platform string //平台id
|
||||
Channel string //渠道
|
||||
Promoter string //推广员
|
||||
PackageTag string //包标识
|
||||
SceneId int32 //场景ID
|
||||
GameMode int32 //游戏类型
|
||||
GameFreeid int32 //游戏类型房间号
|
||||
GameDetailedLogId string //游戏记录Id
|
||||
IsFirstGame bool //是否第一次游戏
|
||||
//对于拉霸类:BetAmount=100 WinAmountNoAnyTax=0 (表示投入多少、收益多少,值>=0)
|
||||
//拉霸类小游戏会是:BetAmount=0 WinAmountNoAnyTax=100 (投入0、收益多少,值>=0)
|
||||
//对战场:BetAmount=0 WinAmountNoAnyTax=100 (投入会有是0、收益有正负,WinAmountNoAnyTax=100则盈利,WinAmountNoAnyTax=-100则输100)
|
||||
BetAmount int64 //下注金额
|
||||
WinAmountNoAnyTax int64 //盈利金额,不包含任何税
|
||||
TotalIn int64 //本局投入
|
||||
TotalOut int64 //本局产出
|
||||
Time time.Time //记录时间
|
||||
RoomType int32 //房间类型
|
||||
GameDif string //游戏标识
|
||||
GameClass int32 //游戏类型 1棋牌 2电子 3百人 4捕鱼 5视讯 6彩票 7体育
|
||||
MatchId int32
|
||||
MatchType int32 //0.普通场 1.锦标赛 2.冠军赛 3.vip专属
|
||||
Ts int32
|
||||
IsFree bool //拉霸专用 是否免费
|
||||
WinSmallGame int64 //拉霸专用 小游戏奖励
|
||||
WinTotal int64 //拉霸专用 输赢
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package modelmongo
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
const LogInviteScore = "log_invitescore"
|
||||
|
||||
type InviteScore struct {
|
||||
Id primitive.ObjectID `bson:"_id"`
|
||||
UpSnid int // 上级代理
|
||||
DownSnid int // 下级代理
|
||||
Level int // 代理层级 例如 1:DownSnid 是 UpSnid 的 1 级代理; 2: DownSnid 是 UpSnid 的 2 级代理
|
||||
Tp int // 返佣类型
|
||||
Rate int // 返佣比例
|
||||
Score int // 积分
|
||||
Money int // 充值金额
|
||||
Ts int // 时间戳
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package modelmongo
|
||||
|
||||
import "go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
||||
const LogItem = "log_itemlog"
|
||||
|
||||
type ItemInfo struct {
|
||||
ItemId int32
|
||||
ItemNum int64
|
||||
}
|
||||
|
||||
type ItemLog struct {
|
||||
LogId primitive.ObjectID `bson:"_id"`
|
||||
Platform string //平台
|
||||
SnId int32 //玩家id
|
||||
LogType int32 //记录类型 0.获取 1.消耗
|
||||
ItemId int32 //道具id
|
||||
ItemName string //道具名称
|
||||
Count int64 //个数
|
||||
CreateTs int64 //记录时间
|
||||
Remark string //备注
|
||||
TypeId int32 // 变化类型
|
||||
GameId int32 // 游戏id,游戏中获得时有值
|
||||
GameFreeId int32 // 场次id,游戏中获得时有值
|
||||
Cost []*ItemInfo // 消耗的道具
|
||||
Id string // 撤销的id,兑换失败
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package modelmongo
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
const LogLogin = "log_login"
|
||||
|
||||
const (
|
||||
LogTypeLogin int32 = iota // 登录
|
||||
LogTypeLogout // 登出
|
||||
LogTypeRehold // 重连
|
||||
LogTypeDrop // 掉线
|
||||
)
|
||||
|
||||
type LoginLog struct {
|
||||
LogId primitive.ObjectID `bson:"_id"`
|
||||
Platform string //平台id
|
||||
SnId int32
|
||||
LogType int32
|
||||
Ts int64
|
||||
Time time.Time
|
||||
GameId int // 玩家掉线时所在游戏id
|
||||
LastGameID int // 玩家最后所在游戏id
|
||||
ChannelId string // 推广渠道
|
||||
|
||||
DeviceName string
|
||||
AppVersion string
|
||||
BuildVersion string
|
||||
AppChannel string
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package modelmongo
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
const UserAccount = "user_account"
|
||||
|
||||
type Account struct {
|
||||
AccountId primitive.ObjectID `bson:"_id"`
|
||||
SnId int32 // 玩家账号直接在这里生成
|
||||
Platform string // 平台
|
||||
RegisterTs int64 // 注册时间戳
|
||||
RegisteTime time.Time
|
||||
ChannelId string // 推广渠道
|
||||
|
||||
Tel string `gorm:"index"`
|
||||
DeviceName string `gorm:"index"`
|
||||
AppVersion string `gorm:"index"`
|
||||
BuildVersion string `gorm:"index"`
|
||||
AppChannel string `gorm:"index"`
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package modelmysql
|
||||
|
||||
type Bankrupt struct {
|
||||
Id int `json:"id" gorm:"column:id"`
|
||||
Platform int `json:"platform" gorm:"column:platform"`
|
||||
Snid int `json:"snid" gorm:"column:snid"`
|
||||
RegTs int `json:"register_time" gorm:"column:register_time"`
|
||||
GameId int `json:"game_id" gorm:"column:game_id"`
|
||||
GameFreeId int `json:"game_free_id" gorm:"column:game_free_id"`
|
||||
Coin int `json:"use_coin" gorm:"column:use_coin"`
|
||||
Ts int `json:"bankrupt_time" gorm:"column:bankrupt_time"`
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package modelmysql
|
||||
|
||||
type LogInviteScoreMid struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
MID string
|
||||
}
|
||||
|
||||
type LogInviteScore struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
UpSnid int `gorm:"index"` // 上级代理
|
||||
DownSnid int `gorm:"index"` // 下级代理
|
||||
Level int `gorm:"index"` // 代理层级 例如 1:DownSnid 是 UpSnid 的 1 级代理; 2: DownSnid 是 UpSnid 的 2 级代理
|
||||
Tp int `gorm:"index"` // 返佣类型
|
||||
Rate int `gorm:"index"` // 返佣比例
|
||||
Score int `gorm:"index"` // 积分
|
||||
Money int `gorm:"index"` // 充值金额
|
||||
Ts int `gorm:"index"` // 时间戳
|
||||
}
|
||||
|
||||
type LogInviteUser struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
Psnid int `gorm:"index"` // 当前玩家
|
||||
Snid int `gorm:"index"` // 一级代理
|
||||
Level int `gorm:"index"` // 代理层级 例如 1:DownSnid 是 UpSnid 的 1 级代理; 2: DownSnid 是 UpSnid 的 2 级代理
|
||||
Ts int `gorm:"index"` // 绑定时间
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package modelmysql
|
||||
|
||||
// ItemGain 道具获得数量,以小时,道具id,做主键
|
||||
type ItemGain struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
Hour int64 `gorm:"index:idx_item"` // 小时时间戳,每小时统计一次
|
||||
ItemId int32 `gorm:"index:idx_item"` // 道具id
|
||||
ItemNum int64 // 道具数量
|
||||
}
|
||||
|
||||
// ItemTotalGain 道具获得总数
|
||||
type ItemTotalGain struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
ItemId int32 `gorm:"index"` // 道具id
|
||||
ItemNum int64 // 道具数量
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package modelmysql
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
LogTypeLogin = 1 // 登录
|
||||
LogTypeRehold = 2 // 重连
|
||||
LogTypeOffline = 3 // 离线
|
||||
)
|
||||
|
||||
type LogLogin struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
Snid int `gorm:"index"`
|
||||
OnlineType int `gorm:"index"`
|
||||
//OnlineTs int `gorm:"index"`
|
||||
OnlineTime time.Time `gorm:"index"`
|
||||
OfflineType int `gorm:"index"`
|
||||
//OfflineTs int `gorm:"index"`
|
||||
OfflineTime time.Time `gorm:"index"`
|
||||
ChannelId string `gorm:"index"` // 推广渠道
|
||||
|
||||
DeviceName string `gorm:"index"`
|
||||
AppVersion string `gorm:"index"`
|
||||
BuildVersion string `gorm:"index"`
|
||||
AppChannel string `gorm:"index"`
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package modelmysql
|
||||
|
||||
type LogLoginMid struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
MID string
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package modelmysql
|
||||
|
||||
const (
|
||||
MidTypeItem = 1 // 道具记录
|
||||
)
|
||||
|
||||
type LogMid struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
Tp int `gorm:"index"` // 类型
|
||||
MID string
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package modelmysql
|
||||
|
||||
// 需要自动迁移的表添加在这里 Tables
|
||||
|
||||
var Tables = []interface{}{
|
||||
&LogLogin{},
|
||||
&LogLoginMid{},
|
||||
&UserAccount{},
|
||||
&UserLogin{},
|
||||
&UserID{},
|
||||
&LogInviteScoreMid{},
|
||||
&LogInviteScore{},
|
||||
&LogInviteUser{},
|
||||
&LogMid{},
|
||||
&ItemGain{},
|
||||
&ItemTotalGain{},
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package modelmysql
|
||||
|
||||
import "time"
|
||||
|
||||
type UserAccount struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
MID string
|
||||
Snid int `gorm:"index"`
|
||||
//RegisterTs int `gorm:"index"`
|
||||
RegisterTime time.Time `gorm:"index"`
|
||||
ChannelId string `gorm:"index"` // 推广渠道
|
||||
|
||||
DeviceName string `gorm:"index"`
|
||||
AppVersion string `gorm:"index"`
|
||||
BuildVersion string `gorm:"index"`
|
||||
AppChannel string `gorm:"index"`
|
||||
Tel string `gorm:"index"`
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package modelmysql
|
||||
|
||||
/*
|
||||
服务定期查询注册和登录信息,然后获取玩家id,保存到这张表中;用于后续触发和玩家相关的数据统计
|
||||
*/
|
||||
|
||||
type UserID struct {
|
||||
Snid int `gorm:"primaryKey"`
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package modelmysql
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
OutTypRegister = 1 // 注册
|
||||
OutTypeLogin = 2 // 登录
|
||||
OutTypeGaming = 3 // 游戏中
|
||||
OutTypeGameOver = 4 // 游戏结束
|
||||
)
|
||||
|
||||
type UserLogin struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
Snid int `gorm:"uniqueIndex"`
|
||||
//OnlineTs int `gorm:"index"`
|
||||
OnlineTime time.Time `gorm:"index"`
|
||||
//OfflineTs int `gorm:"index"`
|
||||
OfflineTime time.Time `gorm:"index"`
|
||||
OutType int `gorm:"index"` // 跳出类型
|
||||
GameID int `gorm:"index"` // 游戏id
|
||||
Age int
|
||||
Sex int
|
||||
DeviceName string `gorm:"index"`
|
||||
AppVersion string `gorm:"index"`
|
||||
BuildVersion string `gorm:"index"`
|
||||
AppChannel string `gorm:"index"`
|
||||
Tel string `gorm:"index"`
|
||||
ChannelId string `gorm:"index"` // 推广渠道
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
package mq
|
|
@ -0,0 +1 @@
|
|||
接收消息队列
|
|
@ -0,0 +1 @@
|
|||
业务统计
|
|
@ -0,0 +1,371 @@
|
|||
package static
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
|
||||
mymongo "mongo.games.com/goserver/core/mongox"
|
||||
mymysql "mongo.games.com/goserver/core/mysqlx"
|
||||
|
||||
mongomodel "mongo.games.com/game/statistics/modelmongo"
|
||||
mysqlmodel "mongo.games.com/game/statistics/modelmysql"
|
||||
)
|
||||
|
||||
func getAccountTel(platform string, id int) (string, error) {
|
||||
acc := &mongomodel.Account{}
|
||||
cc, err := mymongo.GetUserCollection(platform, mongomodel.UserAccount)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("get collection %s error %v", mongomodel.UserAccount, err)
|
||||
return "", err
|
||||
}
|
||||
dd := cc.FindOne(context.TODO(), bson.M{"snid": id}, options.FindOne().SetProjection(bson.M{"tel": 1}))
|
||||
err = dd.Err()
|
||||
if err != nil {
|
||||
if errors.Is(err, mongo.ErrNoDocuments) {
|
||||
logger.Logger.Tracef("getAccountTel %v not found in user_account", id)
|
||||
return "", nil
|
||||
}
|
||||
logger.Logger.Errorf("getAccountTel %v get user_account err: %v", id, err)
|
||||
return "", err
|
||||
}
|
||||
if err := dd.Decode(acc); err != nil {
|
||||
logger.Logger.Errorf("getAccountTel %v decode user_account err: %v", id, err)
|
||||
return "", err
|
||||
}
|
||||
return acc.Tel, nil
|
||||
}
|
||||
|
||||
// 游戏结束离开
|
||||
func checkGameOver(db *mymysql.Database, login *mysqlmodel.UserLogin, platform string, id int) (bool, error) {
|
||||
// 最早的一条掉线记录并且是游戏结束离开
|
||||
a := &mongomodel.LoginLog{}
|
||||
c, err := mymongo.GetLogCollection(platform, mongomodel.LogLogin)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("get collection %s error %v", mongomodel.LogLogin, err)
|
||||
return false, err
|
||||
}
|
||||
d := c.FindOne(context.TODO(), bson.M{"snid": id, "logtype": mongomodel.LogTypeDrop, "gameid": 0, "lastgameid": bson.D{{"$gt", 0}}},
|
||||
options.FindOne().SetSort(bson.D{{"time", 1}}))
|
||||
err = d.Err()
|
||||
if err != nil {
|
||||
if errors.Is(err, mongo.ErrNoDocuments) {
|
||||
logger.Logger.Tracef("checkGameOver %v not found in log_login", id)
|
||||
return false, nil
|
||||
}
|
||||
logger.Logger.Errorf("checkGameOver %v get log_login err: %v", id, err)
|
||||
return false, err
|
||||
}
|
||||
if err := d.Decode(a); err != nil {
|
||||
logger.Logger.Errorf("checkGameOver %v decode log_login err: %v", id, err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
// account tel
|
||||
tel, err := getAccountTel(platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Warnf("get account tel %v err: %v", id, err)
|
||||
}
|
||||
|
||||
update := &mysqlmodel.UserLogin{
|
||||
//OfflineTs: int(a.Ts),
|
||||
OfflineTime: a.Time,
|
||||
OutType: mysqlmodel.OutTypeGameOver,
|
||||
GameID: a.LastGameID,
|
||||
Tel: tel,
|
||||
DeviceName: a.DeviceName,
|
||||
AppVersion: a.AppVersion,
|
||||
BuildVersion: a.BuildVersion,
|
||||
AppChannel: a.AppChannel,
|
||||
ChannelId: a.ChannelId,
|
||||
}
|
||||
|
||||
if err := db.Model(login).Select(
|
||||
"OfflineTime", "OutType", "GameID", "DeviceName", "AppVersion", "BuildVersion", "AppChannel", "Tel",
|
||||
).Updates(update).Error; err != nil {
|
||||
logger.Logger.Errorf("checkLogin %v update user_login err: %v", id, err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// 游戏中离开
|
||||
func checkGaming(db *mymysql.Database, login *mysqlmodel.UserLogin, platform string, id int) (bool, error) {
|
||||
// 最早的一条掉线记录并且是游戏中掉线
|
||||
a := &mongomodel.LoginLog{}
|
||||
c, err := mymongo.GetLogCollection(platform, mongomodel.LogLogin)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("get collection %s error %v", mongomodel.LogLogin, err)
|
||||
return false, err
|
||||
}
|
||||
d := c.FindOne(context.TODO(), bson.M{"snid": id, "logtype": mongomodel.LogTypeDrop, "gameid": bson.D{{"$gt", 0}}},
|
||||
options.FindOne().SetSort(bson.D{{"time", 1}}))
|
||||
err = d.Err()
|
||||
if err != nil {
|
||||
if errors.Is(err, mongo.ErrNoDocuments) {
|
||||
logger.Logger.Tracef("checkGaming %v not found in log_login", id)
|
||||
return false, nil
|
||||
}
|
||||
logger.Logger.Errorf("checkGaming %v get log_login err: %v", id, err)
|
||||
return false, err
|
||||
}
|
||||
if err := d.Decode(a); err != nil {
|
||||
logger.Logger.Errorf("checkGaming %v decode log_login err: %v", id, err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
// account tel
|
||||
tel, err := getAccountTel(platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Warnf("get account tel %v err: %v", id, err)
|
||||
}
|
||||
|
||||
update := &mysqlmodel.UserLogin{
|
||||
//OfflineTs: int(a.Ts),
|
||||
OfflineTime: a.Time,
|
||||
OutType: mysqlmodel.OutTypeGaming,
|
||||
GameID: a.GameId,
|
||||
Tel: tel,
|
||||
DeviceName: a.DeviceName,
|
||||
AppVersion: a.AppVersion,
|
||||
BuildVersion: a.BuildVersion,
|
||||
AppChannel: a.AppChannel,
|
||||
ChannelId: a.ChannelId,
|
||||
}
|
||||
|
||||
if err := db.Model(login).Select(
|
||||
"OfflineTime", "OutType", "GameID", "DeviceName", "AppVersion", "BuildVersion", "AppChannel", "Tel",
|
||||
).Updates(update).Error; err != nil {
|
||||
logger.Logger.Errorf("checkLogin %v update user_login err: %v", id, err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// 登录后离开
|
||||
func checkLogin(db *mymysql.Database, login *mysqlmodel.UserLogin, platform string, id int) (bool, error) {
|
||||
// 最早的一条掉线记录
|
||||
a := &mongomodel.LoginLog{}
|
||||
c, err := mymongo.GetLogCollection(platform, mongomodel.LogLogin)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("get collection %s error %v", mongomodel.LogLogin, err)
|
||||
return false, err
|
||||
}
|
||||
d := c.FindOne(context.TODO(), bson.M{"snid": id, "logtype": mongomodel.LogTypeDrop}, options.FindOne().SetSort(bson.D{{"time", 1}}))
|
||||
err = d.Err()
|
||||
if err != nil {
|
||||
if errors.Is(err, mongo.ErrNoDocuments) {
|
||||
logger.Logger.Tracef("checkLogin %v not found in log_login", id)
|
||||
return false, nil
|
||||
}
|
||||
logger.Logger.Errorf("checkLogin %v get log_login err: %v", id, err)
|
||||
return false, err
|
||||
}
|
||||
if err := d.Decode(a); err != nil {
|
||||
logger.Logger.Errorf("checkLogin %v decode log_login err: %v", id, err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
// account tel
|
||||
tel, err := getAccountTel(platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Warnf("get account tel %v err: %v", id, err)
|
||||
}
|
||||
|
||||
update := &mysqlmodel.UserLogin{
|
||||
//OfflineTs: int(a.Ts),
|
||||
OfflineTime: a.Time,
|
||||
OutType: mysqlmodel.OutTypeLogin,
|
||||
Tel: tel,
|
||||
DeviceName: a.DeviceName,
|
||||
AppVersion: a.AppVersion,
|
||||
BuildVersion: a.BuildVersion,
|
||||
AppChannel: a.AppChannel,
|
||||
ChannelId: a.ChannelId,
|
||||
}
|
||||
|
||||
if err := db.Model(login).Select(
|
||||
"OfflineTime", "OutType", "DeviceName", "AppVersion", "BuildVersion", "AppChannel", "Tel",
|
||||
).Updates(update).Error; err != nil {
|
||||
logger.Logger.Errorf("checkLogin %v update user_login err: %v", id, err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// 注册后离开
|
||||
func checkRegister(db *mymysql.Database, login *mysqlmodel.UserLogin, platform string, id int) (bool, error) {
|
||||
a := &mongomodel.Account{}
|
||||
c, err := mymongo.GetUserCollection(platform, mongomodel.UserAccount)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("get collection %s error %v", mongomodel.UserAccount, err)
|
||||
return false, err
|
||||
}
|
||||
d := c.FindOne(context.TODO(), bson.M{"snid": id})
|
||||
err = d.Err()
|
||||
if err != nil {
|
||||
if errors.Is(err, mongo.ErrNoDocuments) {
|
||||
logger.Logger.Warnf("checkRegister %v not found in user_account", id)
|
||||
return false, nil
|
||||
}
|
||||
logger.Logger.Errorf("checkRegister %v get user_account err: %v", id, err)
|
||||
return false, err
|
||||
}
|
||||
if err := d.Decode(a); err != nil {
|
||||
logger.Logger.Errorf("checkRegister %v decode user_account err: %v", id, err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
// account tel
|
||||
tel, err := getAccountTel(platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Warnf("get account tel %v err: %v", id, err)
|
||||
}
|
||||
|
||||
login.Snid = id
|
||||
//login.OnlineTs = int(a.RegisterTs)
|
||||
login.OnlineTime = a.RegisteTime
|
||||
//login.OfflineTs = int(a.RegisterTs)
|
||||
login.OfflineTime = a.RegisteTime
|
||||
login.OutType = mysqlmodel.OutTypRegister
|
||||
login.Tel = tel
|
||||
login.DeviceName = a.DeviceName
|
||||
login.AppVersion = a.AppVersion
|
||||
login.BuildVersion = a.BuildVersion
|
||||
login.AppChannel = a.AppChannel
|
||||
login.ChannelId = a.ChannelId
|
||||
|
||||
if err := db.Create(login).Error; err != nil {
|
||||
logger.Logger.Errorf("checkRegister create err: %v", err)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// UserLogin 玩家跳出统计
|
||||
func UserLogin(platform string, ids []*mysqlmodel.UserID) error {
|
||||
f := func(id int) error {
|
||||
// 玩家是否已经统计结束,已经是游戏结束状态
|
||||
login := &mysqlmodel.UserLogin{}
|
||||
db, err := mymysql.GetDatabase(platform)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("UserLogin get db err: %v", err)
|
||||
return err
|
||||
}
|
||||
if err = db.Where("snid = ?", id).Find(login).Error; err != nil {
|
||||
logger.Logger.Errorf("UserLogin find %v err: %v", id, err)
|
||||
return err
|
||||
}
|
||||
|
||||
switch login.OutType {
|
||||
case mysqlmodel.OutTypeGameOver:
|
||||
return nil
|
||||
|
||||
case mysqlmodel.OutTypeGaming:
|
||||
_, err := checkGameOver(db, login, platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("UserLogin checkGameOver %v err: %v", id, err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
case mysqlmodel.OutTypeLogin:
|
||||
ret, err := checkGameOver(db, login, platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("UserLogin checkGameOver %v err: %v", id, err)
|
||||
return err
|
||||
}
|
||||
if ret {
|
||||
return nil
|
||||
}
|
||||
ret, err = checkGaming(db, login, platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("UserLogin checkGaming %v err: %v", id, err)
|
||||
return err
|
||||
}
|
||||
if ret {
|
||||
return nil
|
||||
}
|
||||
|
||||
case mysqlmodel.OutTypRegister:
|
||||
ret, err := checkGameOver(db, login, platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("UserLogin checkGameOver %v err: %v", id, err)
|
||||
return err
|
||||
}
|
||||
if ret {
|
||||
return nil
|
||||
}
|
||||
ret, err = checkGaming(db, login, platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("UserLogin checkGaming %v err: %v", id, err)
|
||||
return err
|
||||
}
|
||||
if ret {
|
||||
return nil
|
||||
}
|
||||
ret, err = checkLogin(db, login, platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("UserLogin checkLogin %v err: %v", id, err)
|
||||
return err
|
||||
}
|
||||
if ret {
|
||||
return nil
|
||||
}
|
||||
|
||||
default:
|
||||
ret, err := checkRegister(db, login, platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("UserLogin checkRegister %v err: %v", id, err)
|
||||
return err
|
||||
}
|
||||
if !ret {
|
||||
logger.Logger.Warnf("UserLogin not found user_account checkRegister %v err: %v", id, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
ret, err = checkGameOver(db, login, platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("UserLogin checkGameOver %v err: %v", id, err)
|
||||
return err
|
||||
}
|
||||
if ret {
|
||||
return nil
|
||||
}
|
||||
ret, err = checkGaming(db, login, platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("UserLogin checkGaming %v err: %v", id, err)
|
||||
return err
|
||||
}
|
||||
if ret {
|
||||
return nil
|
||||
}
|
||||
ret, err = checkLogin(db, login, platform, id)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("UserLogin checkLogin %v err: %v", id, err)
|
||||
return err
|
||||
}
|
||||
if ret {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, v := range ids {
|
||||
if err := f(v.Snid); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package syn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"gorm.io/gorm"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
|
||||
mysqlmodel "mongo.games.com/game/statistics/modelmysql"
|
||||
mymongo "mongo.games.com/goserver/core/mongox"
|
||||
mymysql "mongo.games.com/goserver/core/mysqlx"
|
||||
)
|
||||
|
||||
// Data 数据同步方法
|
||||
// T mongodb数据表结构
|
||||
// F mongodb中的每条数据的处理操作,自行实现
|
||||
type Data[T any] struct {
|
||||
Platform string // 平台
|
||||
MidType int // 数据类型 例如 modelmysql.MidTypeItem
|
||||
Database string // 库名称
|
||||
CollectionName string // 集合名称
|
||||
BatchSize int // 一次读取数量
|
||||
// F 自定义数据处理方法
|
||||
// data: mongodb中的一条日志
|
||||
F func(data *T, db *gorm.DB) (string, error)
|
||||
}
|
||||
|
||||
// CommonDone 数据获取方式,根据mongodb集合主键按时间顺序批量读取
|
||||
func (d *Data[T]) CommonDone() error {
|
||||
db, err := mymysql.GetDatabase(d.Platform)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql: failed to get database: %v", err)
|
||||
return err
|
||||
}
|
||||
loginMID := &mysqlmodel.LogMid{Tp: d.MidType}
|
||||
var n int64
|
||||
err = db.Model(&mysqlmodel.LogMid{}).Find(loginMID).Count(&n).Error
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql: failed to get log_mid: %v", err)
|
||||
return err
|
||||
}
|
||||
if n == 0 {
|
||||
if err = db.Create(loginMID).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: failed to create log_mid: %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
logger.Logger.Tracef("start log_mid tp:%v _id:%v", loginMID.Tp, loginMID.MID)
|
||||
|
||||
_id, _ := primitive.ObjectIDFromHex(loginMID.MID)
|
||||
filter := bson.M{"_id": bson.M{"$gt": _id}}
|
||||
c, err := mymongo.GetCollection(d.Platform, mymongo.DatabaseType(d.Database), d.CollectionName)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("get collection %s %s error %v", d.Database, d.CollectionName, err)
|
||||
return err
|
||||
}
|
||||
l, err := c.Find(context.TODO(), filter,
|
||||
options.Find().SetSort(bson.D{primitive.E{Key: "_id", Value: 1}}), options.Find().SetLimit(int64(d.BatchSize)))
|
||||
if err != nil && !errors.Is(err, mongo.ErrNoDocuments) {
|
||||
logger.Logger.Errorf("mongo: failed to get %v: %v", d.CollectionName, err)
|
||||
return err
|
||||
}
|
||||
|
||||
var logs []*T
|
||||
if err = l.All(context.TODO(), &logs); err != nil {
|
||||
l.Close(context.TODO())
|
||||
if errors.Is(err, mongo.ErrNoDocuments) {
|
||||
return nil
|
||||
}
|
||||
|
||||
logger.Logger.Errorf("mongo: failed to get %v: %v", d.CollectionName, err)
|
||||
return err
|
||||
}
|
||||
l.Close(context.TODO())
|
||||
if len(logs) == 0 {
|
||||
logger.Logger.Infof("sync %v finished", d.CollectionName)
|
||||
return nil
|
||||
}
|
||||
|
||||
err = db.Transaction(func(tx *gorm.DB) error {
|
||||
for _, v := range logs {
|
||||
loginMID.MID, err = d.F(v, tx)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("Process %v error:%v", d.CollectionName, err)
|
||||
return err
|
||||
}
|
||||
if err = tx.Model(loginMID).Updates(loginMID).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: failed to update %v log_mid: %v", d.CollectionName, err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
|
@ -0,0 +1,291 @@
|
|||
package syn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"mongo.games.com/game/statistics/constant"
|
||||
mongomodel "mongo.games.com/game/statistics/modelmongo"
|
||||
mysqlmodel "mongo.games.com/game/statistics/modelmysql"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
mymongo "mongo.games.com/goserver/core/mongox"
|
||||
mymysql "mongo.games.com/goserver/core/mysqlx"
|
||||
)
|
||||
|
||||
func SyncInviteScore(platform string, batchSize int) error {
|
||||
db, err := mymysql.GetDatabase(platform)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncInviteScore failed to get database: %v", err)
|
||||
return err
|
||||
}
|
||||
inviteMID := &mysqlmodel.LogInviteScoreMid{ID: 1}
|
||||
var n int64
|
||||
err = db.Model(&mysqlmodel.LogInviteScoreMid{}).Find(inviteMID).Count(&n).Error
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncInviteScore failed to get log_invitescore_mid: %v", err)
|
||||
return err
|
||||
}
|
||||
if n == 0 {
|
||||
if err = db.Create(inviteMID).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncInviteScore failed to create log_invitescore_mid: %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
logger.Logger.Tracef("start SyncInviteScore log_invitescore _id:%v", inviteMID.MID)
|
||||
|
||||
_id, _ := primitive.ObjectIDFromHex(inviteMID.MID)
|
||||
filter := bson.M{"_id": bson.M{"$gt": _id}}
|
||||
c, err := mymongo.GetLogCollection(platform, mongomodel.LogInviteScore)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("get collection %s error %v", mongomodel.LogInviteScore, err)
|
||||
return err
|
||||
}
|
||||
l, err := c.Find(context.TODO(), filter,
|
||||
options.Find().SetSort(bson.D{primitive.E{Key: "_id", Value: 1}}), options.Find().SetLimit(int64(batchSize)))
|
||||
if err != nil && !errors.Is(err, mongo.ErrNoDocuments) {
|
||||
logger.Logger.Errorf("mongo: SyncInviteScore failed to get log_invitescore: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
var logs []*mongomodel.InviteScore
|
||||
if err = l.All(context.TODO(), &logs); err != nil {
|
||||
l.Close(context.TODO())
|
||||
if errors.Is(err, mongo.ErrNoDocuments) {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Logger.Errorf("mongo: SyncInviteScore failed to get log_invitescore: %v", err)
|
||||
return err
|
||||
}
|
||||
l.Close(context.TODO())
|
||||
|
||||
getPSnId := func(tx *gorm.DB, snid int) (int, error) {
|
||||
if snid <= 0 {
|
||||
return 0, nil
|
||||
}
|
||||
ret := new(mysqlmodel.LogInviteUser)
|
||||
if err = tx.First(ret, "snid = ? and level = 1", snid).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logger.Logger.Errorf("mysql: SyncInviteScore failed to getPSnId: %v", err)
|
||||
return 0, err
|
||||
}
|
||||
return ret.Psnid, nil
|
||||
}
|
||||
|
||||
getDownSnId := func(tx *gorm.DB, snid []int) ([]int, error) {
|
||||
if len(snid) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
var ret []int
|
||||
var us []*mysqlmodel.LogInviteUser
|
||||
if err = tx.Select("snid").Where("psnid IN ? AND level = 1", snid).Find(&us).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logger.Logger.Errorf("mysql: SyncInviteScore failed to getDownSnId: %v", err)
|
||||
return ret, err
|
||||
}
|
||||
for _, v := range us {
|
||||
ret = append(ret, v.Snid)
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
bind := func(tx *gorm.DB, psnid, snid int, ts int) ([]*mysqlmodel.LogInviteUser, error) {
|
||||
var lu []*mysqlmodel.LogInviteUser
|
||||
var a1, a2, a3, a4, b1 int
|
||||
var b2, b3, b4 []int
|
||||
a4 = psnid
|
||||
a3, err = getPSnId(tx, a4)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a2, err = getPSnId(tx, a3)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a1, err = getPSnId(tx, a2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b1 = snid
|
||||
b2, err = getDownSnId(tx, []int{b1})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b3, err = getDownSnId(tx, b2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b4, err = getDownSnId(tx, b3)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logger.Logger.Tracef("a1:%d, a2:%d, a3:%d, a4:%d, b1:%d, b2:%v, b3:%v, b4:%v", a1, a2, a3, a4, b1, b2, b3, b4)
|
||||
if a1 > 0 {
|
||||
if b1 > 0 {
|
||||
lu = append(lu, &mysqlmodel.LogInviteUser{
|
||||
Psnid: a1,
|
||||
Snid: b1,
|
||||
Level: 4,
|
||||
Ts: ts,
|
||||
})
|
||||
logger.Logger.Tracef("a1: %v %v %v", b1, 4, ts)
|
||||
}
|
||||
}
|
||||
if a2 > 0 {
|
||||
if b1 > 0 {
|
||||
lu = append(lu, &mysqlmodel.LogInviteUser{
|
||||
Psnid: a2,
|
||||
Snid: b1,
|
||||
Level: 3,
|
||||
Ts: ts,
|
||||
})
|
||||
logger.Logger.Tracef("a2: %v %v %v", b1, 3, ts)
|
||||
}
|
||||
for _, v := range b2 {
|
||||
if v <= 0 {
|
||||
continue
|
||||
}
|
||||
lu = append(lu, &mysqlmodel.LogInviteUser{
|
||||
Psnid: a2,
|
||||
Snid: v,
|
||||
Level: 4,
|
||||
Ts: ts,
|
||||
})
|
||||
logger.Logger.Tracef("a2: %v %v %v", v, 4, ts)
|
||||
}
|
||||
}
|
||||
if a3 > 0 {
|
||||
if b1 > 0 {
|
||||
lu = append(lu, &mysqlmodel.LogInviteUser{
|
||||
Psnid: a3,
|
||||
Snid: b1,
|
||||
Level: 2,
|
||||
Ts: ts,
|
||||
})
|
||||
logger.Logger.Tracef("a3: %v %v %v", b1, 2, ts)
|
||||
}
|
||||
for _, v := range b2 {
|
||||
if v <= 0 {
|
||||
continue
|
||||
}
|
||||
lu = append(lu, &mysqlmodel.LogInviteUser{
|
||||
Psnid: a3,
|
||||
Snid: v,
|
||||
Level: 3,
|
||||
Ts: ts,
|
||||
})
|
||||
logger.Logger.Tracef("a3: %v %v %v", v, 3, ts)
|
||||
}
|
||||
for _, v := range b3 {
|
||||
if v <= 0 {
|
||||
continue
|
||||
}
|
||||
lu = append(lu, &mysqlmodel.LogInviteUser{
|
||||
Psnid: a3,
|
||||
Snid: v,
|
||||
Level: 4,
|
||||
Ts: ts,
|
||||
})
|
||||
logger.Logger.Tracef("a3: %v %v %v", v, 4, ts)
|
||||
}
|
||||
}
|
||||
if a4 > 0 {
|
||||
if b1 > 0 {
|
||||
lu = append(lu, &mysqlmodel.LogInviteUser{
|
||||
Psnid: a4,
|
||||
Snid: b1,
|
||||
Level: 1,
|
||||
Ts: ts,
|
||||
})
|
||||
logger.Logger.Tracef("a4: %v %v %v", b1, 1, ts)
|
||||
}
|
||||
for _, v := range b2 {
|
||||
if v <= 0 {
|
||||
continue
|
||||
}
|
||||
lu = append(lu, &mysqlmodel.LogInviteUser{
|
||||
Psnid: a4,
|
||||
Snid: v,
|
||||
Level: 2,
|
||||
Ts: ts,
|
||||
})
|
||||
logger.Logger.Tracef("a4: %v %v %v", v, 2, ts)
|
||||
}
|
||||
for _, v := range b3 {
|
||||
if v <= 0 {
|
||||
continue
|
||||
}
|
||||
lu = append(lu, &mysqlmodel.LogInviteUser{
|
||||
Psnid: a4,
|
||||
Snid: v,
|
||||
Level: 3,
|
||||
Ts: ts,
|
||||
})
|
||||
logger.Logger.Tracef("a4: %v %v %v", v, 3, ts)
|
||||
}
|
||||
for _, v := range b4 {
|
||||
if v <= 0 {
|
||||
continue
|
||||
}
|
||||
lu = append(lu, &mysqlmodel.LogInviteUser{
|
||||
Psnid: a4,
|
||||
Snid: v,
|
||||
Level: 4,
|
||||
Ts: ts,
|
||||
})
|
||||
logger.Logger.Tracef("a4: %v %v %v", v, 4, ts)
|
||||
}
|
||||
}
|
||||
return lu, nil
|
||||
}
|
||||
|
||||
for _, v := range logs {
|
||||
err = db.Transaction(func(tx *gorm.DB) error {
|
||||
inviteMID.MID = v.Id.Hex()
|
||||
if err = tx.Model(inviteMID).Updates(inviteMID).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncInviteScore failed to update log_invitescore_mid: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
err = tx.Save(&mysqlmodel.LogInviteScore{
|
||||
UpSnid: v.UpSnid,
|
||||
DownSnid: v.DownSnid,
|
||||
Level: v.Level,
|
||||
Tp: v.Tp,
|
||||
Rate: v.Rate,
|
||||
Score: v.Score,
|
||||
Money: v.Money,
|
||||
Ts: v.Ts,
|
||||
}).Error
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncInviteScore failed to insert: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if v.Tp == constant.InviteScoreTypeBind && v.Level == 0 {
|
||||
// 绑定关系
|
||||
lu, err := bind(tx, v.UpSnid, v.DownSnid, v.Ts)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncInviteScore failed to bind: %v", err)
|
||||
return err
|
||||
}
|
||||
if err = tx.CreateInBatches(lu, len(lu)).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncInviteScore failed to create log_invite_user: %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncInviteScore failed to transaction: %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package syn
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"mongo.games.com/goserver/core/mongox"
|
||||
|
||||
mongomodel "mongo.games.com/game/statistics/modelmongo"
|
||||
mysqlmodel "mongo.games.com/game/statistics/modelmysql"
|
||||
)
|
||||
|
||||
func ItemGainDone(data *Data[mongomodel.ItemLog]) error {
|
||||
data.MidType = mysqlmodel.MidTypeItem
|
||||
data.Database = string(mongox.DatabaseLog)
|
||||
data.CollectionName = mongomodel.LogItem
|
||||
data.F = func(data *mongomodel.ItemLog, db *gorm.DB) (string, error) {
|
||||
if data == nil || data.LogId.Hex() == "" {
|
||||
return "", errors.New("null")
|
||||
}
|
||||
if data.LogType != 0 || data.Id != "" {
|
||||
return data.LogId.Hex(), nil
|
||||
}
|
||||
|
||||
hourTime := time.Unix(data.CreateTs, 0).Local()
|
||||
hourTs := time.Date(hourTime.Year(), hourTime.Month(), hourTime.Day(), hourTime.Hour(), 0, 0, 0, time.Local).Unix()
|
||||
|
||||
item := &mysqlmodel.ItemGain{}
|
||||
err := db.Model(item).Where("hour = ? and item_id = ?", hourTs, data.ItemId).First(item).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return "", err
|
||||
}
|
||||
item.Hour = hourTs
|
||||
item.ItemId = data.ItemId
|
||||
item.ItemNum += data.Count
|
||||
if item.ID == 0 {
|
||||
err = db.Create(item).Error
|
||||
} else {
|
||||
err = db.Model(item).Updates(item).Error
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
itemTotal := &mysqlmodel.ItemTotalGain{}
|
||||
err = db.Model(itemTotal).Where("item_id = ?", data.ItemId).First(itemTotal).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return "", err
|
||||
}
|
||||
itemTotal.ItemId = data.ItemId
|
||||
itemTotal.ItemNum += data.Count
|
||||
if itemTotal.ID == 0 {
|
||||
err = db.Create(itemTotal).Error
|
||||
} else {
|
||||
err = db.Model(itemTotal).Updates(itemTotal).Error
|
||||
}
|
||||
return data.LogId.Hex(), err
|
||||
}
|
||||
return data.CommonDone()
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
package syn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"gorm.io/gorm"
|
||||
|
||||
mongomodel "mongo.games.com/game/statistics/modelmongo"
|
||||
mysqlmodel "mongo.games.com/game/statistics/modelmysql"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
mymongo "mongo.games.com/goserver/core/mongox"
|
||||
mymysql "mongo.games.com/goserver/core/mysqlx"
|
||||
)
|
||||
|
||||
/*
|
||||
登录日志同步使用了mongo的_id,从小到大每次同步n个
|
||||
*/
|
||||
|
||||
// LogLogin 同步登录日志
|
||||
func LogLogin(platform string, batchSize int) ([]*mysqlmodel.LogLogin, error) {
|
||||
db, err := mymysql.GetDatabase(platform)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncLogLogin failed to get database: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
loginMID := &mysqlmodel.LogLoginMid{ID: 1}
|
||||
var n int64
|
||||
err = db.Model(&mysqlmodel.LogLoginMid{}).Find(loginMID).Count(&n).Error
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncLogLogin failed to get log_login_mid: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
if n == 0 {
|
||||
if err = db.Create(loginMID).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncLogLogin failed to create log_login_mid: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
logger.Logger.Tracef("start SyncLogLogin log_login _id:%v", loginMID.MID)
|
||||
|
||||
_id, _ := primitive.ObjectIDFromHex(loginMID.MID)
|
||||
filter := bson.M{"_id": bson.M{"$gt": _id}}
|
||||
c, err := mymongo.GetLogCollection(platform, mongomodel.LogLogin)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("get collection %s error %v", mongomodel.LogLogin, err)
|
||||
return nil, err
|
||||
}
|
||||
l, err := c.Find(context.TODO(), filter,
|
||||
options.Find().SetSort(bson.D{primitive.E{Key: "_id", Value: 1}}), options.Find().SetLimit(int64(batchSize)))
|
||||
if err != nil && !errors.Is(err, mongo.ErrNoDocuments) {
|
||||
logger.Logger.Errorf("mongo: SyncLogLogin failed to get log_login: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var logs []*mongomodel.LoginLog
|
||||
if err = l.All(context.TODO(), &logs); err != nil {
|
||||
l.Close(context.TODO())
|
||||
if errors.Is(err, mongo.ErrNoDocuments) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
logger.Logger.Errorf("mongo: SyncLogLogin failed to get loginlog: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
l.Close(context.TODO())
|
||||
|
||||
var ls []*mysqlmodel.LogLogin
|
||||
for _, v := range logs {
|
||||
logger.Logger.Tracef("mongo SyncLogLogin log_login: %+v", *v)
|
||||
var e *mysqlmodel.LogLogin
|
||||
switch v.LogType {
|
||||
case mongomodel.LogTypeLogin, mongomodel.LogTypeRehold:
|
||||
onlineType := mysqlmodel.LogTypeLogin
|
||||
if v.LogType == mongomodel.LogTypeRehold {
|
||||
onlineType = mysqlmodel.LogTypeRehold
|
||||
}
|
||||
|
||||
// 创建数据
|
||||
var n int64
|
||||
if err = db.Model(&mysqlmodel.LogLogin{}).Where("snid = ? AND online_type = ? AND online_time = ?",
|
||||
v.SnId, onlineType, v.Time).Count(&n).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncLogLogin failed to get log_login count: %v", err)
|
||||
return ls, err
|
||||
}
|
||||
|
||||
if n == 0 {
|
||||
e = &mysqlmodel.LogLogin{
|
||||
Snid: int(v.SnId),
|
||||
OnlineType: onlineType,
|
||||
//OnlineTs: int(v.Ts),
|
||||
OnlineTime: v.Time,
|
||||
OfflineType: 0,
|
||||
//OfflineTs: 0,
|
||||
OfflineTime: v.Time,
|
||||
DeviceName: v.DeviceName,
|
||||
AppVersion: v.AppVersion,
|
||||
BuildVersion: v.BuildVersion,
|
||||
AppChannel: v.AppChannel,
|
||||
ChannelId: v.ChannelId,
|
||||
}
|
||||
if err = db.Create(e).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncLogLogin failed to create log_login: %v", err)
|
||||
return ls, err
|
||||
}
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
|
||||
case mongomodel.LogTypeLogout, mongomodel.LogTypeDrop:
|
||||
// 修改数据
|
||||
e = &mysqlmodel.LogLogin{}
|
||||
err = db.Model(&mysqlmodel.LogLogin{}).Where("snid = ?", v.SnId).Order("online_time DESC").First(e).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logger.Logger.Errorf("mysql: SyncLogLogin failed to find log_login: %v", err)
|
||||
return ls, err
|
||||
}
|
||||
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logger.Logger.Warnf("mysql: SyncLogLogin not found log_login: %v", v)
|
||||
continue
|
||||
}
|
||||
|
||||
if e.OfflineType != 0 {
|
||||
logger.Logger.Tracef("mysql: SyncLogLogin already offline: %+v", *e)
|
||||
continue
|
||||
}
|
||||
|
||||
e.OfflineType = mysqlmodel.LogTypeOffline
|
||||
//e.OfflineTs = int(v.Ts)
|
||||
e.OfflineTime = v.Time
|
||||
if err = db.Model(e).Select("OfflineType", "OfflineTime").Updates(e).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncLogLogin failed to update log_login: %v", err)
|
||||
return ls, err
|
||||
}
|
||||
default:
|
||||
continue
|
||||
}
|
||||
|
||||
if e != nil {
|
||||
ls = append(ls, e)
|
||||
}
|
||||
}
|
||||
|
||||
if len(logs) > 0 {
|
||||
err = db.Transaction(func(tx *gorm.DB) error {
|
||||
loginMID.MID = logs[len(logs)-1].LogId.Hex()
|
||||
if err = tx.Model(loginMID).Updates(loginMID).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncLogLogin failed to update log_login_mid: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
for _, v := range ls {
|
||||
if err = tx.First(&mysqlmodel.UserID{}, "snid = ?", v.Snid).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logger.Logger.Errorf("mysql: SyncLogLogin failed to find user_id: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
if err = tx.Create(&mysqlmodel.UserID{Snid: v.Snid}).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncLogLogin failed to create user_id: %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql: SyncLogLogin failed to transaction: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return ls, nil
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
游戏服mongodb同步到mysql
|
|
@ -0,0 +1,105 @@
|
|||
package syn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"gorm.io/gorm"
|
||||
|
||||
mongomodel "mongo.games.com/game/statistics/modelmongo"
|
||||
mysqlmodel "mongo.games.com/game/statistics/modelmysql"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
mymongo "mongo.games.com/goserver/core/mongox"
|
||||
mymysql "mongo.games.com/goserver/core/mysqlx"
|
||||
)
|
||||
|
||||
/*
|
||||
注册信息同步,使用mongo的_id,从小到大每次同步n个
|
||||
*/
|
||||
|
||||
// UserAccount 同步注册表
|
||||
func UserAccount(platform string, batchSize int) ([]*mysqlmodel.UserAccount, error) {
|
||||
db, err := mymysql.GetDatabase(platform)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql: UserAccount failed to get database: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
account := &mysqlmodel.UserAccount{}
|
||||
err = db.Model(&mysqlmodel.UserAccount{}).Last(account).Error
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logger.Logger.Errorf("mysql: UserAccount failed to get account: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
logger.Logger.Tracef("start UserAccount account _id:%v", account.MID)
|
||||
|
||||
_id, _ := primitive.ObjectIDFromHex(account.MID)
|
||||
filter := bson.M{"_id": bson.M{"$gt": _id}}
|
||||
c, err := mymongo.GetUserCollection(platform, mongomodel.UserAccount)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("get collection %s error %v", mongomodel.UserAccount, err)
|
||||
return nil, err
|
||||
}
|
||||
l, err := c.Find(context.TODO(), filter,
|
||||
options.Find().SetSort(bson.D{primitive.E{Key: "_id", Value: 1}}), options.Find().SetLimit(int64(batchSize)))
|
||||
if err != nil && !errors.Is(err, mongo.ErrNoDocuments) {
|
||||
logger.Logger.Errorf("mongo: UserAccount failed to get account: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var accounts []*mongomodel.Account
|
||||
if err = l.All(context.TODO(), &accounts); err != nil {
|
||||
l.Close(context.TODO())
|
||||
if errors.Is(err, mongo.ErrNoDocuments) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
logger.Logger.Errorf("mongo: UserAccount failed to get account: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
l.Close(context.TODO())
|
||||
|
||||
var as []*mysqlmodel.UserAccount
|
||||
err = db.Transaction(func(tx *gorm.DB) error {
|
||||
for _, v := range accounts {
|
||||
logger.Logger.Tracef("mongo account: %+v", *v)
|
||||
a := &mysqlmodel.UserAccount{
|
||||
MID: v.AccountId.Hex(),
|
||||
Snid: int(v.SnId),
|
||||
//RegisterTs: int(v.RegisterTs),
|
||||
RegisterTime: v.RegisteTime,
|
||||
Tel: v.Tel,
|
||||
ChannelId: v.ChannelId,
|
||||
}
|
||||
|
||||
if err = tx.Create(a).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: UserAccount failed to create account: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if err = tx.First(&mysqlmodel.UserID{}, "snid = ?", v.SnId).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logger.Logger.Errorf("mysql: UserAccount failed to find user_id: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
if err = tx.Create(&mysqlmodel.UserID{Snid: int(v.SnId)}).Error; err != nil {
|
||||
logger.Logger.Errorf("mysql: UserAccount failed to create user_id: %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
as = append(as, a)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("mysql: UserAccount failed to transaction: %v", err)
|
||||
return as, err
|
||||
}
|
||||
return as, nil
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
set CGO_ENABLED=0
|
||||
set GOOS=linux
|
||||
set GOARCH=amd64
|
||||
go build -o ./task2
|
||||
pause
|
Binary file not shown.
|
@ -0,0 +1,221 @@
|
|||
StartTime: "2024-11-26T00:00:00+08:00"
|
||||
EndTime: "2024-11-27T00:00:00+08:00"
|
||||
|
||||
Switch: # 1: open, 0: close
|
||||
- 0 # 新用户游戏破产率
|
||||
- 0 # 新用户平均游戏时长
|
||||
- 0 # 新用户平均局数
|
||||
- 0 # 平均倍数
|
||||
- 1 # 活跃破产率
|
||||
- 1 # 控输赢胜率
|
||||
- 1 # 机器人胜率
|
||||
- 1 # 人均获得金币
|
||||
- 1 # 破产后离线
|
||||
- 1 # 充值玩家金币余额
|
||||
|
||||
Gamefreeids:
|
||||
- 2070001
|
||||
- 2070002
|
||||
- 2070003
|
||||
- 2080001
|
||||
- 2080002
|
||||
- 2080003
|
||||
- 2090001
|
||||
- 2090002
|
||||
- 2090003
|
||||
- 2100001
|
||||
- 2100002
|
||||
- 2100003
|
||||
- 2400001
|
||||
- 2400002
|
||||
- 2400003
|
||||
- 2400004
|
||||
- 2400005
|
||||
- 2400006
|
||||
- 2440001
|
||||
- 2440002
|
||||
- 2440003
|
||||
- 2440004
|
||||
- 2440005
|
||||
- 2440006
|
||||
- 2410001
|
||||
- 2410002
|
||||
- 2410003
|
||||
- 2410004
|
||||
- 2410005
|
||||
- 2410006
|
||||
- 2450001
|
||||
- 2450002
|
||||
- 2450003
|
||||
- 2450004
|
||||
- 2450005
|
||||
- 2450006
|
||||
- 2420001
|
||||
- 2420002
|
||||
- 2420003
|
||||
- 2420004
|
||||
- 2420005
|
||||
- 2420006
|
||||
- 2460001
|
||||
- 2460002
|
||||
- 2460003
|
||||
- 2460004
|
||||
- 2460005
|
||||
- 2460006
|
||||
- 2430001
|
||||
- 2430002
|
||||
- 2430003
|
||||
- 2430004
|
||||
- 2430005
|
||||
- 2430006
|
||||
- 2470001
|
||||
- 2470002
|
||||
- 2470003
|
||||
- 2470004
|
||||
- 2470005
|
||||
- 2470006
|
||||
- 2150001
|
||||
- 2160001
|
||||
- 2170001
|
||||
- 2180001
|
||||
- 5210001
|
||||
- 5210002
|
||||
- 5210003
|
||||
- 5210004
|
||||
- 5210005
|
||||
- 2110001
|
||||
- 2110002
|
||||
- 2110003
|
||||
- 2110004
|
||||
- 2110005
|
||||
- 2110006
|
||||
- 2120001
|
||||
- 2120002
|
||||
- 2120003
|
||||
- 2120004
|
||||
- 2120005
|
||||
- 2120006
|
||||
- 2130001
|
||||
- 2130002
|
||||
- 2130003
|
||||
- 2140001
|
||||
- 2140002
|
||||
- 2140003
|
||||
- 6070001
|
||||
- 3010001
|
||||
- 3010002
|
||||
- 3010003
|
||||
- 3010004
|
||||
- 3020001
|
||||
- 3020002
|
||||
- 3020003
|
||||
- 3020004
|
||||
- 3030001
|
||||
- 3030002
|
||||
- 3030003
|
||||
- 3030004
|
||||
- 3040001
|
||||
- 3040002
|
||||
- 3040003
|
||||
- 3050001
|
||||
- 3050002
|
||||
- 3050003
|
||||
- 3060001
|
||||
- 3060002
|
||||
- 3060003
|
||||
- 3060004
|
||||
- 3070001
|
||||
- 3070002
|
||||
- 3070003
|
||||
- 3070004
|
||||
- 3080001
|
||||
- 3090001
|
||||
- 3100001
|
||||
- 3110001
|
||||
- 3120001
|
||||
|
||||
Tienlen:
|
||||
- 2070001
|
||||
- 2070002
|
||||
- 2070003
|
||||
- 2080001
|
||||
- 2080002
|
||||
- 2080003
|
||||
- 2090001
|
||||
- 2090002
|
||||
- 2090003
|
||||
- 2100001
|
||||
- 2100002
|
||||
- 2100003
|
||||
- 2400001
|
||||
- 2400002
|
||||
- 2400003
|
||||
- 2400004
|
||||
- 2400005
|
||||
- 2400006
|
||||
- 2440001
|
||||
- 2440002
|
||||
- 2440003
|
||||
- 2440004
|
||||
- 2440005
|
||||
- 2440006
|
||||
- 2410001
|
||||
- 2410002
|
||||
- 2410003
|
||||
- 2410004
|
||||
- 2410005
|
||||
- 2410006
|
||||
- 2450001
|
||||
- 2450002
|
||||
- 2450003
|
||||
- 2450004
|
||||
- 2450005
|
||||
- 2450006
|
||||
- 2420001
|
||||
- 2420002
|
||||
- 2420003
|
||||
- 2420004
|
||||
- 2420005
|
||||
- 2420006
|
||||
- 2460001
|
||||
- 2460002
|
||||
- 2460003
|
||||
- 2460004
|
||||
- 2460005
|
||||
- 2460006
|
||||
- 2430001
|
||||
- 2430002
|
||||
- 2430003
|
||||
- 2430004
|
||||
- 2430005
|
||||
- 2430006
|
||||
- 2470001
|
||||
- 2470002
|
||||
- 2470003
|
||||
- 2470004
|
||||
- 2470005
|
||||
- 2470006
|
||||
|
||||
|
||||
Thirteen:
|
||||
- 2110001
|
||||
- 2110002
|
||||
- 2110003
|
||||
- 2110004
|
||||
- 2110005
|
||||
- 2110006
|
||||
- 2120001
|
||||
- 2120002
|
||||
- 2120003
|
||||
- 2120004
|
||||
- 2120005
|
||||
- 2120006
|
||||
- 2130001
|
||||
- 2130002
|
||||
- 2130003
|
||||
- 2140001
|
||||
- 2140002
|
||||
- 2140003
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
global:
|
||||
user:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_global
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
||||
log:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_log
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
||||
monitor:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_monitor
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
||||
platforms:
|
||||
0:
|
||||
user:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_user_plt_000
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
||||
log:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_log_plt_000
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
||||
1:
|
||||
user:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_user_plt_001
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
||||
log:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 27017
|
||||
Database: win88_log_plt_001
|
||||
Username:
|
||||
Password:
|
||||
Options:
|
|
@ -0,0 +1,38 @@
|
|||
platforms:
|
||||
global:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 3306
|
||||
Database: win88_user
|
||||
Username: root
|
||||
Password: 123456
|
||||
Options: charset=utf8mb4&parseTime=True&loc=Local
|
||||
0:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 3306
|
||||
Database: win88_plt_000
|
||||
Username: root
|
||||
Password: 123456
|
||||
Options: charset=utf8mb4&parseTime=True&loc=Local
|
||||
1:
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 3306
|
||||
Database: win88_plt_001
|
||||
Username: root
|
||||
Password: 123456
|
||||
Options: charset=utf8mb4&parseTime=True&loc=Local
|
||||
count: # 破产日志库
|
||||
HostName: 127.0.0.1
|
||||
HostPort: 3306
|
||||
Database: dbmis_count
|
||||
Username: root
|
||||
Password: 123456
|
||||
Options: charset=utf8mb4&parseTime=True&loc=Local
|
||||
|
||||
# 最大空闲连接数
|
||||
MaxIdleConns: 10
|
||||
# 最大连接数
|
||||
MaxOpenConns: 100
|
||||
# 连接可复用的最大时间
|
||||
ConnMaxLifetime: 3600
|
||||
# 连接最大空闲时间
|
||||
ConnMaxIdletime: 0
|
|
@ -0,0 +1,88 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/xuri/excelize/v2"
|
||||
)
|
||||
|
||||
type ExcelData struct {
|
||||
*excelize.File
|
||||
Head []string
|
||||
Index int
|
||||
IndexCell int
|
||||
}
|
||||
|
||||
func (e *ExcelData) SetHead(head []string) *ExcelData {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
e.Index = 1
|
||||
e.SetSheetRow("Sheet1", "A1", &head)
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *ExcelData) SetRow(row []string) *ExcelData {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
e.Index++
|
||||
e.SetSheetRow("Sheet1", "A"+fmt.Sprintf("%d", e.Index), &row)
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *ExcelData) SetCell(val interface{}) *ExcelData {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
e.IndexCell++
|
||||
cell := fmt.Sprintf("%c%d", 'A'+e.IndexCell-1, e.Index)
|
||||
e.SetCellValue("Sheet1", cell, val)
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *ExcelData) NewLine() *ExcelData {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
e.Index++
|
||||
e.IndexCell = 0
|
||||
return e
|
||||
}
|
||||
|
||||
type ExcelMgr struct {
|
||||
List map[int]*ExcelData
|
||||
}
|
||||
|
||||
func NewExcelMgr() *ExcelMgr {
|
||||
return &ExcelMgr{
|
||||
List: make(map[int]*ExcelData),
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) Register(id int, head []string) *ExcelData {
|
||||
e.List[id] = &ExcelData{
|
||||
File: excelize.NewFile(),
|
||||
Head: head,
|
||||
Index: 0,
|
||||
}
|
||||
|
||||
e.List[id].NewSheet("Sheet1")
|
||||
|
||||
if len(head) > 0 {
|
||||
e.List[id].SetHead(head)
|
||||
}
|
||||
|
||||
return e.List[id]
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) Get(id int) *ExcelData {
|
||||
return e.List[id]
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) Save(id int, fileName string) error {
|
||||
d := e.List[id]
|
||||
if d == nil {
|
||||
return nil
|
||||
}
|
||||
return d.SaveAs(fileName)
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package gamefree
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
"mongo.games.com/game/protocol/server"
|
||||
"os"
|
||||
)
|
||||
|
||||
func init() {
|
||||
buf, err := os.ReadFile("./etc/DB_GameFree.dat")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = PBDB_GameFreeMgr.unmarshal(buf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
var PBDB_GameFreeMgr = &DB_GameFreeMgr{
|
||||
Datas: &server.DB_GameFreeArray{},
|
||||
pool: make(map[int32]*server.DB_GameFree),
|
||||
}
|
||||
|
||||
type DB_GameFreeMgr struct {
|
||||
Datas *server.DB_GameFreeArray
|
||||
pool map[int32]*server.DB_GameFree
|
||||
}
|
||||
|
||||
func (this *DB_GameFreeMgr) unmarshal(data []byte) error {
|
||||
err := proto.Unmarshal(data, this.Datas)
|
||||
if err == nil {
|
||||
this.arrangeData()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *DB_GameFreeMgr) reunmarshal(data []byte) error {
|
||||
newDatas := &server.DB_GameFreeArray{}
|
||||
err := proto.Unmarshal(data, newDatas)
|
||||
if err == nil {
|
||||
for _, item := range newDatas.Arr {
|
||||
existItem := this.GetData(item.GetId())
|
||||
if existItem == nil {
|
||||
this.pool[item.GetId()] = item
|
||||
this.Datas.Arr = append(this.Datas.Arr, item)
|
||||
|
||||
} else {
|
||||
*existItem = *item
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *DB_GameFreeMgr) arrangeData() {
|
||||
if this.Datas == nil {
|
||||
return
|
||||
}
|
||||
|
||||
dataArr := this.Datas.GetArr()
|
||||
if dataArr == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, data := range dataArr {
|
||||
this.pool[data.GetId()] = data
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (this *DB_GameFreeMgr) GetData(id int32) *server.DB_GameFree {
|
||||
if data, ok := this.pool[id]; ok {
|
||||
return data
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<seelog type="adaptive" mininterval="2000000" maxinterval="100000000" critmsgcount="500" minlevel="trace">
|
||||
<exceptions>
|
||||
<exception filepattern="test*" minlevel="error"/>
|
||||
</exceptions>
|
||||
<outputs formatid="all">
|
||||
<rollingfile formatid="all" type="size" filename="./all.log" maxsize="50000000" maxrolls="5" />
|
||||
<filter levels="info,trace,warn">
|
||||
<console formatid="fmtinfo"/>
|
||||
</filter>
|
||||
<filter levels="error,critical" formatid="fmterror">
|
||||
<console/>
|
||||
<file path="errors.log"/>
|
||||
</filter>
|
||||
</outputs>
|
||||
<formats>
|
||||
<format id="fmtinfo" format="[%Date][%Time] [%Level] %Msg%n"/>
|
||||
<format id="fmterror" format="[%Date][%Time] [%LEVEL] [%FuncShort @ %File.%Line] %Msg%n"/>
|
||||
<format id="all" format="[%Date][%Time] [%Level] [@ %File.%Line] %Msg%n"/>
|
||||
<format id="criticalemail" format="Critical error on our server!\n %Time %Date %RelFile %Func %Msg \nSent by Seelog"/>
|
||||
</formats>
|
||||
</seelog>
|
|
@ -0,0 +1,427 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/mongox"
|
||||
"mongo.games.com/goserver/core/mysqlx"
|
||||
"mongo.games.com/goserver/core/viperx"
|
||||
|
||||
"mongo.games.com/game/statistics/task/gamefree"
|
||||
"mongo.games.com/game/statistics/task/task"
|
||||
)
|
||||
|
||||
const (
|
||||
ExcelTypeNewPlayerBankrupt = iota // 新用户游戏破产率
|
||||
ExcelTypeGameTimeAvg // 新用户平均游戏时长
|
||||
ExcelTypeGameCountAvg // 新用户平均局数
|
||||
ExcelTypeGameRate // 平均倍数
|
||||
ExcelTypeActiveRate // 活跃破产率
|
||||
ExcelTypeCtrlWinRate // 控输赢胜率
|
||||
ExcelTypeRobotWinRate // 机器人胜率
|
||||
ExcelTypeCoinAvg // 人均获得金币
|
||||
ExcelTypeBankruptOffline // 破产后离线
|
||||
ExcelTypeOfflineCoin // 充值当天最后金币
|
||||
)
|
||||
|
||||
var VP *viper.Viper
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
logger.Logger.Flush()
|
||||
logger.Logger.Close()
|
||||
}()
|
||||
VP = viperx.GetViper("config", "yaml")
|
||||
// mongo
|
||||
vp := viperx.GetViper("mongo", "yaml")
|
||||
// mongo初始化
|
||||
conf := &mongox.Config{}
|
||||
err := vp.Unmarshal(conf)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("mongo config error: %v", err))
|
||||
}
|
||||
mongox.Init(conf)
|
||||
defer mongox.Close()
|
||||
|
||||
// mysql
|
||||
vp = viperx.GetViper("mysql", "yaml")
|
||||
myConf := &mysqlx.Config{}
|
||||
err = vp.Unmarshal(myConf)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("mysql config error: %v", err))
|
||||
}
|
||||
mysqlx.Init(myConf)
|
||||
defer mysqlx.Close()
|
||||
|
||||
startTime, err := time.Parse(time.RFC3339, VP.GetString("StartTime"))
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("time.Parse err: %v", err))
|
||||
return
|
||||
}
|
||||
endTime, err := time.Parse(time.RFC3339, VP.GetString("EndTime"))
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("time.Parse err: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
mgr := NewExcelMgr()
|
||||
mgr.Register(ExcelTypeNewPlayerBankrupt, []string{"日期", "场次id", "破产人数", "参与人数", "破产率"})
|
||||
mgr.Register(ExcelTypeGameTimeAvg, []string{"日期", "场次id", "参与人数", "平均游戏时长"})
|
||||
mgr.Register(ExcelTypeGameCountAvg, []string{"日期", "场次id", "参与人数", "平均局数"})
|
||||
mgr.Register(ExcelTypeGameRate, []string{"日期", "场次id", "总局数", "平均倍数", "有炸弹分局数", "炸弹分平均倍数", "2留在手里的局数"})
|
||||
mgr.Register(ExcelTypeActiveRate, []string{"日期", "场次id", "破产人数", "参与人数", "破产率"})
|
||||
mgr.Register(ExcelTypeCtrlWinRate, []string{"日期", "场次id", "总局数", "平均倍数", "有炸弹分局数", "炸弹分平均倍数", "2留在手里的局数"})
|
||||
mgr.Register(ExcelTypeCtrlWinRate*10, []string{"日期", "场次id", "总局数", "平均倍数", "有炸弹分局数", "炸弹分平均倍数", "2留在手里的局数"})
|
||||
mgr.Register(ExcelTypeRobotWinRate, []string{"日期", "场次id", "总局数", "平均倍数", "有炸弹分局数", "炸弹分平均倍数", "2留在手里的局数"})
|
||||
mgr.Register(ExcelTypeCoinAvg, []string{"日期", "场次id", "参与人数", "人均获得金币"})
|
||||
mgr.Register(ExcelTypeBankruptOffline, []string{"日期", "场次id", "破产人数", "参与人数", "破产率"})
|
||||
mgr.Register(ExcelTypeOfflineCoin, []string{"日期", "场次id", "破产人数", "参与人数", "破产率"})
|
||||
switchArr := VP.GetIntSlice("Switch")
|
||||
|
||||
for {
|
||||
if startTime.Unix() >= endTime.Unix() {
|
||||
break
|
||||
}
|
||||
startTimeStr := startTime.Format(time.RFC3339)
|
||||
et := startTime.AddDate(0, 0, 1)
|
||||
endTimeStr := et.Format(time.RFC3339)
|
||||
logger.Logger.Infof("startTime: %v endTime: %v", startTimeStr, endTimeStr)
|
||||
|
||||
if switchArr[ExcelTypeNewPlayerBankrupt] == 1 {
|
||||
// 新用户游戏破产率
|
||||
mgr.GenNewPlayerBankruptRateExcel("1", startTimeStr, endTimeStr)
|
||||
}
|
||||
if switchArr[ExcelTypeGameTimeAvg] == 1 {
|
||||
// 新用户平均游戏时长
|
||||
mgr.GenNewPlayerGameTimeAvgExcel("1", startTimeStr, endTimeStr)
|
||||
}
|
||||
if switchArr[ExcelTypeGameCountAvg] == 1 {
|
||||
// 新用户平均局数
|
||||
mgr.GenGameCountExcel("1", startTimeStr, endTimeStr)
|
||||
}
|
||||
if switchArr[ExcelTypeGameRate] == 1 {
|
||||
// 平均倍数
|
||||
mgr.GenGameRateExcel("1", startTimeStr, endTimeStr)
|
||||
}
|
||||
if switchArr[ExcelTypeActiveRate] == 1 {
|
||||
// 活跃破产率
|
||||
mgr.GenActiveBankruptRateExcel("1", startTimeStr, endTimeStr)
|
||||
}
|
||||
if switchArr[ExcelTypeCtrlWinRate] == 1 {
|
||||
// 控赢胜率
|
||||
mgr.GenCtrlWinRateExcel("1", startTimeStr, endTimeStr)
|
||||
}
|
||||
if switchArr[ExcelTypeRobotWinRate] == 1 {
|
||||
// 机器人胜率
|
||||
mgr.GenRobotWinRateExcel("1", startTimeStr, endTimeStr)
|
||||
}
|
||||
if switchArr[ExcelTypeCoinAvg] == 1 {
|
||||
// 人均获得金币
|
||||
mgr.GenCoinAvgExcel("1", startTimeStr, endTimeStr)
|
||||
}
|
||||
if switchArr[ExcelTypeBankruptOffline] == 1 {
|
||||
// 破产后离线
|
||||
mgr.GenBankruptOfflineExcel("1", startTimeStr, endTimeStr)
|
||||
}
|
||||
if switchArr[ExcelTypeOfflineCoin] == 1 {
|
||||
// 离线金币
|
||||
mgr.GenOfflineCoinExcel("1", startTimeStr, endTimeStr)
|
||||
}
|
||||
|
||||
startTime = et
|
||||
}
|
||||
|
||||
mgr.SaveAll(VP.GetString("StartTime")[:10], endTime.AddDate(0, 0, -1).Format(time.DateOnly))
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) SaveAll(startTime, endTime string) {
|
||||
switchArr := VP.GetIntSlice("Switch")
|
||||
if switchArr[ExcelTypeNewPlayerBankrupt] == 1 {
|
||||
e.Save(ExcelTypeNewPlayerBankrupt, fmt.Sprintf("新用户破产率_%s_%s.xlsx", startTime, endTime))
|
||||
}
|
||||
if switchArr[ExcelTypeGameTimeAvg] == 1 {
|
||||
e.Save(ExcelTypeGameTimeAvg, fmt.Sprintf("新用户平局游戏时长_%s_%s.xlsx", startTime, endTime))
|
||||
}
|
||||
if switchArr[ExcelTypeGameCountAvg] == 1 {
|
||||
e.Save(ExcelTypeGameCountAvg, fmt.Sprintf("新用户平均局数_%s_%s.xlsx", startTime, endTime))
|
||||
}
|
||||
if switchArr[ExcelTypeGameRate] == 1 {
|
||||
e.Save(ExcelTypeGameRate, fmt.Sprintf("平均倍数_%s_%s.xlsx", startTime, endTime))
|
||||
}
|
||||
if switchArr[ExcelTypeActiveRate] == 1 {
|
||||
e.Save(ExcelTypeActiveRate, fmt.Sprintf("活跃破产率_%s_%s.xlsx", startTime, endTime))
|
||||
}
|
||||
if switchArr[ExcelTypeCtrlWinRate] == 1 {
|
||||
e.Save(ExcelTypeCtrlWinRate, fmt.Sprintf("控赢胜率_%s_%s.xlsx", startTime, endTime))
|
||||
e.Save(ExcelTypeCtrlWinRate*10, fmt.Sprintf("控输胜率_%s_%s.xlsx", startTime, endTime))
|
||||
}
|
||||
if switchArr[ExcelTypeRobotWinRate] == 1 {
|
||||
e.Save(ExcelTypeRobotWinRate, fmt.Sprintf("机器人输率_%s_%s.xlsx", startTime, endTime))
|
||||
}
|
||||
if switchArr[ExcelTypeCoinAvg] == 1 {
|
||||
e.Save(ExcelTypeCoinAvg, fmt.Sprintf("人均获得金币_%s_%s.xlsx", startTime, endTime))
|
||||
}
|
||||
if switchArr[ExcelTypeBankruptOffline] == 1 {
|
||||
e.Save(ExcelTypeBankruptOffline, fmt.Sprintf("破产后离线_%s_%s.xlsx", startTime, endTime))
|
||||
}
|
||||
if switchArr[ExcelTypeOfflineCoin] == 1 {
|
||||
e.Save(ExcelTypeOfflineCoin, fmt.Sprintf("离线金币_%s_%s.xlsx", startTime, endTime))
|
||||
}
|
||||
}
|
||||
|
||||
func GetGameFreeName(id int) string {
|
||||
d := gamefree.PBDB_GameFreeMgr.GetData(int32(id))
|
||||
return fmt.Sprintf("%s_%s", d.Name, d.Title)
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) GenNewPlayerBankruptRateExcel(plt string, startTime, endTime string) {
|
||||
for _, v := range VP.GetIntSlice("Gamefreeids") {
|
||||
_, a, b, err := task.NewPlayerBankruptRate(plt, startTime, endTime, v)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("NewPlayerBankruptRate get StartTime:%v EndTime:%v GameFreeId:%v err: %v", startTime, endTime, v, err)
|
||||
continue
|
||||
}
|
||||
ex := e.Get(ExcelTypeNewPlayerBankrupt)
|
||||
ex.NewLine()
|
||||
ex.SetCell(startTime[:10])
|
||||
ex.SetCell(GetGameFreeName(v))
|
||||
ex.SetCell(a)
|
||||
ex.SetCell(b)
|
||||
if b > 0 {
|
||||
ex.SetCell(float64(a) / float64(b))
|
||||
} else {
|
||||
ex.SetCell(0)
|
||||
}
|
||||
logger.Logger.Tracef("NewPlayerBankruptRate GameFreeId: %v rate: %v", v, float64(a)/float64(b))
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) GenNewPlayerGameTimeAvgExcel(plt string, startTime, endTime string) {
|
||||
for _, v := range VP.GetIntSlice("Gamefreeids") {
|
||||
a, b, err := task.NewPlayerGameTimeAvg(plt, startTime, endTime, v)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("NewPlayerGameTimeAvg get StartTime:%v EndTime:%v GameFreeId:%v err: %v", startTime, endTime, v, err)
|
||||
continue
|
||||
}
|
||||
ex := e.Get(ExcelTypeGameTimeAvg)
|
||||
ex.NewLine()
|
||||
ex.SetCell(startTime[:10])
|
||||
ex.SetCell(GetGameFreeName(v))
|
||||
ex.SetCell(a)
|
||||
if a > 0 {
|
||||
avg := float64(b) / float64(a)
|
||||
show := fmt.Sprintf("%v", time.Second*time.Duration(avg))
|
||||
ex.SetCell(show)
|
||||
} else {
|
||||
ex.SetCell(0)
|
||||
}
|
||||
logger.Logger.Tracef("NewPlayerGameTimeAvg GameFreeId: %v avg: %v", v, float64(b)/float64(a))
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) GenGameCountExcel(plt string, startTime, endTime string) {
|
||||
for _, v := range VP.GetIntSlice("Gamefreeids") {
|
||||
a, b, err := task.NewPlayerGameCountAvg(plt, startTime, endTime, v)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("NewPlayerGameCountAvg get StartTime:%v EndTime:%v GameFreeId:%v err: %v", startTime, endTime, v, err)
|
||||
continue
|
||||
}
|
||||
ex := e.Get(ExcelTypeGameCountAvg)
|
||||
ex.NewLine()
|
||||
ex.SetCell(startTime[:10])
|
||||
ex.SetCell(GetGameFreeName(v))
|
||||
ex.SetCell(a)
|
||||
if a > 0 {
|
||||
ex.SetCell(float64(b) / float64(a))
|
||||
} else {
|
||||
ex.SetCell(0)
|
||||
}
|
||||
logger.Logger.Tracef("NewPlayerGameCountAvg GameFreeId: %v avg: %v", v, float64(b)/float64(a))
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) GenGameRateExcel(plt string, startTime, endTime string) {
|
||||
for _, v := range VP.GetIntSlice("Gamefreeids") {
|
||||
total, bombTotal, remain2Total, rateAvg, bombRateAvg, err := task.PlayerGameRate(plt, startTime, endTime, v)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("PlayerGameRate get StartTime:%v EndTime:%v GameFreeId:%v err: %v", startTime, endTime, v, err)
|
||||
continue
|
||||
}
|
||||
ex := e.Get(ExcelTypeGameRate)
|
||||
ex.NewLine()
|
||||
ex.SetCell(startTime[:10])
|
||||
ex.SetCell(GetGameFreeName(v))
|
||||
ex.SetCell(total)
|
||||
ex.SetCell(rateAvg)
|
||||
ex.SetCell(bombTotal)
|
||||
ex.SetCell(bombRateAvg)
|
||||
ex.SetCell(remain2Total)
|
||||
logger.Logger.Tracef("PlayerGameRate GameFreeId: %v total: %v rateAvg: %v bombTotal: %v bombRateAvg: %v remain2Total: %v",
|
||||
v, total, rateAvg, bombTotal, bombRateAvg, remain2Total)
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) GenActiveBankruptRateExcel(plt string, startTime, endTime string) {
|
||||
for _, v := range VP.GetIntSlice("Gamefreeids") {
|
||||
b, t, err := task.ActivePlayerBankruptRate(plt, startTime, endTime, v)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("ActivePlayerBankruptRate get StartTime:%v EndTime:%v GameFreeId:%v err: %v", startTime, endTime, v, err)
|
||||
continue
|
||||
}
|
||||
|
||||
ex := e.Get(ExcelTypeActiveRate)
|
||||
ex.NewLine()
|
||||
ex.SetCell(startTime[:10])
|
||||
ex.SetCell(GetGameFreeName(v))
|
||||
ex.SetCell(b)
|
||||
ex.SetCell(t)
|
||||
if t > 0 {
|
||||
if b > t {
|
||||
b = t
|
||||
}
|
||||
ex.SetCell(float64(b) / float64(t))
|
||||
} else {
|
||||
ex.SetCell(0)
|
||||
}
|
||||
logger.Logger.Tracef("ActivePlayerBankruptRate GameFreeId: %v rate: %v", v, float64(b)/float64(t))
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) GenCtrlWinRateExcel(plt string, startTime, endTime string) {
|
||||
for _, v := range append(VP.GetIntSlice("Tienlen")) {
|
||||
ret, err := task.GameDetailWinRate(plt, startTime, endTime, v)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("GameDetailWinRate get StartTime:%v EndTime:%v GameFreeId:%v err: %v", startTime, endTime, v, err)
|
||||
continue
|
||||
}
|
||||
if len(ret) > 0 {
|
||||
ex := e.Get(ExcelTypeCtrlWinRate)
|
||||
ex.NewLine()
|
||||
ex.SetCell(startTime[:10])
|
||||
ex.SetCell(GetGameFreeName(v))
|
||||
ex.SetCell(ret[0].First)
|
||||
ex.SetCell(ret[0].Second)
|
||||
ex.SetCell(ret[0].Third)
|
||||
ex.SetCell(ret[0].Total)
|
||||
if ret[0].Total > 0 {
|
||||
ex.SetCell(float64(ret[0].First+ret[0].Second) / float64(ret[0].Total))
|
||||
} else {
|
||||
ex.SetCell(0)
|
||||
}
|
||||
logger.Logger.Tracef("GameDetailWinRate GameFreeId:%v %+v", v, ret[0])
|
||||
}
|
||||
if len(ret) > 1 {
|
||||
ex := e.Get(ExcelTypeCtrlWinRate * 10)
|
||||
ex.NewLine()
|
||||
ex.SetCell(startTime[:10])
|
||||
ex.SetCell(GetGameFreeName(v))
|
||||
ex.SetCell(ret[1].First)
|
||||
ex.SetCell(ret[1].Second)
|
||||
ex.SetCell(ret[1].Third)
|
||||
ex.SetCell(ret[1].Total)
|
||||
if ret[1].Total > 0 {
|
||||
ex.SetCell(float64(ret[1].First+ret[1].Second) / float64(ret[1].Total))
|
||||
} else {
|
||||
ex.SetCell(0)
|
||||
}
|
||||
logger.Logger.Tracef("GameDetailWinRate GameFreeId:%v %+v", v, ret[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) GenRobotWinRateExcel(plt string, startTime, endTime string) {
|
||||
for _, v := range append(VP.GetIntSlice("Tienlen"), VP.GetIntSlice("Thirteen")...) {
|
||||
a, b, err := task.RobotWinRate(plt, startTime, endTime, v)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("RobotWinRate get StartTime:%v EndTime:%v GameFreeId:%v err: %v", startTime, endTime, v, err)
|
||||
continue
|
||||
}
|
||||
|
||||
ex := e.Get(ExcelTypeRobotWinRate)
|
||||
ex.NewLine()
|
||||
ex.SetCell(startTime[:10])
|
||||
ex.SetCell(GetGameFreeName(v))
|
||||
ex.SetCell(a)
|
||||
ex.SetCell(b)
|
||||
if b > 0 {
|
||||
ex.SetCell(float64(b-a) / float64(b))
|
||||
} else {
|
||||
ex.SetCell(0)
|
||||
}
|
||||
logger.Logger.Tracef("RobotWinRate GameFreeId: %v rate: %v", v, float64(a)/float64(b))
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) GenCoinAvgExcel(plt string, startTime, endTime string) {
|
||||
type KV struct {
|
||||
K int
|
||||
V string
|
||||
}
|
||||
|
||||
var list []KV
|
||||
for k, v := range task.CoinName {
|
||||
list = append(list, KV{K: k, V: v})
|
||||
}
|
||||
|
||||
sort.Slice(list, func(i, j int) bool {
|
||||
return list[i].K < list[j].K
|
||||
})
|
||||
|
||||
for _, item := range list {
|
||||
k, v := item.K, item.V
|
||||
a, b, err := task.CoinAvg(plt, startTime, endTime, k)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("CoinAvg get StartTime:%v EndTime:%v tp:%v err: %v", startTime, endTime, k, err)
|
||||
continue
|
||||
}
|
||||
ex := e.Get(ExcelTypeCoinAvg)
|
||||
ex.NewLine()
|
||||
ex.SetCell(startTime[:10])
|
||||
ex.SetCell(v)
|
||||
ex.SetCell(a)
|
||||
ex.SetCell(b)
|
||||
if a > 0 {
|
||||
ex.SetCell(float64(b) / float64(a))
|
||||
} else {
|
||||
ex.SetCell(0)
|
||||
}
|
||||
logger.Logger.Tracef("CoinAvg tp: %v rate: %v", k, float64(b)/float64(a))
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) GenBankruptOfflineExcel(plt string, startTime, endTime string) {
|
||||
res, err := task.BankruptOffline(plt, startTime, endTime)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("BankruptOffline get StartTime:%v EndTime:%v err: %v", startTime, endTime, err)
|
||||
return
|
||||
}
|
||||
ex := e.Get(ExcelTypeBankruptOffline)
|
||||
ex.NewLine()
|
||||
ex.SetCell(startTime[:10])
|
||||
ex.SetCell(res.One)
|
||||
ex.SetCell(res.Two)
|
||||
ex.SetCell(res.Three)
|
||||
ex.SetCell(res.Recharge)
|
||||
ex.SetCell(fmt.Sprintf("%v", res.D))
|
||||
logger.Logger.Tracef("BankruptOffline %+v", res)
|
||||
}
|
||||
|
||||
func (e *ExcelMgr) GenOfflineCoinExcel(plt string, startTime, endTime string) {
|
||||
res, err := task.OfflineCoin(plt, startTime, endTime)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("OfflineCoin get StartTime:%v EndTime:%v err: %v", startTime, endTime, err)
|
||||
return
|
||||
}
|
||||
for _, v := range res {
|
||||
ex := e.Get(ExcelTypeOfflineCoin)
|
||||
ex.NewLine()
|
||||
ex.SetCell(startTime[:10])
|
||||
ex.SetCell(v.Snid)
|
||||
ex.SetCell(v.Coin)
|
||||
}
|
||||
logger.Logger.Tracef("OfflineCoin %+v", res)
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
查询历史数据
|
|
@ -0,0 +1,189 @@
|
|||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
mymongo "mongo.games.com/goserver/core/mongox"
|
||||
mymysql "mongo.games.com/goserver/core/mysqlx"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
mongomodel "mongo.games.com/game/statistics/modelmongo"
|
||||
)
|
||||
|
||||
// 新用户id
|
||||
func GetNewPayerIds(plt string, startTime, endTime string) ([]int, error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
c, err := mymongo.GetUserCollection(plt, mongomodel.UserAccount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var res []struct{ Snid int }
|
||||
dd, err := c.Find(context.TODO(), bson.M{"registetime": bson.M{"$gte": s, "$lt": e}}, options.Find().SetProjection(bson.M{"snid": 1}))
|
||||
if err != nil {
|
||||
if errors.Is(err, mongo.ErrNoDocuments) {
|
||||
return nil, nil
|
||||
}
|
||||
logger.Logger.Errorf("find new player snid get err: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
if err := dd.All(context.TODO(), &res); err != nil {
|
||||
logger.Logger.Errorf("find new player snid decode err: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
var ret []int
|
||||
for _, v := range res {
|
||||
ret = append(ret, v.Snid)
|
||||
}
|
||||
logger.Logger.Tracef("find new player snid: %v", ret)
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// 场次破产总人数
|
||||
func GameFreeIdBankruptPlayerCount(plt string, ids []int, startTime, endTime string, gamefreeid int) (int, error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
db, err := mymysql.GetDatabase("count")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var ret int
|
||||
for _, v := range ids {
|
||||
var n int64
|
||||
if err = db.Table("bankrupt_log").Where("snid = ? AND bankrupt_time >= ? AND bankrupt_time < ? AND game_free_id = ?",
|
||||
v, s.Unix(), e.Unix(), gamefreeid).Count(&n).Error; err != nil {
|
||||
logger.Logger.Errorf("find bankrupt player count get err: %v", err)
|
||||
return 0, err
|
||||
}
|
||||
if n > 0 {
|
||||
ret++
|
||||
}
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// 场次参与总人数
|
||||
func PlayingGameCount(plt string, ids []int, startTime, endTime string, gamefreeid int) (int, error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
c, err := mymongo.GetLogCollection(plt, mongomodel.LogGamePlayerListLog)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var ret int
|
||||
for _, v := range ids {
|
||||
// 参与过游戏
|
||||
n, err := c.CountDocuments(context.TODO(), bson.M{"snid": v, "time": bson.M{"$gte": s, "$lt": e}, "gamefreeid": gamefreeid})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("find playing game count get err: %v", err)
|
||||
return 0, err
|
||||
}
|
||||
if n > 0 {
|
||||
ret++
|
||||
}
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// NewPlayerBankruptRate 新用户破产率
|
||||
// 新用户游戏破产率 = 新用户游戏破产玩家数量/新用户游戏参与总人数;破产数量,每个玩家每个游戏破产只统计一次;参与人数,每个玩家每个游戏只统计一次;
|
||||
// 返回 新用户数量,破产人数,参与人数
|
||||
func NewPlayerBankruptRate(plt string, startTime, endTime string, gamefreeid int) (n, a, b int, err error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
if s.IsZero() || e.IsZero() {
|
||||
return 0, 0, 0, fmt.Errorf("time format error")
|
||||
}
|
||||
ids, err := GetNewPayerIds(plt, startTime, endTime)
|
||||
if err != nil {
|
||||
return 0, 0, 0, err
|
||||
}
|
||||
|
||||
a, err = GameFreeIdBankruptPlayerCount(plt, ids, startTime, endTime, gamefreeid)
|
||||
if err != nil {
|
||||
return 0, 0, 0, err
|
||||
}
|
||||
b, err = PlayingGameCount(plt, ids, startTime, endTime, gamefreeid)
|
||||
if err != nil {
|
||||
return 0, 0, 0, err
|
||||
}
|
||||
if b == 0 {
|
||||
return 0, 0, 0, nil
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ActivePlayerCount 活跃玩家游戏总人数
|
||||
func ActivePlayerCount(plt string, startTime, endTime string, gamefreeid int) (int, error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
c, err := mymongo.GetLogCollection(plt, mongomodel.LogGamePlayerListLog)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var count []struct {
|
||||
Count int
|
||||
}
|
||||
cur, err := c.Aggregate(context.TODO(), bson.A{
|
||||
bson.M{"$match": bson.M{"time": bson.M{"$gte": s, "$lt": e}, "gamefreeid": gamefreeid}},
|
||||
bson.M{"$group": bson.M{"_id": "$snid"}},
|
||||
bson.M{"$count": "count"},
|
||||
})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("find active player count get err: %v", err)
|
||||
return 0, err
|
||||
}
|
||||
if err := cur.All(context.TODO(), &count); err != nil {
|
||||
logger.Logger.Errorf("find active player count decode err: %v", err)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if len(count) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
return count[0].Count, nil
|
||||
}
|
||||
|
||||
// ActivePlayerBankruptCount 活跃玩家破产总人数
|
||||
func ActivePlayerBankruptCount(plt string, startTime, endTime string, gamefreeid int) (int, error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
db, err := mymysql.GetDatabase("count")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var n int64
|
||||
if err = db.Table("bankrupt_log").Where("bankrupt_time >= ? AND bankrupt_time < ? AND game_free_id = ?",
|
||||
s.Unix(), e.Unix(), gamefreeid).Group("snid").Count(&n).Error; err != nil {
|
||||
logger.Logger.Errorf("find bankrupt count get err: %v", err)
|
||||
return 0, err
|
||||
}
|
||||
return int(n), nil
|
||||
}
|
||||
|
||||
// ActivePlayerBankruptRate 活跃玩家破产率
|
||||
// 活跃玩家游戏破产率 = 活跃玩家游戏破产玩家数量/活跃玩家游戏总人数;破产数量,每个玩家每个游戏破产只统计一次;参与人数,每个玩家每个游戏只统计一次;
|
||||
// 返回 破产人数,参与人数
|
||||
func ActivePlayerBankruptRate(plt string, startTime, endTime string, gamefreeid int) (a, b int, err error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
if s.IsZero() || e.IsZero() {
|
||||
return 0, 0, fmt.Errorf("time format error")
|
||||
}
|
||||
|
||||
a, err = ActivePlayerBankruptCount(plt, startTime, endTime, gamefreeid)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
b, err = ActivePlayerCount(plt, startTime, endTime, gamefreeid)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
if b == 0 {
|
||||
return 0, 0, nil
|
||||
}
|
||||
return
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"mongo.games.com/game/common"
|
||||
mymongo "mongo.games.com/goserver/core/mongox"
|
||||
mymysql "mongo.games.com/goserver/core/mysqlx"
|
||||
)
|
||||
|
||||
// 破产后离线;破产后5分钟内有离线行为
|
||||
|
||||
type BankruptOfflineData struct {
|
||||
One int
|
||||
Two int
|
||||
Three int
|
||||
Recharge int
|
||||
D time.Duration
|
||||
}
|
||||
|
||||
func BankruptOffline(plt string, startTime, endTime string) (ret *BankruptOfflineData, err error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
if s.IsZero() || e.IsZero() {
|
||||
return nil, fmt.Errorf("time format error")
|
||||
}
|
||||
db, err := mymysql.GetDatabase("count")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
/*
|
||||
SELECT
|
||||
snid,
|
||||
GROUP_CONCAT(bankrupt_time ORDER BY bankrupt_time ASC LIMIT 3) AS top_3_bankrupt_times,
|
||||
COUNT(*) AS record_count
|
||||
FROM
|
||||
bankrupt_log
|
||||
GROUP BY
|
||||
snid;
|
||||
*/
|
||||
|
||||
type BankruptLog struct {
|
||||
Snid int `gorm:"column:snid"`
|
||||
MaxBankruptTime string `gorm:"column:top_3_bankrupt_times"`
|
||||
Times []int64 `gorm:"-"`
|
||||
}
|
||||
|
||||
var logs []*BankruptLog
|
||||
tx := db.Raw(`
|
||||
WITH RankedData AS (
|
||||
SELECT
|
||||
snid,
|
||||
bankrupt_time,
|
||||
ROW_NUMBER() OVER (PARTITION BY snid ORDER BY bankrupt_time ASC) AS ranks
|
||||
FROM bankrupt_log
|
||||
WHERE bankrupt_time >= ? AND bankrupt_time < ?
|
||||
)
|
||||
SELECT
|
||||
snid,
|
||||
GROUP_CONCAT(bankrupt_time ORDER BY bankrupt_time ASC) AS top_3_bankrupt_times
|
||||
FROM RankedData
|
||||
WHERE ranks <= 3
|
||||
GROUP BY snid
|
||||
`, s.Unix(), e.Unix()).Scan(&logs)
|
||||
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
|
||||
var timeSecond int
|
||||
var total int
|
||||
|
||||
ret = &BankruptOfflineData{}
|
||||
for _, v := range logs {
|
||||
if v == nil || len(v.MaxBankruptTime) == 0 {
|
||||
continue
|
||||
}
|
||||
for _, vv := range strings.Split(v.MaxBankruptTime, ",") {
|
||||
n, err := strconv.Atoi(vv)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v.Times = append(v.Times, int64(n))
|
||||
}
|
||||
|
||||
// 破产后5分钟内有离线行为
|
||||
db, err = mymysql.GetDatabase(plt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var isOffline bool
|
||||
for k, vv := range v.Times {
|
||||
var n int64
|
||||
stime, etime := time.Unix(vv, 0), time.Unix(vv, 0).Add(5*time.Minute)
|
||||
if err = db.Table("user_logins").Where("snid = ? AND offline_time >= ? AND offline_time < ?",
|
||||
v.Snid, stime, etime).Count(&n).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch k {
|
||||
case 0:
|
||||
if n > 0 {
|
||||
ret.One++
|
||||
isOffline = true
|
||||
}
|
||||
case 1:
|
||||
if n > 0 {
|
||||
ret.Two++
|
||||
isOffline = true
|
||||
}
|
||||
case 2:
|
||||
if n > 0 {
|
||||
ret.Three++
|
||||
isOffline = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if isOffline {
|
||||
// 充值
|
||||
c, err := mymongo.GetLogCollection(plt, "log_dbshop")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
count, err := c.CountDocuments(context.TODO(), bson.M{"snid": v.Snid, "ts": bson.M{"$gte": s.Unix(), "$lt": e.Unix()}, "consume": 3, "state": 1})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if count > 0 {
|
||||
ret.Recharge++
|
||||
}
|
||||
|
||||
// 平均对局时长
|
||||
times, to, err := NewPlayerGameTime(plt, []int{v.Snid}, startTime, endTime, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
timeSecond += times
|
||||
total += to
|
||||
}
|
||||
}
|
||||
|
||||
if total > 0 {
|
||||
ret.D = time.Second * time.Duration(timeSecond/total)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/goserver/core/mongox"
|
||||
)
|
||||
|
||||
var CoinName = map[int]string{
|
||||
44: "转盘",
|
||||
57: "轮盘视频",
|
||||
43: "签到",
|
||||
58: "签到视频",
|
||||
83: "累计签到",
|
||||
91: "累计签到进阶奖励",
|
||||
47: "vip每日礼包",
|
||||
105: "vip等级礼包",
|
||||
74: "集卡活动",
|
||||
67: "金币存钱罐",
|
||||
94: "赛季通行证等级奖励",
|
||||
95: "赛季通行证排行奖励",
|
||||
52: "排位赛段位奖励",
|
||||
65: "周卡奖励",
|
||||
5: "兑换",
|
||||
49: "礼包码兑换",
|
||||
38: "救济金",
|
||||
56: "救济金视频",
|
||||
}
|
||||
|
||||
func CoinHistory(plt string, startTime, endTime string, tp int, f func(data bson.M) error) error {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
if s.IsZero() || e.IsZero() {
|
||||
return fmt.Errorf("time format error")
|
||||
}
|
||||
c, err := mongox.GetLogCollection(plt, "log_coinex")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cur, err := c.Find(context.TODO(), bson.M{"time": bson.M{"$gte": s, "$lt": e}, "logtype": tp, "cointype": 0})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cur.Close(context.Background())
|
||||
|
||||
for cur.TryNext(context.Background()) {
|
||||
data := bson.M{}
|
||||
if err := cur.Decode(data); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := f(data); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func CoinAvg(plt string, startTime, endTime string, tp int) (playerNumber int, total int, err error) {
|
||||
player := make(map[int32]struct{})
|
||||
err = CoinHistory(plt, startTime, endTime, tp, func(data bson.M) error {
|
||||
snid := data["snid"].(int32)
|
||||
count := int(data["count"].(int64))
|
||||
player[snid] = struct{}{}
|
||||
if count > 0 {
|
||||
total += count
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
playerNumber = len(player)
|
||||
return
|
||||
}
|
|
@ -0,0 +1,214 @@
|
|||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/mongox"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
)
|
||||
|
||||
func GameDetailFunc(plt string, startTime, endTime string, gamefreeid int, f func(data bson.M) error) error {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
if s.IsZero() || e.IsZero() {
|
||||
return fmt.Errorf("time format error")
|
||||
}
|
||||
|
||||
c, err := mongox.GetLogCollection(plt, "log_gamedetailed")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cur, err := c.Find(context.TODO(), bson.M{"time": bson.M{"$gte": s, "$lt": e}, "gamefreeid": gamefreeid})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cur.Close(context.Background())
|
||||
|
||||
for cur.TryNext(context.Background()) {
|
||||
data := bson.M{}
|
||||
if err := cur.Decode(data); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := f(data); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type GameDetailWinRateRet struct {
|
||||
First int
|
||||
Second int
|
||||
Third int
|
||||
Total int
|
||||
IsWin bool
|
||||
}
|
||||
|
||||
func GameDetailWinRate(plt string, startTime, endTime string, gamefreeid int) (ret []GameDetailWinRateRet, err error) {
|
||||
ret = make([]GameDetailWinRateRet, 2)
|
||||
err = GameDetailFunc(plt, startTime, endTime, gamefreeid, func(data bson.M) error {
|
||||
ff, ss, tt, to, ct := GameDetailCount(data)
|
||||
if ct == 1 && to > 0 {
|
||||
ret[0].First += ff
|
||||
ret[0].Second += ss
|
||||
ret[0].Third += tt
|
||||
ret[0].Total += to
|
||||
}
|
||||
if ct == 2 && to > 0 {
|
||||
ret[1].First += ff
|
||||
ret[1].Second += ss
|
||||
ret[1].Third += tt
|
||||
ret[1].Total += to
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
type RabbitMQDataRaw struct {
|
||||
Source int32
|
||||
Data interface{}
|
||||
}
|
||||
|
||||
func GameDetailCount(data bson.M) (first, second, third, to int, ctrlType int) {
|
||||
if data == nil {
|
||||
return
|
||||
}
|
||||
gameid := data["gameid"].(int32)
|
||||
gamefreeid := data["gamefreeid"].(int32)
|
||||
ctrlType = int(data["ctrltype"].(int32))
|
||||
logger.Logger.Tracef("GameDetail gameid:%d, gamefreeid:%d", gameid, gamefreeid)
|
||||
|
||||
if ctrlType != 1 && ctrlType != 2 {
|
||||
return
|
||||
}
|
||||
|
||||
detail := data["gamedetailednote"]
|
||||
if detail == nil {
|
||||
return
|
||||
}
|
||||
|
||||
raw := new(RabbitMQDataRaw)
|
||||
if err := json.Unmarshal([]byte(detail.(string)), raw); err != nil {
|
||||
logger.Logger.Errorf("GameDetailCount Unmarshal 1 error:%v %v", err, gameid)
|
||||
return
|
||||
}
|
||||
|
||||
switch gameid {
|
||||
case 207, 208, 209, 210, 240, 241, 242, 243, 244, 245, 246, 247: // tienlen
|
||||
data := new(TienLenType)
|
||||
b, err := json.Marshal(raw.Data)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("GameDetailCount Marshal error:%v %v", err, gameid)
|
||||
return
|
||||
}
|
||||
if err := json.Unmarshal(b, data); err != nil {
|
||||
logger.Logger.Errorf("GameDetailCount Unmarshal 2 error:%v %v", err, gameid)
|
||||
return
|
||||
}
|
||||
|
||||
var has, hasPlayer bool
|
||||
for _, v := range data.PlayerData {
|
||||
if v.IsRob {
|
||||
has = true
|
||||
}
|
||||
if !v.IsRob {
|
||||
hasPlayer = true
|
||||
}
|
||||
}
|
||||
if !has || !hasPlayer {
|
||||
// 没有机器人
|
||||
return 0, 0, 0, 0, ctrlType
|
||||
}
|
||||
|
||||
sort.Slice(data.PlayerData, func(i, j int) bool {
|
||||
a, b := data.PlayerData[i].BillCoin+data.PlayerData[i].BillTaxCoin, data.PlayerData[j].BillCoin+data.PlayerData[j].BillTaxCoin
|
||||
if a != b {
|
||||
return a > b
|
||||
}
|
||||
if data.PlayerData[i].IsRob != data.PlayerData[j].IsRob {
|
||||
return !data.PlayerData[i].IsRob
|
||||
}
|
||||
return data.PlayerData[i].UserId < data.PlayerData[j].UserId
|
||||
})
|
||||
|
||||
for k, v := range data.PlayerData {
|
||||
if !v.IsRob && v.BillCoin > 0 && k <= 1 {
|
||||
if k == 0 {
|
||||
first = 1
|
||||
}
|
||||
if k == 1 {
|
||||
second = 1
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if len(data.PlayerData) > 2 && first+second == 0 && !data.PlayerData[2].IsRob {
|
||||
third = 1
|
||||
}
|
||||
to = 1
|
||||
|
||||
case 211, 212, 213, 214:
|
||||
data := new(ThirteenWaterType)
|
||||
b, err := json.Marshal(raw.Data)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("GameDetailCount Marshal error:%v %v", err, gameid)
|
||||
return
|
||||
}
|
||||
if err := json.Unmarshal(b, data); err != nil {
|
||||
logger.Logger.Errorf("GameDetailCount Unmarshal 2 error:%v %v", err, gameid)
|
||||
return
|
||||
}
|
||||
|
||||
var has, hasPlayer bool
|
||||
for _, v := range data.PlayerData {
|
||||
if v.IsRob {
|
||||
has = true
|
||||
}
|
||||
if !v.IsRob {
|
||||
hasPlayer = true
|
||||
}
|
||||
}
|
||||
if !has || !hasPlayer {
|
||||
// 没有机器人
|
||||
return 0, 0, 0, 0, ctrlType
|
||||
}
|
||||
|
||||
sort.Slice(data.PlayerData, func(i, j int) bool {
|
||||
a, b := data.PlayerData[i].AllScore, data.PlayerData[j].AllScore
|
||||
if a != b {
|
||||
return a > b
|
||||
}
|
||||
if data.PlayerData[i].IsRob != data.PlayerData[j].IsRob {
|
||||
return !data.PlayerData[i].IsRob
|
||||
}
|
||||
return data.PlayerData[i].UserId < data.PlayerData[j].UserId
|
||||
})
|
||||
|
||||
for k, v := range data.PlayerData {
|
||||
if !v.IsRob && v.AllScore > 0 && k <= 1 {
|
||||
if k == 0 {
|
||||
first = 1
|
||||
}
|
||||
if k == 1 {
|
||||
second = 1
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if len(data.PlayerData) > 2 && first+second == 0 && !data.PlayerData[2].IsRob {
|
||||
third = 1
|
||||
}
|
||||
|
||||
to = 1
|
||||
}
|
||||
return
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
mymongo "mongo.games.com/goserver/core/mongox"
|
||||
mymysql "mongo.games.com/goserver/core/mysqlx"
|
||||
)
|
||||
|
||||
// 场次破产率
|
||||
|
||||
// GameFreeIdBankruptcyTimes 场次破产次数
|
||||
func GameFreeIdBankruptcyTimes(plt string, startTime, endTime string, gamefreeid int) (int, error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
db, err := mymysql.GetDatabase("count")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var n int64
|
||||
if err = db.Table("bankrupt_log").Where("bankrupt_time >= ? AND bankrupt_time < ? AND game_free_id = ?",
|
||||
s.Unix(), e.Unix(), gamefreeid).Count(&n).Error; err != nil {
|
||||
logger.Logger.Errorf("find bankrupt count get err: %v", err)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return int(n), nil
|
||||
}
|
||||
|
||||
// GameFreeIdTotalTimes 场次总局数
|
||||
func GameFreeIdTotalTimes(plt string, startTime, endTime string, gamefreeid int) (int, error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
c, err := mymongo.GetLogCollection(plt, "log_gamedetailed")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
n, err := c.CountDocuments(context.TODO(), bson.M{"time": bson.M{"$gte": s, "$lt": e}, "gamefreeid": gamefreeid})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("find game total times get err: %v", err)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return int(n), nil
|
||||
}
|
||||
|
||||
// GameBankruptcyRate 场次破产率
|
||||
// 返回 破产局数, 总局数, 错误
|
||||
func GameBankruptcyRate(plt string, startTime, endTime string, gamefreeid int) (int, int, error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
if s.IsZero() || e.IsZero() {
|
||||
return 0, 0, fmt.Errorf("time format error")
|
||||
}
|
||||
|
||||
b, err := GameFreeIdBankruptcyTimes(plt, startTime, endTime, gamefreeid)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
t, err := GameFreeIdTotalTimes(plt, startTime, endTime, gamefreeid)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
return b, t, nil
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"mongo.games.com/game/common"
|
||||
mongomodel "mongo.games.com/game/statistics/modelmongo"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
mymongo "mongo.games.com/goserver/core/mongox"
|
||||
)
|
||||
|
||||
// 新用户平均局数
|
||||
|
||||
func NewPlayerGameCount(plt string, ids []int, startTime, endTime string, gamefreeid int) (int, error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
c, err := mymongo.GetLogCollection(plt, mongomodel.LogGamePlayerListLog)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var ret int
|
||||
for _, v := range ids {
|
||||
n, err := c.CountDocuments(context.TODO(), bson.M{"snid": v, "gamefreeid": gamefreeid, "time": bson.M{"$gte": s, "$lt": e}})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("find player gamedetailedlogid get err: %v", err)
|
||||
return 0, err
|
||||
}
|
||||
ret += int(n)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// NewPlayerGameCountAvg 新用户平均局数
|
||||
// 返回 参与人数,总局数
|
||||
func NewPlayerGameCountAvg(plt string, startTime, endTime string, gamefreeid int) (int, int, error) {
|
||||
s, e := common.StrRFC3339TimeToTime(startTime), common.StrRFC3339TimeToTime(endTime)
|
||||
if s.IsZero() || e.IsZero() {
|
||||
return 0, 0, fmt.Errorf("time format error")
|
||||
}
|
||||
ids, err := GetNewPayerIds(plt, startTime, endTime)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
n, err := NewPlayerGameCount(plt, ids, startTime, endTime, gamefreeid)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return 0, 0, nil
|
||||
}
|
||||
|
||||
b, err := PlayingGameCount(plt, ids, startTime, endTime, gamefreeid)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
return b, n, nil
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,110 @@
|
|||
package task
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// 场次平均倍数
|
||||
|
||||
func PlayerGameRate(plt string, startTime, endTime string, gamefreeid int) (total, bombTotal, remain2Total int, rateAvg, bombRateAvg float64, err error) {
|
||||
var totalRate, totalBombRate float64
|
||||
err = GameDetailFunc(plt, startTime, endTime, gamefreeid, func(data bson.M) error {
|
||||
rate, isBomb, bombRate, remain2 := GameDetailRate(data)
|
||||
total++
|
||||
if isBomb {
|
||||
bombTotal++
|
||||
}
|
||||
totalRate += rate
|
||||
totalBombRate += bombRate
|
||||
if remain2 {
|
||||
remain2Total++
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if total > 0 {
|
||||
rateAvg = totalRate / float64(total)
|
||||
}
|
||||
if bombTotal > 0 {
|
||||
bombRateAvg = totalBombRate / float64(bombTotal)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// rate 赢分/底分
|
||||
// isBomb 是否有炸弹
|
||||
// bombRate 炸弹倍数,炸弹赢分/底分
|
||||
// remain2 是否有剩余2
|
||||
func GameDetailRate(data bson.M) (rate float64, isBomb bool, bombRate float64, remain2 bool) {
|
||||
if data == nil {
|
||||
return
|
||||
}
|
||||
gameid := data["gameid"].(int32)
|
||||
gamefreeid := data["gamefreeid"].(int32)
|
||||
logger.Logger.Tracef("GameDetail gameid:%d, gamefreeid:%d", gameid, gamefreeid)
|
||||
|
||||
detail := data["gamedetailednote"]
|
||||
if detail == nil {
|
||||
return
|
||||
}
|
||||
|
||||
raw := new(RabbitMQDataRaw)
|
||||
if err := json.Unmarshal([]byte(detail.(string)), raw); err != nil {
|
||||
logger.Logger.Errorf("GameDetailCount Unmarshal 1 error:%v %v", err, gameid)
|
||||
return
|
||||
}
|
||||
|
||||
switch gameid {
|
||||
case 207, 208, 209, 210, 240, 241, 242, 243, 244, 245, 246, 247: // tienlen
|
||||
d := new(TienLenType)
|
||||
b, err := json.Marshal(raw.Data)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("GameDetailCount Marshal error:%v %v", err, gameid)
|
||||
return
|
||||
}
|
||||
if err := json.Unmarshal(b, d); err != nil {
|
||||
logger.Logger.Errorf("GameDetailCount Unmarshal 2 error:%v %v", err, gameid)
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range d.PlayerData {
|
||||
if v.BillCoin > 0 {
|
||||
rate = float64(v.BillCoin+v.BillTaxCoin) / float64(d.BaseScore)
|
||||
}
|
||||
if v.BombCoin > 0 {
|
||||
isBomb = true
|
||||
bombRate = float64(v.BombCoin+v.BombTaxCoin) / float64(d.BaseScore)
|
||||
}
|
||||
if slices.ContainsFunc(v.CardInfoEnd, func(i int32) bool {
|
||||
switch i {
|
||||
case 51, 38, 25, 12:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}) {
|
||||
remain2 = true
|
||||
}
|
||||
}
|
||||
|
||||
case 211, 212, 213, 214:
|
||||
d := new(ThirteenWaterType)
|
||||
b, err := json.Marshal(raw.Data)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("GameDetailCount Marshal error:%v %v", err, gameid)
|
||||
return
|
||||
}
|
||||
if err := json.Unmarshal(b, d); err != nil {
|
||||
logger.Logger.Errorf("GameDetailCount Unmarshal 2 error:%v %v", err, gameid)
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range d.PlayerData {
|
||||
if v.AllScore > 0 {
|
||||
rate = float64(v.AllScore) / float64(d.BaseScore)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue