比赛场代码优化

This commit is contained in:
sk 2024-05-21 15:08:16 +08:00
parent b1c74ab992
commit c86e28383d
35 changed files with 1170 additions and 1465 deletions

View File

@ -40,6 +40,18 @@ func CopySliceIntToInt32(s []int) []int32 {
return nil
}
func CopySliceInt64ToInt32(s []int64) []int32 {
n := len(s)
if n != 0 {
temp := make([]int32, n)
for i := 0; i < n; i++ {
temp[i] = int32(s[i])
}
return temp
}
return nil
}
func CopySliceInt32ToInt(s []int32) []int {
n := len(s)
if n != 0 {

View File

@ -233,7 +233,7 @@ func AvengersSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *AvengersSceneD
Creator: proto.Int32(s.Creator),
GameId: proto.Int(s.GameId),
RoomMode: proto.Int(s.GameMode),
Params: s.Params,
Params: common.CopySliceInt64ToInt32(s.Params),
State: proto.Int(s.SceneState.GetState()),
Jackpot: proto.Int64(sceneEx.jackpot.VirtualJK),
GameFreeId: proto.Int32(s.DbGameFree.Id),

View File

@ -61,7 +61,7 @@ type Scene struct {
SceneMode int // 房间模式,如:公共房间 common.SceneMode_Public
SceneType int // 场次,新手场,中级场...
Platform string // 平台id
Params []int32
Params []int64
paramsEx []int32
Creator int32
agentor int32
@ -124,12 +124,12 @@ type Scene struct {
WebUser string // 操作人
resultHistory [][]int // 记录数 [控制结果,局数...]
BaseScore int32 //tienlen游戏底分
MatchId int32 //标记本次比赛的id并不是后台id
MatchId int64 //标记本次比赛的id并不是后台id
MatchFinals bool //比赛场决赛
MatchRound int32
MatchCurPlayerNum int32
MatchNextNeed int32
MatchType int32 // 0.普通场 1.锦标赛 2.冠军赛 3.vip专属
MatchRound int64
MatchCurPlayerNum int64
MatchNextNeed int64
MatchType int64 // 0.普通场 1.锦标赛 2.冠军赛 3.vip专属
MatchStop bool
RealCtrl bool
Novice bool
@ -137,7 +137,7 @@ type Scene struct {
KillPoints bool
}
func NewScene(ws *netlib.Session, sceneId, gameMode, sceneMode, gameId int, platform string, params []int32,
func NewScene(ws *netlib.Session, sceneId, gameMode, sceneMode, gameId int, platform string, params []int64,
agentor, creator int32, replayCode string, hallId, groupId, totalOfGames int32, dbGameFree *server.DB_GameFree, bEnterAfterStart bool, baseScore int32, playerNum int, cherank []int32, paramsEx ...int32) *Scene {
sp := GetScenePolicy(gameId, gameMode)
if sp == nil {
@ -267,7 +267,7 @@ func (this *Scene) init() bool {
return true
}
func (this *Scene) GetParam(idx int) int32 {
func (this *Scene) GetParam(idx int) int64 {
if idx < 0 || idx >= len(this.Params) {
return -1
}
@ -387,10 +387,10 @@ func (this *Scene) GetSceneMode() int {
func (this *Scene) SetSceneMode(sceneMode int) {
this.SceneMode = sceneMode
}
func (this *Scene) GetParams() []int32 {
func (this *Scene) GetParams() []int64 {
return this.Params
}
func (this *Scene) SetParams(params []int32) {
func (this *Scene) SetParams(params []int64) {
this.Params = params
}
func (this *Scene) GetParamsEx() []int32 {
@ -614,7 +614,7 @@ func (this *Scene) PlayerLeave(p *Player, reason int, isBill bool) {
LostTimes: proto.Int(p.lostTimes),
TotalConvertibleFlow: proto.Int64(p.TotalConvertibleFlow),
ValidCacheBetTotal: proto.Int64(p.ValidCacheBetTotal),
MatchId: proto.Int32(this.MatchId),
MatchId: this.MatchId,
CurIsWin: proto.Int64(p.CurIsWin), // 负数:输 0平局 正数:赢
}
matchRobotGrades := p.MatchRobotGrades
@ -822,7 +822,7 @@ func (this *Scene) PlayerReturn(p *Player, isLoaded bool) {
RoomId: proto.Int(this.SceneId),
GameId: proto.Int(this.GameId),
ModeType: proto.Int(this.GameMode),
Params: this.Params,
Params: common.CopySliceInt64ToInt32(this.Params),
HallId: proto.Int32(this.hallId),
IsLoaded: proto.Bool(isLoaded),
OpRetCode: gamehall.OpResultCode_Game_OPRC_Sucess_Game,

View File

@ -33,7 +33,7 @@ func (this *SceneMgr) makeKey(gameid, gamemode int) int {
}
func (this *SceneMgr) CreateScene(s *netlib.Session, sceneId, gameMode, sceneMode, gameId int, platform string,
params []int32, agentor, creator int32, replayCode string, hallId, groupId, totalOfGames int32,
params []int64, agentor, creator int32, replayCode string, hallId, groupId, totalOfGames int32,
dbGameFree *server.DB_GameFree, bEnterAfterStart bool, baseScore int32, playerNum int, chessRank []int32, paramsEx ...int32) *Scene {
scene := NewScene(s, sceneId, gameMode, sceneMode, gameId, platform, params, agentor, creator, replayCode,
hallId, groupId, totalOfGames, dbGameFree, bEnterAfterStart, baseScore, playerNum, chessRank, paramsEx...)

View File

@ -234,7 +234,7 @@ func CaiShenSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *CaiShenSceneDat
Creator: proto.Int32(s.Creator),
GameId: proto.Int(s.GameId),
RoomMode: proto.Int(s.GameMode),
Params: s.Params,
Params: common.CopySliceInt64ToInt32(s.Params),
State: proto.Int(s.SceneState.GetState()),
Jackpot: proto.Int64(sceneEx.jackpot.VirtualJK),
GameFreeId: proto.Int32(s.DbGameFree.Id),

View File

@ -481,7 +481,7 @@ func CreateRoomInfoPacket(s *base.Scene, p *base.Player, sceneEx *SceneEx, playe
Creator: proto.Int32(s.GetCreator()),
GameId: proto.Int(s.GetGameId()),
RoomMode: proto.Int(s.GetSceneMode()),
Params: s.GetParams(),
Params: common.CopySliceInt64ToInt32(s.GetParams()),
State: proto.Int32(int32(s.GetSceneState().GetState())),
TimeOut: proto.Int(s.GetSceneState().GetTimeout(s)),
NumOfGames: proto.Int(sceneEx.NumOfGames),
@ -493,10 +493,6 @@ func CreateRoomInfoPacket(s *base.Scene, p *base.Player, sceneEx *SceneEx, playe
MaxPlayerNum: proto.Int(s.GetPlayerNum()),
GameFreeId: proto.Int32(s.GetDBGameFree().GetId()),
SceneType: proto.Int32(s.GetDBGameFree().GetSceneType()),
// 比赛场相关
Round: proto.Int32(s.MatchRound),
CurPlayerNum: proto.Int32(s.MatchCurPlayerNum),
NextNeed: proto.Int32(s.MatchNextNeed),
// 计步
StepSnId: proto.Int32(sceneEx.stepSnId),
StepNum: int64(sceneEx.stepNum),
@ -529,7 +525,7 @@ func CreateRoomInfoPacket(s *base.Scene, p *base.Player, sceneEx *SceneEx, playe
pack.IsMatch = int32(0)
// 0.普通场 1.锦标赛 2.冠军赛 3.vip专属
if s.IsMatchScene() {
pack.IsMatch = s.MatchType
}
pack.MatchFinals = 0
if s.MatchFinals {

View File

@ -234,7 +234,7 @@ func EasterIslandSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *EasterIsla
Creator: proto.Int32(s.Creator),
GameId: proto.Int(s.GameId),
RoomMode: proto.Int(s.GameMode),
Params: s.Params,
Params: common.CopySliceInt64ToInt32(s.Params),
State: proto.Int(s.SceneState.GetState()),
Jackpot: proto.Int64(sceneEx.jackpot.VirtualJK),
GameFreeId: proto.Int32(s.DbGameFree.Id),

View File

@ -185,7 +185,7 @@ func FishingSendRoomInfo(p *base.Player, sceneEx *FishingSceneData) {
RoomMode: proto.Int(sceneEx.sceneMode),
AgentId: proto.Int32(sceneEx.agentor),
SceneType: proto.Int(sceneEx.sceneType),
Params: sceneEx.GetParams(),
Params: common.CopySliceInt64ToInt32(sceneEx.GetParams()),
NumOfGames: proto.Int(sceneEx.GetNumOfGames()),
State: proto.Int(sceneEx.GetSceneState().GetState()),
TimeOut: proto.Int(sceneEx.GetSceneState().GetTimeout(sceneEx.Scene)),

View File

@ -152,7 +152,7 @@ func FruitsCreateRoomInfoPacket(s *base.Scene, sceneEx *FruitsSceneData, playerE
GameId: proto.Int(s.GameId),
RoomMode: proto.Int(s.SceneMode),
SceneType: proto.Int(s.SceneType),
Params: s.Params,
Params: common.CopySliceInt64ToInt32(s.Params),
NumOfGames: proto.Int(sceneEx.NumOfGames),
State: proto.Int(s.SceneState.GetState()),
ParamsEx: s.DbGameFree.OtherIntParams,

View File

@ -234,7 +234,7 @@ func IceAgeSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *IceAgeSceneData,
Creator: proto.Int32(s.GetCreator()),
GameId: proto.Int(s.GetGameId()),
RoomMode: proto.Int(s.GetSceneMode()),
Params: s.GetParams(),
Params: common.CopySliceInt64ToInt32(s.GetParams()),
State: proto.Int(s.GetSceneState().GetState()),
Jackpot: proto.Int64(sceneEx.jackpot.VirtualJK),
GameFreeId: proto.Int32(s.GetDBGameFree().GetId()),

View File

@ -152,7 +152,7 @@ func RichBlessedCreateRoomInfoPacket(s *base.Scene, sceneEx *RichBlessedSceneDat
GameId: proto.Int(s.GameId),
RoomMode: proto.Int(s.SceneMode),
SceneType: proto.Int(s.SceneType),
Params: s.Params,
Params: common.CopySliceInt64ToInt32(s.Params),
NumOfGames: proto.Int(sceneEx.NumOfGames),
State: proto.Int(s.SceneState.GetState()),
ParamsEx: common.Int64ToInt32(s.DbGameFree.OtherIntParams), //s.GetParamsEx(),

View File

@ -3,12 +3,13 @@ package smallrocket
import (
"time"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/common"
rule "mongo.games.com/game/gamerule/smallrocket"
"mongo.games.com/game/gamesrv/base"
"mongo.games.com/game/proto"
"mongo.games.com/game/protocol/smallrocket"
"mongo.games.com/goserver/core/logger"
)
type PlayerData struct {
@ -142,7 +143,7 @@ func (this *SceneEx) SamllRocketCreateRoomInfoPacket(s *base.Scene, p *base.Play
RoomId: proto.Int(s.GetSceneId()),
GameId: proto.Int(s.GetGameId()),
RoomMode: proto.Int(s.GetSceneMode()),
Params: this.Params,
Params: common.CopySliceInt64ToInt32(s.Params),
State: proto.Int(s.GetSceneState().GetState()),
TimeOut: proto.Int(s.GetSceneState().GetTimeout(s)),
BombMul: proto.Float32(float32(0)),

View File

@ -230,7 +230,7 @@ func TamQuocSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *TamQuocSceneDat
Creator: proto.Int32(s.Creator),
GameId: proto.Int(s.GameId),
RoomMode: proto.Int(s.GameMode),
Params: s.Params,
Params: common.CopySliceInt64ToInt32(s.Params),
State: proto.Int(s.SceneState.GetState()),
Jackpot: proto.Int64(sceneEx.jackpot.VirtualJK),
GameFreeId: proto.Int32(s.GetDBGameFree().GetId()),

View File

@ -174,10 +174,10 @@ func (this *SceneEx) ThirteenWaterCreateRoomInfoPacket(s *base.Scene, p *base.Pl
State: proto.Int(s.GetSceneState().GetState()),
TimeOut: proto.Int(s.GetSceneState().GetTimeout(s)),
DisbandGen: proto.Int(this.GetDisbandGen()),
BaseScore: proto.Int32(this.GetBaseScore()),
BaseScore: int32(this.GetBaseScore()),
LeaveDeduct: this.GetDBGameFree().GetLeaveDeduct(),
LeaveCombat: this.GetDBGameFree().GetLeaveCombat(),
Params: this.Params,
Params: common.CopySliceInt64ToInt32(s.Params),
}
// 玩家信息
for _, playerEx := range this.players {
@ -360,7 +360,7 @@ func (this *SceneEx) ThirteenWaterCreateRoomInfoPacket(s *base.Scene, p *base.Pl
return pack
}
func (this *SceneEx) GetBaseScore() int32 { //游戏底分
func (this *SceneEx) GetBaseScore() int64 { //游戏底分
if this.DbGameFree.FreeMode == 1 {
baseScore := this.GetParam(rule.ParamBaseScore)
if baseScore > 0 {
@ -369,7 +369,7 @@ func (this *SceneEx) GetBaseScore() int32 { //游戏底分
}
if this.DbGameFree != nil {
return this.DbGameFree.GetBaseScore()
return int64(this.DbGameFree.GetBaseScore())
}
return 1
}

View File

@ -1258,7 +1258,7 @@ func (this *StateBilled) OnEnter(s *base.Scene) {
RoomId: int32(sceneEx.SceneId),
RoomRounds: int32(sceneEx.NumOfGames),
RoomType: int32(sceneEx.SceneType),
BaseScore: sceneEx.GetBaseScore(),
BaseScore: int32(sceneEx.GetBaseScore()),
NowRound: int32(sceneEx.NumOfGames),
ClubRate: sceneEx.Scene.PumpCoin,
}

View File

@ -399,7 +399,7 @@ func TienLenCreateRoomInfoPacket(s *base.Scene, p *base.Player, sceneEx *TienLen
Creator: proto.Int32(s.GetCreator()),
GameId: proto.Int(s.GetGameId()),
RoomMode: proto.Int(s.GetSceneMode()),
Params: s.GetParams(),
Params: common.CopySliceInt64ToInt32(s.GetParams()),
State: proto.Int32(int32(s.GetSceneState().GetState())),
TimeOut: proto.Int(s.GetSceneState().GetTimeout(s)),
NumOfGames: proto.Int(sceneEx.NumOfGames),
@ -412,15 +412,15 @@ func TienLenCreateRoomInfoPacket(s *base.Scene, p *base.Player, sceneEx *TienLen
RankType: s.GetDBGameFree().GetRankType(),
SceneAdd: s.GetDBGameFree().GetSceneAdd(),
// 比赛场相关
Round: proto.Int32(s.MatchRound),
CurPlayerNum: proto.Int32(s.MatchCurPlayerNum),
NextNeed: proto.Int32(s.MatchNextNeed),
Round: int32(s.MatchRound),
CurPlayerNum: int32(s.MatchCurPlayerNum),
NextNeed: int32(s.MatchNextNeed),
RecordId: sceneEx.recordId,
}
pack.IsMatch = int32(0)
// 0.普通场 1.锦标赛 2.冠军赛 3.vip专属
if s.IsMatchScene() {
pack.IsMatch = s.MatchType
pack.IsMatch = int32(s.MatchType)
}
pack.MatchFinals = 0
if s.MatchFinals {

View File

@ -20,14 +20,14 @@ type FriendRecord struct {
GameId int32 //游戏场次
BaseScore int32 //底分
BillCoin int64 //输赢分(税后)
MatchType int32
MatchType int64
Ts int64
}
func NewFriendRecordLog() *FriendRecord {
return &FriendRecord{LogId: bson.NewObjectId()}
}
func NewFriendRecordLogEx(platform string, snid, isWin, gameId, baseScore int32, billCoin int64, matchType int32) *FriendRecord {
func NewFriendRecordLogEx(platform string, snid, isWin, gameId, baseScore int32, billCoin int64, matchType int64) *FriendRecord {
fri := NewFriendRecordLog()
fri.Platform = platform
fri.SnId = snid

View File

@ -42,7 +42,7 @@ type GameDetailedLog struct {
Platform string //平台id
Channel string //渠道
Promoter string //推广员
MatchId int32 //比赛ID
MatchId int64 //比赛ID
SceneId int32 //场景ID
GameMode int32 //游戏类型
GameFreeid int32 //游戏类型房间号

View File

@ -49,8 +49,8 @@ type GamePlayerListLog struct {
RoomType int32 //房间类型
GameDif string //游戏标识
GameClass int32 //游戏类型 1棋牌 2电子 3百人 4捕鱼 5视讯 6彩票 7体育
MatchId int32
MatchType int32 //0.普通场 1.锦标赛 2.冠军赛 3.vip专属
MatchId int64
MatchType int64 //0.普通场 1.锦标赛 2.冠军赛 3.vip专属
Ts int32
IsFree bool //拉霸专用 是否免费
WinSmallGame int64 //拉霸专用 小游戏奖励
@ -63,7 +63,7 @@ func NewGamePlayerListLog() *GamePlayerListLog {
}
func NewGamePlayerListLogEx(snid int32, gamedetailedlogid string, platform, channel, promoter, packageTag string, gameid, baseScore,
sceneid, gamemode, gamefreeid int32, totalin, totalout int64, clubId int32, clubRoom string, taxCoin, pumpCoin int64, roomType int32,
betAmount, winAmountNoAnyTax int64, key, name string, gameClass int32, isFirst bool, matchid, matchType int32,
betAmount, winAmountNoAnyTax int64, key, name string, gameClass int32, isFirst bool, matchid, matchType int64,
isFree bool, winSmallGame, winTotal int64) *GamePlayerListLog {
cl := NewGamePlayerListLog()
cl.SnId = snid

View File

@ -851,7 +851,7 @@ type WGCreateScene struct {
SceneId int32 `protobuf:"varint,1,opt,name=SceneId,proto3" json:"SceneId,omitempty"`
GameId int32 `protobuf:"varint,2,opt,name=GameId,proto3" json:"GameId,omitempty"`
GameMode int32 `protobuf:"varint,3,opt,name=GameMode,proto3" json:"GameMode,omitempty"`
Params []int32 `protobuf:"varint,4,rep,packed,name=Params,proto3" json:"Params,omitempty"`
Params []int64 `protobuf:"varint,4,rep,packed,name=Params,proto3" json:"Params,omitempty"`
Creator int32 `protobuf:"varint,5,opt,name=Creator,proto3" json:"Creator,omitempty"`
Agentor int32 `protobuf:"varint,6,opt,name=Agentor,proto3" json:"Agentor,omitempty"`
ReplayCode string `protobuf:"bytes,7,opt,name=ReplayCode,proto3" json:"ReplayCode,omitempty"`
@ -926,7 +926,7 @@ func (x *WGCreateScene) GetGameMode() int32 {
return 0
}
func (x *WGCreateScene) GetParams() []int32 {
func (x *WGCreateScene) GetParams() []int64 {
if x != nil {
return x.Params
}
@ -1649,7 +1649,7 @@ type GWPlayerLeave struct {
TotalConvertibleFlow int64 `protobuf:"varint,13,opt,name=TotalConvertibleFlow,proto3" json:"TotalConvertibleFlow,omitempty"` //流水
ValidCacheBetTotal int64 `protobuf:"varint,14,opt,name=ValidCacheBetTotal,proto3" json:"ValidCacheBetTotal,omitempty"` //有效下注缓存
Items map[int32]int64 `protobuf:"bytes,15,rep,name=Items,proto3" json:"Items,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
MatchId int32 `protobuf:"varint,16,opt,name=MatchId,proto3" json:"MatchId,omitempty"` //比赛场id
MatchId int64 `protobuf:"varint,16,opt,name=MatchId,proto3" json:"MatchId,omitempty"` //比赛场id
CurIsWin int64 `protobuf:"varint,17,opt,name=CurIsWin,proto3" json:"CurIsWin,omitempty"` //本局是否赢 负数:输 0平局 正数:赢
MatchRobotGrades map[int32]int32 `protobuf:"bytes,18,rep,name=MatchRobotGrades,proto3" json:"MatchRobotGrades,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //比赛数据
RankScore map[int32]int64 `protobuf:"bytes,19,rep,name=RankScore,proto3" json:"RankScore,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 排位积分
@ -1792,7 +1792,7 @@ func (x *GWPlayerLeave) GetItems() map[int32]int64 {
return nil
}
func (x *GWPlayerLeave) GetMatchId() int32 {
func (x *GWPlayerLeave) GetMatchId() int64 {
if x != nil {
return x.MatchId
}
@ -8723,7 +8723,7 @@ var file_server_proto_rawDesc = []byte{
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x47, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08,
0x47, 0x61, 0x6d, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08,
0x47, 0x61, 0x6d, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61,
0x6d, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x05, 0x52, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73,
0x6d, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x03, 0x52, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73,
0x12, 0x18, 0x0a, 0x07, 0x43, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28,
0x05, 0x52, 0x07, 0x43, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x41, 0x67,
0x65, 0x6e, 0x74, 0x6f, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x41, 0x67, 0x65,
@ -8878,7 +8878,7 @@ var file_server_proto_rawDesc = []byte{
0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x47, 0x57, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72,
0x4c, 0x65, 0x61, 0x76, 0x65, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x61, 0x74, 0x63, 0x68,
0x49, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x49,
0x49, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x49,
0x64, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x75, 0x72, 0x49, 0x73, 0x57, 0x69, 0x6e, 0x18, 0x11, 0x20,
0x01, 0x28, 0x03, 0x52, 0x08, 0x43, 0x75, 0x72, 0x49, 0x73, 0x57, 0x69, 0x6e, 0x12, 0x57, 0x0a,
0x10, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x52, 0x6f, 0x62, 0x6f, 0x74, 0x47, 0x72, 0x61, 0x64, 0x65,

View File

@ -165,7 +165,7 @@ message WGCreateScene {
int32 SceneId = 1;
int32 GameId = 2;
int32 GameMode = 3;
repeated int32 Params = 4;
repeated int64 Params = 4;
int32 Creator = 5;
int32 Agentor = 6;
string ReplayCode = 7;
@ -267,7 +267,7 @@ message GWPlayerLeave{
int64 TotalConvertibleFlow = 13; //
int64 ValidCacheBetTotal = 14; //
map<int32, int64> Items = 15;
int32 MatchId = 16;//id
int64 MatchId = 16;//id
int64 CurIsWin = 17;// 0
map<int32, int32> MatchRobotGrades = 18;//
map<int32, int64> RankScore = 19;//

View File

@ -251,7 +251,7 @@ func (this *CSQueryPlayerGameLogHandler) Process(s *netlib.Session, packetid int
IsWin: proto.Int32(gpl.IsWin),
Ts: proto.Int64(gpl.Ts),
BillCoin: proto.Int64(gpl.BillCoin),
MatchType: proto.Int32(gpl.MatchType),
MatchType: proto.Int32(int32(gpl.MatchType)),
}
pack.GameLogs = append(pack.GameLogs, gl)
}

View File

@ -310,7 +310,7 @@ func (this *CSReturnRoomHandler) Process(s *netlib.Session, packetid int, data i
pack.RoomId = proto.Int(scene.sceneId)
pack.GameId = proto.Int(scene.gameId)
pack.ModeType = proto.Int(scene.gameMode)
pack.Params = scene.params
pack.Params = common.CopySliceInt64ToInt32(scene.params)
pack.HallId = proto.Int32(scene.hallId)
gameVers := srvdata.GetGameVers(p.PackageID)
if ver, ok := gameVers[fmt.Sprintf("%v,%v", scene.gameId, p.Channel)]; ok {
@ -1329,7 +1329,7 @@ func (this *CSQueryRoomInfoHandler) ProcessLocalGame(s *netlib.Session, packetid
MaxPlayer: proto.Int(scene.playerNum),
Creator: proto.Int32(scene.creator),
CreateTs: proto.Int32(int32(scene.createTime.Unix())),
Params: scene.params,
Params: common.CopySliceInt64ToInt32(scene.params),
}
pack.RoomInfo = append(pack.RoomInfo, roomInfo)
}
@ -1380,7 +1380,7 @@ func (this *CSQueryRoomInfoHandler) ProcessId(s *netlib.Session, packetid int, d
MaxPlayer: proto.Int(scene.playerNum),
Creator: proto.Int32(scene.creator),
CreateTs: proto.Int32(int32(scene.createTime.Unix())),
Params: scene.params,
Params: common.CopySliceInt64ToInt32(scene.params),
}
pack.RoomInfo = append(pack.RoomInfo, roomInfo)
}
@ -1819,7 +1819,7 @@ func (this *CSCreateRoomHandler) ProcessLocalGame(s *netlib.Session, packetid in
var playerTakeCoin = p.GetCoin()
var maxPlayerNum = int(msg.GetMaxPlayerNum())
var gameId = msg.GetGameId()
var params = msg.GetParams()
var params = common.CopySliceInt32ToInt64(msg.GetParams())
var roomId int
var scene *Scene
var sp ScenePolicy
@ -1888,7 +1888,7 @@ func (this *CSCreateRoomHandler) ProcessLocalGame(s *netlib.Session, packetid in
}
if len(params) == 0 {
params = common.CopySliceInt32(dbGameRule.GetParams())
params = common.CopySliceInt32ToInt64(dbGameRule.GetParams())
}
sp = GetScenePolicy(int(dbGameFree.GetGameId()), int(dbGameFree.GetGameMode()))
if sp == nil {
@ -1980,7 +1980,7 @@ func (this *CSCreateRoomHandler) ProcessThirteen(s *netlib.Session, packetid int
var code gamehall.OpResultCode_Game
var dbGameFree *server.DB_GameFree
var dbGameRule *server.DB_GameRule
var params = msg.GetParams()
var params = common.CopySliceInt32ToInt64(msg.GetParams())
var baseScore = msg.GetBaseCoin()
var sp ScenePolicy
var gamefreeId = msg.GetId()

View File

@ -1,95 +1,38 @@
package main
import (
"mongo.games.com/game/common"
"mongo.games.com/game/model"
"mongo.games.com/game/proto"
"mongo.games.com/game/protocol/tournament"
"mongo.games.com/game/srvdata"
"mongo.games.com/goserver/core/basic"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/netlib"
"mongo.games.com/goserver/core/task"
"sort"
"strconv"
"time"
"mongo.games.com/game/common"
"mongo.games.com/game/protocol/tournament"
)
// 比赛场信息
type CSTMInfoPacketFactory struct {
}
type CSTMInfoHandler struct {
}
func CSTMInfo(s *netlib.Session, packetid int, data interface{}, sid int64) error {
logger.Logger.Trace("CSTMInfoHandler ", data)
_, ok := data.(*tournament.CSTMInfo)
if !ok {
return nil
}
func (this *CSTMInfoPacketFactory) CreatePacket() interface{} {
pack := &tournament.CSTMInfo{}
return pack
}
func (this *CSTMInfoHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
logger.Logger.Trace("CSTMInfoHandler Process recv ", data)
if _, ok := data.(*tournament.CSTMInfo); ok {
p := PlayerMgrSington.GetPlayer(sid)
if p == nil {
logger.Logger.Warnf("CSTMInfo p == nil.")
return nil
}
pack := TournamentMgr.GetSCTMInfosPack(p.Platform, p.AppChannel)
proto.SetDefaults(pack)
logger.Logger.Trace("SCTMInfos++++++++++++:", pack)
p.SendToClient(int(tournament.TOURNAMENTID_PACKET_TM_SCTMInfos), pack)
}
logger.Logger.Trace("SCTMInfos ", pack)
return nil
}
// 排行榜
type CSTMRankListPacketFactory struct {
}
type CSTMRankListHandler struct {
}
func (this *CSTMRankListPacketFactory) CreatePacket() interface{} {
pack := &tournament.CSTMRankList{}
return pack
}
func (this *CSTMRankListHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
logger.Logger.Trace("CSTMRankListHandler Process recv ", data)
if msg, ok := data.(*tournament.CSTMRankList); ok {
p := PlayerMgrSington.GetPlayer(sid)
if p == nil {
logger.Logger.Warnf("CSTMRankList p == nil.")
func CSSignRace(s *netlib.Session, packetid int, data interface{}, sid int64) error {
logger.Logger.Trace("CSSignRaceHandler ", data)
msg, ok := data.(*tournament.CSSignRace)
if !ok {
return nil
}
pack := &tournament.SCTMRankList{
TMId: msg.TMId,
TimeRange: "9.1-9.30",
TMRank: []*tournament.TMRank{
{RankId: 1, RankName: "rankNo.1", WinnerNum: 5},
{RankId: 2, RankName: "rankNo.2", WinnerNum: 4},
{RankId: 3, RankName: "rankNo.3", WinnerNum: 2}},
}
proto.SetDefaults(pack)
logger.Logger.Trace("CSTMRankList:", pack)
p.SendToClient(int(tournament.TOURNAMENTID_PACKET_TM_SCTMRankList), pack)
}
return nil
}
// 报名
type CSSignRacePacketFactory struct {
}
type CSSignRaceHandler struct {
}
func (this *CSSignRacePacketFactory) CreatePacket() interface{} {
pack := &tournament.CSSignRace{}
return pack
}
func (this *CSSignRaceHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
logger.Logger.Trace("CSSignRaceHandler Process recv ", data)
if msg, ok := data.(*tournament.CSSignRace); ok {
p := PlayerMgrSington.GetPlayer(sid)
if p == nil {
logger.Logger.Warnf("CSSignRace p == nil.")
@ -103,20 +46,22 @@ func (this *CSSignRaceHandler) Process(s *netlib.Session, packetid int, data int
logger.Logger.Warnf("CSSignRace p.IsRob.")
return nil
}
platform := p.Platform
tmid := msg.TMId
tmId := msg.TMId
pack := &tournament.SCSignRace{}
switch msg.GetOpCode() {
case 0:
ok, code := TournamentMgr.SignUp(tmid, p)
case 0: // 报名
ok, code := TournamentMgr.SignUp(tmId, p)
if !ok {
logger.Logger.Infof("player(%v) match(%v) SignUp is fail.", p.SnId, tmid)
logger.Logger.Infof("player(%v) match(%v) SignUp is fail.", p.SnId, tmId)
pack.RetCode = code //0成功 1重复报名 2比赛没有开启 3道具不足 4不在报名时间段 5金币不足 6钻石不足
}
if code == int32(tournament.SignRaceCode_OPRC_Close) ||
code == int32(tournament.SignRaceCode_OPRC_Time) {
TournamentMgr.CancelSignUpAll(platform, tmid)
TournamentMgr.CancelSignUpAll(platform, tmId)
}
waitStart := TournamentMgr.playerWaitStart[p.SnId]
@ -124,342 +69,32 @@ func (this *CSSignRaceHandler) Process(s *netlib.Session, packetid int, data int
pack.WaitStartTime = waitStart
}
proto.SetDefaults(pack)
logger.Logger.Trace("SCSignRace:", pack)
signSucc := p.SendToClient(int(tournament.TOURNAMENTID_PACKET_TM_SCSignRace), pack)
logger.Logger.Trace("SCSignRace ", pack)
// 检查是否可以开始比赛(关闭机器人时,比赛开赛)
if msg.GetOpCode() == 0 && pack.RetCode == 0 && signSucc && !TournamentMgr.IsUseRobot(platform, tmid) {
if TournamentMgr.CanStart(platform, tmid) {
TournamentMgr.Start(platform, tmid)
if code == 0 && signSucc && !TournamentMgr.IsUseRobot(platform, tmId) {
if TournamentMgr.CanStart(platform, tmId) {
TournamentMgr.Start(platform, tmId)
}
}
default:
default: // 取消报名
if TournamentMgr.IsMatching(p.SnId) {
logger.Logger.Infof("player(%v) IsMatching.", p.SnId)
logger.Logger.Warnf("player(%v) IsMatching.", p.SnId)
} else {
//取消报名
TournamentMgr.CancelSignUp(platform, tmid, p.SnId)
TournamentMgr.CancelSignUp(platform, tmId, p.SnId)
}
return nil
}
}
return nil
}
// 赛季信息
type CSTMSeasonInfoPacketFactory struct {
}
type CSTMSeasonInfoHandler struct {
}
func (this *CSTMSeasonInfoPacketFactory) CreatePacket() interface{} {
pack := &tournament.CSTMSeasonInfo{}
return pack
}
func (this *CSTMSeasonInfoHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
logger.Logger.Trace("CSTMSeasonInfoHandler Process recv ", data)
if _, ok := data.(*tournament.CSTMSeasonInfo); ok {
p := PlayerMgrSington.GetPlayer(sid)
if p == nil {
logger.Logger.Warnf("CSTMSeasonInfoHandler p == nil.")
return nil
}
if p.Platform == DefaultPlatform {
logger.Logger.Warnf("CSTMSeasonInfoHandler Platform == Default_Platform.")
return nil
}
msid := MatchSeasonMgrSington.GetMatchSeasonId(p.Platform)
if msid == nil {
logger.Logger.Warnf("CSTMSeasonInfoHandler msid == nil.")
return nil
}
send := func(ms *MatchSeason) {
pack := &tournament.SCTMSeasonInfo{
Id: msid.SeasonId,
SeasonTimeStamp: []int64{msid.StartStamp, msid.EndStamp},
Lv: ms.Lv,
LastLv: ms.LastLv,
IsAward: ms.IsAward,
}
proto.SetDefaults(pack)
logger.Logger.Trace("CSTMSeasonInfoHandler:", pack)
p.SendToClient(int(tournament.TOURNAMENTID_PACKET_TM_SCTMSeasonInfo), pack)
}
snid := p.SnId
ms := MatchSeasonMgrSington.GetMatchSeason(snid)
if ms == nil {
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
ret, err := model.QueryMatchSeasonBySnid(p.Platform, snid)
if err != nil {
return nil
}
return ret
}), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
var ret *model.MatchSeason
dirty := false
if data == nil || data.(*model.MatchSeason) == nil { //新数据
player := PlayerMgrSington.GetPlayerBySnId(snid)
if player != nil {
ret = model.NewMatchSeason(player.Platform, snid, player.Name, msid.SeasonId, 1)
dirty = true
} else {
logger.Logger.Trace("CSTMSeasonInfoHandler error: player==nil ", snid)
}
} else {
ret = data.(*model.MatchSeason)
if ret.SeasonId < msid.SeasonId { //不同赛季段位继承
num := msid.SeasonId - ret.SeasonId
finalLv := ret.Lv
for i := 0; i < int(num); i++ { //继承几次
if i == int(num)-1 { //上个赛季
ret.LastLv = finalLv
}
finalLv = MatchSeasonMgrSington.MatchSeasonInherit(finalLv)
}
ret.Lv = finalLv
ret.SeasonId = msid.SeasonId
ret.IsAward = false
ret.UpdateTs = time.Now().Unix()
dirty = true
}
}
ms = MatchSeasonMgrSington.exchangeModel2Cache(ret)
ms.dirty = dirty
MatchSeasonMgrSington.SetMatchSeason(ms)
send(ms)
})).StartByFixExecutor("SnId:" + strconv.Itoa(int(snid)))
} else {
if ms.SeasonId < msid.SeasonId { //不同赛季段位继承
num := msid.SeasonId - ms.SeasonId
finalLv := ms.Lv
for i := 0; i < int(num); i++ { //继承几次
if i == int(num)-1 { //上个赛季
ms.LastLv = finalLv
}
finalLv = MatchSeasonMgrSington.MatchSeasonInherit(finalLv)
}
ms.Lv = finalLv
ms.SeasonId = msid.SeasonId
ms.IsAward = false
ms.UpdateTs = time.Now().Unix()
ms.dirty = true
MatchSeasonMgrSington.SetMatchSeason(ms)
}
send(ms)
}
}
return nil
}
// 赛季排行榜
type CSTMSeasonRankPacketFactory struct {
}
type CSTMSeasonRankHandler struct {
}
func (this *CSTMSeasonRankPacketFactory) CreatePacket() interface{} {
pack := &tournament.CSTMSeasonRank{}
return pack
}
func (this *CSTMSeasonRankHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
logger.Logger.Trace("CSTMSeasonRankHandler Process recv ", data)
if _, ok := data.(*tournament.CSTMSeasonRank); ok {
p := PlayerMgrSington.GetPlayer(sid)
if p == nil {
logger.Logger.Warnf("CSTMSeasonRankHandler p == nil.")
return nil
}
platform := p.Platform
if platform == DefaultPlatform {
logger.Logger.Warnf("CSTMSeasonRankHandler Platform == Default_Platform.")
return nil
}
pack := &tournament.SCTMSeasonRank{}
tmpMsrs := []*MatchSeasonRank{}
msr := MatchSeasonRankMgrSington.GetMatchSeasonRank(platform)
if msr != nil {
for _, ms := range msr {
sr := &MatchSeasonRank{
SnId: ms.SnId,
Name: ms.Name,
Lv: ms.Lv,
}
tmpMsrs = append(tmpMsrs, sr)
}
}
robotmsr := MatchSeasonRankMgrSington.GetRobotMatchSeasonRank(platform)
if robotmsr != nil {
for _, ms := range robotmsr {
sr := &MatchSeasonRank{
SnId: ms.SnId,
Name: ms.Name,
Lv: ms.Lv,
}
tmpMsrs = append(tmpMsrs, sr)
}
}
if tmpMsrs != nil && len(tmpMsrs) > 0 {
sort.Slice(tmpMsrs, func(i, j int) bool {
return tmpMsrs[i].Lv > tmpMsrs[j].Lv
})
if len(tmpMsrs) > model.GameParamData.MatchSeasonRankMaxNum {
tmpMsrs = append(tmpMsrs[:model.GameParamData.MatchSeasonRankMaxNum])
}
for i := 0; i < len(tmpMsrs); i++ {
ms := tmpMsrs[i]
sr := &tournament.SeasonRank{
Snid: ms.SnId,
Name: ms.Name,
Lv: ms.Lv,
Rank: int32(i) + 1,
}
pack.ReasonRanks = append(pack.ReasonRanks, sr)
}
}
proto.SetDefaults(pack)
logger.Logger.Trace("CSTMSeasonRankHandler:", pack)
p.SendToClient(int(tournament.TOURNAMENTID_PACKET_TM_SCTMSeasonRank), pack)
}
return nil
}
// 领取赛季奖励
type CSTMSeasonAwardPacketFactory struct {
}
type CSTMSeasonAwardHandler struct {
}
func (this *CSTMSeasonAwardPacketFactory) CreatePacket() interface{} {
pack := &tournament.CSTMSeasonAward{}
return pack
}
func (this *CSTMSeasonAwardHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
logger.Logger.Trace("CSTMSeasonAwardHandler Process recv ", data)
if msg, ok := data.(*tournament.CSTMSeasonAward); ok {
p := PlayerMgrSington.GetPlayer(sid)
if p == nil {
logger.Logger.Warnf("CSTMSeasonAwardHandler p == nil.")
return nil
}
if p.Platform == DefaultPlatform {
logger.Logger.Warnf("CSTMSeasonInfoHandler Platform == Default_Platform.")
return nil
}
lv := msg.GetLv()
logger.Logger.Trace("CSTMSeasonAwardHandler lv: ", lv)
pack := &tournament.SCTMSeasonAward{
Lv: lv,
Code: 1,
}
ms := MatchSeasonMgrSington.GetMatchSeason(p.SnId)
msi := MatchSeasonMgrSington.GetMatchSeasonId(p.Platform)
if ms != nil && msi != nil {
if !ms.IsAward && ms.LastLv == lv && msi.SeasonId > 1 { //领取上赛季奖励
for _, v := range srvdata.PBDB_GamMatchLVMgr.Datas.GetArr() {
if v.Star != nil && len(v.Star) > 1 {
startStar := v.Star[0]
endStar := v.Star[1]
if lv >= startStar && lv <= endStar { //匹配段位
pack.Code = 0
MatchSeasonMgrSington.UpdateMatchSeasonAward(p.SnId)
if v.Number1 > 0 {
switch v.AwardType1 {
case 1: //金币
p.AddCoin(int64(v.Number1), 0, common.GainWay_MatchSeason, "system", "赛季奖励")
if !p.IsRob {
LogChannelSingleton.WriteMQData(model.GenerateSystemFreeGive(p.SnId, p.Name, p.Platform, p.Channel, model.SystemFreeGive_GiveType_MatchSeason, model.SystemFreeGive_CoinType_Coin, int64(v.Number1)))
}
case 2: //钻石
p.AddDiamond(int64(v.Number1), 0, common.GainWay_MatchSeason, "system", "赛季奖励")
if !p.IsRob {
LogChannelSingleton.WriteMQData(model.GenerateSystemFreeGive(p.SnId, p.Name, p.Platform, p.Channel, model.SystemFreeGive_GiveType_MatchSeason, model.SystemFreeGive_CoinType_Diamond, int64(v.Number1)))
}
case 3: //道具
item := &Item{
ItemId: v.AwardId1,
ItemNum: int64(v.Number1),
}
BagMgrSingleton.AddItems(p, []*Item{item}, 0, common.GainWay_MatchSeason, "system", "赛季奖励", 0, 0, false)
}
}
if v.Number2 > 0 {
switch v.AwardType2 {
case 1: //金币
p.AddCoin(int64(v.Number2), 0, common.GainWay_MatchSeason, "system", "赛季奖励")
if !p.IsRob {
LogChannelSingleton.WriteMQData(model.GenerateSystemFreeGive(p.SnId, p.Name, p.Platform, p.Channel, model.SystemFreeGive_GiveType_MatchSeason, model.SystemFreeGive_CoinType_Coin, int64(v.Number2)))
}
case 2: //钻石
p.AddDiamond(int64(v.Number2), 0, common.GainWay_MatchSeason, "system", "赛季奖励")
if !p.IsRob {
LogChannelSingleton.WriteMQData(model.GenerateSystemFreeGive(p.SnId, p.Name, p.Platform, p.Channel, model.SystemFreeGive_GiveType_MatchSeason, model.SystemFreeGive_CoinType_Diamond, int64(v.Number2)))
}
case 3: //道具
item := &Item{
ItemId: v.AwardId2,
ItemNum: int64(v.Number2),
}
BagMgrSingleton.AddItems(p, []*Item{item}, 0, common.GainWay_MatchSeason, "system", "赛季奖励", 0, 0, false)
}
}
if v.Number3 > 0 {
switch v.AwardType3 {
case 1: //金币
p.AddCoin(int64(v.Number3), 0, common.GainWay_MatchSeason, "system", "赛季奖励")
if !p.IsRob {
LogChannelSingleton.WriteMQData(model.GenerateSystemFreeGive(p.SnId, p.Name, p.Platform, p.Channel, model.SystemFreeGive_GiveType_MatchSeason, model.SystemFreeGive_CoinType_Coin, int64(v.Number3)))
}
case 2: //钻石
p.AddDiamond(int64(v.Number3), 0, common.GainWay_MatchSeason, "system", "赛季奖励")
if !p.IsRob {
LogChannelSingleton.WriteMQData(model.GenerateSystemFreeGive(p.SnId, p.Name, p.Platform, p.Channel, model.SystemFreeGive_GiveType_MatchSeason, model.SystemFreeGive_CoinType_Diamond, int64(v.Number3)))
}
case 3: //道具
item := &Item{
ItemId: v.AwardId3,
ItemNum: int64(v.Number3),
}
BagMgrSingleton.AddItems(p, []*Item{item}, 0, common.GainWay_MatchSeason, "system", "赛季奖励", 0, 0, false)
}
}
break
}
}
}
}
}
if pack.Code != 0 {
logger.Logger.Trace("CSTMSeasonAwardHandler ms: ", ms)
logger.Logger.Trace("CSTMSeasonAwardHandler msi: ", msi)
}
proto.SetDefaults(pack)
logger.Logger.Trace("SCTMSeasonAward:", pack)
p.SendToClient(int(tournament.TOURNAMENTID_PACKET_TM_SCTMSeasonAward), pack)
}
return nil
}
func init() {
common.RegisterHandler(int(tournament.TOURNAMENTID_PACKET_TM_CSTMInfo), &CSTMInfoHandler{})
netlib.RegisterFactory(int(tournament.TOURNAMENTID_PACKET_TM_CSTMInfo), &CSTMInfoPacketFactory{})
common.RegisterHandler(int(tournament.TOURNAMENTID_PACKET_TM_CSTMRankList), &CSTMRankListHandler{})
netlib.RegisterFactory(int(tournament.TOURNAMENTID_PACKET_TM_CSTMRankList), &CSTMRankListPacketFactory{})
// 比赛信息列表
common.Register(int(tournament.TOURNAMENTID_PACKET_TM_CSTMInfo), tournament.CSTMInfo{}, CSTMInfo)
// 比赛报名
common.RegisterHandler(int(tournament.TOURNAMENTID_PACKET_TM_CSSignRace), &CSSignRaceHandler{})
netlib.RegisterFactory(int(tournament.TOURNAMENTID_PACKET_TM_CSSignRace), &CSSignRacePacketFactory{})
common.RegisterHandler(int(tournament.TOURNAMENTID_PACKET_TM_CSTMSeasonInfo), &CSTMSeasonInfoHandler{})
netlib.RegisterFactory(int(tournament.TOURNAMENTID_PACKET_TM_CSTMSeasonInfo), &CSTMSeasonInfoPacketFactory{})
common.RegisterHandler(int(tournament.TOURNAMENTID_PACKET_TM_CSTMSeasonRank), &CSTMSeasonRankHandler{})
netlib.RegisterFactory(int(tournament.TOURNAMENTID_PACKET_TM_CSTMSeasonRank), &CSTMSeasonRankPacketFactory{})
common.RegisterHandler(int(tournament.TOURNAMENTID_PACKET_TM_CSTMSeasonAward), &CSTMSeasonAwardHandler{})
netlib.RegisterFactory(int(tournament.TOURNAMENTID_PACKET_TM_CSTMSeasonAward), &CSTMSeasonAwardPacketFactory{})
common.Register(int(tournament.TOURNAMENTID_PACKET_TM_CSSignRace), tournament.CSSignRace{}, CSSignRace)
}

View File

@ -224,7 +224,7 @@ func (this *BaseCoinScenePool) NewScene(pool *CoinScenePool, p *Player) *Scene {
}
gameMode := pool.dbGameRule.GetGameMode()
params := pool.dbGameRule.GetParams()
params := common.CopySliceInt32ToInt64(pool.dbGameRule.GetParams())
var platformName string
limitPlatform := PlatformMgrSingleton.GetPlatform(pool.platform)
if limitPlatform == nil || !limitPlatform.Isolated {

View File

@ -234,7 +234,7 @@ func (this *CoinScenePoolLocal) NewScene(pool *CoinScenePool, p *Player) *Scene
return nil
}
scene := SceneMgrSingleton.CreateLocalGameScene(p.SnId, sceneId, gameId, gameSite, common.SceneMode_Public, 1, params,
scene := SceneMgrSingleton.CreateLocalGameScene(p.SnId, sceneId, gameId, gameSite, common.SceneMode_Public, 1, common.CopySliceInt32ToInt64(params),
gs, limitPlatform, 0, pool.dbGameFree, baseScore, pool.groupId, pool.id)
if scene != nil {
scene.hallId = pool.id
@ -296,7 +296,7 @@ func (this *CoinScenePoolLocal) NewPreCreateScene(pool *CoinScenePool) *Scene {
gameSite = int(dbCreateRoom.GetGameSite())
}
if baseScore != 0 {
scene = SceneMgrSingleton.CreateLocalGameScene(0, sceneId, gameId, gameSite, common.SceneMode_Public, 1, params,
scene = SceneMgrSingleton.CreateLocalGameScene(0, sceneId, gameId, gameSite, common.SceneMode_Public, 1, common.CopySliceInt32ToInt64(params),
gs, limitPlatform, playerNum, pool.dbGameFree, baseScore, pool.groupId, pool.id)
if scene != nil {
logger.Logger.Tracef("CreateLocalGameScene success.gameId:%v gameSite:%v baseScore:%v randIdx:%v", scene.gameId, scene.gameSite, baseScore, randIdx)

View File

@ -395,7 +395,7 @@ func (this *HundredSceneMgr) CreateNewScene(id, groupId int32, limitPlatform *Pl
if gs != nil {
sceneId := SceneMgrSingleton.GenOneHundredSceneId()
gameMode := dbGameRule.GetGameMode()
params := dbGameRule.GetParams()
params := common.CopySliceInt32ToInt64(dbGameRule.GetParams())
//SceneType := dbGameFree.GetSceneType()
scene := SceneMgrSingleton.CreateScene(0, 0, sceneId, gameId, int(gameMode), common.SceneMode_Public, 1, -1, params, gs, limitPlatform, groupId, dbGameFree, id)

View File

@ -56,7 +56,7 @@ func (ms *MatchSceneMgr) NewScene(tm *TmMatch, isFinals bool, round int32) *Scen
groupId := PlatformMgrSingleton.GetGameFreeGroup(tm.Platform, tm.dbGameFree.Id)
// 建房参数
// 比赛唯一索引,是否决赛,第几轮,本轮总人数,下一轮总人数,赛制类型
params := []int32{tm.SortId, finals, round, curPlayerNum, nextNeed, tm.gmd.MatchType}
params := []int64{tm.SortId, int64(finals), int64(round), int64(curPlayerNum), int64(nextNeed), int64(tm.gmd.MatchType)}
scene := SceneMgrSingleton.CreateScene(0, 0, sceneId, gameId, int(gameMode), common.SceneMode_Match, 1,
0, params, gs, limitPlatform, groupId, tm.dbGameFree, tm.dbGameFree.GetId())

View File

@ -1462,6 +1462,7 @@ func (this *Player) Kickout(reason int32) {
this.DropLine()
this.DgGameLogout()
}
TournamentMgr.ForceQuit(this.Platform, this.SnId)
}
// DropLine 掉线
@ -2328,7 +2329,7 @@ func (this *Player) GetIP() string {
return this.Ip
}
func (this *Player) CreateScene(sceneId, gameId, gameMode, sceneMode int, numOfGames int32, params []int32, dbGameFree *server_proto.DB_GameFree) (*Scene, hall_proto.OpResultCode_Game) {
func (this *Player) CreateScene(sceneId, gameId, gameMode, sceneMode int, numOfGames int32, params []int64, dbGameFree *server_proto.DB_GameFree) (*Scene, hall_proto.OpResultCode_Game) {
gs := GameSessMgrSington.GetMinLoadSess(gameId)
if gs == nil {
logger.Logger.Warnf("(this *Player) EnterScene %v, %v GameSessMgrSington.GetMinLoadSess() = nil ", this.SnId, gameId)
@ -2343,7 +2344,7 @@ func (this *Player) CreateScene(sceneId, gameId, gameMode, sceneMode int, numOfG
return s, hall_proto.OpResultCode_Game_OPRC_Sucess_Game
}
func (this *Player) CreateLocalGameScene(sceneId, gameId, gameSite, sceneMode, playerNum int, params []int32,
func (this *Player) CreateLocalGameScene(sceneId, gameId, gameSite, sceneMode, playerNum int, params []int64,
dbGameFree *server_proto.DB_GameFree, baseScore, groupId int32) (*Scene, hall_proto.OpResultCode_Game) {
gs := GameSessMgrSington.GetMinLoadSess(gameId)
if gs == nil {

View File

@ -52,7 +52,7 @@ type Scene struct {
gameId int //游戏id
gameMode int //游戏模式
sceneMode int //房间模式,参考common.SceneMode_XXX
params []int32 //场景参数
params []int64 //场景参数
paramsEx []int32 //其他扩展参数
playerNum int //人数
robotNum int //机器人数量
@ -104,13 +104,13 @@ type Scene struct {
quitMatchSnids []int32 //退赛玩家id
gameSite int //tienlen游戏场次区分 1.初级 2.中级 3.高级场
BaseScore int32 //tienlen游戏底分
matchId int32 //比赛场id
matchId int64 //比赛场id
csp *CoinScenePool // 所在场景池
}
// NewScene 创建房间
func NewScene(agentor, creator int32, id, gameId, gameMode, sceneMode int, clycleTimes, numOfGames int32, params []int32,
func NewScene(agentor, creator int32, id, gameId, gameMode, sceneMode int, clycleTimes, numOfGames int32, params []int64,
gs *GameSession, limitPlatform *Platform, groupId int32, dbGameFree *serverproto.DB_GameFree, paramsEx ...int32) *Scene {
sp := GetScenePolicy(gameId, gameMode)
if sp == nil {
@ -159,7 +159,7 @@ func NewScene(agentor, creator int32, id, gameId, gameMode, sceneMode int, clycl
return s
}
func NewLocalGameScene(creator int32, sceneId, gameId, gameSite, sceneMode int, clycleTimes int32, params []int32,
func NewLocalGameScene(creator int32, sceneId, gameId, gameSite, sceneMode int, clycleTimes int32, params []int64,
gs *GameSession, limitPlatform *Platform, playerNum int, dbGameFree *serverproto.DB_GameFree, baseScore, groupId int32, paramsEx ...int32) *Scene {
sp := GetScenePolicy(gameId, 0)
if sp == nil {

View File

@ -131,7 +131,7 @@ func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode
Creator: s.creator,
Agentor: s.agentor,
ReplayCode: s.replayCode,
Params: s.params,
Params: common.CopySliceInt64ToInt32(s.params),
PlayerCnt: int32(len(s.players) - s.robotNum),
RobotCnt: int32(s.robotNum),
CreateTime: s.createTime.Unix(),
@ -225,7 +225,7 @@ func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode
// CreateScene 创建房间
func (m *SceneMgr) CreateScene(agentor, creator int32, sceneId, gameId, gameMode, sceneMode int, clycleTimes int32,
numOfGames int32, params []int32, gs *GameSession, limitPlatform *Platform, groupId int32, dbGameFree *serverproto.DB_GameFree,
numOfGames int32, params []int64, gs *GameSession, limitPlatform *Platform, groupId int32, dbGameFree *serverproto.DB_GameFree,
paramsEx ...int32) *Scene {
logger.Logger.Trace("(this *SceneMgr) CreateScene ")
s := NewScene(agentor, creator, sceneId, gameId, gameMode, sceneMode, clycleTimes, numOfGames, params, gs, limitPlatform, groupId,
@ -251,7 +251,7 @@ func (m *SceneMgr) CreateScene(agentor, creator int32, sceneId, gameId, gameMode
}
// CreateLocalGameScene 创建本地游戏房间
func (m *SceneMgr) CreateLocalGameScene(creator int32, sceneId, gameId, gameSite, sceneMode int, clycleTimes int32, params []int32,
func (m *SceneMgr) CreateLocalGameScene(creator int32, sceneId, gameId, gameSite, sceneMode int, clycleTimes int32, params []int64,
gs *GameSession, limitPlatform *Platform, playerNum int, dbGameFree *serverproto.DB_GameFree, baseScore, groupId int32,
paramsEx ...int32) *Scene {
logger.Logger.Trace("(this *SceneMgr) CreateLocalGameScene gameSite: ", gameSite, " sceneMode: ", sceneMode)
@ -352,7 +352,7 @@ func (m *SceneMgr) GetThirdScene(i webapi.IThirdPlatform) *Scene {
var gameMode = common.SceneMode_Thr
dbGameFree := srvdata.PBDB_GameFreeMgr.GetData(i.GetPlatformBase().VultGameID)
scene := SceneMgrSingleton.CreateScene(0, 0, sceneId, i.GetPlatformBase().BaseGameID, gameMode, int(common.SceneMode_Thr), 1, -1,
[]int32{}, gs, limitPlatform, 0, dbGameFree, i.GetPlatformBase().VultGameID)
[]int64{}, gs, limitPlatform, 0, dbGameFree, i.GetPlatformBase().VultGameID)
return scene
} else {
logger.Logger.Errorf("Get %v game min session failed.", i.GetPlatformBase().BaseGameID)

View File

@ -3,6 +3,7 @@ package main
import (
"time"
"mongo.games.com/game/common"
hall_proto "mongo.games.com/game/protocol/gamehall"
"mongo.games.com/goserver/core/logger"
)
@ -290,7 +291,7 @@ func (spd *ScenePolicyData) getPlayerNum(params []int32) int32 {
func (spd *ScenePolicyData) GetPlayerNum(s *Scene) int32 {
if s != nil {
return spd.getPlayerNum(s.params)
return spd.getPlayerNum(common.CopySliceInt64ToInt32(s.params))
}
return spd.DefaultPlayerCnt
}
@ -311,7 +312,7 @@ func (spd *ScenePolicyData) getBaseCoin(params []int32) int {
func (spd *ScenePolicyData) GetBaseCoin(s *Scene) int {
if s != nil {
return spd.getBaseCoin(s.params)
return spd.getBaseCoin(common.CopySliceInt64ToInt32(s.params))
}
return 0
}

View File

@ -16,6 +16,7 @@ import (
"mongo.games.com/game/protocol/server"
"mongo.games.com/game/protocol/tournament"
webapi_proto "mongo.games.com/game/protocol/webapi"
"mongo.games.com/game/srvdata"
)
type TmPlayer struct {
@ -23,8 +24,15 @@ type TmPlayer struct {
seq int // 报名序号(第几个报名的)
}
type TmGradeInfo struct {
grade int32
copySnid int32
copyLv int32
copyRoleId int32
}
type TmMatch struct {
SortId int32 // 比赛开始时间戳,纳秒
SortId int64 // 比赛开始时间戳,纳秒
TMId int32 // 比赛配置Id
TmPlayer map[int32]*TmPlayer // 比赛玩家
Platform string // 平台
@ -37,23 +45,34 @@ type TmMatch struct {
StartTime int64 // 本场比赛开始时间
}
type TmGradeInfo struct {
grade int32
copySnid int32
copyLv int32
copyRoleId int32
func NewTmMatch(platform string, match *webapi_proto.GameMatchDate, players map[int32]*TmPlayer) *TmMatch {
ret := &TmMatch{
SortId: time.Now().UnixNano(),
TMId: match.Id,
TmPlayer: make(map[int32]*TmPlayer),
Platform: platform,
gmd: match,
gml: srvdata.MatchLevelMgr.Get(match.GameFreeId, match.MatchLevel),
dbGameFree: srvdata.PBDB_GameFreeMgr.GetData(match.GameFreeId),
robotGrades: make(map[int][]*TmGradeInfo),
useRobot: match.UseRobot,
StartTime: time.Now().Unix(),
}
ret.copyPlayers(players)
return ret
}
func (tm *TmMatch) Start() {
logger.Logger.Trace("(this *TmMatch) Start()")
logger.Logger.Trace("TmMatch Start")
//通知客户端比赛开始
pack := &tournament.SCTMStart{
MatchId: proto.Int32(tm.TMId),
}
proto.SetDefaults(pack)
logger.Logger.Trace("SCTMStart:", pack)
tm.BroadcastMessage(int(tournament.TOURNAMENTID_PACKET_TM_SCTMStart), pack)
tm.StartTime = time.Now().Unix()
logger.Logger.Trace("SCTMStart ", pack)
//创建房间
timer.StartTimer(timer.TimerActionWrapper(func(h timer.TimerHandle, ud interface{}) bool {
MatchSceneMgrSingleton.MatchStart(tm)
@ -62,7 +81,7 @@ func (tm *TmMatch) Start() {
}
func (tm *TmMatch) Stop() {
//销毁房间
// 销毁房间
MatchSceneMgrSingleton.MatchStop(tm)
logger.Logger.Trace("(this *TmMatch) Stop()")
}
@ -90,7 +109,7 @@ func (tm *TmMatch) BroadcastMessage(packetId int, rawPack interface{}) {
}
}
func (tm *TmMatch) CopyMap(b map[int32]*TmPlayer) {
func (tm *TmMatch) copyPlayers(b map[int32]*TmPlayer) {
tm.TmPlayer = make(map[int32]*TmPlayer)
for _, v := range b {
var tmp TmPlayer
@ -114,9 +133,9 @@ func (tm *TmMatch) CreateRobotGrades(round int) {
// 上一轮数据,用在线玩家数据填充包含机器人,如果不够填充假数据
if tm.robotGrades[round-1] == nil { //初始化数据
tm.robotGrades[round-1] = []*TmGradeInfo{}
snids := []int32{}
lvs := []int32{}
roleIds := []int32{}
var snids []int32
var lvs []int32
var roleIds []int32
for _, player := range PlayerMgrSington.snidMap {
if len(snids) > int(lastPromotionNum) {
break
@ -234,12 +253,12 @@ func (tm *TmMatch) CreateRobotGrades(round int) {
if tm.robotGrades[round-2] != nil {
delete(tm.robotGrades, round-2)
}
for i, infos := range tm.robotGrades {
logger.Logger.Tracef(">>>积分历史>>> 第 %v 轮", i)
for _, info := range infos {
logger.Logger.Trace("Snid: ", info.copySnid, " grade: ", info.grade, " copyLv: ", info.copyLv, " copyRoleId: ", info.copyRoleId)
}
}
//for i, infos := range tm.robotGrades {
// logger.Logger.Tracef(">>>积分历史>>> 第 %v 轮", i)
// for _, info := range infos {
// logger.Logger.Trace("Snid: ", info.copySnid, " grade: ", info.grade, " copyLv: ", info.copyLv, " copyRoleId: ", info.copyRoleId)
// }
//}
}
// RobotGradesDecline 假积分衰减
@ -250,12 +269,15 @@ func (tm *TmMatch) RobotGradesDecline(round int) {
if tm.robotGrades == nil {
tm.robotGrades = make(map[int][]*TmGradeInfo)
}
// 初始化第一轮积分
if round == 1 {
tm.CreateRobotGrades(1)
}
if tm.robotGrades[lastRound] == nil { //生成假数据
// 生成当前轮积分
if tm.robotGrades[lastRound] == nil {
tm.CreateRobotGrades(lastRound)
}
// 按规则积分衰减
if tm.robotGrades[lastRound] != nil {
for i, info := range tm.robotGrades[lastRound] {
declineGrade := info.grade
@ -275,11 +297,11 @@ func (tm *TmMatch) RobotGradesDecline(round int) {
}
}
}
logger.Logger.Tracef("======积分衰减======当前第 %v 轮============", round)
for i, infos := range tm.robotGrades {
logger.Logger.Tracef(">>>积分历史>>> 第 %v 轮", i)
for _, info := range infos {
logger.Logger.Trace("Snid: ", info.copySnid, " grade: ", info.grade, " copyLv: ", info.copyLv, " copyRoleId: ", info.copyRoleId)
}
}
//logger.Logger.Tracef("======积分衰减======当前第 %v 轮============", round)
//for i, infos := range tm.robotGrades {
// logger.Logger.Tracef(">>>积分历史>>> 第 %v 轮", i)
// for _, info := range infos {
// logger.Logger.Trace("Snid: ", info.copySnid, " grade: ", info.grade, " copyLv: ", info.copyLv, " copyRoleId: ", info.copyRoleId)
// }
//}
}

File diff suppressed because it is too large Load Diff

View File

@ -2279,7 +2279,7 @@ func init() {
Creator: s.creator,
Agentor: s.agentor,
ReplayCode: s.replayCode,
Params: s.params,
Params: common.CopySliceInt64ToInt32(s.params),
PlayerCnt: int32(len(s.players) - s.robotNum),
RobotCnt: int32(s.robotNum),
CreateTime: s.createTime.Unix(),