add suarrush test02
This commit is contained in:
parent
2035a5138d
commit
4adf1f90b1
|
@ -8,41 +8,21 @@ const (
|
|||
FortuneMouse = "FortuneMouse"
|
||||
CashMania = "CashMania"
|
||||
GatesOfOlympus = "GatesOfOlympus"
|
||||
FortuneSnake = "FortuneSnake"
|
||||
GaneshaGold = "GaneshaGold"
|
||||
SugarRush = "SugarRush"
|
||||
Test = "Test"
|
||||
)
|
||||
const (
|
||||
GameId_Min uint = iota
|
||||
GameId_Tiger
|
||||
GameId_Dragon
|
||||
GameId_Rabbit
|
||||
GameId_OX
|
||||
GameId_Mouse
|
||||
GameId_Cash_Mania
|
||||
GameId_GatesOfOlympus
|
||||
|
||||
GameId_Max
|
||||
GameId_Test = 999
|
||||
)
|
||||
|
||||
var GameMap = map[uint]string{
|
||||
GameId_Tiger: FortuneTiger,
|
||||
GameId_Dragon: FortuneDragon,
|
||||
GameId_Rabbit: FortuneRabbit,
|
||||
GameId_OX: FortuneOx,
|
||||
GameId_Mouse: FortuneMouse,
|
||||
GameId_Cash_Mania: CashMania,
|
||||
GameId_GatesOfOlympus: GatesOfOlympus,
|
||||
GameId_Test: Test,
|
||||
}
|
||||
var GameKeyMap = map[int64]uint{
|
||||
0: GameId_Min,
|
||||
308: GameId_Tiger,
|
||||
309: GameId_Dragon,
|
||||
310: GameId_Rabbit,
|
||||
311: GameId_OX,
|
||||
312: GameId_Mouse,
|
||||
313: GameId_Cash_Mania,
|
||||
314: GameId_GatesOfOlympus,
|
||||
999: GameId_Max,
|
||||
var GameKeyMap = map[int64]string{
|
||||
308: FortuneTiger,
|
||||
309: FortuneDragon,
|
||||
310: FortuneRabbit,
|
||||
311: FortuneOx,
|
||||
312: FortuneMouse,
|
||||
313: CashMania,
|
||||
314: GatesOfOlympus,
|
||||
315: FortuneSnake,
|
||||
316: GaneshaGold,
|
||||
317: SugarRush,
|
||||
}
|
||||
|
|
|
@ -13,8 +13,9 @@ import (
|
|||
)
|
||||
|
||||
func (sm *SlotsMgr) Enter(s *base.SlotsSession, gameId int64) (*cli.SlotsEnterResponse, error) {
|
||||
if gid, ok := key.GameKeyMap[gameId]; ok {
|
||||
gameId = int64(gid)
|
||||
var theme string
|
||||
if tm, ok := key.GameKeyMap[gameId]; ok {
|
||||
theme = tm
|
||||
} else {
|
||||
logger.Logger.Error("[slotsMgr.Enter] gameId not exist")
|
||||
return nil, errors.New("gameId not exist")
|
||||
|
@ -24,8 +25,6 @@ func (sm *SlotsMgr) Enter(s *base.SlotsSession, gameId int64) (*cli.SlotsEnterRe
|
|||
|
||||
player.Init(s)
|
||||
|
||||
theme := key.GameMap[uint(gameId)]
|
||||
|
||||
m := machine.NewMachine(s, theme, DataSet(s).Shell, false)
|
||||
if m == nil {
|
||||
logger.Logger.Error("[slotsMgr.enter] module is nil")
|
||||
|
@ -56,8 +55,9 @@ func (sm *SlotsMgr) Enter(s *base.SlotsSession, gameId int64) (*cli.SlotsEnterRe
|
|||
}
|
||||
|
||||
func (sm *SlotsMgr) Play(s *base.SlotsSession, req *base.SpinReq) (*cli.SlotsPlayResponse, error) {
|
||||
if gameId, ok := key.GameKeyMap[req.GameId]; ok {
|
||||
req.GameId = int64(gameId)
|
||||
var theme string
|
||||
if tm, ok := key.GameKeyMap[req.GameId]; ok {
|
||||
theme = tm
|
||||
} else {
|
||||
logger.Logger.Error("[slotsMgr.play] gameId not exist")
|
||||
return nil, errors.New("gameId not exist")
|
||||
|
@ -80,7 +80,6 @@ func (sm *SlotsMgr) Play(s *base.SlotsSession, req *base.SpinReq) (*cli.SlotsPla
|
|||
|
||||
player.Get(s).Book.Coin.Set(s.Coin())
|
||||
|
||||
theme := key.GameMap[uint(req.GameId)]
|
||||
m := machine.NewMachine(s, theme, DataSet(s).Shell, false)
|
||||
if m == nil {
|
||||
logger.Logger.Error("[slotsMgr.play] module is nil")
|
||||
|
@ -162,3 +161,9 @@ func (*SlotsMgr) Leave(s *base.SlotsSession) (*cli.SlotsLeaveResponse, error) {
|
|||
}
|
||||
return Response, nil
|
||||
}
|
||||
|
||||
// pp
|
||||
func (sm *SlotsMgr) PPGetBetIndex(s *base.SlotsSession, theme string, val float64) []int64 {
|
||||
m := machine.NewMachine(s, theme, DataSet(s).Shell, false)
|
||||
return m.GetBetIndexByVal(val)
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ func (m *Machine) SyncLiteClose() *shared.LiteNodeTree {
|
|||
// PlayLiteClose serialize the machine and transform into lite node tree for play
|
||||
func (m *Machine) PlayLiteClose() *shared.LiteNodeTree {
|
||||
m.Serialize()
|
||||
m.Session.Remove(key.SessionMachine)
|
||||
//m.Session.Remove(key.SessionMachine)
|
||||
|
||||
liteNodeTree := &shared.LiteNodeTree{
|
||||
Step: m.NodeTree.Step,
|
||||
|
|
|
@ -12,10 +12,10 @@ type SugarRushPlayerData struct {
|
|||
leaveTime int32 //离开时间
|
||||
SlotsSession *base.SlotsSession
|
||||
|
||||
BetSizeIndex int64 `json:"bsi"` //选中的单注下标
|
||||
BetLevelIndex int64 `json:"bli"` //选中的等级下标
|
||||
BetLineIndex int64 `json:"bii"` //选中的线数下标
|
||||
BetMode int64 `json:"bm,optional"` //0.常规 1.%125 2.购买
|
||||
//BetSizeIndex int64 `json:"bsi"` //选中的单注下标
|
||||
//BetLevelIndex int64 `json:"bli"` //选中的等级下标
|
||||
//BetLineIndex int64 `json:"bii"` //选中的线数下标
|
||||
BetMode int64 `json:"bm,optional"` //0.常规 1.%125 2.购买
|
||||
|
||||
taxCoin int64
|
||||
winCoin int64
|
||||
|
|
|
@ -2,13 +2,11 @@ package sugarrush
|
|||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/assemble"
|
||||
)
|
||||
|
||||
type SugarRushSceneData struct {
|
||||
*base.Scene //场景
|
||||
players map[int32]*SugarRushPlayerData //玩家信息
|
||||
BetConfig *assemble.BetConfig
|
||||
}
|
||||
|
||||
func NewSugarRushSceneData(s *base.Scene) *SugarRushSceneData {
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/gamerule/sugarrush"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/assemble"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/types/cli"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/proto"
|
||||
"mongo.games.com/game/protocol/server"
|
||||
|
@ -214,12 +214,8 @@ func SugarRushCreateRoomInfoPacket(s *base.Scene, sceneEx *SugarRushSceneData, p
|
|||
//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)
|
||||
pi, _ := json.Marshal(Response)
|
||||
pack.PlayerInfo = string(pi)
|
||||
if sceneEx.BetConfig == nil {
|
||||
sceneEx.BetConfig = &data.BetConfig
|
||||
}
|
||||
} else {
|
||||
logger.Logger.Error("slots enter err:", err)
|
||||
}
|
||||
|
@ -375,13 +371,10 @@ func (this *SceneStateStartSugarRush) OnPlayerOp(s *base.Scene, p *base.Player,
|
|||
playerEx.SendToClient(int(protocol.SugarRushPID_PACKET_SUGARRUSH_SCSUGARRUSHBILLED), 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]]) * float64(sceneEx.BetConfig.BaseBet[params[2]])
|
||||
if needCoin > float64(playerEx.Coin) && !playerEx.isFree {
|
||||
cval := params[0]
|
||||
playerEx.BetMode = params[1]
|
||||
needCoin := cval * 20
|
||||
if needCoin > playerEx.Coin && !playerEx.isFree {
|
||||
pack := &protocol.SCSugarRushBilled{
|
||||
OpRetCode: proto.Int32(1),
|
||||
}
|
||||
|
@ -394,73 +387,94 @@ func (this *SceneStateStartSugarRush) OnPlayerOp(s *base.Scene, p *base.Player,
|
|||
//playerEx.SlotsSession.SetCoin(playerEx.Coin * sugarrush.NowByte)
|
||||
//logger.Logger.Trace("=============init dif coin", playerEx.Coin-playerEx.SlotsSession.Coin()/sugarrush.NowByte)
|
||||
|
||||
index := slots.SlotsMgrSington.PPGetBetIndex(playerEx.SlotsSession, "SugarRush", float64(cval*20))
|
||||
if index == nil {
|
||||
pack := &protocol.SCSugarRushBilled{
|
||||
OpRetCode: proto.Int32(2),
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
logger.Logger.Trace("SCSugarRushBilled:", pack.String())
|
||||
playerEx.SendToClient(int(protocol.SugarRushPID_PACKET_SUGARRUSH_SCSUGARRUSHBILLED), pack)
|
||||
return true
|
||||
}
|
||||
//get data
|
||||
Response, err := slots.SlotsMgrSington.Play(playerEx.SlotsSession, &base.SpinReq{
|
||||
GameId: int64(sceneEx.GameId),
|
||||
BetSizeIndex: playerEx.BetSizeIndex,
|
||||
BetLevelIndex: playerEx.BetLevelIndex,
|
||||
BetLineIndex: playerEx.BetLineIndex,
|
||||
BetSizeIndex: index[0],
|
||||
BetLevelIndex: index[1],
|
||||
BetLineIndex: 0,
|
||||
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)
|
||||
|
||||
data.BetSizeIndex = playerEx.BetSizeIndex
|
||||
data.BetLevelIndex = playerEx.BetLevelIndex
|
||||
data.LinesIndex = playerEx.BetLineIndex
|
||||
//data.BaseBetIndex = 1
|
||||
|
||||
data.Results[0].BetMode = playerEx.BetMode
|
||||
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
|
||||
//logger.Logger.Trace("=====================AddCoin=====TotalBet===", -data.TotalBet)
|
||||
//第一次触发或者正常模式
|
||||
playerEx.AddCoin(int64(-data.TotalBet), common.GainWay_HundredSceneLost, base.SyncFlag_ToClient, "system", s.GetSceneName())
|
||||
playerEx.totalBet = int64(data.TotalBet)
|
||||
if err != nil {
|
||||
logger.Logger.Error("slots Play err:", err)
|
||||
pack := &protocol.SCSugarRushBilled{
|
||||
OpRetCode: proto.Int32(3),
|
||||
}
|
||||
var taxCoin float64
|
||||
if data.RoundReward > 0 {
|
||||
proto.SetDefaults(pack)
|
||||
logger.Logger.Trace("SCSugarRushBilled:", pack.String())
|
||||
playerEx.SendToClient(int(protocol.SugarRushPID_PACKET_SUGARRUSH_SCSUGARRUSHBILLED), pack)
|
||||
return true
|
||||
}
|
||||
var ActualWin = Response.ActualWin / sugarrush.NowByte
|
||||
s.SetGameNowTime(time.Now())
|
||||
midNodes := Response.NodeTree.Nodes[1]
|
||||
lastNodes := Response.NodeTree.Nodes[2]
|
||||
playerEx.isFree = false
|
||||
var needWinBilled = true
|
||||
|
||||
var totalIn, totalOut int64
|
||||
//下注
|
||||
if midNodes.Type == "BaseSpin" && lastNodes.Type == "FreeSpin" {
|
||||
playerEx.isFree = true
|
||||
needWinBilled = false
|
||||
if lastNodes.ProgressValue == 0 {
|
||||
//第一次触发
|
||||
playerEx.totalBet = Response.ActualBet / sugarrush.NowByte
|
||||
playerEx.AddCoin(-playerEx.totalBet, common.GainWay_HundredSceneLost, base.SyncFlag_ToClient, "system", s.GetSceneName())
|
||||
totalIn = playerEx.totalBet
|
||||
}
|
||||
if lastNodes.ProgressValue == lastNodes.ProgressMax {
|
||||
needWinBilled = true
|
||||
}
|
||||
} else {
|
||||
//正常模式
|
||||
playerEx.totalBet = Response.ActualBet / sugarrush.NowByte
|
||||
totalIn = playerEx.totalBet
|
||||
playerEx.AddCoin(-playerEx.totalBet, common.GainWay_HundredSceneLost, base.SyncFlag_ToClient, "system", s.GetSceneName())
|
||||
}
|
||||
|
||||
if needWinBilled {
|
||||
var taxCoin int64
|
||||
if ActualWin > 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)
|
||||
taxCoin = ActualWin * int64(taxRate) / 10000
|
||||
playerEx.AddServiceFee(taxCoin)
|
||||
playerEx.taxCoin = taxCoin
|
||||
playerEx.winCoin = ActualWin - taxCoin
|
||||
ActualWin = playerEx.winCoin
|
||||
}
|
||||
pi, _ := json.Marshal(data)
|
||||
gameEndStr = string(pi)
|
||||
|
||||
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
|
||||
//logger.Logger.Trace("=====================AddCoin=====RoundReward===", data.RoundReward)
|
||||
playerEx.AddCoin(int64(data.RoundReward), common.GainWay_HundredSceneWin, 0, "system", s.GetSceneName())
|
||||
//免费游戏结束或者正常模式
|
||||
sceneEx.StaticsLaba(&base.StaticLabaParam{
|
||||
SnId: playerEx.SnId,
|
||||
Gain: int64(data.RoundReward - data.TotalBet),
|
||||
GainTax: int64(taxCoin),
|
||||
IsAddTimes: true,
|
||||
})
|
||||
}
|
||||
if data.Results[0].FreeNum > 0 {
|
||||
playerEx.isFree = true
|
||||
} else {
|
||||
playerEx.isFree = false
|
||||
}
|
||||
} else {
|
||||
logger.Logger.Error("slots Play err:", err)
|
||||
totalOut = ActualWin
|
||||
|
||||
playerEx.AddCoin(ActualWin, common.GainWay_HundredSceneWin, 0, "system", s.GetSceneName())
|
||||
//免费游戏结束或者正常模式
|
||||
sceneEx.StaticsLaba(&base.StaticLabaParam{
|
||||
SnId: playerEx.SnId,
|
||||
Gain: ActualWin - playerEx.totalBet,
|
||||
GainTax: playerEx.taxCoin,
|
||||
IsAddTimes: true,
|
||||
})
|
||||
}
|
||||
|
||||
playerEx.SlotsSession.SetCoin(int64(data.FinalCoin) * sugarrush.NowByte)
|
||||
//logger.Logger.Trace("=====================end===== playerEx.Coin===", playerEx.Coin)
|
||||
//logger.Logger.Trace("=====================end===== data.FinalCoin===", data.FinalCoin)
|
||||
playerEx.SlotsSession.SetCoin(Response.Coin)
|
||||
|
||||
pi, _ := json.Marshal(Response)
|
||||
gameEndStr := string(pi)
|
||||
pack := &protocol.SCSugarRushBilled{
|
||||
OpRetCode: proto.Int32(0),
|
||||
GameEndStr: proto.String(gameEndStr),
|
||||
|
@ -469,12 +483,12 @@ func (this *SceneStateStartSugarRush) OnPlayerOp(s *base.Scene, p *base.Player,
|
|||
logger.Logger.Trace("SCSugarRushBilled", pack.String())
|
||||
playerEx.SendToClient(int(protocol.SugarRushPID_PACKET_SUGARRUSH_SCSUGARRUSHBILLED), pack)
|
||||
|
||||
if playerEx.Coin != int64(data.FinalCoin) {
|
||||
logger.Logger.Error("==========playerEx.Coin != Response.Coin==============", playerEx.Coin, data.FinalCoin)
|
||||
if playerEx.Coin != ActualWin {
|
||||
logger.Logger.Error("==========playerEx.Coin != Response.Coin==============", playerEx.Coin, ActualWin)
|
||||
}
|
||||
|
||||
// 记录本次操作
|
||||
SugarRushAndSaveLog(sceneEx, playerEx, data)
|
||||
SugarRushAndSaveLog(sceneEx, playerEx, Response, totalIn, totalOut)
|
||||
case 1000:
|
||||
playerEx.Save(0)
|
||||
}
|
||||
|
@ -511,23 +525,13 @@ func (this *ScenePolicySugarRush) GetSceneState(s *base.Scene, stateid int) base
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func SugarRushAndSaveLog(sceneEx *SugarRushSceneData, playerEx *SugarRushPlayerData, data assemble.GameEnd) {
|
||||
func SugarRushAndSaveLog(sceneEx *SugarRushSceneData, playerEx *SugarRushPlayerData, Response *cli.SlotsPlayResponse,
|
||||
totalIn, totalOut int64) {
|
||||
if !playerEx.IsRob {
|
||||
data.SnId = playerEx.SnId
|
||||
if data.Results[0].FreeStatus != 1 && data.Results[0].FreeNumMax != 0 {
|
||||
data.TotalBet = 0
|
||||
}
|
||||
info, err := model.MarshalGameNoteByROLL(data)
|
||||
info, err := model.MarshalGameNoteByROLL(Response)
|
||||
if err == nil {
|
||||
logid, _ := model.AutoIncGameLogId()
|
||||
playerEx.currentLogId = logid
|
||||
var totalin, totalout int64
|
||||
if data.Results[0].FreeStatus == 1 || data.Results[0].FreeNumMax == 0 {
|
||||
totalin = playerEx.totalBet
|
||||
}
|
||||
if data.Results[0].FreeStatus == 3 || data.Results[0].FreeNumMax == 0 {
|
||||
totalout = int64(data.RoundReward) + playerEx.taxCoin
|
||||
}
|
||||
playerEx.Cache(sceneEx.Scene, &base.SaveGameDetailedParam{
|
||||
LogId: logid,
|
||||
Detail: info,
|
||||
|
@ -536,11 +540,11 @@ func SugarRushAndSaveLog(sceneEx *SugarRushSceneData, playerEx *SugarRushPlayerD
|
|||
Platform: playerEx.Platform,
|
||||
Snid: playerEx.SnId,
|
||||
PlayerName: playerEx.Name,
|
||||
TotalIn: totalin,
|
||||
TotalOut: totalout,
|
||||
TotalIn: totalIn,
|
||||
TotalOut: totalOut,
|
||||
TaxCoin: playerEx.taxCoin,
|
||||
BetAmount: totalin,
|
||||
WinAmountNoAnyTax: totalout - totalin - playerEx.taxCoin,
|
||||
BetAmount: totalIn,
|
||||
WinAmountNoAnyTax: totalOut - totalIn - playerEx.taxCoin,
|
||||
IsFirstGame: sceneEx.IsPlayerFirst(playerEx.Player),
|
||||
IsFree: playerEx.isFree,
|
||||
})
|
||||
|
@ -552,7 +556,7 @@ func SugarRushAndSaveLog(sceneEx *SugarRushSceneData, playerEx *SugarRushPlayerD
|
|||
playerBet := &server.PlayerData{
|
||||
SnId: proto.Int32(playerEx.SnId),
|
||||
Bet: proto.Int64(playerEx.CurrentBet),
|
||||
Gain: proto.Int64(int64(data.RoundReward) + playerEx.taxCoin),
|
||||
Gain: proto.Int64(Response.ActualWin/sugarrush.NowByte + playerEx.taxCoin),
|
||||
Tax: proto.Int64(playerEx.taxCoin),
|
||||
Coin: proto.Int64(playerEx.GetCoin()),
|
||||
GameCoinTs: proto.Int64(playerEx.GameCoinTs),
|
||||
|
@ -571,7 +575,7 @@ func SugarRushAndSaveLog(sceneEx *SugarRushSceneData, playerEx *SugarRushPlayerD
|
|||
playerEx.taxCoin = 0
|
||||
playerEx.winCoin = 0
|
||||
|
||||
if sceneEx.CheckNeedDestroy() && data.Results[0].FreeNum <= 0 {
|
||||
if sceneEx.CheckNeedDestroy() && !playerEx.isFree {
|
||||
sceneEx.SceneDestroy(true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ message SCSugarRushRoomInfo {
|
|||
//PACKET_SUGARRUSH_CSSUGARRUSHOP
|
||||
message CSSugarRushOp {
|
||||
int32 OpCode = 1; //操作码 0.spin
|
||||
repeated int64 Params = 2; //操作参数 下注索引编号
|
||||
repeated int64 Params = 2; //操作参数 cval
|
||||
}
|
||||
//玩家操作返回
|
||||
//PACKET_SUGARRUSH_SCSUGARRUSHOP
|
||||
|
|
Loading…
Reference in New Issue