Merge remote-tracking branch 'origin/develop' into ma

# Conflicts:
#	data/DB_GameFree.dat
#	data/DB_PropExchange.dat
#	data/DB_Task.dat
#	etcd/keyconf.go
#	model/config.go
#	protocol/webapi/common.pb.go
#	protocol/webapi/common.proto
#	protocol/webapi/webapi.proto
#	public
#	xlsx/DB_GameFree.xlsx
This commit is contained in:
by 2024-09-03 15:46:11 +08:00
commit 981c3860d1
177 changed files with 16404 additions and 66185 deletions

View File

@ -0,0 +1,45 @@
package common
import (
rawproto "google.golang.org/protobuf/proto"
"mongo.games.com/game/proto"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/netlib"
"mongo.games.com/goserver/srvlib"
"mongo.games.com/goserver/srvlib/protocol"
)
func RegisterBoardCastHandler() {
netlib.Register(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), &protocol.SSPacketBroadcast{}, BroadcastHandler)
}
func BroadcastHandler(s *netlib.Session, packetId int, data interface{}) error {
if bp, ok := data.(*protocol.SSPacketBroadcast); ok {
pd := bp.GetData()
sp := bp.GetSessParam()
if bcss := sp.GetBcss(); bcss != nil {
srvlib.ServerSessionMgrSington.Broadcast(int(bp.GetPacketId()), pd, int(bcss.GetSArea()), int(bcss.GetSType()))
}
}
return nil
}
func CreateBroadcastPacket(sp *protocol.BCSessionUnion, packetId int, data interface{}) (rawproto.Message, error) {
pack := &protocol.SSPacketBroadcast{
SessParam: sp,
PacketId: proto.Int(packetId),
}
if byteData, ok := data.([]byte); ok {
pack.Data = byteData
} else {
byteData, err := netlib.MarshalPacket(packetId, data)
if err == nil {
pack.Data = byteData
} else {
logger.Logger.Warnf("CreateBroadcastPacket err:%v", err)
return nil, err
}
}
return pack, nil
}

View File

@ -1,27 +1,26 @@
package main
package common
import (
"time"
"mongo.games.com/game/common"
"mongo.games.com/goserver/core/module"
)
var ClockMgrSington = &ClockMgr{
var ClockMgrSingleton = &ClockMgr{
LastHour: -1,
LastDay: -1,
Notifying: false,
}
const (
CLOCK_EVENT_SECOND int = iota
CLOCK_EVENT_MINUTE
CLOCK_EVENT_HOUR
CLOCK_EVENT_DAY
CLOCK_EVENT_WEEK
CLOCK_EVENT_MONTH
CLOCK_EVENT_SHUTDOWN
CLOCK_EVENT_MAX
ClockEventSecond int = iota
ClockEventMinute
ClockEventHour
ClockEventDay
ClockEventWeek
ClockEventMonth
ClockEventShutdown
ClockEventMax
)
type ClockSinker interface {
@ -38,7 +37,7 @@ type ClockSinker interface {
type BaseClockSinker struct {
}
func (s *BaseClockSinker) InterestClockEvent() int { return (1 << CLOCK_EVENT_MAX) - 1 }
func (s *BaseClockSinker) InterestClockEvent() int { return (1 << ClockEventMax) - 1 }
func (s *BaseClockSinker) OnSecTimer() {}
func (s *BaseClockSinker) OnMiniTimer() {}
func (s *BaseClockSinker) OnHourTimer() {}
@ -48,7 +47,7 @@ func (s *BaseClockSinker) OnMonthTimer() {}
func (s *BaseClockSinker) OnShutdown() {}
type ClockMgr struct {
sinkers [CLOCK_EVENT_MAX][]ClockSinker
sinkers [ClockEventMax][]ClockSinker
LastTickTime time.Time
LastMonth time.Month
LastWeek int
@ -60,9 +59,9 @@ type ClockMgr struct {
LastFiveMin int
}
func (this *ClockMgr) RegisteSinker(sinker ClockSinker) {
func (this *ClockMgr) RegisterSinker(sinker ClockSinker) {
interest := sinker.InterestClockEvent()
for i := 0; i < CLOCK_EVENT_MAX; i++ {
for i := 0; i < ClockEventMax; i++ {
if (1<<i)&interest != 0 {
found := false
ss := this.sinkers[i]
@ -115,7 +114,7 @@ func (this *ClockMgr) Update() {
this.LastDay = day
this.fireDayEvent()
week := common.GetWeekStartTs(tNow.Unix())
week := GetWeekStartTs(tNow.Unix())
if week != int64(this.LastWeek) {
this.LastWeek = int(week)
this.fireWeekEvent()
@ -138,43 +137,43 @@ func (this *ClockMgr) Shutdown() {
}
func (this *ClockMgr) fireSecondEvent() {
for _, s := range this.sinkers[CLOCK_EVENT_SECOND] {
for _, s := range this.sinkers[ClockEventSecond] {
s.OnSecTimer()
}
}
func (this *ClockMgr) fireMinuteEvent() {
for _, s := range this.sinkers[CLOCK_EVENT_MINUTE] {
for _, s := range this.sinkers[ClockEventMinute] {
s.OnMiniTimer()
}
}
func (this *ClockMgr) fireHourEvent() {
for _, s := range this.sinkers[CLOCK_EVENT_HOUR] {
for _, s := range this.sinkers[ClockEventHour] {
s.OnHourTimer()
}
}
func (this *ClockMgr) fireDayEvent() {
for _, s := range this.sinkers[CLOCK_EVENT_DAY] {
for _, s := range this.sinkers[ClockEventDay] {
s.OnDayTimer()
}
}
func (this *ClockMgr) fireWeekEvent() {
for _, s := range this.sinkers[CLOCK_EVENT_WEEK] {
for _, s := range this.sinkers[ClockEventWeek] {
s.OnWeekTimer()
}
}
func (this *ClockMgr) fireMonthEvent() {
for _, s := range this.sinkers[CLOCK_EVENT_MONTH] {
for _, s := range this.sinkers[ClockEventMonth] {
s.OnMonthTimer()
}
}
func (this *ClockMgr) fireShutdownEvent() {
for _, s := range this.sinkers[CLOCK_EVENT_SHUTDOWN] {
for _, s := range this.sinkers[ClockEventShutdown] {
s.OnShutdown()
}
}
@ -184,5 +183,5 @@ func (this *ClockMgr) GetLast() (int, int, int, int, int, int) {
}
func init() {
module.RegisteModule(ClockMgrSington, time.Millisecond*500, 0)
module.RegisteModule(ClockMgrSingleton, time.Millisecond*500, 0)
}

View File

@ -66,6 +66,10 @@ const (
GameID_Thirteen8 = 212 // 十三张(八人场)
GameID_ThirteenFree = 213 // 十三张(自由场经典场)
GameID_ThirteenFreeLaiZi = 214 // 十三张(自由场癞子场)
GameId_TienLenCustom = 215 // tienlen房卡经典版
GameId_TienLenCustom_yl = 216 // tienlen房卡娱乐版
GameId_TienLenCustom_toend = 217 // tienlen房卡典版打到底
GameId_TienLenCustom_yl_toend = 218 // tienlen房卡娱乐版打到底
__GameId_Slot_Min__ = 300 //################拉霸类################
GameId_CaiShen = 301 // 财神
GameId_Avengers = 302 // 复仇者联盟
@ -73,7 +77,12 @@ const (
GameId_IceAge = 304 // 冰河世纪
GameId_TamQuoc = 305 // 百战成神
GameId_Fruits = 306 // 水果拉霸
GameId_Richblessed = 307 // 多福多财
GameId_Richblessed = 307 // 多福
GameId_FortuneTiger = 308 // FortuneTiger
GameId_FortuneDragon = 309 // FortuneDragon
GameId_FortuneRabbit = 310 // FortuneRabbit
GameId_FortuneOx = 311 // FortuneOx
GameId_FortuneMouse = 312 // FortuneMouse
__GameId_Fishing_Min__ = 400 //################捕鱼类################
GameId_HFishing = 401 //欢乐捕鱼
GameId_TFishing = 402 //天天捕鱼
@ -89,7 +98,7 @@ const (
GameId_Clawdoll = 608 // 娃娃机
__GameId_ThrGame_Min__ = 700 //################三方类################
GameId_Thr_Dg = 701 //DG Game
GameId_Thr_XHJ = 901 //DG Game
GameId_Thr_XHJ = 901 ///DG Game
)
const (
@ -116,7 +125,9 @@ func IsTienLenYuLe(gameId int) bool {
GameId_TienLenSelect_yl,
GameId_TienLenRank_yl,
GameId_TienLenSelect_yl_toend,
GameId_TienLenRank_yl_toend:
GameId_TienLenRank_yl_toend,
GameId_TienLenCustom_yl,
GameId_TienLenCustom_yl_toend:
return true
}
return false
@ -131,7 +142,9 @@ func IsTienLenToEnd(gameId int) bool {
GameId_TienLenSelect_toend,
GameId_TienLenSelect_yl_toend,
GameId_TienLenRank_toend,
GameId_TienLenRank_yl_toend:
GameId_TienLenRank_yl_toend,
GameId_TienLenCustom_toend,
GameId_TienLenCustom_yl_toend:
return true
}
return false
@ -163,8 +176,8 @@ func IsDaZhong(gameId int) bool {
// 房间编号区间
const (
PrivateSceneStartId = 10000000
PrivateSceneMaxId = 99999999
PrivateSceneStartId = 100000
PrivateSceneMaxId = 999999
MatchSceneStartId = 100000000
MatchSceneMaxId = 199999999
HundredSceneStartId = 200000000
@ -301,6 +314,8 @@ const (
GainWayItemFenGain = 103 // 道具分解获得
GainWayGuide = 104 //新手引导奖励
GainWayVipGift9 = 105 //vip等级礼包
GainWayRoomCost = 106 //房费消耗
GainWayRoomGain = 107 //房卡场获得
)
// 后台选择 金币变化类型 的充值 类型id号起始
@ -853,3 +868,42 @@ const (
On = 1 // 开启
Off = 2 // 关闭
)
const (
DataConfigAll = 0 // 全部配置
DataConfigSprite = 1 // 精灵配置
DataConfigMatchAudience = 2 // 赛事观战开关
)
// 房间状态
const (
SceneStateWaite = 0 // 等待
SceneStateStart = 1 // 开始
SceneStateEnd = 2 // 结束
)
const (
// PlayerHistoryModel .
PlayerHistoryModel = iota + 1
// BIGWIN_HISTORY_MODEL .
BIGWIN_HISTORY_MODEL
// GameHistoryModel .
GameHistoryModel
)
type ListOpType int // 列表操作类型
const (
ListModify ListOpType = 1 // 修改
ListAdd ListOpType = 2 // 增加
ListDel ListOpType = 3 // 减少
ListFind ListOpType = 4 // 查询
)
type NotifyType int // 通知类型
const (
NotifyPrivateRoomList NotifyType = 1 // 私人房间列表
)

View File

@ -0,0 +1,50 @@
package common
import (
rawproto "google.golang.org/protobuf/proto"
"mongo.games.com/game/proto"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/netlib"
"mongo.games.com/goserver/srvlib"
"mongo.games.com/goserver/srvlib/protocol"
)
func RegisterMulticastHandler() {
netlib.Register(int(protocol.SrvlibPacketID_PACKET_SS_MULTICAST), &protocol.SSPacketMulticast{}, MulticastHandler)
}
func MulticastHandler(s *netlib.Session, packetId int, data interface{}) error {
if mp, ok := data.(*protocol.SSPacketMulticast); ok {
pd := mp.GetData()
sis := mp.GetSessions()
for _, si := range sis {
ss := si.GetMcss()
if ss != nil {
ns := srvlib.ServerSessionMgrSington.GetSession(int(ss.GetSArea()), int(ss.GetSType()), int(ss.GetSId()))
if ns != nil {
ns.Send(int(mp.GetPacketId()), pd /*, s.GetSessionConfig().IsInnerLink*/)
}
}
}
}
return nil
}
func CreateMulticastPacket(packetId int, data interface{}, sis ...*protocol.MCSessionUnion) (rawproto.Message, error) {
pack := &protocol.SSPacketMulticast{
Sessions: sis,
PacketId: proto.Int(packetId),
}
if byteData, ok := data.([]byte); ok {
pack.Data = byteData
} else {
byteData, err := netlib.MarshalPacket(packetId, data)
if err == nil {
pack.Data = byteData
} else {
logger.Logger.Errorf("CreateMulticastPacket err:%v", err)
return nil, err
}
}
return pack, nil
}

View File

@ -452,6 +452,22 @@ func SliceValueWeight(sl []int, index int) float64 {
return float64(value) / float64(totle)
}
func GetMapKeys[K comparable, V any](data map[K]V) []K {
var ret []K
for k := range data {
ret = append(ret, k)
}
return ret
}
func GetMapValues[K comparable, V any](data map[K]V) []V {
var ret []V
for _, v := range data {
ret = append(ret, v)
}
return ret
}
type Int32Slice []int32
func (p Int32Slice) Len() int { return len(p) }

Binary file not shown.

View File

@ -3424,6 +3424,106 @@
"BetWaterRate": 100,
"IsDrop": 1
},
{
"Id": 2150001,
"Name": "tienlen房卡经典",
"Title": "房卡场",
"GameId": 215,
"GameRule": 21500,
"GameType": 2,
"SceneType": 1,
"Desc": "0",
"ShowType": 3,
"BaseScore": 10,
"BetDec": "10",
"Ai": [
0
],
"OtherIntParams": [
0
],
"GameDif": "207",
"GameClass": 1,
"PlatformName": "越南棋牌",
"PlayerWaterRate": 100,
"BetWaterRate": 100,
"IsCustom": 1
},
{
"Id": 2160001,
"Name": "tienlen房卡娱乐",
"Title": "房卡场",
"GameId": 216,
"GameRule": 21600,
"GameType": 2,
"SceneType": 1,
"Desc": "0",
"ShowType": 3,
"BaseScore": 10,
"BetDec": "10",
"Ai": [
0
],
"OtherIntParams": [
0
],
"GameDif": "207",
"GameClass": 1,
"PlatformName": "越南棋牌",
"PlayerWaterRate": 100,
"BetWaterRate": 100,
"IsCustom": 1
},
{
"Id": 2170001,
"Name": "tienlen房卡经典打到底",
"Title": "房卡场",
"GameId": 217,
"GameRule": 21700,
"GameType": 2,
"SceneType": 1,
"Desc": "0",
"ShowType": 3,
"BaseScore": 10,
"BetDec": "10",
"Ai": [
0
],
"OtherIntParams": [
0
],
"GameDif": "207",
"GameClass": 1,
"PlatformName": "越南棋牌",
"PlayerWaterRate": 100,
"BetWaterRate": 100,
"IsCustom": 1
},
{
"Id": 2180001,
"Name": "tienlen房卡娱乐打到底",
"Title": "房卡场",
"GameId": 218,
"GameRule": 21800,
"GameType": 2,
"SceneType": 1,
"Desc": "0",
"ShowType": 3,
"BaseScore": 10,
"BetDec": "10",
"Ai": [
0
],
"OtherIntParams": [
0
],
"GameDif": "207",
"GameClass": 1,
"PlatformName": "越南棋牌",
"PlayerWaterRate": 100,
"BetWaterRate": 100,
"IsCustom": 1
},
{
"Id": 8070001,
"Name": "Tienlen经典",
@ -6437,6 +6537,171 @@
"PlayerWaterRate": 100,
"BetWaterRate": 100
},
{
"Id": 3080001,
"Name": "FortuneTiger",
"Title": "1",
"GameId": 308,
"GameRule": 30800,
"GameType": 3,
"SceneType": 1,
"Desc": "0",
"ShowType": 2,
"ShowId": 30800,
"BaseScore": 1000,
"Turn": 30800,
"BetDec": "1000",
"Ai": [
0
],
"OtherIntParams": [
0
],
"RobotNumRng": [
0
],
"SameIpLimit": 1,
"GameDif": "308",
"GameClass": 2,
"PlatformName": "越南棋牌",
"MaxBetCoin": [
0
],
"PlayerWaterRate": 100,
"BetWaterRate": 100
},
{
"Id": 3090001,
"Name": "FortuneDragon",
"Title": "1",
"GameId": 309,
"GameRule": 30900,
"GameType": 3,
"SceneType": 1,
"Desc": "0",
"ShowType": 2,
"ShowId": 30900,
"BaseScore": 1000,
"Turn": 30900,
"BetDec": "1000",
"Ai": [
0
],
"OtherIntParams": [
0
],
"RobotNumRng": [
0
],
"SameIpLimit": 1,
"GameDif": "309",
"GameClass": 2,
"PlatformName": "越南棋牌",
"MaxBetCoin": [
0
],
"PlayerWaterRate": 100,
"BetWaterRate": 100
},
{
"Id": 3100001,
"Name": "FortuneRabbit",
"Title": "1",
"GameId": 310,
"GameRule": 31000,
"GameType": 3,
"SceneType": 1,
"Desc": "0",
"ShowType": 2,
"ShowId": 31000,
"BaseScore": 1000,
"Turn": 31000,
"BetDec": "1000",
"Ai": [
0
],
"OtherIntParams": [
0
],
"RobotNumRng": [
0
],
"SameIpLimit": 1,
"GameDif": "310",
"GameClass": 2,
"PlatformName": "越南棋牌",
"MaxBetCoin": [
0
],
"PlayerWaterRate": 100,
"BetWaterRate": 100
},
{
"Id": 3110001,
"Name": "FortuneOx",
"Title": "1",
"GameId": 311,
"GameRule": 31100,
"GameType": 3,
"SceneType": 1,
"Desc": "0",
"ShowType": 2,
"ShowId": 31100,
"BaseScore": 1000,
"Turn": 31100,
"BetDec": "1000",
"Ai": [
0
],
"OtherIntParams": [
0
],
"RobotNumRng": [
0
],
"SameIpLimit": 1,
"GameDif": "311",
"GameClass": 2,
"PlatformName": "越南棋牌",
"MaxBetCoin": [
0
],
"PlayerWaterRate": 100,
"BetWaterRate": 100
},
{
"Id": 3120001,
"Name": "FortuneMouse",
"Title": "1",
"GameId": 312,
"GameRule": 31200,
"GameType": 3,
"SceneType": 1,
"Desc": "0",
"ShowType": 2,
"ShowId": 31200,
"BaseScore": 1000,
"Turn": 31200,
"BetDec": "1000",
"Ai": [
0
],
"OtherIntParams": [
0
],
"RobotNumRng": [
0
],
"SameIpLimit": 1,
"GameDif": "312",
"GameClass": 2,
"PlatformName": "越南棋牌",
"MaxBetCoin": [
0
],
"PlayerWaterRate": 100,
"BetWaterRate": 100
},
{
"Id": 6080001,
"Name": "娃娃机",

Binary file not shown.

View File

@ -435,6 +435,72 @@
"Location": "0",
"Describe": "作用:用于报名冠军赛事;\n产出途径参加任意锦标赛获得冠军\n"
},
{
"Id": 40002,
"Name": "房卡",
"ShowLocation": [
1,
1
],
"Classify": [
1,
1,
0
],
"Type": 24,
"Effect0": [
0,
0,
0,
0,
0
],
"Effect": [
0,
0,
0,
0,
0
],
"SaleGold": 10000,
"Composition": 1,
"CompositionMax": 9999,
"Location": "0",
"Describe": "作用:用于参与竞技馆内玩法;\n产出途径商城购买\n"
},
{
"Id": 40003,
"Name": "娃娃卡",
"ShowLocation": [
1,
1
],
"Classify": [
1,
1,
0
],
"Type": 23,
"Effect0": [
0,
0,
0,
0,
0
],
"Effect": [
0,
0,
0,
0,
0
],
"SaleGold": 10000,
"Composition": 1,
"CompositionMax": 9999,
"Location": "0",
"Describe": "作用:用于抓娃娃机抓娃娃;\n产出途径商城购买\n"
},
{
"Id": 50001,
"Name": "碎片礼盒",

Binary file not shown.

View File

@ -10,43 +10,43 @@
"Id": 20800,
"Name": "Tienlen自由桌娱乐场-WTA",
"GameId": 208,
"GameDif": "208"
"GameDif": "207"
},
{
"Id": 20900,
"Name": "Tienlen自由桌经典场(打到底)",
"GameId": 209,
"GameDif": "209"
"GameDif": "207"
},
{
"Id": 21000,
"Name": "Tienlen自由桌娱乐场(打到底)",
"GameId": 210,
"GameDif": "210"
"GameDif": "207"
},
{
"Id": 24000,
"Name": "Tienlen经典场-WTA",
"GameId": 240,
"GameDif": "240"
"GameDif": "207"
},
{
"Id": 24400,
"Name": "Tienlen经典场打到底",
"GameId": 244,
"GameDif": "244"
"GameDif": "207"
},
{
"Id": 24100,
"Name": "Tienlen娱乐场-WTA",
"GameId": 241,
"GameDif": "241"
"GameDif": "207"
},
{
"Id": 24500,
"Name": "tienlen娱乐版打到底",
"GameId": 245,
"GameDif": "245"
"GameDif": "207"
},
{
"Id": 40100,
@ -64,14 +64,14 @@
"Id": 52200,
"Name": "ChessCambodianRobot",
"GameId": 522,
"GameDif": "522"
"GameDif": "521"
},
{
"Id": 21100,
"Name": "十三张(四人场)",
"GameId": 211,
"Params": [
0,
4,
0,
30,
50,
@ -84,20 +84,20 @@
"Name": "十三张(八人场)",
"GameId": 212,
"Params": [
1,
8,
0,
30,
50,
0
],
"GameDif": "212"
"GameDif": "211"
},
{
"Id": 21300,
"Name": "十三张(自由场经典场)",
"GameId": 213,
"Params": [
1,
8,
0,
30,
50,
@ -110,7 +110,7 @@
"Name": "十三张(自由场癞子场)",
"GameId": 214,
"Params": [
1,
8,
0,
30,
50,
@ -122,25 +122,49 @@
"Id": 24200,
"Name": "Tienlen排位赛经典场-WTA",
"GameId": 242,
"GameDif": "242"
"GameDif": "207"
},
{
"Id": 24600,
"Name": "Tienlen排位赛经典场打到底",
"GameId": 246,
"GameDif": "246"
"GameDif": "207"
},
{
"Id": 24300,
"Name": "Tienlen排位赛娱乐场-WTA",
"GameId": 243,
"GameDif": "243"
"GameDif": "207"
},
{
"Id": 24700,
"Name": "tienlen排位赛娱乐打到底",
"GameId": 247,
"GameDif": "247"
"GameDif": "207"
},
{
"Id": 21500,
"Name": "tienlen房卡经典",
"GameId": 215,
"GameDif": "207"
},
{
"Id": 21600,
"Name": "tienlen房卡娱乐",
"GameId": 216,
"GameDif": "207"
},
{
"Id": 21700,
"Name": "tienlen房卡经典打到底",
"GameId": 217,
"GameDif": "207"
},
{
"Id": 21800,
"Name": "tienlen房卡娱乐打到底",
"GameId": 218,
"GameDif": "207"
},
{
"Id": 60600,
@ -196,10 +220,41 @@
"GameId": 307,
"GameDif": "307"
},
{
"Id": 30800,
"Name": "FortuneTiger",
"GameId": 308,
"GameDif": "308"
},
{
"Id": 30900,
"Name": "FortuneDragon",
"GameId": 309,
"GameDif": "309"
},
{
"Id": 31000,
"Name": "FortuneRabbit",
"GameId": 310,
"GameDif": "310"
},
{
"Id": 31100,
"Name": "FortuneOx",
"GameId": 311,
"GameDif": "311"
},
{
"Id": 31200,
"Name": "FortuneMouse",
"GameId": 312,
"GameDif": "312"
},
{
"Id": 60800,
"Name": "娃娃机",
"GameId": 608
"GameId": 608,
"GameDif": "608"
}
]
}

Binary file not shown.

Binary file not shown.

View File

@ -45,9 +45,9 @@
"SkinPic": "icon_300003",
"SkinName": "活力-粉",
"SkinType": "mg_02",
"UnlockType": 3,
"UnlockType": 2,
"UnlockItem": {
"5": 0
"310003": 20
},
"SkinSkillName": "活力满满",
"SkinSkillIcon": "SkillIcon-30003",
@ -66,9 +66,9 @@
"SkinPic": "icon_300004",
"SkinName": "活力-青",
"SkinType": "mg_03",
"UnlockType": 3,
"UnlockType": 2,
"UnlockItem": {
"2": 0
"310004": 20
},
"SkinSkillName": "金币满满",
"SkinSkillIcon": "SkillIcon-30004",

Binary file not shown.

Binary file not shown.

View File

@ -30,10 +30,9 @@
"更多VIP功能正待开发"
],
"Privilege9": [
0,
0
],
"PrivilegeShow": 1000
"PrivilegeShow": 100
},
{
"Id": 1,
@ -70,6 +69,7 @@
],
"MatchFreeTimes": 1,
"Privilege9": [
0,
0,
0
],
@ -110,6 +110,8 @@
],
"MatchFreeTimes": 2,
"Privilege9": [
0,
0,
0,
0
],
@ -150,6 +152,7 @@
],
"MatchFreeTimes": 3,
"Privilege9": [
0,
0,
0
],
@ -190,6 +193,7 @@
],
"MatchFreeTimes": 4,
"Privilege9": [
0,
0,
0
],
@ -230,6 +234,8 @@
],
"MatchFreeTimes": 5,
"Privilege9": [
0,
0,
0,
0
],
@ -270,6 +276,7 @@
],
"MatchFreeTimes": 6,
"Privilege9": [
0,
0,
0
],
@ -310,6 +317,7 @@
],
"MatchFreeTimes": 7,
"Privilege9": [
0,
0,
0
],
@ -350,6 +358,7 @@
],
"MatchFreeTimes": 8,
"Privilege9": [
0,
0,
0
],
@ -390,6 +399,7 @@
],
"MatchFreeTimes": 9,
"Privilege9": [
0,
0,
0
],
@ -430,6 +440,7 @@
],
"MatchFreeTimes": 10,
"Privilege9": [
0,
0,
0
],
@ -470,6 +481,7 @@
],
"MatchFreeTimes": 11,
"Privilege9": [
0,
0,
0
],
@ -510,6 +522,7 @@
],
"MatchFreeTimes": 12,
"Privilege9": [
0,
0,
0
],
@ -550,6 +563,7 @@
],
"MatchFreeTimes": 13,
"Privilege9": [
0,
0,
0
],
@ -590,6 +604,7 @@
],
"MatchFreeTimes": 14,
"Privilege9": [
0,
0,
0
],
@ -630,6 +645,7 @@
],
"MatchFreeTimes": 15,
"Privilege9": [
0,
0,
0
],
@ -670,6 +686,7 @@
],
"MatchFreeTimes": 16,
"Privilege9": [
0,
0,
0
],

View File

@ -1,3 +1,7 @@


ä§*
VIPShow.t1
ã§ *
VIPShow.t2
ц *
VIPShow.t3

View File

@ -2,12 +2,23 @@
"Arr": [
{
"Id": 1,
"SkinId": 300003
"Type": 1,
"SkinId": 300004,
"VIPDes": "VIPShow.t1"
},
{
"Id": 2,
"SkinId": 300004,
"VIPLevel": 3
"Type": 1,
"SkinId": 300003,
"VIPLevel": 3,
"VIPDes": "VIPShow.t2"
},
{
"Id": 3,
"Type": 2,
"SkinId": 50001,
"VIPLevel": 6,
"VIPDes": "VIPShow.t3"
}
]
}

View File

@ -0,0 +1,10 @@
{
"GameName":"dragon",
"GameId":309,
"GameMode":[0],
"SceneType":[1,2,3,4],
"CanForceStart":true,
"DefaultPlayerCnt":1,
"DependentPlayerCnt":true,
"EnterAfterStart":true
}

View File

@ -0,0 +1,10 @@
{
"GameName":"mouse",
"GameId":312,
"GameMode":[0],
"SceneType":[1,2,3,4],
"CanForceStart":true,
"DefaultPlayerCnt":1,
"DependentPlayerCnt":true,
"EnterAfterStart":true
}

View File

@ -0,0 +1,10 @@
{
"GameName":"ox",
"GameId":311,
"GameMode":[0],
"SceneType":[1,2,3,4],
"CanForceStart":true,
"DefaultPlayerCnt":1,
"DependentPlayerCnt":true,
"EnterAfterStart":true
}

View File

@ -0,0 +1,10 @@
{
"GameName":"rabbit",
"GameId":310,
"GameMode":[0],
"SceneType":[1,2,3,4],
"CanForceStart":true,
"DefaultPlayerCnt":1,
"DependentPlayerCnt":true,
"EnterAfterStart":true
}

View File

@ -0,0 +1,10 @@
{
"GameName":"tiger",
"GameId":308,
"GameMode":[0],
"SceneType":[1,2,3,4],
"CanForceStart":true,
"DefaultPlayerCnt":1,
"DependentPlayerCnt":true,
"EnterAfterStart":true
}

View File

@ -12,6 +12,7 @@
"DependentPlayerCnt":true,
"EnterAfterStart":true,
"PerGameTakeCard":100,
"BaseScore": 10,
"Params":[
]
}

View File

@ -12,6 +12,7 @@
"DependentPlayerCnt":true,
"EnterAfterStart":true,
"PerGameTakeCard":100,
"BaseScore": 10,
"Params":[
]
}

View File

@ -0,0 +1,13 @@
{
"GameName":"tienlen房卡经典",
"GameId":215,
"GameMode":[0],
"SceneType":[1],
"CanForceStart":true,
"MinPlayerCnt":2,
"DefaultPlayerCnt":4,
"TimeFreeStart":0,
"TimeFreeEnd":0,
"DependentPlayerCnt":true,
"EnterAfterStart":false
}

View File

@ -0,0 +1,13 @@
{
"GameName":"tienlen房卡经典打到底",
"GameId":217,
"GameMode":[0],
"SceneType":[1],
"CanForceStart":true,
"MinPlayerCnt":2,
"DefaultPlayerCnt":4,
"TimeFreeStart":0,
"TimeFreeEnd":0,
"DependentPlayerCnt":true,
"EnterAfterStart":false
}

View File

@ -0,0 +1,13 @@
{
"GameName":"tienlen房卡娱乐",
"GameId":216,
"GameMode":[0],
"SceneType":[1],
"CanForceStart":true,
"MinPlayerCnt":2,
"DefaultPlayerCnt":4,
"TimeFreeStart":0,
"TimeFreeEnd":0,
"DependentPlayerCnt":true,
"EnterAfterStart":false
}

View File

@ -0,0 +1,13 @@
{
"GameName":"tienlen房卡娱乐打到底",
"GameId":218,
"GameMode":[0],
"SceneType":[1],
"CanForceStart":true,
"MinPlayerCnt":2,
"DefaultPlayerCnt":4,
"TimeFreeStart":0,
"TimeFreeEnd":0,
"DependentPlayerCnt":true,
"EnterAfterStart":false
}

View File

@ -6,7 +6,7 @@
"VerifyClientVersion":true,
"SrvMaintain":false,
"WhiteHttpAddr": [],
"HundredScenePreCreate":true,
"HundredScenePreCreate":false,
"WriteEventLog": true,
"SpreadAccountQPT":100,
"FakeVerifyCode":"123456",
@ -23,6 +23,7 @@
"ClosePreCreateRoom": true,
"AgoraAddress": "http://47.105.78.29:8081",
"InviteUrl": "http://47.105.78.29:8000/",
"GuideTs": 1723790567,
"RankTimeout": 2,
"PermitInitScore": 0
}

36
dbproxy/mq/c_customlog.go Normal file
View File

@ -0,0 +1,36 @@
package mq
import (
"encoding/json"
"mongo.games.com/goserver/core/broker"
"mongo.games.com/goserver/core/broker/rabbitmq"
"mongo.games.com/game/dbproxy/svc"
"mongo.games.com/game/model"
"mongo.games.com/game/mq"
)
func init() {
mq.RegisterSubscriber(mq.DBCustomLog, func(e broker.Event) (err error) {
msg := e.Message()
if msg != nil {
defer func() {
e.Ack()
}()
var log model.CustomLog
err = json.Unmarshal(msg.Body, &log)
if err != nil {
return
}
c := svc.DbCustomLogCollection(log.Platform)
if c != nil {
err = c.Insert(log)
}
return
}
return nil
}, broker.Queue(mq.DBCustomLog), broker.DisableAutoAck(), rabbitmq.DurableQueue())
}

View File

@ -0,0 +1,25 @@
package svc
import (
"github.com/globalsign/mgo"
"mongo.games.com/game/dbproxy/mongo"
"mongo.games.com/game/model"
)
func DbCustomLogCollection(plt string) *mongo.Collection {
s := mongo.MgoSessionMgrSington.GetPltMgoSession(plt, model.DbCustomLogDBName)
if s != nil {
d, first := s.DB().C(model.DbCustomLogCollName)
if first {
d.EnsureIndex(mgo.Index{Key: []string{"cycleid"}, Background: true, Sparse: true})
d.EnsureIndex(mgo.Index{Key: []string{"-startts", "cycleid"}, Background: true, Sparse: true})
d.EnsureIndex(mgo.Index{Key: []string{"roomconfigid"}, Background: true, Sparse: true})
d.EnsureIndex(mgo.Index{Key: []string{"roomid"}, Background: true, Sparse: true})
d.EnsureIndex(mgo.Index{Key: []string{"startts"}, Background: true, Sparse: true})
d.EnsureIndex(mgo.Index{Key: []string{"endts"}, Background: true, Sparse: true})
d.EnsureIndex(mgo.Index{Key: []string{"-endts"}, Background: true, Sparse: true})
}
return d
}
return nil
}

View File

@ -28,6 +28,8 @@ func GameDetailedLogsCollection(plt string) *mongo.Collection {
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"matchid"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"-ts", "gameid"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"-ts", "gamefreeid"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"-ts", "cycleid"}, Background: true, Sparse: true})
c_gamedetailed.EnsureIndex(mgo.Index{Key: []string{"cycleid"}, Background: true, Sparse: true})
}
return c_gamedetailed
}

View File

@ -41,6 +41,8 @@ func GamePlayerListLogsCollection(plt string) *mongo.Collection {
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts", "gamefreeid"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts", "snid", "gameid"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts", "snid", "gamefreeid"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"-ts", "cycleid"}, Background: true, Sparse: true})
c_gameplayerlistlog.EnsureIndex(mgo.Index{Key: []string{"cycleid"}, Background: true, Sparse: true})
}
return c_gameplayerlistlog
}

View File

@ -26,6 +26,8 @@ func ItemLogsCollection(plt string) *mongo.Collection {
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"gameid"}, Background: true, Sparse: true})
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"gamefreeid"}, Background: true, Sparse: true})
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"snid", "logtype", "itemid", "typeid"}, Background: true, Sparse: true})
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"roomconfigid"}, Background: true, Sparse: true})
c_itemlog.EnsureIndex(mgo.Index{Key: []string{"typeid", "roomconfigid"}, Background: true, Sparse: true})
}
return c_itemlog
}

View File

@ -156,10 +156,12 @@ func upJybUser(cjybuse, cjyb *mongo.Collection, snId, codeType int32, plt, useCo
if jybuser.JybInfos == nil {
jybuser.JybInfos = make(map[string]int32)
} else if _, exist := jybuser.JybInfos[jybuseerid]; exist { // 该类型礼包玩家已经领取过
return model.ErrJYBPlCode
if ret.CodeType != 3 {
return model.ErrJYBPlCode
}
}
jybuser.JybInfos[jybuseerid] = 1
jybuser.JybInfos[jybuseerid]++
err = cjybuse.Update(bson.M{"_id": jybuser.JybUserId}, bson.D{{"$set", bson.D{{"jybinfos", jybuser.JybInfos}}}})
if err != nil {

View File

@ -2,17 +2,26 @@ package svc
import (
"errors"
"net/rpc"
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/dbproxy/mongo"
"mongo.games.com/game/model"
"net/rpc"
)
var (
MatchAwardLogDBErr = errors.New("log_matchawardlog db open failed.")
MatchAwardDBErr = errors.New("log_matchawardlog db open failed")
)
func MatchAwardLogCollection(plt string) *mongo.Collection {
type MatchAwardLog struct {
AwardNum map[string]map[int32]int32 // 奖励数量
Platform string
}
func MatchAwardCollection(plt string) *mongo.Collection {
s := mongo.MgoSessionMgrSington.GetPltMgoSession(plt, model.MatchAwardLogDBName)
if s != nil {
c, _ := s.DB().C(model.MatchAwardLogCollName)
@ -21,47 +30,55 @@ func MatchAwardLogCollection(plt string) *mongo.Collection {
return nil
}
func InsertOrUpdateMatchAwardLog(logs ...*model.MatchAwardLog) (err error) {
for _, log := range logs {
clog := MatchAwardLogCollection(log.Platform)
if clog == nil {
return
}
_, err = clog.Upsert(nil, log)
if err != nil {
// 处理错误
return err
}
}
return
type MatchAwardSvc struct {
}
type MatchAwardLogSvc struct {
}
func (svc *MatchAwardSvc) UpsertMatchAward(req *model.MatchAward, ret *bool) (err error) {
c := MatchAwardCollection(req.Platform)
if c == nil {
return MatchAwardDBErr
}
func (svc *MatchAwardLogSvc) InsertOrUpdateMatchAwardLog(args []*model.MatchAwardLog, ret *bool) (err error) {
err = InsertOrUpdateMatchAwardLog(args...)
if err == nil {
*ret = true
}
return
}
func GetMatchAward(plt string, ret *model.MatchAwardLog) (err error) {
clog := MatchAwardLogCollection(plt)
if clog == nil {
return nil
}
selecter := bson.M{"platform": plt}
err = clog.Find(selecter).One(&ret)
_, err = c.Upsert(nil, req)
if err != nil {
return nil
logger.Logger.Errorf("UpsertMatchAward err:%v", err)
}
return
}
func (svc *MatchAwardLogSvc) GetMatchAward(Plt string, ret *model.MatchAwardLog) (err error) {
err = GetMatchAward(Plt, ret)
return err
}
func init() {
rpc.Register(new(MatchAwardLogSvc))
func (svc *MatchAwardSvc) GetMatchAward(plt string, ret *model.MatchAward) (err error) {
c := MatchAwardCollection(plt)
if c == nil {
return MatchAwardDBErr
}
// 旧数据
old := &MatchAwardLog{}
err = c.Find(bson.M{"platform": "1"}).One(old)
if err == nil {
for k, v := range old.AwardNum {
d := &model.MatchAward{
Platform: k,
Award: make(map[int32]int32),
}
for kk, vv := range v {
d.Award[kk] = vv
}
var b bool
svc.UpsertMatchAward(d, &b)
}
c.Remove(bson.M{"platform": "1"})
}
// 旧数据
err = nil
err = c.Find(nil).One(ret)
if err != nil && err != mgo.ErrNotFound {
logger.Logger.Errorf("GetMatchAward err:%v", err)
}
return err
}
func init() {
rpc.Register(new(MatchAwardSvc))
}

View File

@ -0,0 +1,71 @@
package svc
import (
"errors"
"net/rpc"
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
"mongo.games.com/game/dbproxy/mongo"
"mongo.games.com/game/model"
)
var (
PlayerGameDataDBName = "user"
PlayerGameDataCollName = "user_gamedata"
PlayerGameDataColError = errors.New("PlayerGameData collection open failed")
PlayerGameDataSvcSingle = &PlayerGameDataSvc{}
)
func PlayerGameDataCollection(plt string) *mongo.Collection {
s := mongo.MgoSessionMgrSington.GetPltMgoSession(plt, PlayerGameDataDBName)
if s != nil {
c, first := s.DB().C(PlayerGameDataCollName)
if first {
c.EnsureIndex(mgo.Index{Key: []string{"snid", "id"}, Unique: true, Background: true, Sparse: true})
c.EnsureIndex(mgo.Index{Key: []string{"id"}, Background: true, Sparse: true})
}
return c
}
return nil
}
func init() {
rpc.Register(PlayerGameDataSvcSingle)
}
type PlayerGameDataSvc struct{}
func (p *PlayerGameDataSvc) Save(req *model.PlayerGameSaveReq, b *bool) error {
c := PlayerGameDataCollection(req.Platform)
if c == nil {
return PlayerGameDataColError
}
for _, v := range req.Data {
_, err := c.Upsert(bson.M{"snid": v.SnId, "id": v.Id}, v)
if err != nil {
return err
}
}
*b = true
return nil
}
func (p *PlayerGameDataSvc) Find(req *model.PlayerGameDataFindReq, res *model.PlayerGameDataFindRes) error {
c := PlayerGameDataCollection(req.Platform)
if c == nil {
return PlayerGameDataColError
}
var ret []*model.PlayerGameData
err := c.Find(bson.M{"snid": req.SnId}).All(&ret)
if err != nil {
return err
}
res.Data = ret
return nil
}

View File

@ -40,5 +40,8 @@ const (
ETCDKEY_AWARD_CONFIG = "/game/awardlog_config" //获奖记录
ETCDKEY_GUIDE = "/game/guide_config" //新手引导配置
ETCDKEY_MACHINE = "/game/machine_config" //娃娃机配置
ETCDKEY_MatchAudience = "/game/match_audience" //比赛观众
ETCDKEY_Spirit = "/game/spirit" // 小精灵配置
ETCDKEY_RoomType = "/game/room_type" // 房间类型配置
ETCDKEY_RoomConfig = "/game/room_config" // 房间配置
)

View File

@ -18,6 +18,7 @@ import (
// key:监听的key
// msgType:数据类型
// f:数据变更回调方法, completeKey:完整键, isInit:第一次主动拉取数据,event:事件类型, data:已经反序列化的数据类型为msgType,是指针类型
// **isInit** 为true时表示是第一次主动拉取数据此时允许耗时操作。为false时表示是监听到数据变更此时不允许耗时操作。
func Register(key string, msgType interface{}, f func(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{})) {
createFunc := func() interface{} {
tp := reflect.TypeOf(msgType)

View File

@ -29,6 +29,7 @@ const (
TIenLenTianhuTimeout = time.Second * 2 // 天胡动画时长
TienLenHandNotExceedTimeLimit = time.Second * 3 //玩家没有牌可以接上家的牌,出牌时间上限
TienLenHandAutoStateTimeOut = time.Second * 1 //玩家托管出牌时间上限
TienLenCustomWaiteStatTimeout = time.Millisecond * 1500
)
// 场景状态

View File

@ -42,6 +42,10 @@ func (this *CSDestroyRoomHandler) Process(s *netlib.Session, packetid int, data
logger.Logger.Warn("CSDestroyRoomHandler s.creator != p.AccountId")
return nil
}
// 房卡场开始后不能解散
if scene.IsCustom() && scene.NumOfGames > 0 {
return nil
}
scene.Destroy(true)
return nil
}
@ -79,7 +83,7 @@ func (this *CSLeaveRoomHandler) Process(s *netlib.Session, packetid int, data in
logger.Logger.Warnf("CSLeaveRoomHandler[%v][%v] scene.gaming==true", scene.SceneId, p.SnId)
pack := &gamehall.SCLeaveRoom{
OpRetCode: gamehall.OpResultCode_Game_OPRC_YourAreGamingCannotLeave_Game,
RoomId: proto.Int(scene.SceneId),
RoomId: scene.SceneId,
}
proto.SetDefaults(pack)
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_LEAVEROOM), pack)
@ -96,7 +100,7 @@ func (this *CSLeaveRoomHandler) Process(s *netlib.Session, packetid int, data in
Reason: proto.Int(0),
OpRetCode: gamehall.OpResultCode_Game_OPRC_Sucess_Game,
Mode: msg.Mode,
RoomId: proto.Int(scene.SceneId),
RoomId: scene.SceneId,
}
proto.SetDefaults(pack)
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_LEAVEROOM), pack)
@ -289,10 +293,48 @@ func CSRoomEvent(s *netlib.Session, packetid int, data interface{}, sid int64) e
return nil
}
func CSDestroyRoom(s *netlib.Session, packetid int, data interface{}, sid int64) error {
logger.Logger.Trace("CSDestroyRoomHandler Process recv ", data)
p := base.PlayerMgrSington.GetPlayer(sid)
if p == nil {
logger.Logger.Warn("CSDestroyRoomHandler p == nil")
return nil
}
scene := p.GetScene()
if scene == nil {
logger.Logger.Warn("CSDestroyRoomHandler p.GetScene() == nil")
return nil
}
if !scene.HasPlayer(p) {
return nil
}
pack := &gamehall.SCDestroyRoom{
RoomId: scene.SceneId,
OpRetCode: gamehall.OpResultCode_Game_OPRC_Error_Game,
}
send := func() {
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_DESTROYROOM), pack)
logger.Logger.Tracef("SCDestroyRoom: %v", pack)
}
if scene.Creator != p.SnId {
logger.Logger.Warn("CSDestroyRoomHandler s.creator != p.AccountId")
send()
return nil
}
// 房卡场开始后不能解散
if scene.IsCustom() && scene.NumOfGames > 0 {
send()
return nil
}
scene.Destroy(true)
return nil
}
func init() {
// 房间创建者解散房间
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_DESTROYROOM), &CSDestroyRoomHandler{})
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_DESTROYROOM), &CSDestroyRoomPacketFactory{})
common.Register(int(gamehall.GameHallPacketID_PACKET_CS_DESTROYROOM), &gamehall.CSDestroyRoom{}, CSDestroyRoom)
// 离开或暂离房间
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_LEAVEROOM), &CSLeaveRoomHandler{})

View File

@ -38,73 +38,57 @@ func HandleWGBuyRecTimeItem(session *netlib.Session, packetId int, data interfac
return nil
}
func HandleWGPlayerLeave(session *netlib.Session, packetId int, data interface{}) error {
logger.Logger.Trace("receive WGPlayerLeaveGame")
if msg, ok := data.(*server.WGPlayerLeave); ok {
p := base.PlayerMgrSington.GetPlayerBySnId(msg.GetSnId())
if p != nil {
scene := p.GetScene()
if scene != nil {
scene.PlayerLeave(p, common.PlayerLeaveReason_DropLine, false)
}
}
//func HandleWGPlayerLeave(session *netlib.Session, packetId int, data interface{}) error {
// logger.Logger.Trace("receive WGPlayerLeaveGame")
// if msg, ok := data.(*server.WGPlayerLeave); ok {
// p := base.PlayerMgrSington.GetPlayerBySnId(msg.GetSnId())
// if p != nil {
// scene := p.GetScene()
// if scene != nil {
// scene.PlayerLeave(p, common.PlayerLeaveReason_DropLine, false)
// }
// }
// }
// return nil
//}
//func HandlePlayerChangeItems(session *netlib.Session, packetId int, data interface{}) error {
// logger.Logger.Tracef("receive PlayerChangeItems %v", data)
// msg, ok := data.(*server.PlayerChangeItems)
// if !ok {
// return nil
// }
// p := base.PlayerMgrSington.GetPlayerBySnId(msg.GetSnId())
// if p == nil {
// return nil
// }
// var items []*model.Item
// for _, v := range msg.GetItems() {
// items = append(items, &model.Item{
// ItemId: v.GetId(),
// ItemNum: v.GetNum(),
// })
// }
// p.ReceiveAddItems(items)
// return nil
//}
func CreateSceneHandler(session *netlib.Session, packetId int, data interface{}) error {
logger.Logger.Tracef("receive CreateScene %v", data)
msg, ok := data.(*server.WGCreateScene)
if !ok {
return nil
}
base.SceneMgrSington.CreateScene(&base.CreateSceneParam{
Session: session,
WGCreateScene: msg,
})
return nil
}
func init() {
//创建场景
netlib.RegisterFactory(int(server.SSPacketID_PACKET_WG_CREATESCENE), netlib.PacketFactoryWrapper(func() interface{} {
return &server.WGCreateScene{}
}))
netlib.RegisterHandler(int(server.SSPacketID_PACKET_WG_CREATESCENE), netlib.HandlerWrapper(func(s *netlib.Session, packetid int, pack interface{}) error {
logger.Logger.Trace("receive WGCreateScene:", pack)
if msg, ok := pack.(*server.WGCreateScene); ok {
sceneId := int(msg.GetSceneId())
gameMode := int(msg.GetGameMode())
sceneMode := int(msg.GetSceneMode())
gameId := int(msg.GetGameId())
paramsEx := msg.GetParamsEx()
hallId := msg.GetHallId()
groupId := msg.GetGroupId()
dbGameFree := msg.GetDBGameFree()
bEnterAfterStart := msg.GetEnterAfterStart()
totalOfGames := msg.GetTotalOfGames()
baseScore := msg.GetBaseScore()
playerNum := int(msg.GetPlayerNum())
scene := base.SceneMgrSington.CreateScene(s, sceneId, gameMode, sceneMode, gameId, msg.GetPlatform(), msg.GetParams(),
msg.GetAgentor(), msg.GetCreator(), msg.GetReplayCode(), hallId, groupId, totalOfGames, dbGameFree,
bEnterAfterStart, baseScore, playerNum, msg.GetChessRank(), paramsEx...)
if scene != nil {
if scene.IsMatchScene() {
if len(scene.Params) > 0 {
scene.MatchId = scene.Params[0]
}
if len(scene.Params) > 1 {
scene.MatchFinals = scene.Params[1] == 1
}
if len(scene.Params) > 2 {
scene.MatchRound = scene.Params[2]
}
if len(scene.Params) > 3 {
scene.MatchCurPlayerNum = scene.Params[3]
}
if len(scene.Params) > 4 {
scene.MatchNextNeed = scene.Params[4]
}
if len(scene.Params) > 5 {
scene.MatchType = scene.Params[5]
}
}
scene.ClubId = msg.GetClub()
scene.RoomId = msg.GetClubRoomId()
scene.RoomPos = msg.GetClubRoomPos()
scene.PumpCoin = msg.GetClubRate()
scene.RealCtrl = msg.RealCtrl
}
}
return nil
}))
// 创建房间
netlib.Register(int(server.SSPacketID_PACKET_WG_CREATESCENE), &server.WGCreateScene{}, CreateSceneHandler)
//删除场景
// 立刻删除,不管游戏是否结束
@ -254,7 +238,7 @@ func init() {
}
if scene.Testing {
p.Coin = int64(scene.DbGameFree.GetTestTakeCoin())
p.Coin = int64(scene.GetDBGameFree().GetTestTakeCoin())
}
base.PlayerMgrSington.ManagePlayer(p)
scene.PlayerEnter(p, isload)
@ -371,7 +355,7 @@ func init() {
//p.coin = msg.GetTakeCoin()
//p.takeCoin = msg.GetTakeCoin()
if scene.Testing {
p.Coin = int64(scene.DbGameFree.GetTestTakeCoin())
p.Coin = int64(scene.GetDBGameFree().GetTestTakeCoin())
}
p.LastSyncCoin = p.Coin
scene.AudienceSit(p)
@ -576,10 +560,13 @@ func init() {
return nil
}))
//玩家离开
netlib.Register(int(server.SSPacketID_PACKET_WG_PlayerLEAVE), server.WGPlayerLeave{}, HandleWGPlayerLeave)
//同步记牌器过期时间
common.RegisterMulticastHandler()
// 玩家离开
//netlib.Register(int(server.SSPacketID_PACKET_WG_PlayerLEAVE), server.WGPlayerLeave{}, HandleWGPlayerLeave)
// 同步记牌器过期时间
netlib.Register(int(server.SSPacketID_PACKET_WG_BUYRECTIMEITEM), server.WGBuyRecTimeItem{}, HandleWGBuyRecTimeItem)
// 修改皮肤
netlib.Register(int(server.SSPacketID_PACKET_WG_UpdateSkin), server.WGUpdateSkin{}, HandleWGUpdateSkin)
// 同步道具数量
//netlib.Register(int(server.SSPacketID_PACKET_PlayerChangeItems), server.PlayerChangeItems{}, HandlePlayerChangeItems)
}

View File

@ -57,14 +57,14 @@ func (this *AvengersSceneData) SceneDestroy(force bool) {
}
func (this *AvengersSceneData) init() bool {
if this.DbGameFree == nil {
if this.GetDBGameFree() == nil {
return false
}
params := this.DbGameFree.GetJackpot()
params := this.GetDBGameFree().GetJackpot()
this.jackpot = &base.SlotJackpotPool{}
if this.jackpot.Small <= 0 {
this.jackpot.Small = 0
this.jackpot.VirtualJK = int64(params[rule.AVENGERS_JACKPOT_InitJackpot]) * int64(this.DbGameFree.GetBaseScore())
this.jackpot.VirtualJK = int64(params[rule.AVENGERS_JACKPOT_InitJackpot]) * int64(this.GetDBGameFree().GetBaseScore())
}
str := base.SlotsPoolMgr.GetPool(this.GetGameFreeId(), this.Platform)
if str != "" {
@ -100,7 +100,7 @@ type AvengersSpinResult struct {
}
func (this *AvengersSceneData) CalcLinePrize(cards []int, betLines []int64, betValue int64) (spinRes AvengersSpinResult) {
taxRate := this.DbGameFree.GetTaxRate()
taxRate := this.GetDBGameFree().GetTaxRate()
calcTaxScore := func(score int64, taxScore *int64) int64 {
newScore := int64(float64(score) * float64(10000-taxRate) / 10000.0)
if taxScore != nil {
@ -188,7 +188,7 @@ func (this *AvengersSceneData) BroadcastJackpot(sync bool) {
this.lastJackpotValue = this.jackpot.VirtualJK
pack := &gamehall.SCHundredSceneGetGameJackpot{}
jpfi := &gamehall.GameJackpotFundInfo{
GameFreeId: proto.Int32(this.DbGameFree.Id),
GameFreeId: proto.Int32(this.GetDBGameFree().Id),
JackPotFund: proto.Int64(this.jackpot.VirtualJK),
}
pack.GameJackpotFund = append(pack.GameJackpotFund, jpfi)
@ -215,7 +215,7 @@ func (this *AvengersSceneData) PopCoinPool(winCoin int64, IsNovice bool) {
}
}
func (this *AvengersSceneData) RecordBurstLog(name string, wincoin, totalbet int64) {
log := model.NewBurstJackpotLog(this.Platform, this.DbGameFree.GameId, this.GetGameFreeId(), name, wincoin, totalbet)
log := model.NewBurstJackpotLog(this.Platform, this.GetDBGameFree().GameId, this.GetGameFreeId(), name, wincoin, totalbet)
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
return model.InsertBurstJackpotLogs(log)
}), nil, "InsertBurstJackpotLogs").Start()
@ -223,7 +223,7 @@ func (this *AvengersSceneData) RecordBurstLog(name string, wincoin, totalbet int
func (this *AvengersSceneData) BurstHistory(player *AvengersPlayerData) {
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
return model.GetBurstJackpotLog(this.Platform, this.DbGameFree.GameId)
return model.GetBurstJackpotLog(this.Platform, this.GetDBGameFree().GameId)
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
var logsp []*avengers.AvengersBurstHistoryInfo
if data != nil {
@ -251,7 +251,7 @@ func (this *AvengersSceneData) GetLastBurstJackPot() time.Time {
}
func (this *AvengersSceneData) SetLastBurstJackPot() {
var randT = rand.Intn(25200-7200+1) + 7200
switch this.DbGameFree.SceneType {
switch this.GetDBGameFree().SceneType {
case 1:
randT = rand.Intn(25200-7200+1) + 7200
case 2:
@ -267,7 +267,7 @@ func (this *AvengersSceneData) SetLastBurstJackPot() {
func (this *AvengersSceneData) AIAddJackPot() {
if time.Now().Sub(this.lastJackPot) > 0 {
var randT = rand.Intn(3) + 1
switch this.DbGameFree.SceneType {
switch this.GetDBGameFree().SceneType {
case 1:
randT = rand.Intn(3) + 1
case 2:
@ -280,20 +280,20 @@ func (this *AvengersSceneData) AIAddJackPot() {
randT = rand.Intn(3) + 1
}
this.lastJackPot = time.Now().Add(time.Second * time.Duration(randT))
val := int64(math.Floor(float64(this.DbGameFree.GetBaseScore()) * float64(rule.LINENUM) * float64(500) / 10000))
val := int64(math.Floor(float64(this.GetDBGameFree().GetBaseScore()) * float64(rule.LINENUM) * float64(500) / 10000))
this.jackpot.VirtualJK += val
}
}
func (this *AvengersSceneData) AIBurstJackPot() {
if time.Now().Sub(this.GetLastBurstJackPot()) > 0 {
this.SetLastBurstJackPot()
jackpotParams := this.DbGameFree.GetJackpot()
var jackpotInit = int64(jackpotParams[rule.AVENGERS_JACKPOT_InitJackpot]) * int64(this.DbGameFree.GetBaseScore()) //奖池初始值
jackpotParams := this.GetDBGameFree().GetJackpot()
var jackpotInit = int64(jackpotParams[rule.AVENGERS_JACKPOT_InitJackpot]) * int64(this.GetDBGameFree().GetBaseScore()) //奖池初始值
//AI机器人爆奖
val := this.jackpot.VirtualJK
this.jackpot.VirtualJK = jackpotInit
bet := int64(this.DbGameFree.GetBaseScore()) * int64(rule.LINENUM)
bet := int64(this.GetDBGameFree().GetBaseScore()) * int64(rule.LINENUM)
this.RecordBurstLog(this.RandNickName(), val, bet)
}
}
@ -314,11 +314,11 @@ func (this *AvengersSceneData) KickPlayerByTime() {
}
//for _, p := range this.players {
// //游戏次数达到目标值
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(this.DbGameFree.GetId()))
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(this.GetDBGameFree().GetId()))
// if !p.IsRob &&
// todayGamefreeIDSceneData != nil &&
// this.DbGameFree.GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(this.DbGameFree.GetPlayNumLimit()) {
// this.GetDBGameFree().GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(this.GetDBGameFree().GetPlayNumLimit()) {
// this.PlayerLeave(p.Player, common.PlayerLeaveReason_GameTimes, true)
// }
//}

View File

@ -94,8 +94,8 @@ func (this *ScenePolicyAvengers) OnPlayerEnter(s *base.Scene, p *base.Player) {
logger.Logger.Trace("(this *ScenePolicyAvengers) OnPlayerEnter, SceneId=", s.SceneId, " player=", p.SnId)
if sceneEx, ok := s.ExtraData.(*AvengersSceneData); ok {
playerEx := &AvengersPlayerData{Player: p}
playerEx.init(s) // 玩家当前信息初始化
playerEx.score = sceneEx.DbGameFree.GetBaseScore() // 底注
playerEx.init(s) // 玩家当前信息初始化
playerEx.score = sceneEx.GetDBGameFree().GetBaseScore() // 底注
sceneEx.players[p.SnId] = playerEx
p.ExtraData = playerEx
AvengersSendRoomInfo(s, p, sceneEx, playerEx, nil)
@ -229,14 +229,14 @@ func (this *ScenePolicyAvengers) GetJackPotVal(s *base.Scene) int64 {
func AvengersSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *AvengersSceneData, playerEx *AvengersPlayerData, data *avengers.GameBilledData) {
logger.Logger.Trace("-------------------发送房间消息 ", s.RoomId, p.SnId)
pack := &avengers.SCAvengersRoomInfo{
RoomId: proto.Int(s.SceneId),
RoomId: s.SceneId,
Creator: proto.Int32(s.Creator),
GameId: proto.Int(s.GameId),
RoomMode: proto.Int(s.GameMode),
GameId: s.GameId,
RoomMode: s.GameMode,
Params: common.CopySliceInt64ToInt32(s.Params),
State: proto.Int(s.SceneState.GetState()),
Jackpot: proto.Int64(sceneEx.jackpot.VirtualJK),
GameFreeId: proto.Int32(s.DbGameFree.Id),
GameFreeId: proto.Int32(s.GetDBGameFree().Id),
BilledData: data,
}
if playerEx != nil {
@ -252,7 +252,7 @@ func AvengersSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *AvengersSceneD
pack.Players = append(pack.Players, pd)
pack.BetLines = playerEx.betLines
pack.FreeTimes = proto.Int32(playerEx.freeTimes)
pack.Chip = proto.Int32(s.DbGameFree.BaseScore)
pack.Chip = proto.Int32(s.GetDBGameFree().BaseScore)
pack.SpinID = proto.Int64(playerEx.spinID)
if playerEx.totalPriceBonus > 0 {
switch playerEx.bonusStage {
@ -367,8 +367,8 @@ func (this *SceneStateAvengersStart) OnPlayerOp(s *base.Scene, p *base.Player, o
return false
}
//先做底注校验
if sceneEx.DbGameFree.GetBaseScore() != int32(params[0]) {
logger.Logger.Warnf("avengers snid[%v] opcode[%v] params[%v] BaseScore[%v]", p.SnId, opcode, params, sceneEx.DbGameFree.GetBaseScore())
if sceneEx.GetDBGameFree().GetBaseScore() != int32(params[0]) {
logger.Logger.Warnf("avengers snid[%v] opcode[%v] params[%v] BaseScore[%v]", p.SnId, opcode, params, sceneEx.GetDBGameFree().GetBaseScore())
this.OnPlayerSToCOp(s, p, playerEx.Pos, opcode, avengers.OpResultCode_OPRC_Error, params)
return false
}
@ -405,7 +405,7 @@ func (this *SceneStateAvengersStart) OnPlayerOp(s *base.Scene, p *base.Player, o
if playerEx.freeTimes <= 0 && totalBetValue > playerEx.Coin {
this.OnPlayerSToCOp(s, p, playerEx.Pos, opcode, avengers.OpResultCode_OPRC_CoinNotEnough, params)
return false
} else if playerEx.freeTimes <= 0 && int64(sceneEx.DbGameFree.GetBetLimit()) > playerEx.Coin { //押注限制
} else if playerEx.freeTimes <= 0 && int64(sceneEx.GetDBGameFree().GetBetLimit()) > playerEx.Coin { //押注限制
this.OnPlayerSToCOp(s, p, playerEx.Pos, opcode, avengers.OpResultCode_OPRC_CoinNotEnough, params)
return false
}
@ -419,7 +419,7 @@ func (this *SceneStateAvengersStart) OnPlayerOp(s *base.Scene, p *base.Player, o
//获取当前水池的上下文环境
sceneEx.CpCtx = base.CoinPoolMgr.GetCoinPoolCtx(sceneEx.Platform, sceneEx.GetGameFreeId(), sceneEx.GroupId)
//税收比例
taxRate := sceneEx.DbGameFree.GetTaxRate()
taxRate := sceneEx.GetDBGameFree().GetTaxRate()
if taxRate < 0 || taxRate > 10000 {
logger.Logger.Warnf("AvengersErrorTaxRate [%v][%v][%v][%v]", sceneEx.GetGameFreeId(), playerEx.SnId, playerEx.spinID, taxRate)
taxRate = 500
@ -448,8 +448,8 @@ func (this *SceneStateAvengersStart) OnPlayerOp(s *base.Scene, p *base.Player, o
prizeFund := gamePoolCoin - sceneEx.jackpot.VirtualJK // 除去奖池的水池剩余金额
// 奖池参数
jackpotParams := sceneEx.DbGameFree.GetJackpot()
var jackpotInit = int64(jackpotParams[rule.AVENGERS_JACKPOT_InitJackpot]) * int64(sceneEx.DbGameFree.GetBaseScore()) //奖池初始值
jackpotParams := sceneEx.GetDBGameFree().GetJackpot()
var jackpotInit = int64(jackpotParams[rule.AVENGERS_JACKPOT_InitJackpot]) * int64(sceneEx.GetDBGameFree().GetBaseScore()) //奖池初始值
var jackpotFundAdd, prizeFundAdd int64 //奖池/水池增量
if playerEx.freeTimes <= 0 { //正常模式才能记录用户的押注变化,免费模式不能改变押注
@ -469,7 +469,7 @@ func (this *SceneStateAvengersStart) OnPlayerOp(s *base.Scene, p *base.Player, o
////统计参与游戏次数
//if !sceneEx.Testing && !playerEx.IsRob {
// pack := &server.GWSceneEnd{
// GameFreeId: proto.Int32(sceneEx.DbGameFree.GetId()),
// GameFreeId: proto.Int32(sceneEx.GetDBGameFree().GetId()),
// Players: []*server.PlayerCtx{&server.PlayerCtx{SnId: proto.Int32(playerEx.SnId), Coin: proto.Int64(playerEx.Coin)}},
// }
// proto.SetDefaults(pack)
@ -668,7 +668,7 @@ func (this *SceneStateAvengersStart) OnPlayerOp(s *base.Scene, p *base.Player, o
case AvengersPlayerHistory:
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
spinid := strconv.Itoa(int(playerEx.SnId))
gpl := model.GetPlayerListByHallEx(p.SnId, p.Platform, 0, 80, 0, 0, 0, s.DbGameFree.GetGameClass(), s.GameId) //复仇者联盟存储个人操作记录不分场次,因为选场界面也需要拉去个人操作记录
gpl := model.GetPlayerListByHallEx(p.SnId, p.Platform, 0, 80, 0, 0, 0, s.GetDBGameFree().GetGameClass(), int(s.GameId)) //复仇者联盟存储个人操作记录不分场次,因为选场界面也需要拉去个人操作记录
pack := &avengers.SCAvengersPlayerHistory{}
for _, v := range gpl.Data {
if v.GameDetailedLogId == "" {
@ -806,7 +806,7 @@ func (this *SceneStateAvengersStart) BenchTest(s *base.Scene, p *base.Player) {
file.WriteString("玩家id,当前水位,之前余额,之后余额,投入,产出,税收,小游戏,爆奖,中线倍数,中线数,剩余免费次数\r\n")
oldCoin := p.Coin
p.Coin = 5000 * int64(s.DbGameFree.GetBaseScore())
p.Coin = 5000 * int64(s.GetDBGameFree().GetBaseScore())
if playerEx, ok := p.ExtraData.(*AvengersPlayerData); ok {
for i := 0; i < BENCH_CNT; i++ {
startCoin := p.Coin
@ -817,7 +817,7 @@ func (this *SceneStateAvengersStart) BenchTest(s *base.Scene, p *base.Player) {
inCoin := int64(playerEx.RollGameType.BaseResult.TotalBet)
outCoin := playerEx.RollGameType.BaseResult.ChangeCoin + inCoin
taxCoin := playerEx.RollGameType.BaseResult.Tax
lineScore := float64(playerEx.RollGameType.BaseResult.WinRate*s.DbGameFree.GetBaseScore()) * float64(10000.0-s.DbGameFree.GetTaxRate()) / 10000.0
lineScore := float64(playerEx.RollGameType.BaseResult.WinRate*s.GetDBGameFree().GetBaseScore()) * float64(10000.0-s.GetDBGameFree().GetTaxRate()) / 10000.0
jackpotScore := outCoin - playerEx.RollGameType.BaseResult.ChangeCoin - int64(lineScore+0.00001)
str := fmt.Sprintf("%v,%v,%v,%v,%v,%v,%v,%v,%v,%v,%v,%v\r\n", p.SnId, poolCoin, startCoin, p.Coin, inCoin, outCoin, taxCoin,
@ -860,7 +860,7 @@ func (this *SceneStateAvengersStart) WinTargetBenchTest(s *base.Scene, p *base.P
}
file.WriteString("玩家id,当前水位,之前余额,之后余额,投入,产出,税收,小游戏,爆奖,中线倍数,中线数,剩余免费次数\r\n")
oldCoin := p.Coin
switch s.DbGameFree.GetSceneType() {
switch s.GetDBGameFree().GetSceneType() {
case 1:
p.Coin = 100000
case 2:
@ -883,7 +883,7 @@ func (this *SceneStateAvengersStart) WinTargetBenchTest(s *base.Scene, p *base.P
inCoin := int64(playerEx.RollGameType.BaseResult.TotalBet)
outCoin := playerEx.RollGameType.BaseResult.ChangeCoin + inCoin
taxCoin := playerEx.RollGameType.BaseResult.Tax
lineScore := float64(playerEx.RollGameType.BaseResult.WinRate*s.DbGameFree.GetBaseScore()) * float64(10000.0-s.DbGameFree.GetTaxRate()) / 10000.0
lineScore := float64(playerEx.RollGameType.BaseResult.WinRate*s.GetDBGameFree().GetBaseScore()) * float64(10000.0-s.GetDBGameFree().GetTaxRate()) / 10000.0
jackpotScore := outCoin - playerEx.RollGameType.BaseResult.WinSmallGame - int64(lineScore+0.00001)
str := fmt.Sprintf("%v,%v,%v,%v,%v,%v,%v,%v,%v,%v,%v,%v\r\n", p.SnId, poolCoin, startCoin, p.Coin, inCoin, outCoin, taxCoin,
@ -915,7 +915,7 @@ func AvengersCheckAndSaveLog(sceneEx *AvengersSceneData, playerEx *AvengersPlaye
//log2
playerEx.RollGameType.BaseResult.ChangeCoin = changeCoin
playerEx.RollGameType.BaseResult.BasicBet = sceneEx.DbGameFree.GetBaseScore()
playerEx.RollGameType.BaseResult.BasicBet = sceneEx.GetDBGameFree().GetBaseScore()
playerEx.RollGameType.BaseResult.RoomId = int32(sceneEx.SceneId)
playerEx.RollGameType.BaseResult.AfterCoin = playerEx.Coin
playerEx.RollGameType.BaseResult.BeforeCoin = startCoin
@ -974,8 +974,8 @@ func AvengersCheckAndSaveLog(sceneEx *AvengersSceneData, playerEx *AvengersPlaye
GameCoinTs: proto.Int64(playerEx.GameCoinTs),
}
gwPlayerBet := &server.GWPlayerData{
SceneId: proto.Int(sceneEx.SceneId),
GameFreeId: proto.Int32(sceneEx.DbGameFree.GetId()),
SceneId: sceneEx.SceneId,
GameFreeId: proto.Int32(sceneEx.GetDBGameFree().GetId()),
}
gwPlayerBet.Datas = append(gwPlayerBet.Datas, playerBet)
sceneEx.SyncPlayerDatas(&base.PlayerDataParam{

View File

@ -1,61 +0,0 @@
package base
import (
rawproto "google.golang.org/protobuf/proto"
"mongo.games.com/game/proto"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/netlib"
"mongo.games.com/goserver/srvlib"
"mongo.games.com/goserver/srvlib/protocol"
)
var (
BroadcastMaker = &BroadcastPacketFactory{}
)
type BroadcastPacketFactory struct {
}
type BroadcastHandler struct {
}
func init() {
netlib.RegisterHandler(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), &BroadcastHandler{})
netlib.RegisterFactory(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), BroadcastMaker)
}
func (this *BroadcastPacketFactory) CreatePacket() interface{} {
pack := &protocol.SSPacketBroadcast{}
return pack
}
func (this *BroadcastPacketFactory) CreateBroadcastPacket(sp *protocol.BCSessionUnion, packetid int, data interface{}) (rawproto.Message, error) {
pack := &protocol.SSPacketBroadcast{
SessParam: sp,
PacketId: proto.Int(packetid),
}
if byteData, ok := data.([]byte); ok {
pack.Data = byteData
} else {
byteData, err := netlib.MarshalPacket(packetid, data)
if err == nil {
pack.Data = byteData
} else {
logger.Logger.Warn("BroadcastPacketFactory.CreateBroadcastPacket err:", err)
return nil, err
}
}
proto.SetDefaults(pack)
return pack, nil
}
func (this *BroadcastHandler) Process(s *netlib.Session, packetid int, data interface{}) error {
if bp, ok := data.(*protocol.SSPacketBroadcast); ok {
pd := bp.GetData()
sp := bp.GetSessParam()
if bcss := sp.GetBcss(); bcss != nil {
srvlib.ServerSessionMgrSington.Broadcast(int(bp.GetPacketId()), pd, int(bcss.GetSArea()), int(bcss.GetSType()))
}
}
return nil
}

View File

@ -2,5 +2,5 @@ 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.DbGameFree.GetId(), p.PromoterTree))
//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))
}

View File

@ -3,6 +3,8 @@ package base
import (
"reflect"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/model"
"mongo.games.com/game/mq"
)
@ -38,6 +40,7 @@ func (c *LogChannel) WriteLog(log interface{}) {
if cname == "" {
cname = "_null_"
}
logger.Logger.Tracef("LogChannel ==> %#v", log)
mq.Send(cname, log)
}
@ -54,4 +57,5 @@ func init() {
LogChannelSingleton.RegisterLogCName(model.GamePlayerListLogCollName, &model.GamePlayerListLog{})
LogChannelSingleton.RegisterLogCName(model.FriendRecordLogCollName, &model.FriendRecord{})
LogChannelSingleton.RegisterLogCName(model.ItemLogCollName, &model.ItemLog{})
LogChannelSingleton.RegisterLogCName(mq.DBCustomLog, &model.CustomLog{})
}

View File

@ -1,67 +0,0 @@
package base
import (
rawproto "google.golang.org/protobuf/proto"
"mongo.games.com/game/proto"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/netlib"
"mongo.games.com/goserver/srvlib"
"mongo.games.com/goserver/srvlib/protocol"
)
var (
MulticastMaker = &MulticastPacketFactory{}
)
type MulticastPacketFactory struct {
}
type MulticastHandler struct {
}
func init() {
netlib.RegisterHandler(int(protocol.SrvlibPacketID_PACKET_SS_MULTICAST), &MulticastHandler{})
netlib.RegisterFactory(int(protocol.SrvlibPacketID_PACKET_SS_MULTICAST), MulticastMaker)
}
func (this *MulticastPacketFactory) CreatePacket() interface{} {
pack := &protocol.SSPacketMulticast{}
return pack
}
func (this *MulticastPacketFactory) CreateMulticastPacket(packetid int, data interface{}, sis ...*protocol.MCSessionUnion) (rawproto.Message, error) {
pack := &protocol.SSPacketMulticast{
Sessions: sis,
PacketId: proto.Int(packetid),
}
if byteData, ok := data.([]byte); ok {
pack.Data = byteData
} else {
byteData, err := netlib.MarshalPacket(packetid, data)
if err == nil {
pack.Data = byteData
} else {
logger.Logger.Info("MulticastPacketFactory.CreateMulticastPacket err:", err)
return nil, err
}
}
proto.SetDefaults(pack)
return pack, nil
}
func (this *MulticastHandler) Process(s *netlib.Session, packetid int, data interface{}) error {
if mp, ok := data.(*protocol.SSPacketMulticast); ok {
pd := mp.GetData()
sis := mp.GetSessions()
for _, si := range sis {
ss := si.GetMcss()
if ss != nil {
ns := srvlib.ServerSessionMgrSington.GetSession(int(ss.GetSArea()), int(ss.GetSType()), int(ss.GetSId()))
if ns != nil {
ns.Send(int(mp.GetPacketId()), pd /*, s.GetSessionConfig().IsInnerLink*/)
}
}
}
}
return nil
}

View File

@ -68,8 +68,8 @@ const (
)
type Player struct {
model.PlayerData //po 持久化对象
ExtraData interface{} //扩展接口
model.WGPlayerInfo
ExtraData interface{} //具体游戏对局中的玩家扩展信息
gateSess *netlib.Session //所在GateServer的session
worldSess *netlib.Session //所在WorldServer的session
scene *Scene //当前所在个Scene
@ -113,7 +113,7 @@ type Player struct {
Iparams map[int]int64 //整形参数
sparams map[int]string //字符参数
IsLocal bool //是否本地player
Items map[int32]int64 //背包数据
Items map[int32]int64 //背包数据, 不可直接修改,使用 AddItems 方法
MatchParams []int32 //比赛参数 排名、段位、假snid、假角色、假皮肤
MatchRobotGrades []MatchRobotGrade
TestLog []string // 调试日志
@ -141,13 +141,15 @@ func NewPlayer(sid int64, data []byte, ws, gs *netlib.Session) *Player {
RankScore: make(map[int32]int64),
}
// 需要make的统一在这里初始化默认值别的地方就不用再初始化了
p.PlayerData = model.PlayerData{
//TotalGameData: make(map[int][]*model.PlayerGameTotal),
GDatas: make(map[string]*model.PlayerGameInfo),
ShopTotal: make(map[int32]*model.ShopTotal),
ShopLastLookTime: make(map[int32]int64),
IsFoolPlayer: make(map[string]bool),
//todo 初始化
p.WGPlayerInfo = model.WGPlayerInfo{
PlayerData: &model.PlayerData{
GDatas: make(map[string]*model.PlayerGameInfo),
ShopTotal: make(map[int32]*model.ShopTotal),
ShopLastLookTime: make(map[int32]int64),
IsFoolPlayer: make(map[string]bool),
},
GameData: make(map[int32]*model.PlayerGameData),
}
if p.init(data) {
@ -246,7 +248,7 @@ func (this *Player) SyncFlagToWorld() {
}
pack := &server.GWPlayerFlag{
SnId: proto.Int32(this.SnId),
RoomId: proto.Int(this.scene.SceneId),
RoomId: this.scene.SceneId,
Flag: proto.Int(this.flag),
}
proto.SetDefaults(pack)
@ -373,7 +375,20 @@ func (this *Player) OnAudienceLeave(reason int) {
}
func (this *Player) MarshalData(gameid int) (d []byte, e error) {
d, e = netlib.Gob.Marshal(&this.PlayerData)
// 防止参数遗漏
for k, v := range this.GameData {
if v.SnId == 0 {
v.SnId = this.SnId
}
if v.Platform == "" {
v.Platform = this.Platform
}
if v.Id == 0 {
v.Id = k
}
}
d, e = netlib.Gob.Marshal(&this.WGPlayerInfo)
logger.Logger.Trace("(this *Player) MarshalData(gameid int)")
return
}
@ -382,7 +397,7 @@ func (this *Player) UnmarshalData(data []byte) bool {
if len(data) == 0 {
return true
}
err := netlib.Gob.Unmarshal(data, &this.PlayerData)
err := netlib.Gob.Unmarshal(data, &this.WGPlayerInfo)
if err == nil {
this.dirty = true
return true
@ -439,7 +454,6 @@ func (this *Player) AddCoin(num int64, gainWay int32, syncFlag int, oper, remark
return
}
this.Coin += num
this.Items[common.ItemIDCoin] = this.Coin
if this.scene != nil {
if !this.IsRob && !this.scene.Testing { //机器人log排除掉
log := model.NewCoinLogEx(&model.CoinLogParam{
@ -467,9 +481,6 @@ func (this *Player) AddCoin(num int64, gainWay int32, syncFlag int, oper, remark
if this.Coin < 0 {
this.Coin = 0
}
if this.scene.IsHundredScene() {
this.scene.NewBigCoinNotice(this, int64(num), 5)
}
}
//增加玩家经验
if num > 0 {
@ -524,7 +535,6 @@ func (this *Player) AddCoinAsync(num int64, gainWay int32, notifyC, broadcast bo
return
}
this.Coin += num
this.Items[common.ItemIDCoin] = this.Coin
if this.scene != nil {
if !this.IsRob && !this.scene.Testing && writeLog { //机器人log排除掉
log := model.NewCoinLogEx(&model.CoinLogParam{
@ -607,62 +617,6 @@ func (this *Player) AddRankScore(rankType int32, num int64) {
}
}
// 保存金币变动日志
// 数据用途: 个人房间内牌局账变记录,后台部分报表使用,确保数据计算无误,否则可能影响月底对账
// takeCoin: 牌局结算前玩家身上的金币
// changecoin: 本局玩家输赢的钱,注意是税后
// coin: 结算后玩家当前身上的金币余额
// totalbet: 总下注额
// taxcoin: 本局该玩家产生的税收,这里要包含俱乐部的税
// wincoin: 本局赢取的金币,含税 wincoin==changecoin+taxcoin
// jackpotWinCoin: 从奖池中赢取的金币(拉霸类游戏)
// smallGameWinCoin: 小游戏赢取的金币(拉霸类游戏)
func (this *Player) SaveSceneCoinLog(takeCoin, changecoin, coin, totalbet, taxcoin, wincoin int64, jackpotWinCoin int64, smallGameWinCoin int64) {
if this.scene != nil {
if !this.IsRob && !this.scene.Testing && !this.scene.IsMatchScene() { //机器人log排除掉
var eventType int64 //输赢事件值 默认值为0
if coin-takeCoin > 0 {
eventType = 1
} else if coin-takeCoin < 0 {
eventType = -1
}
log := model.NewSceneCoinLogEx(this.SnId, changecoin, takeCoin, coin, eventType,
int64(this.scene.DbGameFree.GetBaseScore()), totalbet, int32(this.scene.GameId), this.PlayerData.Ip,
this.scene.paramsEx[0], this.Pos, this.Platform, this.Channel, this.BeUnderAgentCode, int32(this.scene.SceneId),
this.scene.DbGameFree.GetGameMode(), this.scene.GetGameFreeId(), taxcoin, wincoin,
jackpotWinCoin, smallGameWinCoin, this.PackageID)
if log != nil {
LogChannelSingleton.WriteLog(log)
}
}
}
}
// 需要关照
func (this *Player) IsNeedCare() bool {
return false
}
// 需要削弱
func (this *Player) IsNeedWeaken() bool {
return false
}
func (this *Player) GetCoinOverPercent() int32 {
return 0
}
func (this *Player) SyncCoin() {
pack := &player.SCPlayerCoinChange{
SnId: proto.Int32(this.SnId),
AddCoin: proto.Int64(0),
RestCoin: proto.Int64(this.Coin),
}
proto.SetDefaults(pack)
this.SendToClient(int(player.PlayerPacketID_PACKET_SC_PLAYERCOINCHANGE), pack)
logger.Logger.Trace("(this *Player) SyncCoin SCPlayerCoinChange:", pack)
}
func (this *Player) ReportGameEvent(tax, taxex, changeCoin, validbet, validFlow, in, out int64) {
// 记录玩家 首次参与该场次的游戏时间 游戏次数
var gameFirstTime, gameFreeFirstTime time.Time
@ -682,25 +636,12 @@ func (this *Player) ReportGameEvent(tax, taxex, changeCoin, validbet, validFlow,
gamingTime := int32(time.Now().Sub(this.scene.GameNowTime).Seconds())
LogChannelSingleton.WriteMQData(model.GenerateGameEvent(model.CreatePlayerGameRecEvent(this.SnId, tax, taxex, changeCoin, validbet, validFlow, in, out,
int32(this.scene.GameId), this.scene.DbGameFree.GetId(), int32(this.scene.GameMode),
int32(this.scene.GameId), this.scene.GetGameFreeId(), int32(this.scene.GameMode),
this.scene.GetRecordId(), this.Channel, this.BeUnderAgentCode, this.Platform, this.City, this.DeviceOS,
this.CreateTime, gamingTime, gameFirstTime, gameFreeFirstTime, gameTimes, gameFreeTimes, this.LastLoginTime,
this.TelephonePromoter, this.DeviceId)))
}
// 破产事件
func (this *Player) ReportBankRuptcy(gameId, gameMode, gameFreeId int32) {
//if !this.IsRob {
// d, e := model.MarshalBankruptcyEvent(2, this.SnId, this.TelephonePromoter, this.Channel, this.BeUnderAgentCode, this.Platform, this.City, this.CreateTime, gameId, gameMode, gameFreeId)
// if e == nil {
// rmd := model.NewInfluxDBData("hj.player_bankruptcy", d)
// if rmd != nil {
// InfluxDBDataChannelSington.Write(rmd)
// }
// }
//}
}
// 汇总玩家该次游戏总产生的税收
// 数据用途: 平台和推广间分账用,确保数据计算无误,
// 注意:该税收不包含俱乐部的抽水
@ -714,30 +655,6 @@ func (this *Player) AddServiceFee(tax int64) {
}
}
//func (this *Player) SaveReportForm(showId, sceneMode int, keyGameId string, profitCoin, flow int64, validBet int64) {
// //个人报表统计
// if this.TotalGameData == nil {
// this.TotalGameData = make(map[int][]*model.PlayerGameTotal)
// }
// if this.TotalGameData[showId] == nil {
// this.TotalGameData[showId] = []*model.PlayerGameTotal{new(model.PlayerGameTotal)}
// }
// td := this.TotalGameData[showId][len(this.TotalGameData[showId])-1]
// td.ProfitCoin += profitCoin
// td.BetCoin += validBet
// td.FlowCoin += flow
// ///////////////最多盈利
// if pgs, exist := this.GDatas[keyGameId]; exist {
// if pgs.Statics.MaxSysOut < profitCoin {
// pgs.Statics.MaxSysOut = profitCoin
// }
// } else {
// gs := model.NewPlayerGameStatics()
// gs.MaxSysOut = profitCoin
// this.GDatas[keyGameId] = &model.PlayerGameInfo{FirstTime: time.Now(), Statics: *gs}
// }
//}
// Statics 弃用,使用 Scene.Statistics 方法
// 个人投入产出汇总以游戏id为key存储
// 数据用途:计算玩家赔率用,数据确保计算无误,否则可能影响玩家手牌的调控
@ -851,61 +768,18 @@ func (this *Player) Statics(keyGameId string, keyGameFreeId string, gain int64,
////}
}
func (this *Player) SendTrusteeshipTips() {
pack := &player.SCTrusteeshipTips{
Trusteeship: proto.Int32(this.Trusteeship),
TotalNum: proto.Int32(model.GameParamData.PlayerWatchNum),
}
proto.SetDefaults(pack)
logger.Logger.Trace("SCTrusteeshipTips: ", pack)
this.SendToClient(int(player.PlayerPacketID_PACKET_SC_TRUSTEESHIPTIPS), pack)
}
func (this *Player) MarshalIParam() []*server.PlayerIParam {
var params []*server.PlayerIParam
for i, v := range this.Iparams {
params = append(params, &server.PlayerIParam{
ParamId: proto.Int(i),
IntVal: proto.Int64(v),
})
}
return params
}
func (this *Player) UnmarshalIParam(params []*server.PlayerIParam) {
for _, p := range params {
this.Iparams[int(p.GetParamId())] = p.GetIntVal()
}
}
func (this *Player) MarshalSParam() []*server.PlayerSParam {
var params []*server.PlayerSParam
for i, v := range this.sparams {
params = append(params, &server.PlayerSParam{
ParamId: proto.Int(i),
StrVal: proto.String(v),
})
}
return params
}
func (this *Player) UnmarshalSParam(params []*server.PlayerSParam) {
for _, p := range params {
this.sparams[int(p.GetParamId())] = p.GetStrVal()
}
}
func (this *Player) MarshalCParam() []*server.PlayerCParam {
var params []*server.PlayerCParam
for k, v := range this.cparams {
params = append(params, &server.PlayerCParam{
StrKey: proto.String(k),
StrVal: proto.String(v),
})
}
return params
}
func (this *Player) UnmarshalCParam(params []*server.PlayerCParam) {
for _, p := range params {
this.cparams[p.GetStrKey()] = p.GetStrVal()
@ -1219,17 +1093,6 @@ func (this *Player) NoviceOdds(gameId int) (int32, bool) {
return int32(odds), b1
}
/*// 设置玩家捕鱼等级
func (this *Player) SetFishLevel(level int64) {
data := srvdata.PBDB_PlayerExpMgr.GetData(int32(level))
if data == nil {
logger.Logger.Errorf("设置玩家等级错误snid = %v, lvel = %v", this.SnId, level)
return
}
this.FishLevel = level
this.FishExp = int64(data.Exp)
}*/
// 增加玩家经验
func (this *Player) AddPlayerExp(exp int64) bool {
this.Exp += exp
@ -1395,3 +1258,71 @@ func (this *Player) PetUseSkill() bool {
func (this *Player) GetSkillAdd(id int32) int32 {
return this.GetSkillAdd2(id, ConfigMgrInst)
}
// AddItems 添加道具
// 增加或减少道具
// 同步到 worldsrv
func (this *Player) AddItems(args *model.AddItemParam) {
pack := &server.PlayerChangeItems{
SnId: args.P.SnId,
}
for _, v := range args.Change {
item := srvdata.GameItemMgr.Get(this.Platform, v.ItemId)
if item == nil {
continue
}
if v.ItemNum < 0 && this.Items[v.ItemId] < -v.ItemNum {
v.ItemNum = -this.Items[v.ItemId]
}
if v.ItemNum == 0 {
continue
}
this.Items[v.ItemId] += v.ItemNum
if !args.NoLog {
logType := 0
if v.ItemNum < 0 {
logType = 1
}
LogChannelSingleton.WriteLog(model.NewItemLogEx(model.ItemParam{
Platform: this.Platform,
SnId: this.SnId,
LogType: int32(logType),
ItemId: v.ItemId,
ItemName: item.Name,
Count: v.ItemNum,
Remark: args.Remark,
TypeId: args.GainWay,
GameId: args.GameId,
GameFreeId: args.GameFreeId,
Cost: args.Cost,
}))
}
pack.Items = append(pack.Items, &server.Item{
Id: v.ItemId,
Num: v.ItemNum,
})
}
if len(pack.Items) > 0 {
this.SendToWorld(int(server.SSPacketID_PACKET_PlayerChangeItems), pack)
logger.Logger.Tracef("PlayerChangeItems: %v", pack)
}
}
//func (this *Player) ReceiveAddItems(items []*model.Item) {
// for _, v := range items {
// item := srvdata.GameItemMgr.Get(this.Platform, v.ItemId)
// if item == nil {
// continue
// }
// if v.ItemNum < 0 && this.Items[v.ItemId] < -v.ItemNum {
// v.ItemNum = -this.Items[v.ItemId]
// }
// if v.ItemNum == 0 {
// continue
// }
// this.Items[v.ItemId] += v.ItemNum
// logger.Logger.Tracef("ReceiveAddItems snid:%v, item:%v, num:%v change:%v", this.SnId, v.ItemId, this.Items[v.ItemId], v.ItemNum)
// }
//}

View File

@ -55,9 +55,9 @@ func (this *PlayerMgr) AddPlayer(id int64, data []byte, ws, gs *netlib.Session)
logger.Logger.Warnf("(this *PlayerMgr) AddPlayer found id=%v player exist snid=%v", id, oldPlayer.SnId)
testFlag = true
if oldPlayer.scene != nil {
logger.Logger.Warnf("(this *PlayerMgr) AddPlayer found snid=%v in sceneid=%v", id, oldPlayer.SnId, oldPlayer.scene.SceneId)
if SceneMgrSington.GetScene(oldPlayer.scene.SceneId) != nil {
logger.Logger.Warnf("(this *PlayerMgr) AddPlayer found snid=%v in sceneid=%v SceneMgrSington.GetScene(oldPlayer.scene.sceneId) != nil", id, oldPlayer.SnId, oldPlayer.scene.SceneId)
logger.Logger.Warnf("(this *PlayerMgr) AddPlayer found id=%v snid=%v in sceneid=%v", id, oldPlayer.SnId, oldPlayer.scene.SceneId)
if SceneMgrSington.GetScene(int(oldPlayer.scene.SceneId)) != nil {
logger.Logger.Warnf("(this *PlayerMgr) AddPlayer found id=%v snid=%v in sceneid=%v SceneMgrSington.GetScene(oldPlayer.scene.sceneId) != nil", id, oldPlayer.SnId, oldPlayer.scene.SceneId)
}
}
this.DelPlayer(id)
@ -158,7 +158,7 @@ func (this *PlayerMgr) BroadcastMessage(packetid int, rawpack interface{}) bool
sc := &protocol.BCSessionUnion{
Bccs: &protocol.BCClientSession{},
}
pack, err := BroadcastMaker.CreateBroadcastPacket(sc, packetid, rawpack)
pack, err := common.CreateBroadcastPacket(sc, packetid, rawpack)
if err == nil && pack != nil {
srvlib.ServerSessionMgrSington.Broadcast(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), pack, common.GetSelfAreaId(), srvlib.GateServerType)
return true

View File

@ -13,11 +13,6 @@ import (
"mongo.games.com/goserver/core/netlib"
)
const (
ReplayServerType int = 8
ReplayServerId = 801
)
var _replayIgnorePacketIds = map[int]bool{}
type ReplayRecorder struct {
@ -97,13 +92,13 @@ func (this *ReplayRecorder) Fini(s *Scene) {
// todo dev
//Rec: this.rs,
LogId: proto.String(this.Logid),
GameId: proto.Int32(s.DbGameFree.GetGameId()),
RoomMode: proto.Int32(s.DbGameFree.GetGameMode()),
GameId: int32(s.GetGameId()),
RoomMode: int32(s.GetGameMode()),
NumOfGames: proto.Int(s.NumOfGames),
Platform: proto.String(s.Platform),
DatasVer: proto.Int32(s.rrVer),
GameFreeid: proto.Int32(s.GetGameFreeId()),
RoomId: proto.Int(s.SceneId),
RoomId: s.SceneId,
}
if s.ClubId != 0 {
pack.ClubId = proto.Int32(s.ClubId)

File diff suppressed because it is too large Load Diff

View File

@ -21,136 +21,82 @@ var SceneMgrSington = &SceneMgr{
}
type SceneMgr struct {
scenes map[int]*Scene
scenesByGame map[int]map[int]*Scene
scenesByGameFree map[int32]map[int]*Scene
lastSendJackPot time.Time
PlatformScene map[string]bool
scenes map[int]*Scene // 房间id
scenesByGame map[int]map[int]*Scene // 游戏id:房间id
scenesByGameFree map[int32]map[int]*Scene // 场次id:房间id
lastSendJackPot time.Time //
PlatformScene map[string]bool //
}
func (this *SceneMgr) makeKey(gameid, gamemode int) int {
return int(gameid*10000 + gamemode)
type CreateSceneParam struct {
Session *netlib.Session
*server.WGCreateScene
}
func (this *SceneMgr) CreateScene(s *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, 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...)
func (this *SceneMgr) CreateScene(args *CreateSceneParam) *Scene {
scene := NewScene(args)
if scene == nil {
logger.Logger.Error("(this *SceneMgr) CreateScene, scene == nil")
return nil
}
this.scenes[scene.SceneId] = scene
platform := args.GetPlatform()
gameId := args.GetGameId()
gameFreeId := args.GetDBGameFree().GetId()
// 平台标记
this.scenes[int(scene.SceneId)] = scene
if _, ok := this.PlatformScene[platform]; !ok {
this.PlatformScene[platform] = true
}
//
key := this.makeKey(gameId, gameMode)
if ss, exist := this.scenesByGame[key]; exist {
ss[scene.SceneId] = scene
// 游戏id索引
if ss, exist := this.scenesByGame[int(gameId)]; exist {
ss[int(scene.SceneId)] = scene
} else {
ss = make(map[int]*Scene)
ss[scene.SceneId] = scene
this.scenesByGame[key] = ss
ss[int(scene.SceneId)] = scene
this.scenesByGame[int(gameId)] = ss
}
//
if ss, exist := this.scenesByGameFree[dbGameFree.GetId()]; exist {
ss[scene.SceneId] = scene
// 场次id索引
if ss, exist := this.scenesByGameFree[gameFreeId]; exist {
ss[int(scene.SceneId)] = scene
} else {
ss = make(map[int]*Scene)
ss[scene.SceneId] = scene
this.scenesByGameFree[dbGameFree.GetId()] = ss
ss[int(scene.SceneId)] = scene
this.scenesByGameFree[gameFreeId] = ss
}
scene.OnStart()
logger.Logger.Infof("(this *SceneMgr) CreateScene,New scene,id:[%d] replaycode:[%v]", scene.SceneId, replayCode)
logger.Logger.Infof("(this *SceneMgr) CreateScene,New scene,id:[%d] replaycode:[%v]", scene.SceneId, args.GetReplayCode())
return scene
}
func (this *SceneMgr) DestroyScene(sceneId int) {
if scene, exist := this.scenes[sceneId]; exist {
scene.OnStop()
//
key := this.makeKey(scene.GameId, scene.GameMode)
if ss, exist := this.scenesByGame[key]; exist {
delete(ss, scene.SceneId)
// 游戏id
if ss, exist := this.scenesByGame[scene.GetGameId()]; exist {
delete(ss, int(scene.SceneId))
}
//
// 场次id
if ss, exist := this.scenesByGameFree[scene.GetGameFreeId()]; exist {
delete(ss, scene.SceneId)
delete(ss, int(scene.SceneId))
}
// 房间id
delete(this.scenes, sceneId)
logger.Logger.Infof("(this *SceneMgr) DestroyScene, sceneid = %v", sceneId)
}
}
func (this *SceneMgr) GetPlayerNumByGameFree(platform string, gamefreeid, groupId int32) int32 {
var num int32
if ss, exist := SceneMgrSington.scenesByGameFree[gamefreeid]; exist {
for _, scene := range ss {
if groupId != 0 {
if scene.GroupId == groupId {
cnt := scene.GetRealPlayerCnt()
num += int32(cnt)
}
} else {
if scene.Platform == platform {
cnt := scene.GetRealPlayerCnt()
num += int32(cnt)
}
}
}
}
return num
}
func (this *SceneMgr) GetPlayerNumByGame(platform string, gameid, gamemode, groupId int32) map[int32]int32 {
nums := make(map[int32]int32)
key := this.makeKey(int(gameid), int(gamemode))
if ss, exist := SceneMgrSington.scenesByGame[key]; exist {
for _, scene := range ss {
if groupId != 0 {
if scene.GroupId == groupId {
cnt := scene.GetRealPlayerCnt()
nums[scene.GetGameFreeId()] = nums[scene.GetGameFreeId()] + int32(cnt)
}
} else {
if scene.Platform == platform {
cnt := scene.GetRealPlayerCnt()
nums[scene.GetGameFreeId()] = nums[scene.GetGameFreeId()] + int32(cnt)
}
}
}
}
return nums
}
func (this *SceneMgr) GetPlayersByGameFree(platform string, gamefreeid int32) []*Player {
players := make([]*Player, 0)
if ss, exist := SceneMgrSington.scenesByGameFree[gamefreeid]; exist {
for _, scene := range ss {
if scene.Platform == platform {
for _, p := range scene.Players {
if p != nil {
players = append(players, p)
}
}
}
}
}
return players
}
func (this *SceneMgr) GetScene(sceneId int) *Scene {
if s, exist := this.scenes[sceneId]; exist {
return s
}
return nil
}
func (this *SceneMgr) GetSceneByGameId(platform string, gameId int32) []*Scene {
key := this.makeKey(int(gameId), 0)
var ss []*Scene
if data, ok := this.scenesByGame[key]; ok {
if data, ok := this.scenesByGame[int(gameId)]; ok {
for _, scene := range data {
if scene.Platform == platform {
ss = append(ss, scene)
@ -159,6 +105,7 @@ func (this *SceneMgr) GetSceneByGameId(platform string, gameId int32) []*Scene {
}
return ss
}
func (this *SceneMgr) JackPotSync(platform string, gameIds ...int32) {
for _, gameId := range gameIds {
ss := this.GetSceneByGameId(platform, gameId)
@ -169,7 +116,7 @@ func (this *SceneMgr) JackPotSync(platform string, gameIds ...int32) {
val := s.sp.GetJackPotVal(s)
if val > 0 {
jpfi := &gamehall.GameJackpotFundInfo{
GameFreeId: proto.Int32(s.DbGameFree.Id),
GameFreeId: proto.Int32(s.GetGameFreeId()),
JackPotFund: proto.Int64(val),
}
pack.GameJackpotFund = append(pack.GameJackpotFund, jpfi)
@ -195,7 +142,7 @@ func (this *SceneMgr) JackPotSync(platform string, gameIds ...int32) {
for gateSess, v := range mgs {
if gateSess != nil && len(v) != 0 {
cPack, err := MulticastMaker.CreateMulticastPacket(int(gamehall.HundredScenePacketID_PACKET_SC_GAMEJACKPOT), pack, v...)
cPack, err := common.CreateMulticastPacket(int(gamehall.HundredScenePacketID_PACKET_SC_GAMEJACKPOT), pack, v...)
if err == nil {
proto.SetDefaults(cPack)
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), cPack)
@ -205,16 +152,13 @@ func (this *SceneMgr) JackPotSync(platform string, gameIds ...int32) {
}
}
}
func (this *SceneMgr) OnMiniTimer() {
for _, scene := range this.scenes {
scene.SyncPlayerCoin()
}
}
func (this *SceneMgr) OnHourTimer() {
// for _, scene := range this.scenes {
// scene.OnHourTimer()
// }
}
func (this *SceneMgr) OnDayTimer() {

View File

@ -1,15 +1,9 @@
package base
import (
"time"
)
// 根据不同的房间模式,选择不同的房间业务逻辑
var ScenePolicyPool = make(map[int]map[int]ScenePolicy) // gameId:gameMode
type ScenePolicy interface {
//心跳间隔
GetHeartBeatInterval() time.Duration
//场景开启事件
OnStart(s *Scene)
//场景关闭事件
@ -105,7 +99,6 @@ func RegisteScenePolicy(gameId, mode int, sp ScenePolicy) {
type BaseScenePolicy struct {
}
func (bsp *BaseScenePolicy) GetHeartBeatInterval() time.Duration { return time.Second }
func (bsp *BaseScenePolicy) OnStart(s *Scene) {
if s.aiMgr != nil {
s.aiMgr.OnStart(s)

View File

@ -59,14 +59,14 @@ func (this *CaiShenSceneData) SceneDestroy(force bool) {
}
func (this *CaiShenSceneData) init() bool {
if this.DbGameFree == nil {
if this.GetDBGameFree() == nil {
return false
}
params := this.DbGameFree.GetJackpot()
params := this.GetDBGameFree().GetJackpot()
this.jackpot = &base.SlotJackpotPool{}
if this.jackpot.Small <= 0 {
this.jackpot.Small = 0
this.jackpot.VirtualJK = int64(params[rule.CAISHEN_JACKPOT_InitJackpot]) * int64(this.DbGameFree.GetBaseScore())
this.jackpot.VirtualJK = int64(params[rule.CAISHEN_JACKPOT_InitJackpot]) * int64(this.GetDBGameFree().GetBaseScore())
}
str := base.XSlotsPoolMgr.GetPool(this.GetGameFreeId(), this.Platform)
if str != "" {
@ -102,7 +102,7 @@ type CaiShenSpinResult struct {
}
func (this *CaiShenSceneData) CalcLinePrize(cards []int, betLines []int64, betValue int64) (spinRes CaiShenSpinResult) {
taxRate := this.DbGameFree.GetTaxRate()
taxRate := this.GetDBGameFree().GetTaxRate()
calcTaxScore := func(score int64, taxScore *int64) int64 {
newScore := int64(float64(score) * float64(10000-taxRate) / 10000.0)
if taxScore != nil {
@ -188,7 +188,7 @@ func (this *CaiShenSceneData) BroadcastJackpot(sync bool) {
this.lastJackpotValue = this.jackpot.VirtualJK
pack := &gamehall.SCHundredSceneGetGameJackpot{}
jpfi := &gamehall.GameJackpotFundInfo{
GameFreeId: proto.Int32(this.DbGameFree.Id),
GameFreeId: proto.Int32(this.GetDBGameFree().Id),
JackPotFund: proto.Int64(this.jackpot.VirtualJK),
}
pack.GameJackpotFund = append(pack.GameJackpotFund, jpfi)
@ -215,7 +215,7 @@ func (this *CaiShenSceneData) PopCoinPool(winCoin int64, IsNovice bool) {
}
}
func (this *CaiShenSceneData) RecordBurstLog(name string, wincoin, totalbet int64) {
log := model.NewBurstJackpotLog(this.Platform, this.DbGameFree.GameId, this.GetGameFreeId(), name, wincoin, totalbet)
log := model.NewBurstJackpotLog(this.Platform, this.GetDBGameFree().GameId, this.GetGameFreeId(), name, wincoin, totalbet)
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
return model.InsertBurstJackpotLogs(log)
}), nil, "InsertBurstJackpotLogs").Start()
@ -223,7 +223,7 @@ func (this *CaiShenSceneData) RecordBurstLog(name string, wincoin, totalbet int6
func (this *CaiShenSceneData) BurstHistory(player *CaiShenPlayerData) {
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
return model.GetBurstJackpotLog(this.Platform, this.DbGameFree.GameId)
return model.GetBurstJackpotLog(this.Platform, this.GetDBGameFree().GameId)
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
var logsp []*caishen.CaiShenBurstHistoryInfo
if data != nil {
@ -251,7 +251,7 @@ func (this *CaiShenSceneData) GetLastBurstJackPot() time.Time {
}
func (this *CaiShenSceneData) SetLastBurstJackPot() {
var randT = rand.Intn(25200-7200+1) + 7200
switch this.DbGameFree.SceneType {
switch this.GetDBGameFree().SceneType {
case 1:
randT = rand.Intn(25200-7200+1) + 7200
case 2:
@ -267,7 +267,7 @@ func (this *CaiShenSceneData) SetLastBurstJackPot() {
func (this *CaiShenSceneData) AIAddJackPot() {
if time.Now().Sub(this.lastJackPot) > 0 {
var randT = rand.Intn(3) + 1
switch this.DbGameFree.SceneType {
switch this.GetDBGameFree().SceneType {
case 1:
randT = rand.Intn(3) + 1
case 2:
@ -280,20 +280,20 @@ func (this *CaiShenSceneData) AIAddJackPot() {
randT = rand.Intn(3) + 1
}
this.lastJackPot = time.Now().Add(time.Second * time.Duration(randT))
val := int64(math.Floor(float64(this.DbGameFree.GetBaseScore()) * float64(rule.LINENUM) * float64(500) / 10000))
val := int64(math.Floor(float64(this.GetDBGameFree().GetBaseScore()) * float64(rule.LINENUM) * float64(500) / 10000))
this.jackpot.VirtualJK += val
}
}
func (this *CaiShenSceneData) AIBurstJackPot() {
if time.Now().Sub(this.GetLastBurstJackPot()) > 0 {
this.SetLastBurstJackPot()
jackpotParams := this.DbGameFree.GetJackpot()
var jackpotInit = int64(jackpotParams[rule.CAISHEN_JACKPOT_InitJackpot]) * int64(this.DbGameFree.GetBaseScore()) //奖池初始值
jackpotParams := this.GetDBGameFree().GetJackpot()
var jackpotInit = int64(jackpotParams[rule.CAISHEN_JACKPOT_InitJackpot]) * int64(this.GetDBGameFree().GetBaseScore()) //奖池初始值
//AI机器人爆奖
val := this.jackpot.VirtualJK
this.jackpot.VirtualJK = jackpotInit
bet := int64(this.DbGameFree.GetBaseScore()) * int64(rule.LINENUM)
bet := int64(this.GetDBGameFree().GetBaseScore()) * int64(rule.LINENUM)
this.RecordBurstLog(this.RandNickName(), val, int64(bet))
}
}
@ -314,11 +314,11 @@ func (this *CaiShenSceneData) KickPlayerByTime() {
}
//for _, p := range this.players {
// //游戏次数达到目标值
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(this.DbGameFree.GetId()))
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(this.GetDBGameFree().GetId()))
// if !p.IsRob &&
// todayGamefreeIDSceneData != nil &&
// this.DbGameFree.GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(this.DbGameFree.GetPlayNumLimit()) {
// this.GetDBGameFree().GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(this.GetDBGameFree().GetPlayNumLimit()) {
// this.PlayerLeave(p.Player, common.PlayerLeaveReason_GameTimes, true)
// }
//}

View File

@ -94,8 +94,8 @@ func (this *ScenePolicyCaiShen) OnPlayerEnter(s *base.Scene, p *base.Player) {
logger.Logger.Trace("(this *ScenePolicyCaiShen) OnPlayerEnter, SceneId=", s.SceneId, " player=", p.SnId)
if sceneEx, ok := s.ExtraData.(*CaiShenSceneData); ok {
playerEx := &CaiShenPlayerData{Player: p}
playerEx.init(s) // 玩家当前信息初始化
playerEx.score = sceneEx.DbGameFree.GetBaseScore() // 底注
playerEx.init(s) // 玩家当前信息初始化
playerEx.score = sceneEx.GetDBGameFree().GetBaseScore() // 底注
sceneEx.players[p.SnId] = playerEx
p.ExtraData = playerEx
CaiShenSendRoomInfo(s, p, sceneEx, playerEx, nil)
@ -230,14 +230,14 @@ func (this *ScenePolicyCaiShen) GetJackPotVal(s *base.Scene) int64 {
func CaiShenSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *CaiShenSceneData, playerEx *CaiShenPlayerData, data *caishen.GameBilledData) {
logger.Logger.Trace("-------------------发送房间消息 ", s.RoomId, p.SnId)
pack := &caishen.SCCaiShenRoomInfo{
RoomId: proto.Int(s.SceneId),
RoomId: s.SceneId,
Creator: proto.Int32(s.Creator),
GameId: proto.Int(s.GameId),
RoomMode: proto.Int(s.GameMode),
GameId: s.GameId,
RoomMode: s.GameMode,
Params: common.CopySliceInt64ToInt32(s.Params),
State: proto.Int(s.SceneState.GetState()),
Jackpot: proto.Int64(sceneEx.jackpot.VirtualJK),
GameFreeId: proto.Int32(s.DbGameFree.Id),
GameFreeId: proto.Int32(s.GetDBGameFree().Id),
BilledData: data,
}
@ -257,7 +257,7 @@ func CaiShenSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *CaiShenSceneDat
//}
pack.BetLines = playerEx.betLines
pack.FreeTimes = proto.Int32(playerEx.freeTimes)
pack.Chip = proto.Int32(s.DbGameFree.BaseScore)
pack.Chip = proto.Int32(s.GetDBGameFree().BaseScore)
pack.SpinID = proto.Int64(playerEx.spinID)
if playerEx.totalPriceBonus > 0 {
switch playerEx.bonusStage {
@ -373,7 +373,7 @@ func (this *SceneStateCaiShenStart) OnPlayerOp(s *base.Scene, p *base.Player, op
return false
}
//先做底注校验
if sceneEx.DbGameFree.GetBaseScore() != int32(params[0]) {
if sceneEx.GetDBGameFree().GetBaseScore() != int32(params[0]) {
this.OnPlayerSToCOp(s, p, playerEx.Pos, opcode, caishen.OpResultCode_OPRC_Error, params)
return false
}
@ -407,7 +407,7 @@ func (this *SceneStateCaiShenStart) OnPlayerOp(s *base.Scene, p *base.Player, op
if playerEx.freeTimes <= 0 && totalBetValue > playerEx.Coin {
this.OnPlayerSToCOp(s, p, playerEx.Pos, opcode, caishen.OpResultCode_OPRC_CoinNotEnough, params)
return false
} else if playerEx.freeTimes <= 0 && int64(sceneEx.DbGameFree.GetBetLimit()) > playerEx.Coin { //押注限制
} else if playerEx.freeTimes <= 0 && int64(sceneEx.GetDBGameFree().GetBetLimit()) > playerEx.Coin { //押注限制
this.OnPlayerSToCOp(s, p, playerEx.Pos, opcode, caishen.OpResultCode_OPRC_CoinNotEnough, params)
return false
}
@ -422,7 +422,7 @@ func (this *SceneStateCaiShenStart) OnPlayerOp(s *base.Scene, p *base.Player, op
sceneEx.CpCtx = base.CoinPoolMgr.GetCoinPoolCtx(sceneEx.Platform, sceneEx.GetGameFreeId(), sceneEx.GroupId)
//税收比例
taxRate := sceneEx.DbGameFree.GetTaxRate()
taxRate := sceneEx.GetDBGameFree().GetTaxRate()
if taxRate < 0 || taxRate > 10000 {
logger.Logger.Tracef("CaiShenErrorTaxRate [%v][%v][%v][%v]", sceneEx.GetGameFreeId(), playerEx.SnId, playerEx.spinID, taxRate)
taxRate = 500
@ -445,8 +445,8 @@ func (this *SceneStateCaiShenStart) OnPlayerOp(s *base.Scene, p *base.Player, op
prizeFund := gamePoolCoin - sceneEx.jackpot.VirtualJK // 除去奖池的水池剩余金额
// 奖池参数
var jackpotParam = sceneEx.DbGameFree.GetJackpot()
var jackpotInit = int64(jackpotParam[rule.CAISHEN_JACKPOT_InitJackpot]) * int64(sceneEx.DbGameFree.GetBaseScore()) //奖池初始值
var jackpotParam = sceneEx.GetDBGameFree().GetJackpot()
var jackpotInit = int64(jackpotParam[rule.CAISHEN_JACKPOT_InitJackpot]) * int64(sceneEx.GetDBGameFree().GetBaseScore()) //奖池初始值
var jackpotFundAdd, prizeFundAdd int64
if playerEx.freeTimes <= 0 { //正常模式才能记录用户的押注变化,免费模式不能改变押注
@ -466,7 +466,7 @@ func (this *SceneStateCaiShenStart) OnPlayerOp(s *base.Scene, p *base.Player, op
////统计参与游戏次数
//if !sceneEx.Testing && !playerEx.IsRob {
// pack := &server.GWSceneEnd{
// GameFreeId: proto.Int32(sceneEx.DbGameFree.GetId()),
// GameFreeId: proto.Int32(sceneEx.GetDBGameFree().GetId()),
// Players: []*server.PlayerCtx{&server.PlayerCtx{SnId: proto.Int32(playerEx.SnId), Coin: proto.Int64(playerEx.Coin)}},
// }
// proto.SetDefaults(pack)
@ -656,7 +656,7 @@ func (this *SceneStateCaiShenStart) OnPlayerOp(s *base.Scene, p *base.Player, op
case CaiShenPlayerHistory:
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
spinid := strconv.FormatInt(int64(playerEx.SnId), 10)
gpl := model.GetPlayerListByHallEx(p.SnId, p.Platform, 0, 80, 0, 0, 0, s.DbGameFree.GetGameClass(), s.GameId)
gpl := model.GetPlayerListByHallEx(p.SnId, p.Platform, 0, 80, 0, 0, 0, s.GetDBGameFree().GetGameClass(), int(s.GameId))
pack := &caishen.SCCaiShenPlayerHistory{}
for _, v := range gpl.Data {
//if v.GameDetailedLogId == "" {
@ -847,7 +847,7 @@ func (this *SceneStateCaiShenStart) WinTargetBenchTest(s *base.Scene, p *base.Pl
}
file.WriteString("玩家id,当前水位,之前余额,之后余额,投入,产出,税收,小游戏,中线倍数,中线数,剩余免费次数\r\n")
oldCoin := p.Coin
switch s.DbGameFree.GetSceneType() {
switch s.GetDBGameFree().GetSceneType() {
case 1:
p.Coin = 100000
case 2:
@ -905,7 +905,7 @@ func (this *SceneStateCaiShenStart) MultiplayerBenchTest(s *base.Scene) {
})
caiShenBenchTestTimes++
fileName := fmt.Sprintf("caishen-total-%v-%d.csv", s.DbGameFree.GetSceneType(), caiShenBenchTestTimes)
fileName := fmt.Sprintf("caishen-total-%v-%d.csv", s.GetDBGameFree().GetSceneType(), caiShenBenchTestTimes)
file, err := os.OpenFile(fileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, os.ModePerm)
defer file.Close()
if err != nil {
@ -918,7 +918,7 @@ func (this *SceneStateCaiShenStart) MultiplayerBenchTest(s *base.Scene) {
playersFile := make(map[int32]*os.File)
oldCoins := make(map[int32]int64)
hasCoin := 1000 * int64(s.DbGameFree.GetBaseScore())
hasCoin := 1000 * int64(s.GetDBGameFree().GetBaseScore())
robots := make(map[int32]bool)
testPlayers := make(map[int32]*base.Player)
for _, p := range s.Players {
@ -926,7 +926,7 @@ func (this *SceneStateCaiShenStart) MultiplayerBenchTest(s *base.Scene) {
p.IsRob = false
robots[p.SnId] = true
}
fileName := fmt.Sprintf("caishen-player%v-%v-%d.csv", p.SnId, s.DbGameFree.GetSceneType(), caiShenBenchTestTimes)
fileName := fmt.Sprintf("caishen-player%v-%v-%d.csv", p.SnId, s.GetDBGameFree().GetSceneType(), caiShenBenchTestTimes)
file, err := os.OpenFile(fileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, os.ModePerm)
if err != nil {
file, err = os.Create(fileName)
@ -955,7 +955,7 @@ func (this *SceneStateCaiShenStart) MultiplayerBenchTest(s *base.Scene) {
}
}()
totalBet := int64(s.DbGameFree.GetBaseScore()) * int64(len(rule.AllBetLines))
totalBet := int64(s.GetDBGameFree().GetBaseScore()) * int64(len(rule.AllBetLines))
for i := 0; i < BENCH_CNT; i++ {
for snid, p := range testPlayers {
if playerEx, ok := p.ExtraData.(*CaiShenPlayerData); ok {
@ -970,7 +970,7 @@ func (this *SceneStateCaiShenStart) MultiplayerBenchTest(s *base.Scene) {
inCoin := int64(playerEx.RollGameType.BaseResult.TotalBet)
outCoin := playerEx.RollGameType.BaseResult.ChangeCoin + inCoin
taxCoin := playerEx.RollGameType.BaseResult.Tax
lineScore := float64(playerEx.RollGameType.BaseResult.WinRate*s.DbGameFree.GetBaseScore()) * float64(10000.0-s.DbGameFree.GetTaxRate()) / 10000.0
lineScore := float64(playerEx.RollGameType.BaseResult.WinRate*s.GetDBGameFree().GetBaseScore()) * float64(10000.0-s.GetDBGameFree().GetTaxRate()) / 10000.0
jackpotScore := outCoin - playerEx.RollGameType.BaseResult.WinSmallGame - int64(lineScore+0.00001)
str := fmt.Sprintf("%v,%v,%v,%v,%v,%v,%v,%v,%v,%v,%v,%v\r\n", p.SnId, poolCoin, StartCoin, p.Coin, inCoin, outCoin, taxCoin,
@ -1004,7 +1004,7 @@ func CaiShenCheckAndSaveLog(sceneEx *CaiShenSceneData, playerEx *CaiShenPlayerDa
//log2
playerEx.RollGameType.BaseResult.ChangeCoin = changeCoin
playerEx.RollGameType.BaseResult.BasicBet = sceneEx.DbGameFree.GetBaseScore()
playerEx.RollGameType.BaseResult.BasicBet = sceneEx.GetDBGameFree().GetBaseScore()
playerEx.RollGameType.BaseResult.RoomId = int32(sceneEx.SceneId)
playerEx.RollGameType.BaseResult.AfterCoin = playerEx.Coin
playerEx.RollGameType.BaseResult.BeforeCoin = startCoin
@ -1063,8 +1063,8 @@ func CaiShenCheckAndSaveLog(sceneEx *CaiShenSceneData, playerEx *CaiShenPlayerDa
GameCoinTs: proto.Int64(playerEx.GameCoinTs),
}
gwPlayerBet := &server.GWPlayerData{
SceneId: proto.Int(sceneEx.SceneId),
GameFreeId: proto.Int32(sceneEx.DbGameFree.GetId()),
SceneId: sceneEx.SceneId,
GameFreeId: proto.Int32(sceneEx.GetDBGameFree().GetId()),
}
gwPlayerBet.Datas = append(gwPlayerBet.Datas, playerBet)
sceneEx.SyncPlayerDatas(&base.PlayerDataParam{

View File

@ -53,7 +53,7 @@ func getChessVariant(gameId int) int {
}
func NewSceneEx(s *base.Scene) *SceneEx {
variant := getChessVariant(s.GameId)
variant := getChessVariant(int(s.GameId))
chess := rule.NewChess(variant)
chess.Init()
sceneEx := &SceneEx{

View File

@ -485,7 +485,7 @@ func CreateRoomInfoPacket(s *base.Scene, p *base.Player, sceneEx *SceneEx, playe
State: proto.Int32(int32(s.GetSceneState().GetState())),
TimeOut: proto.Int(s.GetSceneState().GetTimeout(s)),
NumOfGames: proto.Int(sceneEx.NumOfGames),
TotalOfGames: proto.Int(sceneEx.TotalOfGames),
TotalOfGames: sceneEx.TotalOfGames,
CurOpIdx: proto.Int(-1),
MasterSnid: proto.Int32(sceneEx.masterSnId),
AudienceNum: proto.Int(s.GetAudiencesNum()),
@ -528,7 +528,7 @@ func CreateRoomInfoPacket(s *base.Scene, p *base.Player, sceneEx *SceneEx, playe
}
pack.MatchFinals = 0
if s.MatchFinals {
if s.GetMatch().GetIsFinals() {
pack.MatchFinals = 1
if s.NumOfGames >= 2 {
pack.MatchFinals = 2
@ -852,7 +852,7 @@ func (this *SceneStateWaitStart) OnTick(s *base.Scene) {
if sceneEx, ok := s.GetExtraData().(*SceneEx); ok {
if sceneEx.IsMatchScene() {
delayT := time.Second * 2
if sceneEx.MatchRound != 1 { //第一轮延迟2s其他延迟3s 配合客户端播放动画
if sceneEx.GetMatch().GetCurrRound() != 1 { //第一轮延迟2s其他延迟3s 配合客户端播放动画
delayT = time.Second * 4
}
if time.Now().Sub(sceneEx.StateStartTime) > delayT {
@ -1215,14 +1215,14 @@ func (this *SceneStateBilled) OnEnter(s *base.Scene) {
pack := &chesstitians.SCChesstitiansGameBilled{}
chessType := model.ChesstitiansType{
GameId: sceneEx.GameId,
GameId: int(sceneEx.GameId),
RoomId: int32(sceneEx.GetSceneId()),
RoomType: int32(sceneEx.Scene.SceneType),
RoomType: sceneEx.Scene.GetDBGameFree().GetSceneType(),
NumOfGames: int32(sceneEx.Scene.NumOfGames),
BankId: sceneEx.masterSnId,
PlayerCount: rule.MaxNumOfPlayer,
BaseScore: s.BaseScore,
TaxRate: s.DbGameFree.GetTaxRate(),
TaxRate: s.GetDBGameFree().GetTaxRate(),
RoomMode: s.GetSceneMode(),
}
@ -1462,7 +1462,7 @@ func (this *SceneStateBilled) OnLeave(s *base.Scene) {
return
}
if s.CheckNeedDestroy() || (s.IsMatchScene() && (!s.MatchFinals || (s.MatchFinals && s.NumOfGames >= 2))) { // 非决赛打一场 决赛打两场
if s.CheckNeedDestroy() || (s.IsMatchScene() && (!s.GetMatch().GetIsFinals() || (s.GetMatch().GetIsFinals() && s.NumOfGames >= 2))) { // 非决赛打一场 决赛打两场
sceneEx.SceneDestroy(true)
}
s.TryRelease()

View File

@ -53,14 +53,14 @@ func (this *EasterIslandSceneData) OnPlayerLeave(p *base.Player, reason int) {
}
func (this *EasterIslandSceneData) init() bool {
if this.DbGameFree == nil {
if this.GetDBGameFree() == nil {
return false
}
params := this.DbGameFree.GetJackpot()
params := this.GetDBGameFree().GetJackpot()
this.jackpot = &base.SlotJackpotPool{}
if this.jackpot.Small <= 0 {
this.jackpot.Small = 0
this.jackpot.VirtualJK = int64(params[rule.EL_JACKPOT_InitJackpot]) * int64(this.DbGameFree.GetBaseScore())
this.jackpot.VirtualJK = int64(params[rule.EL_JACKPOT_InitJackpot]) * int64(this.GetDBGameFree().GetBaseScore())
}
str := base.SlotsPoolMgr.GetPool(this.GetGameFreeId(), this.Platform)
if str != "" {
@ -101,7 +101,7 @@ type EasterIslandSpinResult struct {
}
func (this *EasterIslandSceneData) CalcLinePrize(cards []int, betLines []int64, betValue int64) (spinRes EasterIslandSpinResult) {
taxRate := this.DbGameFree.GetTaxRate()
taxRate := this.GetDBGameFree().GetTaxRate()
calcTaxScore := func(score int64, taxScore *int64) int64 {
newScore := int64(float64(score) * float64(10000-taxRate) / 10000.0)
if taxScore != nil {
@ -192,7 +192,7 @@ func (this *EasterIslandSceneData) BroadcastJackpot(sync bool) {
this.lastJackpotValue = this.jackpot.VirtualJK
pack := &gamehall.SCHundredSceneGetGameJackpot{}
jpfi := &gamehall.GameJackpotFundInfo{
GameFreeId: proto.Int32(this.DbGameFree.Id),
GameFreeId: proto.Int32(this.GetDBGameFree().Id),
JackPotFund: proto.Int64(this.jackpot.VirtualJK),
}
pack.GameJackpotFund = append(pack.GameJackpotFund, jpfi)
@ -218,7 +218,7 @@ func (this *EasterIslandSceneData) PopCoinPool(winCoin int64, IsNovice bool) {
}
}
func (this *EasterIslandSceneData) RecordBurstLog(name string, wincoin, totalbet int64) {
log := model.NewBurstJackpotLog(this.Platform, this.DbGameFree.GameId, this.GetGameFreeId(), name, wincoin, totalbet)
log := model.NewBurstJackpotLog(this.Platform, this.GetDBGameFree().GameId, this.GetGameFreeId(), name, wincoin, totalbet)
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
return model.InsertBurstJackpotLogs(log)
}), nil, "InsertBurstJackpotLogs").Start()
@ -226,7 +226,7 @@ func (this *EasterIslandSceneData) RecordBurstLog(name string, wincoin, totalbet
func (this *EasterIslandSceneData) BurstHistory(player *EasterIslandPlayerData) {
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
return model.GetBurstJackpotLog(this.Platform, this.DbGameFree.GameId)
return model.GetBurstJackpotLog(this.Platform, this.GetDBGameFree().GameId)
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
var logsp []*easterisland.EasterIslandBurstHistoryInfo
if data != nil {
@ -254,7 +254,7 @@ func (this *EasterIslandSceneData) GetLastBurstJackPot() time.Time {
}
func (this *EasterIslandSceneData) SetLastBurstJackPot() {
var randT = rand.Intn(25200-7200+1) + 7200
switch this.DbGameFree.SceneType {
switch this.GetDBGameFree().SceneType {
case 1:
randT = rand.Intn(25200-7200+1) + 7200
case 2:
@ -269,7 +269,7 @@ func (this *EasterIslandSceneData) SetLastBurstJackPot() {
func (this *EasterIslandSceneData) AIAddJackPot() {
if time.Now().Sub(this.lastJackPot) > 0 {
var randT = rand.Intn(3) + 1
switch this.DbGameFree.SceneType {
switch this.GetDBGameFree().SceneType {
case 1:
randT = rand.Intn(3) + 1
case 2:
@ -282,20 +282,20 @@ func (this *EasterIslandSceneData) AIAddJackPot() {
randT = rand.Intn(3) + 1
}
this.lastJackPot = time.Now().Add(time.Second * time.Duration(randT))
val := int64(math.Floor(float64(this.DbGameFree.GetBaseScore()) * float64(rule.LINENUM) * float64(500) / 10000))
val := int64(math.Floor(float64(this.GetDBGameFree().GetBaseScore()) * float64(rule.LINENUM) * float64(500) / 10000))
this.jackpot.VirtualJK += val
}
}
func (this *EasterIslandSceneData) AIBurstJackPot() {
if time.Now().Sub(this.GetLastBurstJackPot()) > 0 {
this.SetLastBurstJackPot()
jackpotParams := this.DbGameFree.GetJackpot()
var jackpotInit = int64(jackpotParams[rule.EL_JACKPOT_InitJackpot]) * int64(this.DbGameFree.GetBaseScore()) //奖池初始值
jackpotParams := this.GetDBGameFree().GetJackpot()
var jackpotInit = int64(jackpotParams[rule.EL_JACKPOT_InitJackpot]) * int64(this.GetDBGameFree().GetBaseScore()) //奖池初始值
//AI机器人爆奖
val := this.jackpot.VirtualJK
this.jackpot.VirtualJK = jackpotInit
bet := int64(this.DbGameFree.GetBaseScore()) * int64(rule.LINENUM)
bet := int64(this.GetDBGameFree().GetBaseScore()) * int64(rule.LINENUM)
this.RecordBurstLog(this.RandNickName(), val, bet)
}
}
@ -316,11 +316,11 @@ func (this *EasterIslandSceneData) KickPlayerByTime() {
}
//for _, p := range this.players {
// //游戏次数达到目标值
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(this.DbGameFree.GetId()))
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(this.GetDBGameFree().GetId()))
// if !p.IsRob &&
// todayGamefreeIDSceneData != nil &&
// this.DbGameFree.GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(this.DbGameFree.GetPlayNumLimit()) {
// this.GetDBGameFree().GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(this.GetDBGameFree().GetPlayNumLimit()) {
// this.PlayerLeave(p.Player, common.PlayerLeaveReason_GameTimes, true)
// }
//}

View File

@ -94,8 +94,8 @@ func (this *ScenePolicyEasterIsland) OnPlayerEnter(s *base.Scene, p *base.Player
logger.Logger.Trace("(this *ScenePolicyEasterIsland) OnPlayerEnter, sceneId=", s.SceneId, " player=", p.SnId)
if sceneEx, ok := s.ExtraData.(*EasterIslandSceneData); ok {
playerEx := &EasterIslandPlayerData{Player: p}
playerEx.init(s) // 玩家当前信息初始化
playerEx.score = sceneEx.DbGameFree.GetBaseScore() // 底注
playerEx.init(s) // 玩家当前信息初始化
playerEx.score = sceneEx.GetDBGameFree().GetBaseScore() // 底注
sceneEx.players[p.SnId] = playerEx
p.ExtraData = playerEx
EasterIslandSendRoomInfo(s, p, sceneEx, playerEx, nil)
@ -230,14 +230,14 @@ func (this *ScenePolicyEasterIsland) GetJackPotVal(s *base.Scene) int64 {
func EasterIslandSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *EasterIslandSceneData, playerEx *EasterIslandPlayerData, data *easterisland.GameBilledData) {
logger.Logger.Trace("-------------------发送房间消息 ", s.RoomId, p.SnId)
pack := &easterisland.SCEasterIslandRoomInfo{
RoomId: proto.Int(s.SceneId),
RoomId: s.SceneId,
Creator: proto.Int32(s.Creator),
GameId: proto.Int(s.GameId),
RoomMode: proto.Int(s.GameMode),
GameId: s.GameId,
RoomMode: s.GameMode,
Params: common.CopySliceInt64ToInt32(s.Params),
State: proto.Int(s.SceneState.GetState()),
Jackpot: proto.Int64(sceneEx.jackpot.VirtualJK),
GameFreeId: proto.Int32(s.DbGameFree.Id),
GameFreeId: proto.Int32(s.GetDBGameFree().Id),
BilledData: data,
}
if playerEx != nil {
@ -256,7 +256,7 @@ func EasterIslandSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *EasterIsla
//}
pack.BetLines = playerEx.betLines
pack.FreeTimes = proto.Int32(playerEx.freeTimes)
pack.Chip = proto.Int32(s.DbGameFree.BaseScore)
pack.Chip = proto.Int32(s.GetDBGameFree().BaseScore)
pack.SpinID = proto.Int64(playerEx.spinID)
if playerEx.totalPriceBonus > 0 {
switch playerEx.bonusStage {
@ -367,7 +367,7 @@ func (this *SceneStateEasterIslandStart) OnPlayerOp(s *base.Scene, p *base.Playe
return false
}
//先做底注校验
if sceneEx.DbGameFree.GetBaseScore() != int32(params[0]) {
if sceneEx.GetDBGameFree().GetBaseScore() != int32(params[0]) {
this.OnPlayerSToCOp(s, p, playerEx.Pos, opcode, easterisland.OpResultCode_OPRC_Error, params)
return false
}
@ -401,7 +401,7 @@ func (this *SceneStateEasterIslandStart) OnPlayerOp(s *base.Scene, p *base.Playe
if playerEx.freeTimes <= 0 && totalBetValue > playerEx.Coin {
this.OnPlayerSToCOp(s, p, playerEx.Pos, opcode, easterisland.OpResultCode_OPRC_CoinNotEnough, params)
return false
} else if playerEx.freeTimes <= 0 && int64(sceneEx.DbGameFree.GetBetLimit()) > playerEx.Coin { //押注限制
} else if playerEx.freeTimes <= 0 && int64(sceneEx.GetDBGameFree().GetBetLimit()) > playerEx.Coin { //押注限制
this.OnPlayerSToCOp(s, p, playerEx.Pos, opcode, easterisland.OpResultCode_OPRC_CoinNotEnough, params)
return false
}
@ -413,7 +413,7 @@ func (this *SceneStateEasterIslandStart) OnPlayerOp(s *base.Scene, p *base.Playe
//获取当前水池的上下文环境
sceneEx.CpCtx = base.CoinPoolMgr.GetCoinPoolCtx(sceneEx.Platform, sceneEx.GetGameFreeId(), sceneEx.GroupId)
taxRate := sceneEx.DbGameFree.GetTaxRate()
taxRate := sceneEx.GetDBGameFree().GetTaxRate()
if taxRate < 0 || taxRate > 10000 {
logger.Logger.Warnf("EasterIslandErrorTaxRate [%v][%v][%v][%v]", sceneEx.GetGameFreeId(), playerEx.SnId, playerEx.spinID, taxRate)
taxRate = 500
@ -430,9 +430,9 @@ func (this *SceneStateEasterIslandStart) OnPlayerOp(s *base.Scene, p *base.Playe
} else {
gamePoolCoin = base.CoinPoolMgr.GetCoin(sceneEx.GetGameFreeId(), sceneEx.Platform, sceneEx.GroupId) // 当前水池金额
}
prizeFund := gamePoolCoin - sceneEx.jackpot.VirtualJK // 除去奖池的水池剩余金额
jackpotParams := sceneEx.DbGameFree.GetJackpot() // 奖池参数
var jackpotInit = int64(jackpotParams[rule.EL_JACKPOT_InitJackpot]) * int64(sceneEx.DbGameFree.GetBaseScore()) //奖池初始值
prizeFund := gamePoolCoin - sceneEx.jackpot.VirtualJK // 除去奖池的水池剩余金额
jackpotParams := sceneEx.GetDBGameFree().GetJackpot() // 奖池参数
var jackpotInit = int64(jackpotParams[rule.EL_JACKPOT_InitJackpot]) * int64(sceneEx.GetDBGameFree().GetBaseScore()) //奖池初始值
var jackpotFundAdd, prizeFundAdd int64
if playerEx.freeTimes <= 0 { //正常模式才能记录用户的押注变化,免费模式不能改变押注
@ -449,7 +449,7 @@ func (this *SceneStateEasterIslandStart) OnPlayerOp(s *base.Scene, p *base.Playe
////统计参与游戏次数
//if !sceneEx.Testing && !playerEx.IsRob {
// pack := &server.GWSceneEnd{
// GameFreeId: proto.Int32(sceneEx.DbGameFree.GetId()),
// GameFreeId: proto.Int32(sceneEx.GetDBGameFree().GetId()),
// Players: []*server.PlayerCtx{&server.PlayerCtx{SnId: proto.Int32(playerEx.SnId), Coin: proto.Int64(playerEx.Coin)}},
// }
// proto.SetDefaults(pack)
@ -629,7 +629,7 @@ func (this *SceneStateEasterIslandStart) OnPlayerOp(s *base.Scene, p *base.Playe
case EasterIslandPlayerHistory:
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
spinid := strconv.FormatInt(int64(playerEx.SnId), 10)
gpl := model.GetPlayerListByHallEx(p.SnId, p.Platform, 0, 80, 0, 0, 0, s.DbGameFree.GetGameClass(), s.GameId)
gpl := model.GetPlayerListByHallEx(p.SnId, p.Platform, 0, 80, 0, 0, 0, s.GetDBGameFree().GetGameClass(), int(s.GameId))
pack := &easterisland.SCEasterIslandPlayerHistory{}
for _, v := range gpl.Data {
//if v.GameDetailedLogId == "" {
@ -819,7 +819,7 @@ func (this *SceneStateEasterIslandStart) WinTargetBenchTest(s *base.Scene, p *ba
}
file.WriteString("玩家id,当前水位,之前余额,之后余额,投入,产出,税收,小游戏,中线倍数,中线数,剩余免费次数\r\n")
oldCoin := p.Coin
switch s.DbGameFree.GetSceneType() {
switch s.GetDBGameFree().GetSceneType() {
case 1:
p.Coin = 100000
case 2:
@ -873,7 +873,7 @@ func EasterIslandCheckAndSaveLog(sceneEx *EasterIslandSceneData, playerEx *Easte
//log2
playerEx.RollGameType.BaseResult.ChangeCoin = changeCoin
playerEx.RollGameType.BaseResult.BasicBet = sceneEx.DbGameFree.GetBaseScore()
playerEx.RollGameType.BaseResult.BasicBet = sceneEx.GetDBGameFree().GetBaseScore()
playerEx.RollGameType.BaseResult.RoomId = int32(sceneEx.SceneId)
playerEx.RollGameType.BaseResult.AfterCoin = playerEx.Coin
playerEx.RollGameType.BaseResult.BeforeCoin = startCoin
@ -932,8 +932,8 @@ func EasterIslandCheckAndSaveLog(sceneEx *EasterIslandSceneData, playerEx *Easte
GameCoinTs: proto.Int64(playerEx.GameCoinTs),
}
gwPlayerBet := &server.GWPlayerData{
SceneId: proto.Int(sceneEx.SceneId),
GameFreeId: proto.Int32(sceneEx.DbGameFree.GetId()),
SceneId: sceneEx.SceneId,
GameFreeId: proto.Int32(sceneEx.GetDBGameFree().GetId()),
}
gwPlayerBet.Datas = append(gwPlayerBet.Datas, playerBet)
sceneEx.SyncPlayerDatas(&base.PlayerDataParam{

View File

@ -406,7 +406,7 @@ func (this *CSFishSkillUseReqHandler) Process(s *netlib.Session, packetid int, d
status := false
for _, s := range strSlice {
num, _ := strconv.Atoi(s)
if num == player.GetScene().SceneType {
if int32(num) == player.GetScene().GetSceneType() {
status = true
}
}
@ -414,7 +414,7 @@ func (this *CSFishSkillUseReqHandler) Process(s *netlib.Session, packetid int, d
pack.Result = 1
pack.Status = fishing_proto.SCFishSkillUseResp_ROOM_DISALLOW
player.SendToClient(int(fishing_proto.FIPacketID_FISHING_SC_SKILLUSERESP), pack)
fishlogger.Trace("当前房间不允许使用此技能 skillId = %v,sceneType = %v", skillId, player.GetScene().SceneType)
fishlogger.Trace("当前房间不允许使用此技能 skillId = %v,sceneType = %v", skillId, player.GetScene().GetSceneType())
return nil
}
//判断当前技能在不在CD中
@ -516,7 +516,7 @@ func (this *CSSkillListReqHandler) Process(s *netlib.Session, packetid int, data
pack := &fishing_proto.SCSkillListResp{}
for _, skill := range srvdata.PBDB_FishSkillMgr.Datas.Arr {
//获取房间类型
sceneType := player.GetScene().SceneType
sceneType := player.GetScene().GetSceneType()
str := skill.Hidden
num, err := strconv.Atoi(str)
status := true

View File

@ -300,7 +300,7 @@ func (this *FishingPlayerData) SaveDetailedLog(s *base.Scene) {
GameCoinTs: proto.Int64(this.GameCoinTs),
}
gwPlayerData := &server_proto.GWPlayerData{
SceneId: proto.Int(sceneEx.SceneId),
SceneId: sceneEx.SceneId,
GameFreeId: proto.Int32(sceneEx.GetDBGameFree().GetId()),
}
gwPlayerData.Datas = append(gwPlayerData.Datas, playerBet)

View File

@ -108,12 +108,11 @@ func (this *FishingSceneData) init() bool {
this.SetPlayerNum(4)
this.gameId = this.GetGameId()
this.platform = this.GetPlatform()
this.sceneType = int(this.DbGameFree.GetSceneType())
this.sceneType = int(this.GetDBGameFree().GetSceneType())
this.keyGameId = this.GetKeyGameId()
this.testing = this.GetTesting()
this.gamefreeId = this.GetGameFreeId()
this.groupId = this.GetGroupId()
this.agentor = this.GetAgentor()
this.sceneMode = this.GetSceneMode()
this.TimePoint = 0
this.lastLittleBossTime = time.Now().Unix()
@ -905,7 +904,7 @@ func (this *FishingSceneData) fishSettlements(fishs []*Fish, player *FishingPlay
}
//BOSS鱼死亡 更新BOSS池和个人池
if value.IsBoss == fishing.Boss {
bossPond := base.GetCoinPoolMgr().GetBossPond(this.DbGameFree.SceneType)
bossPond := base.GetCoinPoolMgr().GetBossPond(this.GetDBGameFree().SceneType)
this.isBossDie(player, int64(dropCoin), bossPond)
}
@ -1458,7 +1457,7 @@ func (this *FishingSceneData) BroadCastMessage(packetid int, msg proto.Message,
if gateSess == nil || len(v) == 0 {
continue
}
pack, err := base.MulticastMaker.CreateMulticastPacket(packetid, msg, v...)
pack, err := common.CreateMulticastPacket(packetid, msg, v...)
if err == nil {
proto.SetDefaults(pack)
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
@ -1508,7 +1507,7 @@ func (this *FishingSceneData) AddBossPond(player *FishingPlayerData, fishtype in
// 减掉个人池数值
if score > 0 {
player.MoneyPond -= score
base.GetCoinPoolMgr().AddBossPond(this.DbGameFree.SceneType, score)
base.GetCoinPoolMgr().AddBossPond(this.GetDBGameFree().SceneType, score)
}
}
@ -1522,7 +1521,7 @@ func (this *FishingSceneData) isBossDie(player *FishingPlayerData, score int64,
minNum = bossPond
}
player.MoneyPond += minNum
base.GetCoinPoolMgr().AddBossPond(this.DbGameFree.SceneType, -minNum)
base.GetCoinPoolMgr().AddBossPond(this.GetDBGameFree().SceneType, -minNum)
fishlogger.Infof("玩家:%vBoss奖池剩余金币数量%v\n", player.SnId, bossPond)
}

View File

@ -101,7 +101,7 @@ func (p *FruitsPlayerData) Clear() {
p.weightPos = 0
}
func (p *FruitsPlayerData) TestCode(eleLineAppearRate [][]int32, sceneEx *FruitsSceneData) bool {
//if sceneEx.DbGameFree.GetId() == 3060004 {
//if sceneEx.GetDBGameFree().GetId() == 3060004 {
// p.result.CreateLine(eleLineAppearRate, p.gameState == fruits.FreeGame)
// if p.testIdx == 1 {
// //test mary
@ -186,7 +186,7 @@ func (p *FruitsPlayerData) CreateResult(eleLineAppearRate [][]int32, sceneEx *Fr
case 5:
winjackpot = int64(math.Ceil(float64(JackPotVal) * 0.4 / float64(fruits.NowByte)))
}
if winjackpot < int64(sceneEx.DbGameFree.GetJackpotMin())*fruits.NowByte {
if winjackpot < int64(sceneEx.GetDBGameFree().GetJackpotMin())*fruits.NowByte {
isNeed = false
break
}

View File

@ -40,7 +40,7 @@ func NewFruitsSceneData(s *base.Scene) *FruitsSceneData {
func (s *FruitsSceneData) Init() {
s.LoadJackPotData()
//for _, data := range srvdata.PBDB_SlotRateWeightMgr.Datas.Arr {
// if data.Id == s.DbGameFree.Id {
// if data.Id == s.GetDBGameFree().Id {
// //s.levelRate = append(s.levelRate, data.EleWeight1)
// //s.slotRateWeightTotal = append(s.slotRateWeightTotal, data.EleWeight1, data.EleWeight2, data.EleWeight3, data.EleWeight4, data.EleWeight5)
// }
@ -59,12 +59,12 @@ func (s *FruitsSceneData) SceneDestroy(force bool) {
}
func (s *FruitsSceneData) AddPrizeCoin(playerEx *FruitsPlayerData) {
val := playerEx.betCoin
tax := int64(math.Ceil(float64(val) * float64(s.DbGameFree.GetTaxRate()) / 10000))
tax := int64(math.Ceil(float64(val) * float64(s.GetDBGameFree().GetTaxRate()) / 10000))
//playerEx.taxCoin = tax
//playerEx.AddServiceFee(tax)
val -= tax
addPrizeCoin := int64(math.Floor(float64(val*fruits.NowByte*int64(s.DbGameFree.GetJackpotRatio())) / 1000)) //扩大10000倍
addPrizeCoin := int64(math.Floor(float64(val*fruits.NowByte*int64(s.GetDBGameFree().GetJackpotRatio())) / 1000)) //扩大10000倍
s.jackpot.AddToSmall(playerEx.IsRob, addPrizeCoin)
logger.Logger.Tracef("奖池增加...AddPrizeCoin... %f", float64(addPrizeCoin)/float64(fruits.NowByte))
base.SlotsPoolMgr.SetPool(s.GetGameFreeId(), s.Platform, s.jackpot)
@ -95,7 +95,7 @@ func (s *FruitsSceneData) OnPlayerLeave(p *base.Player, reason int) {
if playerEx.winCoin != 0 {
//SysProfitCoinMgr.Add(s.sysProfitCoinKey, 0, playerEx.winCoin)
p.Statics(s.KeyGameId, s.KeyGamefreeId, playerEx.winCoin, false)
//tax := int64(math.Ceil(float64(playerEx.winCoin) * float64(s.DbGameFree.GetTaxRate()) / 10000))
//tax := int64(math.Ceil(float64(playerEx.winCoin) * float64(s.GetDBGameFree().GetTaxRate()) / 10000))
//playerEx.taxCoin = tax
//playerEx.winCoin -= tax
//p.AddServiceFee(tax)
@ -140,7 +140,7 @@ func (s *FruitsSceneData) Win(p *FruitsPlayerData) {
p.noWinTimes = 0
//SysProfitCoinMgr.Add(s.sysProfitCoinKey, 0, p.winCoin)
p.Statics(s.KeyGameId, s.KeyGamefreeId, p.winCoin, false)
//tax := int64(math.Ceil(float64(p.winCoin) * float64(s.DbGameFree.GetTaxRate()) / 10000))
//tax := int64(math.Ceil(float64(p.winCoin) * float64(s.GetDBGameFree().GetTaxRate()) / 10000))
//p.taxCoin = tax
//p.winCoin -= tax
//p.AddServiceFee(tax)
@ -210,7 +210,7 @@ func (s *FruitsSceneData) LoadJackPotData() {
base.SlotsPoolMgr.SetPool(s.GetGameFreeId(), s.Platform, s.jackpot)
} else {
s.jackpot = &base.SlotJackpotPool{}
jp := s.DbGameFree.GetJackpot()
jp := s.GetDBGameFree().GetJackpot()
if len(jp) > 0 {
s.jackpot.Small += int64(jp[0] * 10000)
}
@ -244,7 +244,7 @@ func (s *FruitsSceneData) SaveLog(p *FruitsPlayerData, isOffline int) {
}
}
FruitsType := model.FruitsType{
RoomId: s.SceneId,
RoomId: int(s.SceneId),
BasicScore: int32(p.oneBetCoin),
PlayerSnId: p.SnId,
BeforeCoin: p.startCoin,
@ -372,7 +372,7 @@ func (s *FruitsSceneData) SendPlayerBet(p *FruitsPlayerData) {
Tax: proto.Int64(p.taxCoin),
}
gwPlayerBet := &server.GWPlayerData{
GameFreeId: proto.Int32(s.DbGameFree.GetId()),
GameFreeId: proto.Int32(s.GetDBGameFree().GetId()),
}
gwPlayerBet.Datas = append(gwPlayerBet.Datas, playerBet)
s.SyncPlayerDatas(&base.PlayerDataParam{
@ -604,8 +604,8 @@ func (s *FruitsSceneData) GetEleWeight(needpos int32) (norms, frees, marys [][]i
curCoin := base.CoinPoolMgr.GetCoin(s.GetGameFreeId(), s.Platform, s.GroupId)
curCoin = int64(math.Floor(float64(curCoin) / float64(fruits.NowByte)))
for i := len(s.DbGameFree.BalanceLine) - 1; i >= 0; i-- {
balance := s.DbGameFree.BalanceLine[i]
for i := len(s.GetDBGameFree().BalanceLine) - 1; i >= 0; i-- {
balance := s.GetDBGameFree().BalanceLine[i]
if curCoin >= int64(balance) {
key = int32(i)
break

View File

@ -148,16 +148,16 @@ func FruitsSendRoomInfo(s *base.Scene, sceneEx *FruitsSceneData, playerEx *Fruit
func FruitsCreateRoomInfoPacket(s *base.Scene, sceneEx *FruitsSceneData, playerEx *FruitsPlayerData) interface{} {
//房间信息
pack := &protocol.SCFruitsRoomInfo{
RoomId: proto.Int(s.SceneId),
GameId: proto.Int(s.GameId),
RoomMode: proto.Int(s.SceneMode),
SceneType: proto.Int(s.SceneType),
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.DbGameFree.OtherIntParams,
GameFreeId: proto.Int32(s.DbGameFree.Id),
//BetLimit: s.DbGameFree.BetLimit,
ParamsEx: s.GetDBGameFree().OtherIntParams,
GameFreeId: proto.Int32(s.GetDBGameFree().Id),
//BetLimit: s.GetDBGameFree().BetLimit,
}
//自己的信息
@ -299,11 +299,11 @@ func (this *SceneBaseStateFruits) OnTick(s *base.Scene) {
if sceneEx, ok := s.ExtraData.(*FruitsSceneData); ok {
//for _, p := range sceneEx.players {
// //游戏次数达到目标值
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(sceneEx.DbGameFree.GetId()))
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(sceneEx.GetDBGameFree().GetId()))
// if !p.IsRob &&
// todayGamefreeIDSceneData != nil &&
// sceneEx.DbGameFree.GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(sceneEx.DbGameFree.GetPlayNumLimit()) {
// sceneEx.GetDBGameFree().GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(sceneEx.GetDBGameFree().GetPlayNumLimit()) {
// s.PlayerLeave(p.Player, common.PlayerLeaveReason_GameTimes, true)
// }
//}
@ -397,7 +397,7 @@ func (this *SceneStateStartFruits) OnPlayerOp(s *base.Scene, p *base.Player, opc
//只有开始算操作
p.LastOPTimer = time.Now()
idx := int(params[0])
if len(sceneEx.DbGameFree.GetOtherIntParams()) <= idx {
if len(sceneEx.GetDBGameFree().GetOtherIntParams()) <= idx {
pack := &protocol.SCFruitsOp{
OpCode: proto.Int(opcode),
OpRetCode: proto.Int(3),
@ -419,12 +419,12 @@ func (this *SceneStateStartFruits) OnPlayerOp(s *base.Scene, p *base.Player, opc
if playerEx.gameState == fruits.Normal {
playerEx.freeTotal = 0
playerEx.betIdx = idx
playerEx.betCoin = int64(sceneEx.DbGameFree.GetOtherIntParams()[idx])
playerEx.betCoin = int64(sceneEx.GetDBGameFree().GetOtherIntParams()[idx])
playerEx.oneBetCoin = playerEx.betCoin / 9
//playerEx.isReportGameEvent = true
playerEx.noWinTimes++
if playerEx.Coin < int64(s.DbGameFree.GetBetLimit()) {
if playerEx.Coin < int64(s.GetDBGameFree().GetBetLimit()) {
//押注限制(低于该值不能押注)
pack := &protocol.SCFruitsOp{
OpCode: proto.Int(opcode),
@ -486,9 +486,9 @@ func (this *SceneStateStartFruits) OnPlayerOp(s *base.Scene, p *base.Player, opc
case fruits.FruitsPlayerOpSwitch:
if len(params) > 0 && playerEx.freeTimes == 0 && playerEx.maryFreeTimes == 0 {
idx := int(params[0])
if len(sceneEx.DbGameFree.GetOtherIntParams()) > idx {
if len(sceneEx.GetDBGameFree().GetOtherIntParams()) > idx {
playerEx.betIdx = idx
playerEx.betCoin = int64(sceneEx.DbGameFree.GetOtherIntParams()[idx])
playerEx.betCoin = int64(sceneEx.GetDBGameFree().GetOtherIntParams()[idx])
playerEx.oneBetCoin = playerEx.betCoin / 9
}
}

View File

@ -67,7 +67,7 @@ func (this *IceAgeSceneData) init() bool {
this.jackpot = &base.SlotJackpotPool{}
if this.jackpot.Small <= 0 {
this.jackpot.Small = 0
this.jackpot.VirtualJK = int64(params[rule.ICEAGE_JACKPOT_InitJackpot]) * int64(this.DbGameFree.GetBaseScore())
this.jackpot.VirtualJK = int64(params[rule.ICEAGE_JACKPOT_InitJackpot]) * int64(this.GetDBGameFree().GetBaseScore())
}
str := base.SlotsPoolMgr.GetPool(this.GetGameFreeId(), this.GetPlatform())
@ -238,7 +238,7 @@ func (this *IceAgeSceneData) BroadcastJackpot(sync bool) {
this.lastJackpotValue = this.jackpot.VirtualJK
pack := &gamehall.SCHundredSceneGetGameJackpot{}
jpfi := &gamehall.GameJackpotFundInfo{
GameFreeId: proto.Int32(this.DbGameFree.Id),
GameFreeId: proto.Int32(this.GetDBGameFree().Id),
JackPotFund: proto.Int64(this.jackpot.VirtualJK),
}
pack.GameJackpotFund = append(pack.GameJackpotFund, jpfi)
@ -264,7 +264,7 @@ func (this *IceAgeSceneData) PopCoinPool(winCoin int64, IsNovice bool) {
}
}
func (this *IceAgeSceneData) RecordBurstLog(name string, wincoin, totalbet int64) {
log := model.NewBurstJackpotLog(this.Platform, this.DbGameFree.GameId, this.GetGameFreeId(), name, wincoin, totalbet)
log := model.NewBurstJackpotLog(this.Platform, this.GetDBGameFree().GameId, this.GetGameFreeId(), name, wincoin, totalbet)
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
return model.InsertBurstJackpotLogs(log)
}), nil, "InsertBurstJackpotLogs").Start()
@ -272,7 +272,7 @@ func (this *IceAgeSceneData) RecordBurstLog(name string, wincoin, totalbet int64
func (this *IceAgeSceneData) BurstHistory(player *IceAgePlayerData) {
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
return model.GetBurstJackpotLog(this.Platform, this.DbGameFree.GameId)
return model.GetBurstJackpotLog(this.Platform, this.GetDBGameFree().GameId)
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
var logsp []*iceage.IceAgeBurstHistoryInfo
if data != nil {
@ -300,7 +300,7 @@ func (this *IceAgeSceneData) GetLastBurstJackPot() time.Time {
}
func (this *IceAgeSceneData) SetLastBurstJackPot() {
var randT = rand.Intn(25200-7200+1) + 7200
switch this.DbGameFree.SceneType {
switch this.GetDBGameFree().SceneType {
case 1:
randT = rand.Intn(25200-7200+1) + 7200
case 2:
@ -313,7 +313,7 @@ func (this *IceAgeSceneData) SetLastBurstJackPot() {
func (this *IceAgeSceneData) AIAddJackPot() {
if time.Now().Sub(this.lastJackPot) > 0 {
var randT = rand.Intn(3) + 1
switch this.DbGameFree.SceneType {
switch this.GetDBGameFree().SceneType {
case 1:
randT = rand.Intn(3) + 1
case 2:
@ -324,20 +324,20 @@ func (this *IceAgeSceneData) AIAddJackPot() {
randT = rand.Intn(3) + 1
}
this.lastJackPot = time.Now().Add(time.Second * time.Duration(randT))
val := int64(math.Floor(float64(this.DbGameFree.GetBaseScore()) * float64(rule.LINENUM) * float64(500) / 10000))
val := int64(math.Floor(float64(this.GetDBGameFree().GetBaseScore()) * float64(rule.LINENUM) * float64(500) / 10000))
this.jackpot.VirtualJK += val
}
}
func (this *IceAgeSceneData) AIBurstJackPot() {
if time.Now().Sub(this.GetLastBurstJackPot()) > 0 {
this.SetLastBurstJackPot()
jackpotParams := this.DbGameFree.GetJackpot()
var jackpotInit = int64(jackpotParams[rule.ICEAGE_JACKPOT_InitJackpot]) * int64(this.DbGameFree.GetBaseScore()) //奖池初始值
jackpotParams := this.GetDBGameFree().GetJackpot()
var jackpotInit = int64(jackpotParams[rule.ICEAGE_JACKPOT_InitJackpot]) * int64(this.GetDBGameFree().GetBaseScore()) //奖池初始值
//AI机器人爆奖
val := this.jackpot.VirtualJK
this.jackpot.VirtualJK = jackpotInit
bet := int64(this.DbGameFree.GetBaseScore()) * int64(rule.LINENUM)
bet := int64(this.GetDBGameFree().GetBaseScore()) * int64(rule.LINENUM)
this.RecordBurstLog(this.RandNickName(), val, bet)
}
}
@ -358,11 +358,11 @@ func (this *IceAgeSceneData) KickPlayerByTime() {
}
//for _, p := range this.players {
// //游戏次数达到目标值
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(this.DbGameFree.GetId()))
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(this.GetDBGameFree().GetId()))
// if !p.IsRob &&
// todayGamefreeIDSceneData != nil &&
// this.DbGameFree.GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(this.DbGameFree.GetPlayNumLimit()) {
// this.GetDBGameFree().GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(this.GetDBGameFree().GetPlayNumLimit()) {
// this.PlayerLeave(p.Player, common.PlayerLeaveReason_GameTimes, true)
// }
//}

View File

@ -253,7 +253,7 @@ func IceAgeSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *IceAgeSceneData,
pack.Players = append(pack.Players, pd)
pack.BetLines = playerEx.betLines
pack.FreeTimes = proto.Int32(playerEx.freeTimes)
pack.Chip = proto.Int32(s.DbGameFree.BaseScore)
pack.Chip = proto.Int32(s.GetDBGameFree().BaseScore)
pack.TotalPriceBonus = proto.Int64(playerEx.totalPriceBonus)
pack.SpinID = proto.Int64(playerEx.spinID)
}
@ -681,7 +681,7 @@ func (this *SceneStateIceAgeStart) OnPlayerOp(s *base.Scene, p *base.Player, opc
case IceAgePlayerHistory:
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
spinid := strconv.FormatInt(int64(playerEx.SnId), 10)
gpl := model.GetPlayerListByHallEx(p.SnId, p.Platform, 0, 80, 0, 0, 0, s.DbGameFree.GetGameClass(), s.GetGameId())
gpl := model.GetPlayerListByHallEx(p.SnId, p.Platform, 0, 80, 0, 0, 0, s.GetDBGameFree().GetGameClass(), s.GetGameId())
pack := &iceage.SCIceAgePlayerHistory{}
for _, v := range gpl.Data {
//if v.GameDetailedLogId == "" {
@ -982,7 +982,7 @@ func IceAgeCheckAndSaveLog(sceneEx *IceAgeSceneData, playerEx *IceAgePlayerData)
GameCoinTs: proto.Int64(playerEx.GameCoinTs),
}
gwPlayerBet := &server.GWPlayerData{
SceneId: proto.Int(sceneEx.SceneId),
SceneId: sceneEx.SceneId,
GameFreeId: proto.Int32(sceneEx.GetDBGameFree().GetId()),
}
gwPlayerBet.Datas = append(gwPlayerBet.Datas, playerBet)

View File

@ -58,13 +58,13 @@ func (s *RichBlessedSceneData) SceneDestroy(force bool) {
}
func (s *RichBlessedSceneData) AddPrizeCoin(playerEx *RichBlessedPlayerData) {
val := playerEx.betCoin
tax := int64(math.Ceil(float64(val) * float64(s.DbGameFree.GetTaxRate()) / 10000))
tax := int64(math.Ceil(float64(val) * float64(s.GetDBGameFree().GetTaxRate()) / 10000))
//playerEx.taxCoin = tax
//playerEx.AddServiceFee(tax)
val -= tax
addPrizeCoin := val * richblessed.NowByte * int64(s.DbGameFree.GetJackpotRatio()) //扩大10000倍
jk1 := int64(math.Floor(float64(addPrizeCoin) / 1000 / 4)) //千分之奖池比例 分四份
addPrizeCoin := val * richblessed.NowByte * int64(s.GetDBGameFree().GetJackpotRatio()) //扩大10000倍
jk1 := int64(math.Floor(float64(addPrizeCoin) / 1000 / 4)) //千分之奖池比例 分四份
s.jackpot.AddToGrand(playerEx.IsRob, jk1)
s.jackpot.AddToBig(playerEx.IsRob, jk1)
s.jackpot.AddToMiddle(playerEx.IsRob, jk1)
@ -177,7 +177,7 @@ func (s *RichBlessedSceneData) Win(p *RichBlessedPlayerData) {
p.noWinTimes = 0
//SysProfitCoinMgr.Add(s.sysProfitCoinKey, 0, p.winCoin)
p.Statics(s.KeyGameId, s.KeyGamefreeId, p.winCoin, false)
//tax := int64(math.Ceil(float64(p.winCoin) * float64(s.DbGameFree.GetTaxRate()) / 10000))
//tax := int64(math.Ceil(float64(p.winCoin) * float64(s.GetDBGameFree().GetTaxRate()) / 10000))
//p.taxCoin = tax
//p.winCoin -= tax
//p.AddServiceFee(tax)
@ -198,7 +198,7 @@ func (s *RichBlessedSceneData) JACKPOTWin(p *RichBlessedPlayerData) {
p.noWinTimes = 0
//SysProfitCoinMgr.Add(s.sysProfitCoinKey, 0, p.JackwinCoin)
p.Statics(s.KeyGameId, s.KeyGamefreeId, p.JackwinCoin, false)
//tax := int64(math.Ceil(float64(p.JackwinCoin) * float64(s.DbGameFree.GetTaxRate()) / 10000))
//tax := int64(math.Ceil(float64(p.JackwinCoin) * float64(s.GetDBGameFree().GetTaxRate()) / 10000))
//p.taxCoin = tax
//p.JackwinCoin -= tax
//p.AddServiceFee(tax)
@ -271,7 +271,7 @@ func (s *RichBlessedSceneData) LoadJackPotData() {
base.SlotsPoolMgr.SetPool(s.GetGameFreeId(), s.Platform, s.jackpot)
} else {
s.jackpot = &base.SlotJackpotPool{}
jp := s.DbGameFree.GetJackpot()
jp := s.GetDBGameFree().GetJackpot()
if len(jp) > 0 {
s.jackpot.Small += int64(jp[0] * 10000)
}
@ -300,7 +300,7 @@ func (s *RichBlessedSceneData) SaveLog(p *RichBlessedPlayerData, isOffline int)
}
RichBlessed := model.RichBlessedType{
RoomId: s.SceneId,
RoomId: int(s.SceneId),
BasicScore: int32(p.oneBetCoin),
PlayerSnId: p.SnId,
BeforeCoin: p.startCoin,
@ -388,8 +388,8 @@ func (s *RichBlessedSceneData) GetEleWeight(needpos int32) (norms, frees [][]int
curCoin := base.CoinPoolMgr.GetCoin(s.GetGameFreeId(), s.Platform, s.GroupId)
curCoin = int64(math.Floor(float64(curCoin) / float64(richblessed.NowByte)))
for i := len(s.DbGameFree.BalanceLine) - 1; i >= 0; i-- {
balance := s.DbGameFree.BalanceLine[i]
for i := len(s.GetDBGameFree().BalanceLine) - 1; i >= 0; i-- {
balance := s.GetDBGameFree().BalanceLine[i]
if curCoin >= int64(balance) {
key = int32(i)
break
@ -426,7 +426,7 @@ func (s *RichBlessedSceneData) GetEleWeight(needpos int32) (norms, frees [][]int
}
func (s *RichBlessedSceneData) CreateResult(eleLineAppearRate [][]int32, playerEx *RichBlessedPlayerData) {
//if s.DbGameFree.GetId() == 3070004 {
//if s.GetDBGameFree().GetId() == 3070004 {
// playerEx.TestCode(eleLineAppearRate)
//} else {
playerEx.result.CreateLine(eleLineAppearRate)
@ -448,7 +448,7 @@ func (s *RichBlessedSceneData) SendPlayerBet(p *RichBlessedPlayerData) {
GameCoinTs: p.GameCoinTs,
}
gwPlayerBet := &server.GWPlayerData{
GameFreeId: proto.Int32(s.DbGameFree.GetId()),
GameFreeId: proto.Int32(s.GetDBGameFree().GetId()),
SceneId: int32(s.SceneId),
}
gwPlayerBet.Datas = append(gwPlayerBet.Datas, playerBet)

View File

@ -71,7 +71,7 @@ func (this *ScenePolicyRichBlessed) OnPlayerEnter(s *base.Scene, p *base.Player)
if s == nil || p == nil {
return
}
logger.Logger.Trace("(this *ScenePolicyRichBlessed) OnPlayerEnter, sceneId=", s.GetSceneId(), " player=", p.Name, "bet:", s.DbGameFree.GetOtherIntParams())
logger.Logger.Trace("(this *ScenePolicyRichBlessed) OnPlayerEnter, sceneId=", s.GetSceneId(), " player=", p.Name, "bet:", s.GetDBGameFree().GetOtherIntParams())
if sceneEx, ok := s.GetExtraData().(*RichBlessedSceneData); ok {
playerEx := &RichBlessedPlayerData{Player: p}
playerEx.init()
@ -148,15 +148,15 @@ func RichBlessedSendRoomInfo(s *base.Scene, sceneEx *RichBlessedSceneData, playe
func RichBlessedCreateRoomInfoPacket(s *base.Scene, sceneEx *RichBlessedSceneData, playerEx *RichBlessedPlayerData) interface{} {
//房间信息
pack := &protocol.SCRBRoomInfo{
RoomId: proto.Int(s.SceneId),
GameId: proto.Int(s.GameId),
RoomMode: proto.Int(s.SceneMode),
SceneType: proto.Int(s.SceneType),
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: common.Int64ToInt32(s.DbGameFree.OtherIntParams), //s.GetParamsEx(),
//BetLimit: s.DbGameFree.BetLimit,
ParamsEx: common.Int64ToInt32(s.GetDBGameFree().OtherIntParams), //s.GetParamsEx(),
//BetLimit: s.GetDBGameFree().BetLimit,
NowGameState: proto.Int(playerEx.gameState),
BetIdx: proto.Int(playerEx.betIdx),
@ -172,11 +172,11 @@ func RichBlessedCreateRoomInfoPacket(s *base.Scene, sceneEx *RichBlessedSceneDat
WinFreeTimes: proto.Int32(int32(playerEx.nowFreeTimes)),
JackpotEle: proto.Int32(playerEx.result.JackpotEle),
WinJackpot: proto.Int64(playerEx.JackwinCoin),
GameFreeId: proto.Int32(s.DbGameFree.Id),
GameFreeId: proto.Int32(s.GetDBGameFree().Id),
}
if playerEx.oneBetCoin == 0 && len(s.DbGameFree.GetOtherIntParams()) != 0 { // 初始化客户端jack显示
oneBetCoin := int64(s.DbGameFree.GetOtherIntParams()[0] / richblessed.LineNum)
if playerEx.oneBetCoin == 0 && len(s.GetDBGameFree().GetOtherIntParams()) != 0 { // 初始化客户端jack显示
oneBetCoin := int64(s.GetDBGameFree().GetOtherIntParams()[0] / richblessed.LineNum)
pack.SmallJackpot = oneBetCoin * richblessed.JkEleNumRate[richblessed.BlueGirl]
pack.MiddleJackpot = oneBetCoin * richblessed.JkEleNumRate[richblessed.BlueBoy]
pack.BigJackpot = oneBetCoin * richblessed.JkEleNumRate[richblessed.GoldGirl]
@ -302,11 +302,11 @@ func (this *SceneBaseStateRichBlessed) OnTick(s *base.Scene) {
if sceneEx, ok := s.ExtraData.(*RichBlessedSceneData); ok {
//for _, p := range sceneEx.players {
// //游戏次数达到目标值
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(sceneEx.DbGameFree.GetId()))
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(sceneEx.GetDBGameFree().GetId()))
// if !p.IsRob &&
// todayGamefreeIDSceneData != nil &&
// sceneEx.DbGameFree.GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(sceneEx.DbGameFree.GetPlayNumLimit()) {
// sceneEx.GetDBGameFree().GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(sceneEx.GetDBGameFree().GetPlayNumLimit()) {
// s.PlayerLeave(p.Player, common.PlayerLeaveReason_GameTimes, true)
// }
//}
@ -401,7 +401,7 @@ func (this *SceneStateStartRichBlessed) OnPlayerOp(s *base.Scene, p *base.Player
//只有开始算操作
p.LastOPTimer = time.Now()
idx := int(params[0])
if len(sceneEx.DbGameFree.GetOtherIntParams()) <= idx {
if len(sceneEx.GetDBGameFree().GetOtherIntParams()) <= idx {
pack := &protocol.SCRichBlessedOp{
OpCode: proto.Int(opcode),
OpRetCode: proto.Int(3),
@ -423,13 +423,13 @@ func (this *SceneStateStartRichBlessed) OnPlayerOp(s *base.Scene, p *base.Player
if playerEx.gameState == richblessed.Normal {
logger.Logger.Tracef("(this *SceneStateStartRichBlessed) OnPlayerOp, 下注 %v %v %v", playerEx.betCoin, playerEx.maxbetCoin, playerEx.oneBetCoin)
playerEx.betIdx = idx
playerEx.betCoin = int64(sceneEx.DbGameFree.GetOtherIntParams()[idx])
maxidx := len(sceneEx.DbGameFree.GetOtherIntParams()) - 1
playerEx.maxbetCoin = int64(sceneEx.DbGameFree.GetOtherIntParams()[maxidx])
playerEx.betCoin = int64(sceneEx.GetDBGameFree().GetOtherIntParams()[idx])
maxidx := len(sceneEx.GetDBGameFree().GetOtherIntParams()) - 1
playerEx.maxbetCoin = int64(sceneEx.GetDBGameFree().GetOtherIntParams()[maxidx])
playerEx.oneBetCoin = playerEx.betCoin / richblessed.LineNum // 单注
playerEx.noWinTimes++
if playerEx.Coin < int64(s.DbGameFree.GetBetLimit()) {
if playerEx.Coin < int64(s.GetDBGameFree().GetBetLimit()) {
//押注限制(低于该值不能押注)
pack := &protocol.SCRichBlessedOp{
OpCode: proto.Int(opcode),
@ -495,9 +495,9 @@ func (this *SceneStateStartRichBlessed) OnPlayerOp(s *base.Scene, p *base.Player
case richblessed.RichBlessedPlayerOpSwitch:
if len(params) > 0 && playerEx.freeTimes == 0 {
idx := int(params[0])
if len(sceneEx.DbGameFree.GetOtherIntParams()) > idx {
if len(sceneEx.GetDBGameFree().GetOtherIntParams()) > idx {
playerEx.betIdx = idx
playerEx.betCoin = int64(sceneEx.DbGameFree.GetOtherIntParams()[idx])
playerEx.betCoin = int64(sceneEx.GetDBGameFree().GetOtherIntParams()[idx])
playerEx.oneBetCoin = playerEx.betCoin / richblessed.LineNum
pack := &protocol.SCRichBlessedOp{
OpCode: proto.Int(opcode),

View File

@ -271,15 +271,15 @@ func (this *SceneEx) init() bool {
}
func (this *SceneEx) GetBaseScore() int32 { //游戏底分
if this.DbGameFree != nil {
return this.DbGameFree.GetBaseScore()
if this.GetDBGameFree() != nil {
return this.GetDBGameFree().GetBaseScore()
}
return 1
}
func (this *SceneEx) GetBetMaxCoin() int32 { //游戏底分
if this.DbGameFree != nil {
return this.DbGameFree.GetBaseScore() * 10000
if this.GetDBGameFree() != nil {
return this.GetDBGameFree().GetBaseScore() * 10000
}
return 1 * 10000
}

View File

@ -52,14 +52,14 @@ func (this *TamQuocSceneData) SceneDestroy(force bool) {
}
func (this *TamQuocSceneData) init() bool {
if this.DbGameFree == nil {
if this.GetDBGameFree() == nil {
return false
}
params := this.DbGameFree.GetJackpot()
params := this.GetDBGameFree().GetJackpot()
this.jackpot = &base.SlotJackpotPool{}
if this.jackpot.Small <= 0 {
this.jackpot.Small = 0
this.jackpot.VirtualJK = int64(params[rule.TAMQUOC_JACKPOT_InitJackpot]) * int64(this.DbGameFree.GetBaseScore())
this.jackpot.VirtualJK = int64(params[rule.TAMQUOC_JACKPOT_InitJackpot]) * int64(this.GetDBGameFree().GetBaseScore())
}
str := base.SlotsPoolMgr.GetPool(this.GetGameFreeId(), this.Platform)
if str != "" {
@ -95,7 +95,7 @@ type TamQuocSpinResult struct {
}
func (this *TamQuocSceneData) CalcLinePrize(cards []int, betLines []int64, betValue int64) (spinRes TamQuocSpinResult) {
taxRate := this.DbGameFree.GetTaxRate()
taxRate := this.GetDBGameFree().GetTaxRate()
calcTaxScore := func(score int64, taxScore *int64) int64 {
newScore := int64(float64(score) * float64(10000-taxRate) / 10000.0)
if taxScore != nil {
@ -114,7 +114,7 @@ func (this *TamQuocSceneData) CalcLinePrize(cards []int, betLines []int64, betVa
if spinRes.TotalPrizeJackpot == 0 { // 第一个爆奖 获取当前奖池所有
prizeJackpot = this.jackpot.VirtualJK
} else { // 之后的爆奖 奖励为奖池初值
prizeJackpot = int64(this.DbGameFree.GetJackpot()[rule.TAMQUOC_JACKPOT_InitJackpot]) * int64(this.DbGameFree.GetBaseScore())
prizeJackpot = int64(this.GetDBGameFree().GetJackpot()[rule.TAMQUOC_JACKPOT_InitJackpot]) * int64(this.GetDBGameFree().GetBaseScore())
}
prizeJackpot = calcTaxScore(prizeJackpot, &spinRes.TotalTaxScore)
spinRes.TotalPrizeJackpot += prizeJackpot
@ -177,7 +177,7 @@ func (this *TamQuocSceneData) BroadcastJackpot(sync bool) {
this.lastJackpotValue = this.jackpot.VirtualJK
pack := &gamehall.SCHundredSceneGetGameJackpot{}
jpfi := &gamehall.GameJackpotFundInfo{
GameFreeId: proto.Int32(this.DbGameFree.Id),
GameFreeId: proto.Int32(this.GetDBGameFree().Id),
JackPotFund: proto.Int64(this.jackpot.VirtualJK),
}
pack.GameJackpotFund = append(pack.GameJackpotFund, jpfi)
@ -204,7 +204,7 @@ func (this *TamQuocSceneData) PopCoinPool(winCoin int64, IsNovice bool) {
}
}
func (this *TamQuocSceneData) RecordBurstLog(name string, wincoin, totalbet int64) {
log := model.NewBurstJackpotLog(this.Platform, this.DbGameFree.GameId, this.GetGameFreeId(), name, wincoin, totalbet)
log := model.NewBurstJackpotLog(this.Platform, this.GetDBGameFree().GameId, this.GetGameFreeId(), name, wincoin, totalbet)
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
return model.InsertBurstJackpotLogs(log)
}), nil, "InsertBurstJackpotLogs").Start()
@ -212,7 +212,7 @@ func (this *TamQuocSceneData) RecordBurstLog(name string, wincoin, totalbet int6
func (this *TamQuocSceneData) BurstHistory(player *TamQuocPlayerData) {
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
return model.GetBurstJackpotLog(this.Platform, this.DbGameFree.GameId)
return model.GetBurstJackpotLog(this.Platform, this.GetDBGameFree().GameId)
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
var logsp []*tamquoc.TamQuocBurstHistoryInfo
if data != nil {
@ -240,7 +240,7 @@ func (this *TamQuocSceneData) GetLastBurstJackPot() time.Time {
}
func (this *TamQuocSceneData) SetLastBurstJackPot() {
var randT = rand.Intn(25200-7200+1) + 7200
switch this.DbGameFree.SceneType {
switch this.GetDBGameFree().SceneType {
case 1:
randT = rand.Intn(25200-7200+1) + 7200
case 2:
@ -254,7 +254,7 @@ func (this *TamQuocSceneData) SetLastBurstJackPot() {
func (this *TamQuocSceneData) AIAddJackPot() {
if time.Now().Sub(this.lastJackPot) > 0 {
var randT = rand.Intn(3) + 1
switch this.DbGameFree.SceneType {
switch this.GetDBGameFree().SceneType {
case 1:
randT = rand.Intn(3) + 1
case 2:
@ -265,20 +265,20 @@ func (this *TamQuocSceneData) AIAddJackPot() {
randT = rand.Intn(3) + 1
}
this.lastJackPot = time.Now().Add(time.Second * time.Duration(randT))
val := int64(math.Floor(float64(this.DbGameFree.GetBaseScore()) * float64(rule.LINENUM) * float64(500) / 10000))
val := int64(math.Floor(float64(this.GetDBGameFree().GetBaseScore()) * float64(rule.LINENUM) * float64(500) / 10000))
this.jackpot.VirtualJK += val
}
}
func (this *TamQuocSceneData) AIBurstJackPot() {
if time.Now().Sub(this.GetLastBurstJackPot()) > 0 {
this.SetLastBurstJackPot()
jackpotParams := this.DbGameFree.GetJackpot()
var jackpotInit = int64(jackpotParams[rule.TAMQUOC_JACKPOT_InitJackpot]) * int64(this.DbGameFree.GetBaseScore()) //奖池初始值
jackpotParams := this.GetDBGameFree().GetJackpot()
var jackpotInit = int64(jackpotParams[rule.TAMQUOC_JACKPOT_InitJackpot]) * int64(this.GetDBGameFree().GetBaseScore()) //奖池初始值
//AI机器人爆奖
val := this.jackpot.VirtualJK
this.jackpot.VirtualJK = jackpotInit
bet := int64(this.DbGameFree.GetBaseScore()) * int64(rule.LINENUM)
bet := int64(this.GetDBGameFree().GetBaseScore()) * int64(rule.LINENUM)
this.RecordBurstLog(this.RandNickName(), val, int64(bet))
}
}
@ -299,11 +299,11 @@ func (this *TamQuocSceneData) KickPlayerByTime() {
}
//for _, p := range this.players {
// //游戏次数达到目标值
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(this.DbGameFree.GetId()))
// todayGamefreeIDSceneData, _ := p.GetDaliyGameData(int(this.GetDBGameFree().GetId()))
// if !p.IsRob &&
// todayGamefreeIDSceneData != nil &&
// this.DbGameFree.GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(this.DbGameFree.GetPlayNumLimit()) {
// this.GetDBGameFree().GetPlayNumLimit() != 0 &&
// todayGamefreeIDSceneData.GameTimes >= int64(this.GetDBGameFree().GetPlayNumLimit()) {
// this.PlayerLeave(p.Player, common.PlayerLeaveReason_GameTimes, true)
// }
//}

View File

@ -90,8 +90,8 @@ func (this *ScenePolicyTamQuoc) OnPlayerEnter(s *base.Scene, p *base.Player) {
logger.Logger.Trace("(this *ScenePolicyTamQuoc) OnPlayerEnter, sceneId=", s.SceneId, " player=", p.SnId)
if sceneEx, ok := s.ExtraData.(*TamQuocSceneData); ok {
playerEx := &TamQuocPlayerData{Player: p}
playerEx.init(s) // 玩家当前信息初始化
playerEx.score = sceneEx.DbGameFree.GetBaseScore() // 底注
playerEx.init(s) // 玩家当前信息初始化
playerEx.score = sceneEx.GetDBGameFree().GetBaseScore() // 底注
sceneEx.players[p.SnId] = playerEx
p.ExtraData = playerEx
TamQuocSendRoomInfo(s, p, sceneEx, playerEx, nil)
@ -226,10 +226,10 @@ func (this *ScenePolicyTamQuoc) GetJackPotVal(s *base.Scene) int64 {
func TamQuocSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *TamQuocSceneData, playerEx *TamQuocPlayerData, data *tamquoc.GameBilledData) {
logger.Logger.Trace("-------------------发送房间消息 ", s.RoomId, p.SnId)
pack := &tamquoc.SCTamQuocRoomInfo{
RoomId: proto.Int(s.SceneId),
RoomId: s.SceneId,
Creator: proto.Int32(s.Creator),
GameId: proto.Int(s.GameId),
RoomMode: proto.Int(s.GameMode),
GameId: s.GameId,
RoomMode: s.GameMode,
Params: common.CopySliceInt64ToInt32(s.Params),
State: proto.Int(s.SceneState.GetState()),
Jackpot: proto.Int64(sceneEx.jackpot.VirtualJK),
@ -252,7 +252,7 @@ func TamQuocSendRoomInfo(s *base.Scene, p *base.Player, sceneEx *TamQuocSceneDat
//}
pack.BetLines = playerEx.betLines
pack.FreeTimes = proto.Int32(playerEx.freeTimes)
pack.Chip = proto.Int32(s.DbGameFree.BaseScore)
pack.Chip = proto.Int32(s.GetDBGameFree().BaseScore)
pack.SpinID = proto.Int64(playerEx.spinID)
if playerEx.totalPriceBonus > 0 && playerEx.bonusGameStartTime.Add(TamQuocBonusGamePickTime).Before(time.Now()) {
playerEx.totalPriceBonus = 0
@ -339,7 +339,7 @@ func (this *SceneStateTamQuocStart) OnPlayerOp(s *base.Scene, p *base.Player, op
return false
}
//先做底注校验
if sceneEx.DbGameFree.GetBaseScore() != int32(params[0]) {
if sceneEx.GetDBGameFree().GetBaseScore() != int32(params[0]) {
this.OnPlayerSToCOp(s, p, playerEx.Pos, opcode, tamquoc.OpResultCode_OPRC_Error, params)
return false
}
@ -373,7 +373,7 @@ func (this *SceneStateTamQuocStart) OnPlayerOp(s *base.Scene, p *base.Player, op
if playerEx.freeTimes <= 0 && totalBetValue > playerEx.Coin {
this.OnPlayerSToCOp(s, p, playerEx.Pos, opcode, tamquoc.OpResultCode_OPRC_CoinNotEnough, params)
return false
} else if playerEx.freeTimes <= 0 && int64(sceneEx.DbGameFree.GetBetLimit()) > playerEx.Coin { //押注限制
} else if playerEx.freeTimes <= 0 && int64(sceneEx.GetDBGameFree().GetBetLimit()) > playerEx.Coin { //押注限制
this.OnPlayerSToCOp(s, p, playerEx.Pos, opcode, tamquoc.OpResultCode_OPRC_CoinNotEnough, params)
return false
}
@ -388,7 +388,7 @@ func (this *SceneStateTamQuocStart) OnPlayerOp(s *base.Scene, p *base.Player, op
sceneEx.CpCtx = base.CoinPoolMgr.GetCoinPoolCtx(sceneEx.Platform, sceneEx.GetGameFreeId(), sceneEx.GroupId)
//税收比例
taxRate := sceneEx.DbGameFree.GetTaxRate()
taxRate := sceneEx.GetDBGameFree().GetTaxRate()
if taxRate < 0 || taxRate > 10000 {
logger.Logger.Tracef("TamQuocErrorTaxRate [%v][%v][%v][%v]", sceneEx.GetGameFreeId(), playerEx.SnId, playerEx.spinID, taxRate)
taxRate = 500
@ -410,8 +410,8 @@ func (this *SceneStateTamQuocStart) OnPlayerOp(s *base.Scene, p *base.Player, op
prizeFund := gamePoolCoin - sceneEx.jackpot.VirtualJK // 除去奖池的水池剩余金额
// 奖池参数
var jackpotParam = sceneEx.DbGameFree.GetJackpot()
var jackpotInit = int64(jackpotParam[rule.TAMQUOC_JACKPOT_InitJackpot]) * int64(sceneEx.DbGameFree.GetBaseScore()) //奖池初始值
var jackpotParam = sceneEx.GetDBGameFree().GetJackpot()
var jackpotInit = int64(jackpotParam[rule.TAMQUOC_JACKPOT_InitJackpot]) * int64(sceneEx.GetDBGameFree().GetBaseScore()) //奖池初始值
var jackpotFundAdd, prizeFundAdd int64
if playerEx.freeTimes <= 0 { //正常模式才能记录用户的押注变化,免费模式不能改变押注
@ -431,7 +431,7 @@ func (this *SceneStateTamQuocStart) OnPlayerOp(s *base.Scene, p *base.Player, op
//统计参与游戏次数
//if !sceneEx.Testing && !playerEx.IsRob {
// pack := &server.GWSceneEnd{
// GameFreeId: proto.Int32(sceneEx.DbGameFree.GetId()),
// GameFreeId: proto.Int32(sceneEx.GetDBGameFree().GetId()),
// Players: []*server.PlayerCtx{&server.PlayerCtx{SnId: proto.Int32(playerEx.SnId), Coin: proto.Int64(playerEx.Coin)}},
// }
// proto.SetDefaults(pack)
@ -454,11 +454,11 @@ func (this *SceneStateTamQuocStart) OnPlayerOp(s *base.Scene, p *base.Player, op
var slotDataIsOk bool
for i := 0; i < 3; i++ {
slotData = rule.GenerateSlotsData_v2(symbolType)
//if sceneEx.DbGameFree.GetSceneType() == 1 {
//if sceneEx.GetDBGameFree().GetSceneType() == 1 {
// slotData = []int{1, 1, 1, 1, 1, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7}
//}
spinRes = sceneEx.CalcLinePrize(slotData, playerEx.betLines, params[0])
//if sceneEx.DbGameFree.GetSceneType() == 1 {
//if sceneEx.GetDBGameFree().GetSceneType() == 1 {
// slotDataIsOk = true
// break
//}
@ -641,7 +641,7 @@ func (this *SceneStateTamQuocStart) OnPlayerOp(s *base.Scene, p *base.Player, op
case TamQuocPlayerHistory:
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
spinid := strconv.FormatInt(int64(playerEx.SnId), 10)
gpl := model.GetPlayerListByHallEx(p.SnId, p.Platform, 0, 80, 0, 0, 0, s.DbGameFree.GetGameClass(), s.GameId)
gpl := model.GetPlayerListByHallEx(p.SnId, p.Platform, 0, 80, 0, 0, 0, s.GetDBGameFree().GetGameClass(), int(s.GameId))
pack := &tamquoc.SCTamQuocPlayerHistory{}
for _, v := range gpl.Data {
//if v.GameDetailedLogId == "" {
@ -759,7 +759,7 @@ func TamQuocCheckAndSaveLog(sceneEx *TamQuocSceneData, playerEx *TamQuocPlayerDa
//log2
playerEx.RollGameType.BaseResult.ChangeCoin = changeCoin
playerEx.RollGameType.BaseResult.BasicBet = sceneEx.DbGameFree.GetBaseScore()
playerEx.RollGameType.BaseResult.BasicBet = sceneEx.GetDBGameFree().GetBaseScore()
playerEx.RollGameType.BaseResult.RoomId = int32(sceneEx.SceneId)
playerEx.RollGameType.BaseResult.AfterCoin = playerEx.Coin
playerEx.RollGameType.BaseResult.BeforeCoin = startCoin
@ -818,8 +818,8 @@ func TamQuocCheckAndSaveLog(sceneEx *TamQuocSceneData, playerEx *TamQuocPlayerDa
GameCoinTs: proto.Int64(playerEx.GameCoinTs),
}
gwPlayerBet := &server.GWPlayerData{
SceneId: proto.Int(sceneEx.SceneId),
GameFreeId: proto.Int32(sceneEx.DbGameFree.GetId()),
SceneId: sceneEx.SceneId,
GameFreeId: proto.Int32(sceneEx.GetDBGameFree().GetId()),
}
gwPlayerBet.Datas = append(gwPlayerBet.Datas, playerBet)
sceneEx.SyncPlayerDatas(&base.PlayerDataParam{

View File

@ -173,7 +173,6 @@ func (this *SceneEx) ThirteenWaterCreateRoomInfoPacket(s *base.Scene, p *base.Pl
Creator: proto.Int32(s.GetCreator()),
GameId: proto.Int(s.GetGameId()),
RoomMode: proto.Int(s.GetSceneMode()),
AgentId: proto.Int32(s.GetAgentor()),
SceneType: s.GetDBGameFree().SceneType,
State: proto.Int(s.GetSceneState().GetState()),
TimeOut: proto.Int(s.GetSceneState().GetTimeout(s)),
@ -369,15 +368,15 @@ func (this *SceneEx) ThirteenWaterCreateRoomInfoPacket(s *base.Scene, p *base.Pl
}
func (this *SceneEx) GetBaseScore() int64 { //游戏底分
if this.DbGameFree.FreeMode == 1 {
if this.GetDBGameFree().FreeMode == 1 {
baseScore := this.GetParam(rule.ParamBaseScore)
if baseScore > 0 {
return baseScore
}
}
if this.DbGameFree != nil {
return int64(this.DbGameFree.GetBaseScore())
if this.GetDBGameFree() != nil {
return int64(this.GetDBGameFree().GetBaseScore())
}
return 1
}
@ -1269,7 +1268,7 @@ func (this *SceneEx) CountBilled() {
}
if playerEx.gainCoin > 0 {
gainCoin := playerEx.gainCoin
playerEx.gainCoin = playerEx.gainCoin * int64(10000-this.DbGameFree.GetTaxRate()) / 10000
playerEx.gainCoin = playerEx.gainCoin * int64(10000-this.GetDBGameFree().GetTaxRate()) / 10000
playerEx.taxCoin = gainCoin - playerEx.gainCoin
}
logger.Logger.Tracef("玩家分数 %v, coin:%v tax:%v win:%v", playerEx.SnId, playerEx.gainCoin, playerEx.taxCoin, playerEx.winAllPlayers)
@ -1335,7 +1334,7 @@ func (this *SceneEx) SendHandCardOdds() {
if seat.IsRob {
robotPlayers = append(robotPlayers, seat)
} else {
seat.odds = this.GetPlayerOdds(seat.Player, this.GameId, this.robotNum > 0)
seat.odds = this.GetPlayerOdds(seat.Player, int(this.GameId), this.robotNum > 0)
seat.playerPool = int(this.PlayerPoolOdds(seat.Player))
if seat.odds > 0 {
realPlayersGood = append(realPlayersGood, seat)

View File

@ -1258,9 +1258,9 @@ func (this *StateBilled) OnEnter(s *base.Scene) {
if sceneEx.gamePlayerNum-sceneEx.robotNum > 0 {
/////////////////////////////////////统计牌局详细记录
thirteenWaterType := model.ThirteenWaterType{
RoomId: int32(sceneEx.SceneId),
RoomId: sceneEx.SceneId,
RoomRounds: int32(sceneEx.NumOfGames),
RoomType: int32(sceneEx.SceneType),
RoomType: sceneEx.GetSceneType(),
BaseScore: int32(sceneEx.GetBaseScore()),
NowRound: int32(sceneEx.NumOfGames),
ClubRate: sceneEx.Scene.PumpCoin,
@ -1462,7 +1462,7 @@ func (this *StateBilled) OnLeave(s *base.Scene) {
s.TryDismissRob()
}
if s.CheckNeedDestroy() || (s.IsMatchScene() && (!s.MatchFinals || (s.MatchFinals && s.NumOfGames >= 2))) { // 非决赛打一场 决赛打两场
if s.CheckNeedDestroy() || (s.IsMatchScene() && (!s.GetMatch().GetIsFinals() || (s.GetMatch().GetIsFinals() && s.NumOfGames >= 2))) { // 非决赛打一场 决赛打两场
sceneEx.SceneDestroy(true)
}
s.TryRelease()

View File

@ -21,6 +21,17 @@ import (
"mongo.games.com/game/srvdata"
)
type BilledInfo struct {
Round int32 // 第几局
ChangeScore int64 // 积分变化
Score int64 // 结算后积分
}
type Item struct {
Id int32
Num int64
}
// 房间上的额外数据
type TienLenSceneData struct {
*base.Scene //场景
@ -56,13 +67,20 @@ type TienLenSceneData struct {
isCardsKu bool //是否是牌库
cardsKuId int32 //牌库ID
ctrlType int // 1控赢 2控输 0不控
BilledList map[int32]*[]*BilledInfo // 多轮结算记录, 玩家id:每局结算记录
RoundEndTime []int64 // 每局结束时间
RoundLogId []string // 每局牌局记录id
CustomLogSave bool // 是否已经保存日志
PlayerAward map[int32]*[]*model.Item // 房卡场最终奖励
}
func NewTienLenSceneData(s *base.Scene) *TienLenSceneData {
sceneEx := &TienLenSceneData{
Scene: s,
poker: rule.NewPoker(),
players: make(map[int32]*TienLenPlayerData),
Scene: s,
poker: rule.NewPoker(),
players: make(map[int32]*TienLenPlayerData),
BilledList: map[int32]*[]*BilledInfo{},
PlayerAward: make(map[int32]*[]*model.Item),
}
sceneEx.Clear()
return sceneEx
@ -143,6 +161,11 @@ func (this *TienLenSceneData) CanStart() bool {
return false
}
}
if this.IsCustom() {
return this.IsAllReady() && this.GetPlayerCnt() >= this.GetPlayerNum()
}
// 房间人数>=2开始,并且有真人或者是预创建房间,并且有房主
if nPlayerCount >= 2 && (this.GetRealPlayerNum() > 0 || this.IsPreCreateScene()) { //人数>=2开始
return true
@ -267,6 +290,7 @@ func (this *TienLenSceneData) OnPlayerLeave(p *base.Player, reason int) {
}
func (this *TienLenSceneData) SceneDestroy(force bool) {
this.SaveCustomLog()
//销毁房间
this.Scene.Destroy(force)
}
@ -371,7 +395,7 @@ func (this *TienLenSceneData) BroadcastOpPos() {
for _, seat := range this.seats {
if seat != nil && seat.IsGameing() {
if !seat.IsRob {
seat.odds = this.GetPlayerOdds(seat.Player, this.GameId, this.robotGamingNum > 0)
seat.odds = this.GetPlayerOdds(seat.Player, int(this.GameId), this.robotGamingNum > 0)
if seat.odds < 0 {
B -= seat.odds
}
@ -523,7 +547,7 @@ func (this *TienLenSceneData) IsTienLenToEnd() bool {
return common.IsTienLenToEnd(this.GetGameId())
}
func (this *TienLenSceneData) GetFreeGameSceneType() int32 {
return int32(this.SceneType)
return this.GetSceneType()
}
// 比赛场发牌
@ -619,6 +643,9 @@ func (this *TienLenSceneData) SendHandCard_Match() {
proto.SetDefaults(pack)
seat.SendToClient(int(tienlen.TienLenPacketID_PACKET_SCTienLenCard), pack)
logger.Logger.Trace("SnId: ", seat.SnId, ";SCTienLenCard: ", pack.Cards)
pack.SnId = seat.SnId
this.BroadcastToAudience(int(tienlen.TienLenPacketID_PACKET_SCTienLenCard), pack)
}
}
@ -652,6 +679,9 @@ func (this *TienLenSceneData) SendHandCard_Match() {
proto.SetDefaults(pack)
seat.SendToClient(int(tienlen.TienLenPacketID_PACKET_SCTienLenCard), pack)
logger.Logger.Trace("SnId: ", seat.SnId, ";SCTienLenCard: ", pack.Cards)
pack.SnId = seat.SnId
this.BroadcastToAudience(int(tienlen.TienLenPacketID_PACKET_SCTienLenCard), pack)
}
}
}
@ -1055,7 +1085,7 @@ func (this *TienLenSceneData) SendHandCardOdds() {
if seat.IsRob {
robotPlayers = append(robotPlayers, seat)
} else {
seat.odds = this.GetPlayerOdds(seat.Player, this.GameId, this.robotGamingNum > 0)
seat.odds = this.GetPlayerOdds(seat.Player, int(this.GameId), this.robotGamingNum > 0)
seat.playerPool = int(this.PlayerPoolOdds(seat.Player))
if seat.odds > 0 {
realPlayersGood = append(realPlayersGood, seat)
@ -1066,7 +1096,7 @@ func (this *TienLenSceneData) SendHandCardOdds() {
} else {
realPlayers = append(realPlayers, seat)
}
_, isNovice := seat.NoviceOdds(this.GameId)
_, isNovice := seat.NoviceOdds(int(this.GameId))
if isNovice {
novicePlayers = append(novicePlayers, seat)
} else {
@ -1946,7 +1976,7 @@ func (this *TienLenSceneData) TrySmallGameBilled() {
logger.Logger.Trace("宠物技能抵挡炸弹生效,发送消息 SCTienLenPetSkillRes: ", pack)
}
if score != 0 {
taxRate := this.DbGameFree.GetTaxRate() //万分比
taxRate := this.GetDBGameFree().GetTaxRate() //万分比
gainScore := int64(float64(score) * float64(10000-taxRate) / 10000.0) //税后
bombTaxScore := score - gainScore
// win
@ -2072,3 +2102,61 @@ func (this *TienLenSceneData) SendFirstGiveTimeItem(p *base.Player) {
p.SendToClient(int(tienlen.TienLenPacketID_PACKET_SCTienLenFirstGiveItemItem), pack)
}
}
// SaveCustomLog 保存竞技馆对局记录
func (this *TienLenSceneData) SaveCustomLog() {
if this.CustomLogSave || !this.IsCustom() {
return
}
this.CustomLogSave = true
state := int32(0)
if len(this.RoundEndTime) < int(this.TotalOfGames) {
state = 1
}
log := &model.CustomLog{
Platform: this.Platform,
CycleId: this.CycleID,
RoomConfigId: this.GetCustom().GetRoomConfigId(),
RoomId: this.SceneId,
StartTs: this.GameStartTime.Unix(),
EndTs: time.Now().Unix(),
State: state,
GameFreeId: this.GetGameFreeId(),
TotalRound: this.TotalOfGames,
Password: this.GetCustom().GetPassword(),
CostType: this.GetCustom().GetCostType(),
Voice: this.GetCustom().GetVoice(),
}
for snid := range this.BilledList {
var items []*model.Item
if this.PlayerAward[snid] != nil {
items = *this.PlayerAward[snid]
}
log.SnId = append(log.SnId, model.PlayerInfo{
SnId: snid,
Awards: items,
})
}
sort.Slice(log.SnId, func(i, j int) bool {
p1 := base.PlayerMgrSington.GetPlayerBySnId(log.SnId[i].SnId)
p2 := base.PlayerMgrSington.GetPlayerBySnId(log.SnId[j].SnId)
return p1.GetCoin() > p2.GetCoin()
})
for k, v := range this.RoundEndTime {
score := make([]int64, len(this.BilledList))
for kk, vv := range log.SnId {
if k < len(*this.BilledList[vv.SnId]) {
score[kk] = (*this.BilledList[vv.SnId])[k].ChangeScore
}
}
log.List = append(log.List, model.RoundInfo{
Round: int32(k + 1),
Ts: v,
Score: score,
LogId: this.RoundLogId[k],
})
}
base.LogChannelSingleton.WriteLog(log)
}

View File

@ -423,7 +423,7 @@ func TienLenCreateRoomInfoPacket(s *base.Scene, p *base.Player, sceneEx *TienLen
State: proto.Int32(int32(s.GetSceneState().GetState())),
TimeOut: proto.Int(s.GetSceneState().GetTimeout(s)),
NumOfGames: proto.Int(sceneEx.NumOfGames),
TotalOfGames: proto.Int(sceneEx.TotalOfGames),
TotalOfGames: sceneEx.TotalOfGames,
CurOpIdx: proto.Int(-1),
MasterSnid: proto.Int32(sceneEx.masterSnid),
AudienceNum: proto.Int(s.GetAudiencesNum()),
@ -432,18 +432,27 @@ func TienLenCreateRoomInfoPacket(s *base.Scene, p *base.Player, sceneEx *TienLen
RankType: s.GetDBGameFree().GetRankType(),
SceneAdd: s.GetDBGameFree().GetSceneAdd(),
// 比赛场相关
Round: int32(s.MatchRound),
CurPlayerNum: int32(s.MatchCurPlayerNum),
NextNeed: int32(s.MatchNextNeed),
Round: s.GetMatch().GetCurrRound(),
CurPlayerNum: s.GetMatch().GetCurrPlayerNum(),
NextNeed: s.GetMatch().GetNextPlayerNum(),
RecordId: sceneEx.recordId,
TMInfoId: s.GetMatch().GetMatchId(),
RoomTypeId: s.GetCustom().GetRoomTypeId(),
RoomConfigId: s.GetCustom().GetRoomConfigId(),
CostType: s.GetCustom().GetCostType(),
Voice: s.GetCustom().GetVoice(),
Password: s.GetCustom().GetPassword(),
}
if s.GetCustom().GetPassword() != "" {
pack.NeedPassword = 1
}
pack.IsMatch = int32(0)
// 0.普通场 1.锦标赛 2.冠军赛 3.vip专属
if s.IsMatchScene() {
pack.IsMatch = int32(s.MatchType)
pack.IsMatch = s.GetMatch().GetMatchType()
}
pack.MatchFinals = 0
if s.MatchFinals {
if s.GetMatch().GetIsFinals() {
pack.MatchFinals = 1
if s.NumOfGames >= 2 {
pack.MatchFinals = 2
@ -517,7 +526,7 @@ func TienLenCreateRoomInfoPacket(s *base.Scene, p *base.Player, sceneEx *TienLen
//手牌
for j := int32(0); j < rule.HandCardNum; j++ {
if nowPlayer.cards[j] != rule.InvalideCard {
if s.GetSceneState().GetState() == rule.TienLenSceneStateBilled { //结算状态显示用
if s.GetSceneState().GetState() == rule.TienLenSceneStateBilled || p.IsMarkFlag(base.PlayerState_Audience) { //结算状态显示用
pd1.Cards = append(pd1.Cards, nowPlayer.cards[j])
} else {
pd1.Cards = append(pd1.Cards, rule.InvalideCard)
@ -594,6 +603,9 @@ func (this *SceneBaseStateTienLen) OnTick(s *base.Scene) {
s.RandRobotCnt()
s.SetTimerRandomRobot(s.GetRobotTime())
}
if s.IsCustom() && len(s.Players) == 0 {
s.Destroy(true)
}
}
// 发送玩家操作情况
@ -813,7 +825,7 @@ func (this *SceneWaitStartStateTienLen) OnEnter(s *base.Scene) {
if sceneEx, ok := s.GetExtraData().(*TienLenSceneData); ok {
sceneEx.Clear()
sceneEx.SetGaming(false)
this.BroadcastRoomState(s, this.GetState())
this.BroadcastRoomState(s, this.GetState(), int64(sceneEx.NumOfGames))
logger.Logger.Trace("(this *SceneWaitStartStateTienLen) OnEnter", this.GetState())
}
}
@ -879,7 +891,7 @@ func (this *SceneWaitStartStateTienLen) OnTick(s *base.Scene) {
if sceneEx, ok := s.GetExtraData().(*TienLenSceneData); ok {
if sceneEx.IsMatchScene() {
delayT := time.Second * 2
if sceneEx.MatchRound != 1 { //第一轮延迟2s其他延迟3s 配合客户端播放动画
if sceneEx.GetMatch().GetCurrRound() != 1 { //第一轮延迟2s其他延迟3s 配合客户端播放动画
delayT = time.Second * 4
}
if time.Now().Sub(sceneEx.StateStartTime) > delayT {
@ -894,7 +906,16 @@ func (this *SceneWaitStartStateTienLen) OnTick(s *base.Scene) {
return
}
//开始前再次检查开始条件
if sceneEx.CanStart() == true {
if sceneEx.CanStart() {
s.ChangeSceneState(rule.TienLenSceneStateHandCard)
} else {
s.ChangeSceneState(rule.TienLenSceneStateWaitPlayer)
}
}
}
if sceneEx.IsCustom() {
if time.Now().Sub(sceneEx.StateStartTime) > rule.TienLenCustomWaiteStatTimeout {
if sceneEx.CanStart() {
s.ChangeSceneState(rule.TienLenSceneStateHandCard)
} else {
s.ChangeSceneState(rule.TienLenSceneStateWaitPlayer)
@ -953,13 +974,17 @@ func (this *SceneHandCardStateTienLen) OnEnter(s *base.Scene) {
s.NotifySceneRoundStart(s.NumOfGames)
this.BroadcastRoomState(s, this.GetState(), int64(s.NumOfGames))
if s.IsCustom() && s.NumOfGames == 1 {
s.SyncSceneState(common.SceneStateStart)
}
//同步防伙牌数据
sceneEx.SyncScenePlayer()
//发牌
if rule.TestOpen {
sceneEx.SendHandCardTest()
} else {
if sceneEx.IsMatchScene() {
if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
sceneEx.SendHandCard_Match()
} else {
sceneEx.SendHandCardOdds()
@ -981,7 +1006,7 @@ func (this *SceneHandCardStateTienLen) OnEnter(s *base.Scene) {
seat.tianHu = rule.TianHu12Straight
}
if seat.tianHu > 0 {
keyNovice := common.GetKeyNoviceGameId(sceneEx.GameId)
keyNovice := common.GetKeyNoviceGameId(int(sceneEx.GameId))
data, ok := seat.GDatas[keyNovice]
if !ok {
data = &model.PlayerGameInfo{FirstTime: time.Now()}
@ -1636,14 +1661,14 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
winRankScore := int64(0)
pack := &tienlen.SCTienLenGameBilled{}
tienlenType := model.TienLenType{
GameId: sceneEx.GameId,
GameId: int(sceneEx.GameId),
RoomId: int32(sceneEx.GetSceneId()),
RoomType: sceneEx.GetFreeGameSceneType(),
NumOfGames: int32(sceneEx.Scene.NumOfGames),
BankId: sceneEx.masterSnid,
PlayerCount: sceneEx.curGamingPlayerNum,
BaseScore: s.GetBaseScore(),
TaxRate: s.DbGameFree.GetTaxRate(),
TaxRate: s.GetDBGameFree().GetTaxRate(),
RoomMode: s.GetSceneMode(),
PlayerPool: make(map[int]int),
}
@ -1772,7 +1797,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
gainScore = losePlayerCoin
}
losePlayerScore = gainScore
if sceneEx.IsMatchScene() { //比赛场是积分,不应该增加账变
if sceneEx.IsMatchScene() || sceneEx.IsCustom() { //比赛场是积分,不应该增加账变
losePlayer.AddCoinNoLog(int64(-gainScore), 0)
} else {
losePlayer.AddCoin(int64(-gainScore), common.GainWay_CoinSceneLost, 0, "system", s.GetSceneName())
@ -1787,7 +1812,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
// vip加成分
vipScore = int64(math.Ceil(float64(rankScore) * float64(losePlayer.VipExtra) / 100.0))
// 角色加成分
_, roleAdd = srvdata.RolePetMgrSington.GetRoleAdd(&losePlayer.PlayerData, common.RoleAddRankScore)
_, roleAdd = srvdata.RolePetMgrSington.GetRoleAdd(losePlayer.PlayerData, common.RoleAddRankScore)
roleScore = int64(math.Ceil(float64(rankScore) * float64(roleAdd) / 100.0))
//周卡加成
if losePlayer.GetWeekCardPrivilege(2) {
@ -1914,7 +1939,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
astWinGainScore = lastWinPlayerCoin
}
lastWinPlayerScore = astWinGainScore
if sceneEx.IsMatchScene() {
if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
lastWinPlayer.AddCoinNoLog(int64(-astWinGainScore), 0)
} else {
lastWinPlayer.AddCoin(int64(-astWinGainScore), common.GainWay_CoinSceneLost, 0, "system", s.GetSceneName())
@ -1929,7 +1954,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
// vip加成分
vipScore = int64(math.Ceil(float64(rankScore) * float64(lastWinPlayer.VipExtra) / 100.0))
// 角色加成分
_, roleAdd = srvdata.RolePetMgrSington.GetRoleAdd(&lastWinPlayer.PlayerData, common.RoleAddRankScore)
_, roleAdd = srvdata.RolePetMgrSington.GetRoleAdd(lastWinPlayer.PlayerData, common.RoleAddRankScore)
roleScore = int64(math.Ceil(float64(rankScore) * float64(roleAdd) / 100.0))
//周卡加成
if lastWinPlayer.GetWeekCardPrivilege(2) {
@ -2019,7 +2044,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
var otherScore int64 // 额外总加分
oldRankScore := playerEx.GetRankScore(sceneEx.GetDBGameFree().GetRankType())
rankScore = loseRankScore
taxRate := sceneEx.DbGameFree.GetTaxRate() //万分比
taxRate := sceneEx.GetDBGameFree().GetTaxRate() //万分比
gainScore := int64(float64(losePlayerScore) * float64(10000-taxRate) / 10000.0) //税后
gainTaxScore := losePlayerScore - gainScore // 税收
if playerNum == 3 {
@ -2027,7 +2052,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
gainTaxScore = losePlayerScore + lastWinPlayerScore - gainScore
rankScore = loseRankScore + lastWinPlayerRankScore
}
if sceneEx.IsMatchScene() {
if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
playerEx.AddCoinNoLog(int64(gainScore), 0)
} else {
playerEx.AddCoin(gainScore, common.GainWay_CoinSceneWin, 0, "system", s.GetSceneName())
@ -2040,7 +2065,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
// vip加成分
vipScore = int64(math.Ceil(float64(rankScore) * float64(playerEx.VipExtra) / 100.0))
// 角色加成分
_, roleAdd = srvdata.RolePetMgrSington.GetRoleAdd(&playerEx.PlayerData, common.RoleAddRankScore)
_, roleAdd = srvdata.RolePetMgrSington.GetRoleAdd(playerEx.PlayerData, common.RoleAddRankScore)
roleScore = int64(math.Ceil(float64(rankScore) * float64(roleAdd) / 100.0))
//周卡加成
if playerEx.GetWeekCardPrivilege(2) {
@ -2129,10 +2154,10 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
var otherScore int64 // 额外总加分
oldRankScore := playerEx.GetRankScore(sceneEx.GetDBGameFree().GetRankType())
rankScore = lastWinPlayerRankScore
taxRate := sceneEx.DbGameFree.GetTaxRate() //万分比
taxRate := sceneEx.GetDBGameFree().GetTaxRate() //万分比
gainScore := int64(float64(lastWinPlayerScore) * float64(10000-taxRate) / 10000.0) //税后
gainTaxScore := lastWinPlayerScore - gainScore
if sceneEx.IsMatchScene() {
if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
playerEx.AddCoinNoLog(int64(gainScore), 0)
} else {
playerEx.AddCoin(gainScore, common.GainWay_CoinSceneWin, 0, "system", s.GetSceneName())
@ -2145,7 +2170,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
// vip加成分
vipScore = int64(math.Ceil(float64(rankScore) * float64(playerEx.VipExtra) / 100.0))
// 角色加成分
_, roleAdd = srvdata.RolePetMgrSington.GetRoleAdd(&playerEx.PlayerData, common.RoleAddRankScore)
_, roleAdd = srvdata.RolePetMgrSington.GetRoleAdd(playerEx.PlayerData, common.RoleAddRankScore)
roleScore = int64(math.Ceil(float64(rankScore) * float64(roleAdd) / 100.0))
//周卡加成
if playerEx.GetWeekCardPrivilege(2) {
@ -2274,7 +2299,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
gainScore = losePlayerCoin
}
winScore += gainScore
if sceneEx.IsMatchScene() {
if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
playerEx.AddCoinNoLog(int64(-gainScore), 0)
} else {
playerEx.AddCoin(int64(-gainScore), common.GainWay_CoinSceneLost, 0, "system", s.GetSceneName())
@ -2294,7 +2319,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
// vip加成分
vipScore = int64(math.Ceil(float64(rankScore) * float64(playerEx.VipExtra) / 100.0))
// 角色加成分
_, roleAdd = srvdata.RolePetMgrSington.GetRoleAdd(&playerEx.PlayerData, common.RoleAddRankScore)
_, roleAdd = srvdata.RolePetMgrSington.GetRoleAdd(playerEx.PlayerData, common.RoleAddRankScore)
roleScore = int64(math.Ceil(float64(rankScore) * float64(roleAdd) / 100.0))
//周卡加成
if playerEx.GetWeekCardPrivilege(2) {
@ -2410,10 +2435,10 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
var otherScore int64 // 额外总加分
playerEx := sceneEx.players[winSnid]
if playerEx != nil {
taxRate := sceneEx.DbGameFree.GetTaxRate() //万分比
taxRate := sceneEx.GetDBGameFree().GetTaxRate() //万分比
gainScore := int64(float64(winScore) * float64(10000-taxRate) / 10000.0) //税后
gainTaxScore := winScore - gainScore
if sceneEx.IsMatchScene() {
if sceneEx.IsMatchScene() || sceneEx.IsCustom() {
playerEx.AddCoinNoLog(int64(gainScore), 0)
} else {
playerEx.AddCoin(gainScore, common.GainWay_CoinSceneWin, 0, "system", s.GetSceneName())
@ -2426,7 +2451,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
// vip加成分
vipScore = int64(math.Ceil(float64(rankScore) * float64(playerEx.VipExtra) / 100.0))
// 角色加成分
_, roleAdd = srvdata.RolePetMgrSington.GetRoleAdd(&playerEx.PlayerData, common.RoleAddRankScore)
_, roleAdd = srvdata.RolePetMgrSington.GetRoleAdd(playerEx.PlayerData, common.RoleAddRankScore)
roleScore = int64(math.Ceil(float64(rankScore) * float64(roleAdd) / 100.0))
//周卡加成
if playerEx.GetWeekCardPrivilege(2) {
@ -2530,6 +2555,92 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
s.Broadcast(int(tienlen.TienLenPacketID_PACKET_SCTienLenGameBilled), pack, 0)
logger.Logger.Trace("TienLenPacketID_PACKET_SCTienLenGameBilled gameFreeId:", sceneEx.GetGameFreeId(), ";pack:", pack)
if sceneEx.IsCustom() && sceneEx.TotalOfGames > 0 {
for _, v := range tienlenType.PlayerData {
d := sceneEx.BilledList[v.UserId]
if d == nil {
arr := make([]*BilledInfo, 0)
d = &arr
sceneEx.BilledList[v.UserId] = d
}
*d = append(*d, &BilledInfo{
Round: int32(sceneEx.NumOfGames),
ChangeScore: v.BillCoin,
Score: base.PlayerMgrSington.GetPlayerBySnId(v.UserId).GetCoin(),
})
}
sceneEx.RoundEndTime = append(sceneEx.RoundEndTime, time.Now().Unix())
sceneEx.RoundLogId = append(sceneEx.RoundLogId, sceneEx.recordId)
if sceneEx.NumOfGames >= int(sceneEx.TotalOfGames) {
packBilled := &tienlen.SCTienLenCycleBilled{}
for snid, billedList := range sceneEx.BilledList {
info := &tienlen.TienLenCycleBilledInfo{
SnId: snid,
TotalScore: 1000,
Score: 1000,
}
for _, bill := range *billedList {
info.RoundScore = append(info.RoundScore, bill.ChangeScore)
info.TotalScore += bill.ChangeScore
}
packBilled.List = append(packBilled.List, info)
}
sort.Slice(packBilled.List, func(i, j int) bool {
var a, b int64
for _, v := range packBilled.List[i].RoundScore {
a += v
}
a += packBilled.List[i].Score
for _, v := range packBilled.List[j].RoundScore {
b += v
}
b += packBilled.List[j].Score
return a > b
})
if len(packBilled.List) > 0 {
for _, v := range sceneEx.Items {
packBilled.List[0].Award = append(packBilled.List[0].Award, &tienlen.ItemInfo{
Id: v.Id,
Num: v.Num,
})
}
// 发奖品
if len(sceneEx.Items) > 0 {
p := base.PlayerMgrSington.GetPlayerBySnId(packBilled.List[0].SnId)
if p != nil {
var items []*model.Item
for _, v := range packBilled.List[0].Award {
itemData := srvdata.GameItemMgr.Get(p.Platform, v.GetId())
if itemData != nil {
items = append(items, &model.Item{
ItemId: v.GetId(),
ItemNum: v.GetNum(),
})
}
}
p.AddItems(&model.AddItemParam{
P: p.PlayerData,
Change: items,
GainWay: common.GainWayRoomGain,
Operator: "system",
Remark: "房卡场奖励",
GameId: int64(sceneEx.GameId),
GameFreeId: int64(sceneEx.GetGameFreeId()),
})
sceneEx.PlayerAward[p.SnId] = &items
}
}
}
s.Broadcast(int(tienlen.TienLenPacketID_PACKET_SCTienLenCycleBilled), packBilled, 0)
logger.Logger.Tracef("SCTienLenCycleBilled: %v", packBilled)
s.SyncSceneState(common.SceneStateEnd)
sceneEx.SaveCustomLog()
sceneEx.BilledList = make(map[int32]*[]*BilledInfo)
sceneEx.RoundEndTime = sceneEx.RoundEndTime[:0]
sceneEx.RoundLogId = sceneEx.RoundLogId[:0]
}
}
// 牌局记录
info, err := model.MarshalGameNoteByFIGHT(&tienlenType)
if err == nil {
@ -2578,10 +2689,11 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
})
// 保存玩家游戏记录
sceneEx.SaveGamePlayerListLog(o_player.UserId,
base.GetSaveGamePlayerListLogParam(o_player.Platform, o_player.Channel, o_player.Promoter,
o_player.PackageTag, sceneEx.recordId, o_player.InviterId, totalin, totalout, o_player.BillTaxCoin,
0, 0, o_player.GainCoin+o_player.BombCoin, validBet, validFlow, o_player.IsFirst, o_player.IsLeave))
param := base.GetSaveGamePlayerListLogParam(o_player.Platform, o_player.Channel, o_player.Promoter,
o_player.PackageTag, sceneEx.recordId, o_player.InviterId, totalin, totalout, o_player.BillTaxCoin,
0, 0, o_player.GainCoin+o_player.BombCoin, validBet, validFlow, o_player.IsFirst, o_player.IsLeave)
param.CycleId = sceneEx.CycleID
sceneEx.SaveGamePlayerListLog(o_player.UserId, param)
}
}
if isSave {
@ -2590,6 +2702,7 @@ func (this *SceneBilledStateTienLen) OnEnter(s *base.Scene) {
Trend20Lately: "",
CtrlType: sceneEx.ctrlType,
PlayerPool: tienlenType.PlayerPool,
CycleId: sceneEx.CycleID,
})
}
}
@ -2693,7 +2806,10 @@ func (this *SceneBilledStateTienLen) OnLeave(s *base.Scene) {
s.TryDismissRob()
}
if s.CheckNeedDestroy() || (s.IsMatchScene() && (!s.MatchFinals || (s.MatchFinals && s.NumOfGames >= 2))) { // 非决赛打一场 决赛打两场
if s.CheckNeedDestroy() || (s.IsMatchScene() && (!s.GetMatch().GetIsFinals() || (s.GetMatch().GetIsFinals() && s.NumOfGames >= 2))) { // 非决赛打一场 决赛打两场
sceneEx.SceneDestroy(true)
}
if s.TotalOfGames > 0 && s.NumOfGames >= int(s.TotalOfGames) {
sceneEx.SceneDestroy(true)
}
s.RankMatchDestroy()
@ -2780,6 +2896,11 @@ func init() {
base.RegisteScenePolicy(common.GameId_TienLenRank_toend, 0, ScenePolicyTienLenSingleton)
base.RegisteScenePolicy(common.GameId_TienLenRank_yl, 0, ScenePolicyTienLenSingleton)
base.RegisteScenePolicy(common.GameId_TienLenRank_yl_toend, 0, ScenePolicyTienLenSingleton)
// 房卡场
base.RegisteScenePolicy(common.GameId_TienLenCustom, 0, ScenePolicyTienLenSingleton)
base.RegisteScenePolicy(common.GameId_TienLenCustom_toend, 0, ScenePolicyTienLenSingleton)
base.RegisteScenePolicy(common.GameId_TienLenCustom_yl, 0, ScenePolicyTienLenSingleton)
base.RegisteScenePolicy(common.GameId_TienLenCustom_yl_toend, 0, ScenePolicyTienLenSingleton)
return nil
})
}

View File

@ -1,153 +1,150 @@
package transact
//
//import (
// "errors"
// "fmt"
// "mongo.games.com/game/common"
// "mongo.games.com/game/gamesrv/base"
// "mongo.games.com/game/model"
// "mongo.games.com/game/proto"
// webapi_proto "mongo.games.com/game/protocol/webapi"
// "mongo.games.com/goserver/core/basic"
// "mongo.games.com/goserver/core/logger"
// "mongo.games.com/goserver/core/netlib"
// "mongo.games.com/goserver/core/task"
// "mongo.games.com/goserver/core/transact"
// "sync"
//)
//
//const __REQIP__ = "__REQIP__"
//
//var (
// WebAPIErrParam = errors.New("param err")
// WebAPIErrNoPlayer = errors.New("player no find")
//)
//
//func init() {
// transact.RegisteHandler(common.TransType_GameSrvWebApi, &WebAPITranscateHandler{})
//}
//
//var WebAPIHandlerMgrSingleton = &WebAPIHandlerMgr{wshMap: make(map[string]WebAPIHandler)}
//
//type WebAPITranscateHandler struct {
//}
//
//func (this *WebAPITranscateHandler) OnExcute(tNode *transact.TransNode, ud interface{}) transact.TransExeResult {
// logger.Logger.Trace("WebAPITranscateHandler.OnExcute ")
// req := &common.M2GWebApiRequest{}
// err := netlib.UnmarshalPacketNoPackId(ud.([]byte), req)
// if err == nil {
// wsh := WebAPIHandlerMgrSingleton.GetWebAPIHandler(req.Path)
// if wsh == nil {
// logger.Logger.Error("WebAPITranscateHandler no registe WebAPIHandler ", req.Path)
// return transact.TransExeResult_Failed
// }
// tag, msg := wsh.Handler(tNode, req.Body)
// tNode.TransRep.RetFiels = msg
// switch tag {
// case common.ResponseTag_Ok:
// return transact.TransExeResult_Success
// case common.ResponseTag_TransactYield:
// return transact.TransExeResult_Yield
// }
// }
// logger.Logger.Error("WebAPITranscateHandler.OnExcute err:", err.Error())
// return transact.TransExeResult_Failed
//}
//
//func (this *WebAPITranscateHandler) OnCommit(tNode *transact.TransNode) transact.TransExeResult {
// logger.Logger.Trace("WebAPITranscateHandler.OnCommit ")
// return transact.TransExeResult_Success
//}
//
//func (this *WebAPITranscateHandler) OnRollBack(tNode *transact.TransNode) transact.TransExeResult {
// logger.Logger.Trace("WebAPITranscateHandler.OnRollBack ")
// return transact.TransExeResult_Success
//}
//
//func (this *WebAPITranscateHandler) OnChildTransRep(tNode *transact.TransNode, hChild transact.TransNodeID, retCode int,
// ud interface{}) transact.TransExeResult {
// logger.Logger.Trace("WebAPITranscateHandler.OnChildTransRep ")
// return transact.TransExeResult_Success
//}
//
//type WebAPIHandler interface {
// Handler(*transact.TransNode, []byte) (int, proto.Message)
//}
//
//type WebAPIHandlerWrapper func(*transact.TransNode, []byte) (int, proto.Message)
//
//func (wshw WebAPIHandlerWrapper) Handler(tNode *transact.TransNode, params []byte) (int, proto.Message) {
// return wshw(tNode, params)
//}
//
//type WebAPIHandlerMgr struct {
// wshMap map[string]WebAPIHandler
// DataWaitList sync.Map
//}
//
//func (this *WebAPIHandlerMgr) RegisteWebAPIHandler(name string, wsh WebAPIHandler) {
// this.wshMap[name] = wsh
//}
//
//func (this *WebAPIHandlerMgr) GetWebAPIHandler(name string) WebAPIHandler {
// if wsh, exist := this.wshMap[name]; exist {
// return wsh
// }
// return nil
//}
//
//func init() {
// //单控
// WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/game/SinglePlayerAdjust", WebAPIHandlerWrapper(
// func(tNode *transact.TransNode, params []byte) (int, proto.Message) {
// pack := &webapi_proto.SASinglePlayerAdjust{}
// msg := &webapi_proto.ASSinglePlayerAdjust{}
// err := proto.Unmarshal(params, msg)
// if err != nil {
// fmt.Printf("err:%v", err)
// pack.Tag = webapi_proto.TagCode_FAILED
// pack.Msg = "数据序列化失败"
// return common.ResponseTag_ParamError, pack
// }
// pack.Tag = webapi_proto.TagCode_SUCCESS
// switch msg.GetOpration() {
// case 1:
// psa := base.PlayerSingleAdjustMgr.AddNewSingleAdjust(msg.GetPlayerSingleAdjust())
// if psa != nil {
// task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
// return model.AddNewSingleAdjust(psa)
// }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
// if data != nil {
// pack.Tag = webapi_proto.TagCode_FAILED
// pack.Msg = "insert err" + data.(error).Error()
// }
// tNode.TransRep.RetFiels = pack
// tNode.Resume()
// }), "AddNewSingleAdjust").Start()
// return common.ResponseTag_TransactYield, pack
// }
// case 2:
// base.PlayerSingleAdjustMgr.EditSingleAdjust(msg.GetPlayerSingleAdjust())
// case 3:
// psa := msg.PlayerSingleAdjust
// if psa != nil {
// base.PlayerSingleAdjustMgr.DeleteSingleAdjust(psa.Platform, psa.SnId, psa.GameFreeId)
// }
// case 4:
// ps := msg.PlayerSingleAdjust
// webp := base.PlayerSingleAdjustMgr.GetSingleAdjust(ps.Platform, ps.SnId, ps.GameFreeId)
// if webp == nil {
// pack.Tag = webapi_proto.TagCode_FAILED
// pack.Msg = fmt.Sprintf("webp == nil %v %v %v", ps.Platform, ps.SnId, ps.GameFreeId)
// }
// pack.PlayerSingleAdjust = webp
// default:
// pack.Tag = webapi_proto.TagCode_FAILED
// pack.Msg = "Opration param is error!"
// return common.ResponseTag_ParamError, pack
// }
// return common.ResponseTag_Ok, pack
// }))
//}
import (
"errors"
"sync"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/netlib"
"mongo.games.com/goserver/core/transact"
"mongo.games.com/game/common"
"mongo.games.com/game/gamesrv/base"
"mongo.games.com/game/gamesrv/tienlen"
"mongo.games.com/game/proto"
webapiproto "mongo.games.com/game/protocol/webapi"
)
const __REQIP__ = "__REQIP__"
var (
WebAPIErrParam = errors.New("param err")
WebAPIErrNoPlayer = errors.New("player no find")
)
func init() {
transact.RegisteHandler(common.TransType_GameSrvWebApi, &WebAPITranscateHandler{})
}
var WebAPIHandlerMgrSingleton = &WebAPIHandlerMgr{wshMap: make(map[string]WebAPIHandler)}
type WebAPITranscateHandler struct {
}
func (this *WebAPITranscateHandler) OnExcute(tNode *transact.TransNode, ud interface{}) transact.TransExeResult {
logger.Logger.Trace("WebAPITranscateHandler.OnExcute ")
req := &common.M2GWebApiRequest{}
err := netlib.UnmarshalPacketNoPackId(ud.([]byte), req)
if err == nil {
wsh := WebAPIHandlerMgrSingleton.GetWebAPIHandler(req.Path)
if wsh == nil {
logger.Logger.Error("WebAPITranscateHandler no registe WebAPIHandler ", req.Path)
return transact.TransExeResult_Failed
}
tag, msg := wsh.Handler(tNode, req.Body)
tNode.TransRep.RetFiels = msg
switch tag {
case common.ResponseTag_Ok:
return transact.TransExeResult_Success
case common.ResponseTag_TransactYield:
return transact.TransExeResult_Yield
}
}
logger.Logger.Error("WebAPITranscateHandler.OnExcute err:", err.Error())
return transact.TransExeResult_Failed
}
func (this *WebAPITranscateHandler) OnCommit(tNode *transact.TransNode) transact.TransExeResult {
logger.Logger.Trace("WebAPITranscateHandler.OnCommit ")
return transact.TransExeResult_Success
}
func (this *WebAPITranscateHandler) OnRollBack(tNode *transact.TransNode) transact.TransExeResult {
logger.Logger.Trace("WebAPITranscateHandler.OnRollBack ")
return transact.TransExeResult_Success
}
func (this *WebAPITranscateHandler) OnChildTransRep(tNode *transact.TransNode, hChild transact.TransNodeID, retCode int,
ud interface{}) transact.TransExeResult {
logger.Logger.Trace("WebAPITranscateHandler.OnChildTransRep ")
return transact.TransExeResult_Success
}
type WebAPIHandler interface {
Handler(*transact.TransNode, []byte) (int, proto.Message)
}
type WebAPIHandlerWrapper func(*transact.TransNode, []byte) (int, proto.Message)
func (wshw WebAPIHandlerWrapper) Handler(tNode *transact.TransNode, params []byte) (int, proto.Message) {
return wshw(tNode, params)
}
type WebAPIHandlerMgr struct {
wshMap map[string]WebAPIHandler
DataWaitList sync.Map
}
func (this *WebAPIHandlerMgr) RegisteWebAPIHandler(name string, wsh WebAPIHandler) {
this.wshMap[name] = wsh
}
func (this *WebAPIHandlerMgr) GetWebAPIHandler(name string) WebAPIHandler {
if wsh, exist := this.wshMap[name]; exist {
return wsh
}
return nil
}
func init() {
// 对局详情
WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/game/room_info", WebAPIHandlerWrapper(
func(tNode *transact.TransNode, params []byte) (int, proto.Message) {
pack := &webapiproto.SARoomInfo{}
msg := &webapiproto.ASRoomInfo{}
err := proto.Unmarshal(params, msg)
if err != nil {
pack.Tag = webapiproto.TagCode_FAILED
pack.Msg = "数据序列化失败"
return common.ResponseTag_ParamError, pack
}
pack.Tag = webapiproto.TagCode_SUCCESS
scene := base.SceneMgrSington.GetScene(int(msg.GetRoomId()))
if scene == nil || scene.ExtraData == nil {
pack.Tag = webapiproto.TagCode_NotFound
pack.Msg = "房间没找到"
return common.ResponseTag_NoFindRoom, pack
}
switch d := scene.ExtraData.(type) {
case tienlen.TienLenSceneData:
for k := range d.BilledList {
pack.SnId = append(pack.SnId, k)
}
for k, v := range d.RoundLogId {
var score []int64
for _, vv := range pack.SnId {
list := d.BilledList[vv]
if list == nil || len(*list) <= k {
score = append(score, 0)
continue
}
score = append(score, (*list)[k].ChangeScore)
}
item := &webapiproto.RoundInfo{
Round: int32(k + 1),
Ts: d.RoundEndTime[k],
Score: score,
LogId: v,
}
pack.List = append(pack.List, item)
}
default:
pack.Tag = webapiproto.TagCode_FAILED
pack.Msg = "未实现"
}
return common.ResponseTag_Ok, pack
}))
}

View File

@ -1,56 +1,16 @@
package main
import (
rawproto "google.golang.org/protobuf/proto"
"mongo.games.com/game/proto"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/netlib"
"mongo.games.com/goserver/srvlib"
"mongo.games.com/goserver/srvlib/protocol"
)
var (
BroadcastMaker = &BroadcastPacketFactory{}
)
type BroadcastPacketFactory struct {
}
type BroadcastHandler struct {
}
func init() {
// 给所有玩家或某个类型的所有服务发消息
netlib.RegisterHandler(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), &BroadcastHandler{})
netlib.RegisterFactory(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), BroadcastMaker)
netlib.Register(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), &protocol.SSPacketBroadcast{}, BroadcastHandler)
}
func (this *BroadcastPacketFactory) CreatePacket() interface{} {
pack := &protocol.SSPacketBroadcast{}
return pack
}
func (this *BroadcastPacketFactory) CreateBroadcastPacket(sp *protocol.BCSessionUnion, packetid int, data interface{}) (rawproto.Message, error) {
pack := &protocol.SSPacketBroadcast{
SessParam: sp,
PacketId: proto.Int(packetid),
}
if byteData, ok := data.([]byte); ok {
pack.Data = byteData
} else {
byteData, err := netlib.MarshalPacket(packetid, data)
if err == nil {
pack.Data = byteData
} else {
logger.Logger.Warn("BroadcastPacketFactory.CreateBroadcastPacket err:", err)
return nil, err
}
}
proto.SetDefaults(pack)
return pack, nil
}
func (this *BroadcastHandler) Process(s *netlib.Session, packetid int, data interface{}) error {
func BroadcastHandler(s *netlib.Session, packetid int, data interface{}) error {
if bp, ok := data.(*protocol.SSPacketBroadcast); ok {
pd := bp.GetData()
sp := bp.GetSessParam()

View File

@ -1,61 +1,21 @@
package main
import (
rawproto "google.golang.org/protobuf/proto"
"mongo.games.com/game/proto"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/netlib"
"mongo.games.com/goserver/srvlib"
"mongo.games.com/goserver/srvlib/protocol"
)
var (
MulticastMaker = &MulticastPacketFactory{}
)
type MulticastPacketFactory struct {
}
type MulticastHandler struct {
}
func init() {
// 给某些玩家和某些服务发消息
netlib.RegisterHandler(int(protocol.SrvlibPacketID_PACKET_SS_MULTICAST), &MulticastHandler{})
netlib.RegisterFactory(int(protocol.SrvlibPacketID_PACKET_SS_MULTICAST), MulticastMaker)
netlib.Register(int(protocol.SrvlibPacketID_PACKET_SS_MULTICAST), &protocol.SSPacketMulticast{}, MulticastHandler)
}
func (this *MulticastPacketFactory) CreatePacket() interface{} {
pack := &protocol.SSPacketMulticast{}
return pack
}
func (this *MulticastPacketFactory) CreateMulticastPacket(packetid int, data interface{}, sis ...*protocol.MCSessionUnion) (rawproto.Message, error) {
pack := &protocol.SSPacketMulticast{
Sessions: sis,
PacketId: proto.Int(packetid),
}
if byteData, ok := data.([]byte); ok {
pack.Data = byteData
} else {
byteData, err := netlib.MarshalPacket(packetid, data)
if err == nil {
pack.Data = byteData
} else {
logger.Logger.Info("MulticastPacketFactory.CreateMulticastPacket err:", err)
return nil, err
}
}
proto.SetDefaults(pack)
return pack, nil
}
func (this *MulticastHandler) Process(s *netlib.Session, packetid int, data interface{}) error {
func MulticastHandler(s *netlib.Session, packetid int, data interface{}) error {
if mp, ok := data.(*protocol.SSPacketMulticast); ok {
pd := mp.GetData()
sis := mp.GetSessions()
for _, si := range sis {
ns := this.getSession(si)
ns := getSession(si)
if ns != nil {
ns.Send(int(mp.GetPacketId()), pd /*, s.GetSessionConfig().IsInnerLink*/)
}
@ -64,7 +24,7 @@ func (this *MulticastHandler) Process(s *netlib.Session, packetid int, data inte
return nil
}
func (this *MulticastHandler) getSession(su *protocol.MCSessionUnion) *netlib.Session {
func getSession(su *protocol.MCSessionUnion) *netlib.Session {
cs := su.GetMccs()
if cs != nil {
return srvlib.ClientSessionMgrSington.GetSession(cs.GetSId())

View File

@ -1,61 +1,9 @@
package api
import (
rawproto "google.golang.org/protobuf/proto"
"mongo.games.com/game/proto"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/netlib"
"mongo.games.com/goserver/srvlib"
"mongo.games.com/goserver/srvlib/protocol"
"mongo.games.com/game/common"
)
var (
BroadcastMaker = &BroadcastPacketFactory{}
)
type BroadcastPacketFactory struct {
}
type BroadcastHandler struct {
}
func init() {
netlib.RegisterHandler(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), &BroadcastHandler{})
netlib.RegisterFactory(int(protocol.SrvlibPacketID_PACKET_SS_BROADCAST), BroadcastMaker)
}
func (this *BroadcastPacketFactory) CreatePacket() interface{} {
pack := &protocol.SSPacketBroadcast{}
return pack
}
func (this *BroadcastPacketFactory) CreateBroadcastPacket(sp *protocol.BCSessionUnion, packetid int, data interface{}) (rawproto.Message, error) {
pack := &protocol.SSPacketBroadcast{
SessParam: sp,
PacketId: proto.Int(packetid),
}
if byteData, ok := data.([]byte); ok {
pack.Data = byteData
} else {
byteData, err := netlib.MarshalPacket(packetid, data)
if err == nil {
pack.Data = byteData
} else {
logger.Logger.Warn("BroadcastPacketFactory.CreateBroadcastPacket err:", err)
return nil, err
}
}
proto.SetDefaults(pack)
return pack, nil
}
func (this *BroadcastHandler) Process(s *netlib.Session, packetid int, data interface{}) error {
if bp, ok := data.(*protocol.SSPacketBroadcast); ok {
pd := bp.GetData()
sp := bp.GetSessParam()
if bcss := sp.GetBcss(); bcss != nil {
srvlib.ServerSessionMgrSington.Broadcast(int(bp.GetPacketId()), pd, int(bcss.GetSArea()), int(bcss.GetSType()))
}
}
return nil
common.RegisterBoardCastHandler()
}

View File

@ -9,6 +9,7 @@ import (
"mongo.games.com/game/common"
"mongo.games.com/game/model"
"mongo.games.com/goserver/core"
"mongo.games.com/goserver/core/admin"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/netlib"
"mongo.games.com/goserver/core/transact"
@ -176,14 +177,6 @@ func init() {
return transact.TransExeResult(retCode)
}),
})
// //参数设置
// admin.MyAdminApp.Route("/api/Param/CommonTax", GameSrvWebAPI)
// //捕鱼金币池查询
// admin.MyAdminApp.Route("/api/CoinPool/FishingPool", GameSrvWebAPI)
// //通用金币池查询
// admin.MyAdminApp.Route("/api/CoinPool/GamePool", GameSrvWebAPI)
// //捕鱼渔场保留金币
// admin.MyAdminApp.Route("/api/CoinPool/GameFishsAllCoin", GameSrvWebAPI)
// //单控数据
//admin.MyAdminApp.Route("/api/game/SinglePlayerAdjust", GameSrvWebAPI)
// 对局详情
admin.MyAdminApp.Route("/api/game/room_info", GameSrvWebAPI)
}

View File

@ -229,7 +229,7 @@ func SrvCtrlNotice(rw http.ResponseWriter, data []byte) {
sc := &protocol.BCSessionUnion{
Bccs: &protocol.BCClientSession{},
}
broadcast, err := BroadcastMaker.CreateBroadcastPacket(sc, int(msg_proto.MSGPacketID_PACKET_SC_NOTICE), noticePacket)
broadcast, err := common.CreateBroadcastPacket(sc, int(msg_proto.MSGPacketID_PACKET_SC_NOTICE), noticePacket)
if err != nil || broadcast == nil {
pack.Tag = webapi.TagCode_FAILED
pack.Msg = "send notice failed(inner error)"

View File

@ -243,7 +243,7 @@ func init() {
admin.MyAdminApp.Route("/api/player/update_tel", WorldSrvApi)
// 删除账号
admin.MyAdminApp.Route("/api/player/delete", WorldSrvApi)
//添加道具
// 添加道具
admin.MyAdminApp.Route("/api/player/AddItem", WorldSrvApi)
}

View File

@ -84,3 +84,16 @@ func SaveToDelBackupBagItem(args *BagInfo) error {
}
return nil
}
type AddItemParam struct {
P *PlayerData
Change []*Item // 道具变化数量
Cost []*Item // 获得道具时消耗的道具数量
Add int64 // 加成数量
GainWay int32 // 记录类型
Operator, Remark string // 操作人,备注
GameId, GameFreeId int64 // 游戏id,场次id
NoLog bool // 是否不记录日志
LogId string // 撤销的id,道具兑换失败
RoomConfigId int32 // 房间配置id
}

View File

@ -1,10 +1,14 @@
package model
import (
"mongo.games.com/game/protocol/gamehall"
"strconv"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/game/common"
"mongo.games.com/game/protocol/shop"
"mongo.games.com/game/protocol/webapi"
"strconv"
)
/*
@ -30,7 +34,7 @@ const (
type ShopInfo struct {
Id int32 // 商品ID
Page int32 // 页面 1金币页面 2钻石页面 3道具页面
Page int32 // 页面 1金币页面 2钻石页面 3道具页面 4,房卡
Order int32 // 排序 页面内商品的位置排序
Location []int32 // 显示位置 第1位竖版大厅 第2位Tienlen1级选场 第3位捕鱼1级选场
Picture string // 图片id
@ -40,7 +44,7 @@ type ShopInfo struct {
AdTime int32 // 观看几次广告
RepeatTimes int32 // 领取次数
CoolingTime []int32 // 观看冷却时间
Type int32 // 获得类型 1金币 2钻石 3道具类型
Type int32 // 获得类型 1金币 2钻石 3道具类型 4房卡
Amount int64 // 获得数量
AddArea []int32 // 加送百分比比如加送10%就配置110
ItemId int32 // 获得道具ID
@ -137,6 +141,14 @@ type AllConfig struct {
*webapi.GuideConfig
//娃娃机配置
*webapi.MachineConfig
MatchAudience map[int32]*webapi.MatchAudience // 比赛观众列表 key: 玩家id
// 小精灵配置
*webapi.SpiritConfig
// 房卡场房间类型
RoomType map[int32]*webapi.RoomType // key: 房间类型id
// 房卡场房间配置
RoomConfig map[int32]*webapi.RoomConfig // key: 房间配置id
RoomTypeMap map[int32][]*webapi.RoomConfig // key: 房间类型id:房间配置
}
type GlobalConfig struct {
@ -165,6 +177,10 @@ func (cm *ConfigMgr) GetConfig(platform string) *AllConfig {
EntrySwitch: make(map[int32]*webapi.EntrySwitch),
ShopInfos: make(map[int32]*ShopInfo),
ChannelSwitch: make(map[int32]*webapi.ChannelSwitchConfig),
MatchAudience: make(map[int32]*webapi.MatchAudience),
RoomType: make(map[int32]*webapi.RoomType),
RoomConfig: make(map[int32]*webapi.RoomConfig),
RoomTypeMap: make(map[int32][]*webapi.RoomConfig),
}
cm.platform[platform] = c
}
@ -358,3 +374,106 @@ func (cm *ConfigMgr) GetSkinSkillMaxLevel(plt string, skinId int32) int32 {
}
return level
}
func (cm *ConfigMgr) AddMatchAudience(d *webapi.MatchAudience) {
cfg := cm.GetConfig(d.Platform)
cfg.MatchAudience[d.GetSnId()] = d
}
func (cm *ConfigMgr) DelMatchAudience(plt string, snid int32) {
logger.Logger.Tracef("del match audience plt:%s, snid:%d", plt, snid)
delete(cm.GetConfig(plt).MatchAudience, snid)
}
// IsMatchAudience 是不是比赛场观众
func (cm *ConfigMgr) IsMatchAudience(plt string, snId int32) bool {
_, ok := cm.GetConfig(plt).MatchAudience[snId]
return ok
}
func (cm *ConfigMgr) UpdateRoomType(data *webapi.RoomType) {
cm.GetConfig(data.GetPlatform()).RoomType[data.GetId()] = data
}
func (cm *ConfigMgr) DelRoomType(plt string, id int32) {
delete(cm.GetConfig(plt).RoomType, id)
}
func (cm *ConfigMgr) UpdateRoomConfig(data *webapi.RoomConfig) {
cm.GetConfig(data.GetPlatform()).RoomConfig[data.GetId()] = data
d := cm.GetConfig(data.GetPlatform()).RoomTypeMap[data.GetRoomType()]
if d == nil {
d = make([]*webapi.RoomConfig, 0)
}
d = append(d, data)
cm.GetConfig(data.GetPlatform()).RoomTypeMap[data.GetRoomType()] = d
}
func (cm *ConfigMgr) DelRoomConfig(plt string, id int32) {
d := cm.GetConfig(plt).RoomConfig[id]
if d != nil {
b := cm.GetConfig(plt).RoomTypeMap[d.GetRoomType()]
if b != nil {
for i, v := range b {
if v.GetId() == id {
b = append(b[:i], b[i+1:]...)
cm.GetConfig(plt).RoomTypeMap[d.GetRoomType()] = b
}
}
}
}
delete(cm.GetConfig(plt).RoomConfig, id)
}
func (cm *ConfigMgr) GetRoomConfig(plt string) *gamehall.SCRoomConfig {
pack := &gamehall.SCRoomConfig{}
for _, v := range cm.GetConfig(plt).RoomType {
if v.GetOn() != common.On {
continue
}
var list []*gamehall.RoomConfigInfo
for _, vv := range cm.GetConfig(plt).RoomTypeMap[v.GetId()] {
if vv.GetOn() != common.On {
continue
}
var cost, reward []*gamehall.ItemInfo
for _, item := range vv.GetCost() {
cost = append(cost, &gamehall.ItemInfo{
Id: item.GetItemId(),
Num: int32(item.GetItemNum()),
})
}
for _, item := range vv.GetReward() {
reward = append(reward, &gamehall.ItemInfo{
Id: item.GetItemId(),
Num: int32(item.GetItemNum()),
})
}
list = append(list, &gamehall.RoomConfigInfo{
Id: vv.GetId(),
Name: vv.GetName(),
RoomType: vv.GetRoomType(),
On: vv.GetOn(),
SortId: vv.GetSortId(),
Cost: cost,
Reward: reward,
OnChannelName: vv.GetOnChannelName(),
GameFreeId: vv.GetGameFreeId(),
Round: vv.GetRound(),
PlayerNum: vv.GetPlayerNum(),
NeedPassword: vv.GetNeedPassword(),
CostType: vv.GetCostType(),
Voice: vv.GetVoice(),
ImageURI: vv.GetImageURI(),
})
}
pack.List = append(pack.List, &gamehall.RoomTypeInfo{
Id: v.GetId(),
Name: v.GetName(),
On: v.GetOn(),
SortId: v.GetSortId(),
List: list,
})
}
return pack
}

35
model/customlog.go Normal file
View File

@ -0,0 +1,35 @@
package model
var (
DbCustomLogDBName = "log"
DbCustomLogCollName = "log_custom"
)
type PlayerInfo struct {
SnId int32 // 玩家id
Awards []*Item // 奖品
}
type RoundInfo struct {
Round int32 // 第几局
Ts int64 // 结算时间
Score []int64 // 分数
LogId string // 牌局记录id
}
type CustomLog struct {
Platform string `bson:"-"`
CycleId string // 本轮id多局游戏属于同一轮
RoomConfigId int32 // 房间配置id
GameFreeId int32 // 场次id
TotalRound int32 // 总局数
PlayerNum int32 // 最大人数
Password string // 密码
CostType int32 // 付费方式 1房主 2AA
Voice int32 // 是否开启语音 1开启
RoomId int32 // 房间id
SnId []PlayerInfo // 所有玩家
List []RoundInfo // 对局记录
StartTs, EndTs int64 // 开始,结束时间
State int32 // 0正常结束 1后台中途解散
}

View File

@ -35,15 +35,15 @@ type GameDetailedLogType struct {
type GameDetailedLog struct {
Id bson.ObjectId `bson:"_id"` //记录ID
LogId string //记录ID
LogId string //记录ID,每局游戏唯一
GameId int32 //游戏id
ClubId int32 //俱乐部Id
ClubRoom string //俱乐部包间
Platform string //平台id
Channel string //渠道
Promoter string //推广员
MatchId int64 //比赛ID
SceneId int32 //场景ID
MatchId int64 //比赛ID,应该用字符串的
SceneId int32 //房间id会重复
GameMode int32 //游戏类型
GameFreeid int32 //游戏类型房间号
PlayerCount int32 //玩家数量
@ -57,6 +57,7 @@ type GameDetailedLog struct {
Ts int64 //时间戳
CtrlType int // 1控赢 2控输 0不控
PlayerPool map[int]int // 个人水池分
CycleId string // 本轮id打一轮有多局
}
func NewGameDetailedLog() *GameDetailedLog {
@ -65,7 +66,8 @@ func NewGameDetailedLog() *GameDetailedLog {
}
func NewGameDetailedLogEx(logid string, gameid, sceneid, gamemode, gamefreeid, playercount, gametiming, gamebasebet int32,
gamedetailednote string, platform string, clubId int32, clubRoom string, cpCtx CoinPoolCtx, ver int32, trend20Lately string, ctrlType int, playerPool map[int]int) *GameDetailedLog {
gamedetailednote string, platform string, clubId int32, clubRoom string, cpCtx CoinPoolCtx, ver int32,
trend20Lately string, ctrlType int, playerPool map[int]int, cycleId string) *GameDetailedLog {
cl := NewGameDetailedLog()
cl.LogId = logid
cl.GameId = gameid
@ -87,6 +89,7 @@ func NewGameDetailedLogEx(logid string, gameid, sceneid, gamemode, gamefreeid, p
cl.Ts = time.Now().Unix()
cl.CtrlType = ctrlType
cl.PlayerPool = playerPool
cl.CycleId = cycleId
return cl
}

View File

@ -52,9 +52,10 @@ type GamePlayerListLog struct {
MatchId int64
MatchType int64 //0.普通场 1.锦标赛 2.冠军赛 3.vip专属
Ts int32
IsFree bool //拉霸专用 是否免费
WinSmallGame int64 //拉霸专用 小游戏奖励
WinTotal int64 //拉霸专用 输赢
IsFree bool //拉霸专用 是否免费
WinSmallGame int64 //拉霸专用 小游戏奖励
WinTotal int64 //拉霸专用 输赢
CycleId string // 本轮id打一轮有多局
}
func NewGamePlayerListLog() *GamePlayerListLog {
@ -64,7 +65,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 int64,
isFree bool, winSmallGame, winTotal int64) *GamePlayerListLog {
isFree bool, winSmallGame, winTotal int64, cycleId string) *GamePlayerListLog {
cl := NewGamePlayerListLog()
cl.SnId = snid
cl.GameDetailedLogId = gamedetailedlogid
@ -98,6 +99,7 @@ func NewGamePlayerListLogEx(snid int32, gamedetailedlogid string, platform, chan
cl.Time = tNow
cl.MatchId = matchid
cl.MatchType = matchType
cl.CycleId = cycleId
return cl
}

View File

@ -14,20 +14,21 @@ var (
)
type ItemLog struct {
LogId bson.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兑换失败
LogId bson.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 []*Item // 消耗的道具
Id string // 撤销的id兑换失败
RoomConfigId int32 // 房间配置id
}
func NewItemLog() *ItemLog {
@ -36,18 +37,19 @@ func NewItemLog() *ItemLog {
}
type ItemParam struct {
Platform string // 平台
SnId int32 // 玩家id
LogType int32 // 记录类型 0.获取 1.消耗
ItemId int32 // 道具id
ItemName string // 道具名称
Count int64 // 个数
Remark string // 备注
TypeId int32 // 变化类型
GameId int64 // 游戏id,游戏中获得时有值
GameFreeId int64 // 场次id,游戏中获得时有值
Cost []*ItemInfo // 消耗的道具
LogId string // 撤销的id兑换失败
Platform string // 平台
SnId int32 // 玩家id
LogType int32 // 记录类型 0.获取 1.消耗
ItemId int32 // 道具id
ItemName string // 道具名称
Count int64 // 个数
Remark string // 备注
TypeId int32 // 变化类型
GameId int64 // 游戏id,游戏中获得时有值
GameFreeId int64 // 场次id,游戏中获得时有值
Cost []*Item // 消耗的道具
LogId string // 撤销的id兑换失败
RoomConfigId int32 // 房间配置id
}
func NewItemLogEx(param ItemParam) *ItemLog {
@ -65,6 +67,7 @@ func NewItemLogEx(param ItemParam) *ItemLog {
itemLog.GameFreeId = int32(param.GameFreeId)
itemLog.Cost = param.Cost
itemLog.Id = param.LogId
itemLog.RoomConfigId = param.RoomConfigId
return itemLog
}

View File

@ -53,7 +53,7 @@ type JybInfo struct {
JybId bson.ObjectId `bson:"_id"` // 礼包ID
Platform string //平台
Name string // 礼包名称
CodeType int32 // 礼包类型 1 通用 2 特殊
CodeType int32 // 礼包类型 1 通用 2专属(自动生成兑换码,每个玩家领一个) 3活动(自动生产兑换码,每个兑换码领一个)
StartTime int64 // 开始时间 Unix
EndTime int64 // 结束时间
Content string // 礼包内容

View File

@ -4,30 +4,29 @@ import (
"time"
)
// 比赛详情
type MatchAwardLog struct {
AwardNum map[string]map[int32]int32 // 奖励数量
Platform string
}
var (
MatchAwardLogDBName = "log"
MatchAwardLogCollName = "log_matchawardlog"
)
func NewMatchAwardLog() *MatchAwardLog {
return &MatchAwardLog{}
type MatchAward struct {
Platform string `bson:"-"`
Award map[int32]int32
}
func InsertOrUpdateMatchAwardLog(logs ...*MatchAwardLog) (err error) {
func UpsertMatchAward(data *MatchAward) error {
if rpcCli == nil {
return ErrRPClientNoConn
}
var ret bool
return rpcCli.CallWithTimeout("MatchAwardLogSvc.InsertOrUpdateMatchAwardLog", logs, &ret, time.Second*30)
return rpcCli.CallWithTimeout("MatchAwardSvc.UpsertMatchAward", data, &ret, time.Second*30)
}
func GetMatchAwardLog(platform string) (ret MatchAwardLog, err error) {
err = rpcCli.CallWithTimeout("MatchAwardLogSvc.GetMatchAward", platform, &ret, time.Second*30)
return ret, err
func GetMatchAward(platform string) (ret *MatchAward, err error) {
if rpcCli == nil {
return nil, ErrRPClientNoConn
}
ret = new(MatchAward)
err = rpcCli.CallWithTimeout("MatchAwardSvc.GetMatchAward", platform, ret, time.Second*30)
return
}

View File

@ -344,6 +344,13 @@ type MatchFreeSignupRec struct {
UseTimes int32 //累计使用免费次数
}
// WGPlayerInfo 游戏服玩家信息
// 大厅玩家信息发送给游戏服
type WGPlayerInfo struct {
*PlayerData
GameData map[int32]*PlayerGameData // 游戏数据,只允许存储玩家对应某个游戏需要持久化的数据
}
type PlayerData struct {
Id bson.ObjectId `bson:"_id"`
AccountId string //账号id

56
model/playergamedata.go Normal file
View File

@ -0,0 +1,56 @@
package model
import (
"time"
"mongo.games.com/goserver/core/logger"
)
type PlayerGameData struct {
Platform string `bson:"-"`
SnId int32
Id int32 // 游戏id或场次id
Data interface{} // 数据
}
type PlayerGameSaveReq struct {
Platform string
Data []*PlayerGameData
}
func SavePlayerGameData(platform string, data []*PlayerGameData) error {
if rpcCli == nil {
logger.Logger.Error("model.SavePlayerGameData rpcCli == nil")
return nil
}
b := false
err := rpcCli.CallWithTimeout("PlayerGameDataSvc.Save", &PlayerGameSaveReq{Platform: platform, Data: data}, &b, time.Second*30)
if err != nil {
logger.Logger.Error("model.SavePlayerGameData err:%v", err)
return err
}
return nil
}
type PlayerGameDataFindReq struct {
Platform string
SnId int32
}
type PlayerGameDataFindRes struct {
Data []*PlayerGameData
}
func GetPlayerGameData(platform string, snid int32) ([]*PlayerGameData, error) {
if rpcCli == nil {
logger.Logger.Error("model.GetPlayerGameData rpcCli == nil")
return nil, nil
}
res := &PlayerGameDataFindRes{}
err := rpcCli.CallWithTimeout("PlayerGameDataSvc.Find", &PlayerGameDataFindReq{Platform: platform, SnId: snid}, res, time.Second*30)
if err != nil {
logger.Logger.Error("model.GetPlayerGameData err:%v", err)
return nil, err
}
return res.Data, nil
}

View File

@ -23,4 +23,5 @@ const (
const (
DBVipGiftLog = "db_vipgift"
DBCustomLog = "db_customlog" // 房卡场对局记录
)

View File

@ -66,7 +66,7 @@
- 2720~2739
#### tournament锦标赛
- 2740~2759
- 2740~2779
#### RankMatch 排位赛
- 2780~2800

View File

@ -30,14 +30,14 @@ enum OpResultCode {
}
// 2320-2339
enum CoinSceneGamePacketID {
PACKET_CoinSceneGame_ZERO = 0; //
PACKET_CoinSceneGame_ZERO = 0; //
PACKET_CS_COINSCENE_GETPLAYERNUM = 2320;
PACKET_SC_COINSCENE_GETPLAYERNUM = 2321;
PACKET_CS_COINSCENE_OP = 2322;
PACKET_SC_COINSCENE_OP = 2323;
PACKET_CS_COINSCENE_LISTROOM = 2324;
PACKET_SC_COINSCENE_LISTROOM = 2325;
PACKET_SC_COINSCENE_QUEUESTATE = 2326;
PACKET_SC_COINSCENE_QUEUESTATE = 2326;
}
//PACKET_CS_COINSCENE_GETPLAYERNUM

View File

@ -1,5 +0,0 @@
cd $CCC_CLIENT_DIR/protocol/gamehall
npx pbjs --dependency protobufjs/minimal.js --target static-module --wrap commonjs --out gamehall.js ./*.proto
npx pbts --main --out ./gamehall.d.ts ./gamehall.js
cp ./gamehall.d.ts ./gamehall.js $CCC_CLIENT_DIR/vietnam/assets/ScriptCore/protocol

Some files were not shown because too many files have changed in this diff Show More