596 lines
19 KiB
Go
596 lines
19 KiB
Go
package fortuneox
|
|
|
|
import (
|
|
"encoding/json"
|
|
"mongo.games.com/game/common"
|
|
"mongo.games.com/game/gamerule/fortuneox"
|
|
"mongo.games.com/game/gamesrv/base"
|
|
"mongo.games.com/game/gamesrv/slotspkg/assemble"
|
|
"mongo.games.com/game/gamesrv/slotspkg/slots"
|
|
"mongo.games.com/game/model"
|
|
"mongo.games.com/game/proto"
|
|
protocol "mongo.games.com/game/protocol/fortuneox"
|
|
"mongo.games.com/game/protocol/server"
|
|
"mongo.games.com/goserver/core"
|
|
"mongo.games.com/goserver/core/logger"
|
|
"time"
|
|
)
|
|
|
|
// ////////////////////////////////////////////////////////////
|
|
var ScenePolicyFortuneOxSington = &ScenePolicyFortuneOx{}
|
|
|
|
type ScenePolicyFortuneOx struct {
|
|
base.BaseScenePolicy
|
|
states [fortuneox.FortuneOxStateMax]base.SceneState
|
|
}
|
|
|
|
// 创建场景扩展数据
|
|
func (this *ScenePolicyFortuneOx) CreateSceneExData(s *base.Scene) interface{} {
|
|
sceneEx := NewFortuneOxSceneData(s)
|
|
if sceneEx != nil {
|
|
if sceneEx.GetInit() {
|
|
s.SetExtraData(sceneEx)
|
|
}
|
|
}
|
|
return sceneEx
|
|
}
|
|
|
|
// 创建玩家扩展数据
|
|
func (this *ScenePolicyFortuneOx) CreatePlayerExData(s *base.Scene, p *base.Player) interface{} {
|
|
playerEx := &FortuneOxPlayerData{Player: p}
|
|
p.SetExtraData(playerEx)
|
|
return playerEx
|
|
}
|
|
|
|
// 场景开启事件
|
|
func (this *ScenePolicyFortuneOx) OnStart(s *base.Scene) {
|
|
logger.Logger.Trace("(this *ScenePolicyFortuneOx) OnStart, sceneId=", s.GetSceneId())
|
|
sceneEx := NewFortuneOxSceneData(s)
|
|
if sceneEx != nil {
|
|
if sceneEx.GetInit() {
|
|
s.SetExtraData(sceneEx)
|
|
s.ChangeSceneState(fortuneox.FortuneOxStateStart)
|
|
}
|
|
}
|
|
}
|
|
|
|
// 场景关闭事件
|
|
func (this *ScenePolicyFortuneOx) OnStop(s *base.Scene) {
|
|
logger.Logger.Trace("(this *ScenePolicyFortuneOx) OnStop , sceneId=", s.GetSceneId())
|
|
}
|
|
|
|
// 场景心跳事件
|
|
func (this *ScenePolicyFortuneOx) OnTick(s *base.Scene) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
if s.GetSceneState() != nil {
|
|
s.GetSceneState().OnTick(s)
|
|
}
|
|
}
|
|
|
|
// 玩家进入事件
|
|
func (this *ScenePolicyFortuneOx) OnPlayerEnter(s *base.Scene, p *base.Player) {
|
|
if s == nil || p == nil {
|
|
return
|
|
}
|
|
logger.Logger.Trace("(this *ScenePolicyFortuneOx) OnPlayerEnter, sceneId=", s.GetSceneId(), " player=", p.Name)
|
|
if sceneEx, ok := s.GetExtraData().(*FortuneOxSceneData); ok {
|
|
playerEx := &FortuneOxPlayerData{Player: p}
|
|
|
|
playerEx.init()
|
|
|
|
d := p.GameData[fortuneox.GameDataKey]
|
|
if d != nil {
|
|
m := make(map[string]string)
|
|
json.Unmarshal(d.Data.([]byte), &m)
|
|
playerEx.PullPlayer(m)
|
|
} else {
|
|
m := make(map[string]string)
|
|
//json.Unmarshal(d.Data.([]byte), &m)
|
|
playerEx.PullPlayer(m)
|
|
}
|
|
|
|
playerEx.SlotsSession.SetCoin(playerEx.Coin * fortuneox.NowByte)
|
|
|
|
playerEx.Clear()
|
|
|
|
sceneEx.players[p.SnId] = playerEx
|
|
|
|
p.SetExtraData(playerEx)
|
|
FortuneOxSendRoomInfo(s, sceneEx, playerEx)
|
|
|
|
s.FirePlayerEvent(p, base.PlayerEventEnter, nil)
|
|
}
|
|
}
|
|
|
|
// 玩家离开事件
|
|
func (this *ScenePolicyFortuneOx) OnPlayerLeave(s *base.Scene, p *base.Player, reason int) {
|
|
if s == nil || p == nil {
|
|
return
|
|
}
|
|
logger.Logger.Trace("(this *ScenePolicyFortuneOx) OnPlayerLeave, sceneId=", s.GetSceneId(), " player=", p.SnId)
|
|
if playerEx, ok := p.ExtraData.(*FortuneOxPlayerData); ok {
|
|
m := playerEx.PushPlayer()
|
|
if m != nil && len(m) > 0 {
|
|
b, err := json.Marshal(m)
|
|
if err != nil {
|
|
logger.Logger.Error("OnPlayerLeave, json.Marshal error:", err)
|
|
} else {
|
|
p.GameData[fortuneox.GameDataKey] = &model.PlayerGameData{
|
|
Platform: p.Platform,
|
|
SnId: p.SnId,
|
|
Id: fortuneox.GameDataKey,
|
|
Data: b,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if sceneEx, ok := s.ExtraData.(*FortuneOxSceneData); ok {
|
|
s.FirePlayerEvent(p, base.PlayerEventLeave, nil)
|
|
sceneEx.OnPlayerLeave(p, reason)
|
|
}
|
|
}
|
|
|
|
// 玩家掉线
|
|
func (this *ScenePolicyFortuneOx) OnPlayerDropLine(s *base.Scene, p *base.Player) {
|
|
if s == nil || p == nil {
|
|
return
|
|
}
|
|
logger.Logger.Trace("(this *ScenePolicyFortuneOx) OnPlayerDropLine, sceneId=", s.GetSceneId(), " player=", p.SnId)
|
|
s.FirePlayerEvent(p, base.PlayerEventDropLine, nil)
|
|
}
|
|
|
|
// 玩家重连
|
|
func (this *ScenePolicyFortuneOx) OnPlayerRehold(s *base.Scene, p *base.Player) {
|
|
if s == nil || p == nil {
|
|
return
|
|
}
|
|
logger.Logger.Trace("(this *ScenePolicyFortuneOx) OnPlayerRehold, sceneId=", s.GetSceneId(), " player=", p.SnId)
|
|
if sceneEx, ok := s.GetExtraData().(*FortuneOxSceneData); ok {
|
|
if playerEx, ok := p.GetExtraData().(*FortuneOxPlayerData); ok {
|
|
FortuneOxSendRoomInfo(s, sceneEx, playerEx)
|
|
}
|
|
}
|
|
}
|
|
|
|
// 返回房间
|
|
func (this *ScenePolicyFortuneOx) OnPlayerReturn(s *base.Scene, p *base.Player) {
|
|
if s == nil || p == nil {
|
|
return
|
|
}
|
|
logger.Logger.Trace("(this *ScenePolicyFortuneOx) OnPlayerReturn, GetSceneId()=", s.GetSceneId(), " player=", p.Name)
|
|
if sceneEx, ok := s.GetExtraData().(*FortuneOxSceneData); ok {
|
|
if playerEx, ok := p.GetExtraData().(*FortuneOxPlayerData); ok {
|
|
//if p.IsMarkFlag(base.PlayerState_Auto) {
|
|
// p.UnmarkFlag(base.PlayerState_Auto)
|
|
// p.SyncFlag()
|
|
//}
|
|
//发送房间信息给自己
|
|
FortuneOxSendRoomInfo(s, sceneEx, playerEx)
|
|
s.FirePlayerEvent(p, base.PlayerEventReturn, nil)
|
|
}
|
|
}
|
|
}
|
|
|
|
func FortuneOxSendRoomInfo(s *base.Scene, sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerData) {
|
|
pack := FortuneOxCreateRoomInfoPacket(s, sceneEx, playerEx)
|
|
logger.Logger.Trace("RoomInfo: ", pack)
|
|
playerEx.SendToClient(int(protocol.FortuneOxPID_PACKET_FORTUNEOX_SCFORTUNEOXROOMINFO), pack)
|
|
}
|
|
func FortuneOxCreateRoomInfoPacket(s *base.Scene, sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerData) interface{} {
|
|
//房间信息
|
|
pack := &protocol.SCFortuneOxRoomInfo{
|
|
RoomId: s.SceneId,
|
|
GameId: s.GameId,
|
|
RoomMode: s.SceneMode,
|
|
SceneType: s.GetSceneType(),
|
|
Params: common.CopySliceInt64ToInt32(s.Params),
|
|
NumOfGames: proto.Int(sceneEx.NumOfGames),
|
|
State: proto.Int(s.SceneState.GetState()),
|
|
ParamsEx: s.GetDBGameFree().OtherIntParams,
|
|
GameFreeId: proto.Int32(s.GetDBGameFree().Id),
|
|
//BetLimit: s.GetDBGameFree().BetLimit,
|
|
}
|
|
|
|
//自己的信息
|
|
if playerEx != nil {
|
|
pd := &protocol.FortuneOxPlayerData{
|
|
SnId: proto.Int32(playerEx.SnId),
|
|
Name: proto.String(playerEx.Name),
|
|
Head: proto.Int32(playerEx.Head),
|
|
Sex: proto.Int32(playerEx.Sex),
|
|
Coin: proto.Int64(playerEx.Coin),
|
|
Pos: proto.Int(playerEx.Pos),
|
|
Flag: proto.Int(playerEx.GetFlag()),
|
|
City: proto.String(playerEx.City),
|
|
HeadOutLine: proto.Int32(playerEx.HeadOutLine),
|
|
VIP: proto.Int32(playerEx.VIP),
|
|
}
|
|
pack.Player = pd
|
|
}
|
|
|
|
//get data
|
|
Response, err := slots.SlotsMgrSington.Enter(playerEx.SlotsSession, int64(s.GameId))
|
|
if err == nil {
|
|
data := assemble.DataToCli(Response).(assemble.TableInfo)
|
|
pi, _ := json.Marshal(data)
|
|
pack.PlayerInfo = string(pi)
|
|
if sceneEx.BetConfig == nil {
|
|
sceneEx.BetConfig = &data.BetConfig
|
|
}
|
|
} else {
|
|
logger.Logger.Error("slots enter err:", err)
|
|
}
|
|
proto.SetDefaults(pack)
|
|
return pack
|
|
}
|
|
func (this *ScenePolicyFortuneOx) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, params []int64) bool {
|
|
if s == nil || p == nil {
|
|
return false
|
|
}
|
|
logger.Logger.Trace("(this *ScenePolicyFortuneOx) OnPlayerOp, sceneId=", s.GetSceneId(), " player=", p.SnId, " opcode=", opcode, " params=", params)
|
|
if s.GetSceneState() != nil {
|
|
if s.GetSceneState().OnPlayerOp(s, p, opcode, params) {
|
|
p.SetLastOPTimer(time.Now())
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (this *ScenePolicyFortuneOx) OnPlayerEvent(s *base.Scene, p *base.Player, evtcode int, params []int64) {
|
|
if s == nil || p == nil {
|
|
return
|
|
}
|
|
logger.Logger.Trace("(this *ScenePolicyFortuneOx) OnPlayerEvent, sceneId=", s.GetSceneId(), " player=", p.SnId, " eventcode=", evtcode, " params=", params)
|
|
if s.GetSceneState() != nil {
|
|
s.GetSceneState().OnPlayerEvent(s, p, evtcode, params)
|
|
}
|
|
}
|
|
|
|
// 当前状态能否换桌
|
|
func (this *ScenePolicyFortuneOx) CanChangeCoinScene(s *base.Scene, p *base.Player) bool {
|
|
if s == nil || p == nil {
|
|
return false
|
|
}
|
|
if s.GetSceneState() != nil {
|
|
return s.GetSceneState().CanChangeCoinScene(s, p)
|
|
}
|
|
return false
|
|
}
|
|
|
|
// 状态基类
|
|
type SceneBaseStateFortuneOx struct {
|
|
}
|
|
|
|
func (this *SceneBaseStateFortuneOx) GetTimeout(s *base.Scene) int {
|
|
if sceneEx, ok := s.GetExtraData().(*FortuneOxSceneData); ok {
|
|
return int(time.Now().Sub(sceneEx.GetStateStartTime()) / time.Second)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
func (this *SceneBaseStateFortuneOx) CanChangeTo(s base.SceneState) bool {
|
|
return true
|
|
}
|
|
|
|
// 当前状态能否换桌
|
|
func (this *SceneBaseStateFortuneOx) CanChangeCoinScene(s *base.Scene, p *base.Player) bool {
|
|
return true
|
|
}
|
|
func (this *SceneBaseStateFortuneOx) OnEnter(s *base.Scene) {
|
|
if sceneEx, ok := s.GetExtraData().(*FortuneOxSceneData); ok {
|
|
sceneEx.SetStateStartTime(time.Now())
|
|
}
|
|
}
|
|
|
|
func (this *SceneBaseStateFortuneOx) OnLeave(s *base.Scene) {}
|
|
func (this *SceneBaseStateFortuneOx) OnTick(s *base.Scene) {
|
|
if time.Now().Sub(s.GameStartTime) > time.Second*3 {
|
|
if sceneEx, ok := s.ExtraData.(*FortuneOxSceneData); ok {
|
|
for _, p := range sceneEx.players {
|
|
if p.IsOnLine() {
|
|
p.leaveTime = 0
|
|
continue
|
|
}
|
|
p.leaveTime++
|
|
if p.leaveTime < 60*2 {
|
|
continue
|
|
}
|
|
//踢出玩家
|
|
sceneEx.PlayerLeave(p.Player, common.PlayerLeaveReason_LongTimeNoOp, true)
|
|
}
|
|
}
|
|
s.GameStartTime = time.Now()
|
|
}
|
|
}
|
|
func (this *SceneBaseStateFortuneOx) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, params []int64) bool {
|
|
return false
|
|
}
|
|
func (this *SceneBaseStateFortuneOx) OnPlayerEvent(s *base.Scene, p *base.Player, evtcode int, params []int64) {
|
|
}
|
|
|
|
// ////////////////////////////////////////////////////////////
|
|
// 开始状态
|
|
// ////////////////////////////////////////////////////////////
|
|
type SceneStateStartFortuneOx struct {
|
|
SceneBaseStateFortuneOx
|
|
}
|
|
|
|
func (this *SceneStateStartFortuneOx) GetState() int {
|
|
return fortuneox.FortuneOxStateStart
|
|
}
|
|
|
|
func (this *SceneStateStartFortuneOx) CanChangeTo(s base.SceneState) bool {
|
|
return false
|
|
}
|
|
|
|
// 当前状态能否换桌
|
|
func (this *SceneStateStartFortuneOx) CanChangeCoinScene(s *base.Scene, p *base.Player) bool {
|
|
if playerEx, ok := p.GetExtraData().(*FortuneOxPlayerData); ok {
|
|
if playerEx.isRespin {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (this *SceneStateStartFortuneOx) GetTimeout(s *base.Scene) int {
|
|
return 0
|
|
}
|
|
|
|
func (this *SceneStateStartFortuneOx) OnEnter(s *base.Scene) {
|
|
this.SceneBaseStateFortuneOx.OnEnter(s)
|
|
if sceneEx, ok := s.GetExtraData().(*FortuneOxSceneData); ok {
|
|
sceneEx.SetGameNowTime(time.Now())
|
|
}
|
|
}
|
|
|
|
// 状态离开时
|
|
func (this *SceneStateStartFortuneOx) OnLeave(s *base.Scene) {
|
|
this.SceneBaseStateFortuneOx.OnLeave(s)
|
|
logger.Logger.Tracef("(this *SceneStateStartFortuneOx) OnLeave, sceneid=%v", s.GetSceneId())
|
|
}
|
|
|
|
// 玩家操作
|
|
func (this *SceneStateStartFortuneOx) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, params []int64) bool {
|
|
logger.Logger.Tracef("(this *SceneStateStartFortuneOx) OnPlayerOp, sceneid=%v params=%v", s.GetSceneId(), params)
|
|
if this.SceneBaseStateFortuneOx.OnPlayerOp(s, p, opcode, params) {
|
|
return true
|
|
}
|
|
if sceneEx, ok := s.GetExtraData().(*FortuneOxSceneData); ok {
|
|
if playerEx, ok := p.GetExtraData().(*FortuneOxPlayerData); ok {
|
|
switch opcode {
|
|
case fortuneox.FortuneOxPlayerOpStart:
|
|
playerEx.Clear()
|
|
if len(params) < 3 {
|
|
pack := &protocol.SCFortuneOxBilled{
|
|
OpRetCode: proto.Int32(1),
|
|
}
|
|
proto.SetDefaults(pack)
|
|
logger.Logger.Trace("SCFortuneOxBilled", pack.String())
|
|
playerEx.SendToClient(int(protocol.FortuneOxPID_PACKET_FORTUNEOX_SCFORTUNEOXBILLED), pack)
|
|
return true
|
|
}
|
|
playerEx.BetSizeIndex = params[0]
|
|
playerEx.BetLevelIndex = params[1]
|
|
playerEx.BetLineIndex = params[2]
|
|
//playerEx.BetMode = params[3]
|
|
needCoin := sceneEx.BetConfig.BetSize[params[0]] * float64(sceneEx.BetConfig.BetLevel[params[1]]) *
|
|
float64(sceneEx.BetConfig.BetLines[params[2]])
|
|
if needCoin > float64(playerEx.Coin) {
|
|
pack := &protocol.SCFortuneOxBilled{
|
|
OpRetCode: proto.Int32(1),
|
|
}
|
|
proto.SetDefaults(pack)
|
|
logger.Logger.Trace("SCFortuneOxBilled:", pack.String())
|
|
playerEx.SendToClient(int(protocol.FortuneOxPID_PACKET_FORTUNEOX_SCFORTUNEOXBILLED), pack)
|
|
return true
|
|
}
|
|
|
|
//playerEx.SlotsSession.SetCoin(playerEx.Coin * fortuneox.NowByte)
|
|
//logger.Logger.Trace("=============init dif coin", playerEx.Coin-playerEx.SlotsSession.Coin()/fortuneox.NowByte)
|
|
|
|
//get data
|
|
Response, err := slots.SlotsMgrSington.Play(playerEx.SlotsSession, &base.SpinReq{
|
|
GameId: int64(sceneEx.GameId),
|
|
BetSizeIndex: playerEx.BetSizeIndex,
|
|
BetLevelIndex: playerEx.BetLevelIndex,
|
|
BetLineIndex: playerEx.BetLineIndex,
|
|
BetMode: playerEx.BetMode,
|
|
Ts: time.Now().Unix(),
|
|
})
|
|
var gameEndStr string
|
|
var data assemble.GameEnd
|
|
if err == nil {
|
|
s.SetGameNowTime(time.Now())
|
|
data = assemble.DataToCli(Response).(assemble.GameEnd)
|
|
var respinStatus int
|
|
if data.Results[0].ArrSpins[0].Special != nil {
|
|
sp, _ := json.Marshal(data.Results[0].ArrSpins[0].Special)
|
|
var spinLock SpinLock
|
|
json.Unmarshal(sp, &spinLock)
|
|
respinStatus = spinLock.ReSpinStatus
|
|
}
|
|
if respinStatus == 0 || respinStatus == 1 {
|
|
//第一次触发或者正常模式
|
|
//logger.Logger.Trace("=============addcoin1111 ", -data.TotalBet)
|
|
playerEx.AddCoin(int64(-data.TotalBet), common.GainWay_HundredSceneLost, base.SyncFlag_ToClient, "system", s.GetSceneName())
|
|
playerEx.totalBet = int64(data.TotalBet)
|
|
//logger.Logger.Trace("=======bet======dif++++ ", float64(playerEx.Coin)-data.BetAfterCoin)
|
|
}
|
|
var taxCoin float64
|
|
if data.RoundReward > 0 {
|
|
//税收比例
|
|
taxRate := sceneEx.GetDBGameFree().GetTaxRate()
|
|
if taxRate < 0 || taxRate > 10000 {
|
|
taxRate = 500
|
|
}
|
|
taxCoin = data.RoundReward * float64(taxRate) / 10000
|
|
data.RoundReward = data.RoundReward - taxCoin
|
|
playerEx.AddServiceFee(int64(taxCoin))
|
|
playerEx.taxCoin = int64(taxCoin)
|
|
playerEx.winCoin = int64(data.RoundReward)
|
|
}
|
|
pi, _ := json.Marshal(data)
|
|
gameEndStr = string(pi)
|
|
if respinStatus == 0 || respinStatus == 3 {
|
|
//logger.Logger.Trace("===win==========addcoin222 ", data.RoundReward)
|
|
playerEx.AddCoin(int64(data.RoundReward), common.GainWay_HundredSceneWin, 0, "system", s.GetSceneName())
|
|
//logger.Logger.Trace("=======win======dif++++ ", float64(playerEx.Coin)-data.FinalCoin)
|
|
//免费游戏结束或者正常模式
|
|
sceneEx.StaticsLaba(&base.StaticLabaParam{
|
|
SnId: playerEx.SnId,
|
|
Gain: int64(data.RoundReward - data.TotalBet),
|
|
GainTax: int64(taxCoin),
|
|
IsAddTimes: true,
|
|
})
|
|
}
|
|
if respinStatus == 0 || respinStatus == 3 {
|
|
playerEx.isRespin = false
|
|
} else {
|
|
playerEx.isRespin = true
|
|
}
|
|
} else {
|
|
logger.Logger.Error("slots Play err:", err)
|
|
}
|
|
|
|
playerEx.SlotsSession.SetCoin(int64(data.FinalCoin) * fortuneox.NowByte)
|
|
|
|
//logger.Logger.Trace("======end=======init dif coin", playerEx.Coin-playerEx.SlotsSession.Coin()/fortuneox.NowByte)
|
|
|
|
if playerEx.Coin != int64(data.FinalCoin) {
|
|
logger.Logger.Error("==========playerEx.Coin != data.FinalCoin==============", (float64(playerEx.Coin)-data.FinalCoin)/10000)
|
|
}
|
|
pack := &protocol.SCFortuneOxBilled{
|
|
OpRetCode: proto.Int32(0),
|
|
GameEndStr: proto.String(gameEndStr),
|
|
}
|
|
proto.SetDefaults(pack)
|
|
logger.Logger.Trace("SCFortuneOxBilled", pack.String())
|
|
playerEx.SendToClient(int(protocol.FortuneOxPID_PACKET_FORTUNEOX_SCFORTUNEOXBILLED), pack)
|
|
|
|
// 记录本次操作
|
|
FortuneOxAndSaveLog(sceneEx, playerEx, data)
|
|
}
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
// 玩家事件
|
|
func (this *SceneStateStartFortuneOx) OnPlayerEvent(s *base.Scene, p *base.Player, evtcode int, params []int64) {
|
|
logger.Logger.Trace("(this *SceneStateStartFortuneOx) OnPlayerEvent, sceneId=", s.GetSceneId(), " player=", p.SnId, " evtcode=", evtcode)
|
|
this.SceneBaseStateFortuneOx.OnPlayerEvent(s, p, evtcode, params)
|
|
}
|
|
|
|
func (this *SceneStateStartFortuneOx) OnTick(s *base.Scene) {
|
|
this.SceneBaseStateFortuneOx.OnTick(s)
|
|
}
|
|
|
|
// //////////////////////////////////////////////////////////////////////////////
|
|
func (this *ScenePolicyFortuneOx) RegisteSceneState(state base.SceneState) {
|
|
if state == nil {
|
|
return
|
|
}
|
|
stateid := state.GetState()
|
|
if stateid < 0 || stateid >= fortuneox.FortuneOxStateMax {
|
|
return
|
|
}
|
|
this.states[stateid] = state
|
|
}
|
|
|
|
func (this *ScenePolicyFortuneOx) GetSceneState(s *base.Scene, stateid int) base.SceneState {
|
|
if stateid >= 0 && stateid < fortuneox.FortuneOxStateMax {
|
|
return this.states[stateid]
|
|
}
|
|
return nil
|
|
}
|
|
func FortuneOxAndSaveLog(sceneEx *FortuneOxSceneData, playerEx *FortuneOxPlayerData, data assemble.GameEnd) {
|
|
if !playerEx.IsRob {
|
|
data.SnId = playerEx.SnId
|
|
var respinStatus int
|
|
if data.Results[0].ArrSpins[0].Special != nil {
|
|
sp, _ := json.Marshal(data.Results[0].ArrSpins[0].Special)
|
|
var spinLock SpinLock
|
|
json.Unmarshal(sp, &spinLock)
|
|
respinStatus = spinLock.ReSpinStatus
|
|
}
|
|
if respinStatus == 0 || respinStatus == 1 {
|
|
data.TotalBet = 0
|
|
}
|
|
|
|
info, err := model.MarshalGameNoteByROLL(data)
|
|
if err == nil {
|
|
logid, _ := model.AutoIncGameLogId()
|
|
playerEx.currentLogId = logid
|
|
sceneEx.SaveGameDetailedLog(&base.SaveGameDetailedParam{
|
|
LogId: logid,
|
|
Detail: info,
|
|
GameTime: 2,
|
|
})
|
|
var totalin, totalout int64
|
|
if respinStatus == 0 || respinStatus == 1 {
|
|
totalin = playerEx.totalBet
|
|
}
|
|
if respinStatus == 0 || respinStatus == 3 {
|
|
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
|
}
|
|
sceneEx.SaveGamePlayerListLog(&base.SaveGamePlayerListLogParam{
|
|
LogId: logid,
|
|
Platform: playerEx.Platform,
|
|
Snid: playerEx.SnId,
|
|
PlayerName: playerEx.Name,
|
|
Channel: playerEx.Channel,
|
|
ChannelId: playerEx.ChannelId,
|
|
TotalIn: totalin,
|
|
TotalOut: totalout,
|
|
TaxCoin: playerEx.taxCoin,
|
|
BetAmount: totalin,
|
|
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
|
|
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
|
|
IsFree: totalin == 0,
|
|
GameTime: 2,
|
|
})
|
|
}
|
|
}
|
|
|
|
//统计输下注金币数
|
|
if !sceneEx.Testing && !playerEx.IsRob {
|
|
playerBet := &server.PlayerData{
|
|
SnId: proto.Int32(playerEx.SnId),
|
|
Bet: proto.Int64(playerEx.CurrentBet),
|
|
Gain: proto.Int64(int64(data.RoundReward) + playerEx.taxCoin),
|
|
Tax: proto.Int64(playerEx.taxCoin),
|
|
Coin: proto.Int64(playerEx.GetCoin()),
|
|
GameCoinTs: proto.Int64(playerEx.GameCoinTs),
|
|
}
|
|
gwPlayerBet := &server.GWPlayerData{
|
|
SceneId: sceneEx.SceneId,
|
|
GameFreeId: proto.Int32(sceneEx.GetDBGameFree().GetId()),
|
|
}
|
|
gwPlayerBet.Datas = append(gwPlayerBet.Datas, playerBet)
|
|
sceneEx.SyncPlayerDatas(&base.PlayerDataParam{
|
|
HasRobotGaming: false,
|
|
Data: gwPlayerBet,
|
|
})
|
|
}
|
|
|
|
playerEx.taxCoin = 0
|
|
playerEx.winCoin = 0
|
|
|
|
if sceneEx.CheckNeedDestroy() && data.Results[0].FreeNum <= 0 {
|
|
sceneEx.SceneDestroy(true)
|
|
}
|
|
}
|
|
func init() {
|
|
//主状态
|
|
ScenePolicyFortuneOxSington.RegisteSceneState(&SceneStateStartFortuneOx{})
|
|
core.RegisteHook(core.HOOK_BEFORE_START, func() error {
|
|
base.RegisteScenePolicy(common.GameId_FortuneOx, fortuneox.RoomMode_Classic, ScenePolicyFortuneOxSington)
|
|
return nil
|
|
})
|
|
}
|