game_sync/model/matchlog.go

76 lines
1.8 KiB
Go

package model
import (
"time"
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
)
// 比赛参赛人员信息
type MatchPlayer struct {
SnId int32 //玩家id
CostCoin int64 //报名消耗金币
CostDiamond int64 //报名消耗钻石
Coin int64 //比赛获得金币
Diamond int64 //比赛获得钻石
Item map[int32]int64 //比赛获得物品id
Rank int32 //名次
}
// 比赛牌局记录
type MatchGameLog struct {
GameLogId string //牌局id
Name string //赛程名称
ProcessIdx int32 //赛程索引
NumOfGame int32 //第几局
SpendTime int32 //花费时间
SnIds []int32 //参与玩家
}
// 比赛详情
type MatchLog struct {
Id bson.ObjectId `bson:"_id"`
Platform string //平台编号
MatchId int32 //比赛编号
MatchName string //比赛名称
GameFreeId int32 //游戏类型
StartTime time.Time //开始时间
EndTime time.Time //结束时间
Players []*MatchPlayer //参赛人员数据
}
var (
MatchLogDBName = "log"
MatchLogCollName = "log_matchlog"
)
func NewMatchLog() *MatchLog {
return &MatchLog{Id: bson.NewObjectId()}
}
func InsertMatchLogs(logs ...*MatchLog) (err error) {
if rpcCli == nil {
return ErrRPClientNoConn
}
var ret bool
return rpcCli.CallWithTimeout("MatchLogSvc.InsertMatchLogs", logs, &ret, time.Second*30)
}
type RemoveMatchLogsArgs struct {
Plt string
Ts time.Time
}
func RemoveMatchLogs(plt string, ts time.Time) (ret *mgo.ChangeInfo, err error) {
if rpcCli == nil {
return nil, ErrRPClientNoConn
}
args := &RemoveMatchLogsArgs{
Plt: plt,
Ts: ts,
}
rpcCli.CallWithTimeout("MatchLogSvc.RemoveMatchLogs", args, &ret, time.Second*30)
return
}