add slots

This commit is contained in:
tomas 2024-09-09 10:24:59 +08:00
parent da9efde313
commit e61cc19bce
10 changed files with 49 additions and 81 deletions

View File

@ -17,6 +17,7 @@ type FortuneDragonPlayerData struct {
} }
func (p *FortuneDragonPlayerData) init() { func (p *FortuneDragonPlayerData) init() {
p.SlotsSession = base.NewSession(uint64(p.SnId), p.Coin)
} }
func (p *FortuneDragonPlayerData) Clear() { func (p *FortuneDragonPlayerData) Clear() {

View File

@ -79,14 +79,19 @@ func (this *ScenePolicyFortuneDragon) OnPlayerEnter(s *base.Scene, p *base.Playe
if sceneEx, ok := s.GetExtraData().(*FortuneDragonSceneData); ok { if sceneEx, ok := s.GetExtraData().(*FortuneDragonSceneData); ok {
playerEx := &FortuneDragonPlayerData{Player: p} playerEx := &FortuneDragonPlayerData{Player: p}
playerEx.init()
d := p.GameData[fortunedragon.GameDataKey] d := p.GameData[fortunedragon.GameDataKey]
if d != nil { if d != nil {
m := map[string]string{} m := make(map[string]string)
json.Unmarshal(d.Data.([]byte), &m) json.Unmarshal(d.Data.([]byte), &m)
playerEx.PullPlayer(m) playerEx.PullPlayer(m)
} else {
m := make(map[string]string)
//json.Unmarshal(d.Data.([]byte), &m)
playerEx.PullPlayer(m)
} }
playerEx.init()
playerEx.Clear() playerEx.Clear()
sceneEx.players[p.SnId] = playerEx sceneEx.players[p.SnId] = playerEx
@ -203,10 +208,10 @@ func FortuneDragonCreateRoomInfoPacket(s *base.Scene, sceneEx *FortuneDragonScen
VIP: proto.Int32(playerEx.VIP), VIP: proto.Int32(playerEx.VIP),
} }
pack.Player = pd pack.Player = pd
playerEx.SlotsSession = base.NewSession(uint64(playerEx.SnId), playerEx.Coin)
} }
//get data //get data
Response, err := slots.SlotsMgrSington.Enter(playerEx.SlotsSession, 0) Response, err := slots.SlotsMgrSington.Enter(playerEx.SlotsSession, int64(s.GameId))
if err == nil { if err == nil {
data := assemble.DataToCli(Response).(assemble.TableInfo) data := assemble.DataToCli(Response).(assemble.TableInfo)
pi, _ := json.Marshal(data) pi, _ := json.Marshal(data)

View File

@ -174,9 +174,9 @@ func (f *Formatter) FormatSuper(ctx *shared.LogContext) *Super {
SessionBranch: ctx.Srv.GetSessionBranch(), SessionBranch: ctx.Srv.GetSessionBranch(),
Cluster: ctx.Srv.GetCluster(), Cluster: ctx.Srv.GetCluster(),
// Cli //// Cli
CliPlatform: ctx.Cli.GetThirdName(), //CliPlatform: ctx.Cli.GetThirdName(),
CliLanguage: ctx.Cli.GetLanguage(), //CliLanguage: ctx.Cli.GetLanguage(),
// User // User
Nickname: ctx.User.GetNickname(), Nickname: ctx.User.GetNickname(),
@ -230,8 +230,8 @@ func (f *Formatter) FormatUserProperties(ctx *shared.LogContext, body interface{
func (f *Formatter) formatUserBase(ctx *shared.LogContext) *UserBase { func (f *Formatter) formatUserBase(ctx *shared.LogContext) *UserBase {
return &UserBase{ return &UserBase{
// Cli // Cli
CliPlatform: ctx.Cli.GetThirdName(), //CliPlatform: ctx.Cli.GetThirdName(),
CliLanguage: ctx.Cli.GetLanguage(), //CliLanguage: ctx.Cli.GetLanguage(),
// User // User
Nickname: ctx.User.GetNickname(), Nickname: ctx.User.GetNickname(),

View File

@ -6,6 +6,7 @@ import (
"github.com/gofrs/uuid" "github.com/gofrs/uuid"
"github.com/gogo/protobuf/codec" "github.com/gogo/protobuf/codec"
"github.com/tomas-qstarrs/boost/config" "github.com/tomas-qstarrs/boost/config"
"github.com/tomas-qstarrs/boost/dogfish"
"github.com/tomas-qstarrs/boost/httpx" "github.com/tomas-qstarrs/boost/httpx"
"github.com/tomas-qstarrs/boost/logger" "github.com/tomas-qstarrs/boost/logger"
"github.com/tomas-qstarrs/boost/regexp" "github.com/tomas-qstarrs/boost/regexp"
@ -103,7 +104,7 @@ func init() {
WorkingDirectory = getWorkingDirectory() WorkingDirectory = getWorkingDirectory()
ProjectDirectory = getProjectDirectory() ProjectDirectory = getProjectDirectory()
ConfigDirectory = getConfigDirectory() ConfigDirectory = getConfigDirectory()
//Timex = getTimex() Timex = getTimex()
//Logger = getLogger() //Logger = getLogger()
ProcessTime = getProcessTime() ProcessTime = getProcessTime()
HTTPClient = getHTTPClient() HTTPClient = getHTTPClient()
@ -206,11 +207,12 @@ func getConfigDirectory() string {
return filepath.Join(ProjectDirectory, "resource/config") return filepath.Join(ProjectDirectory, "resource/config")
} }
//func getTimex() *timex.Timex { func getTimex() *timex.Timex {
// tm := timex.Init(config.JSON("timex")) timexJson := "{\"timex\":{\"zone\":\"UTC+8\",\"delta\":3600,\"fake\":0}}"
// dogfish.LocateAt(timex.TimeLocation()) tm := timex.Init(timexJson)
// return tm dogfish.LocateAt(timex.TimeLocation())
//} return tm
}
func getHTTPClient() *httpx.Client { func getHTTPClient() *httpx.Client {
c := httpx.NewClient(httpx.ClientConfig{ c := httpx.NewClient(httpx.ClientConfig{

View File

@ -40,12 +40,12 @@ var GameMapTheme = map[string]uint{
CashMania: GameId_Cash_Mania, CashMania: GameId_Cash_Mania,
Test: GameId_Test, Test: GameId_Test,
} }
var GameKeyMap = map[uint]int64{ var GameKeyMap = map[int64]uint{
GameId_Min: 0, 0: GameId_Min,
GameId_Tiger: 308, 308: GameId_Tiger,
GameId_Dragon: 309, 309: GameId_Dragon,
GameId_Rabbit: 310, 310: GameId_Rabbit,
GameId_OX: 311, 311: GameId_OX,
GameId_Mouse: 312, 312: GameId_Mouse,
GameId_Max: 999, 999: GameId_Max,
} }

View File

@ -1,16 +0,0 @@
package player
func (p *Player) AddLastBetId(theme string, betId string) {
var oc = map[string]string{}
p.Cli.LastBetId.Get(&oc)
if oc == nil {
oc = map[string]string{}
}
oc[theme] = betId
p.Cli.LastBetId.Set(oc)
}
func (p *Player) GetLastBetId(theme string) string {
var oc = map[string]string{}
p.Cli.LastBetId.Get(&oc)
return oc[theme]
}

View File

@ -107,14 +107,14 @@ func (p *Player) handleLogin(s *base.SlotsSession) {
} }
func (p *Player) updateCli(s *base.SlotsSession) { func (p *Player) updateCli(s *base.SlotsSession) {
sessionContext := s.Value(key.SessionContext).(*shared.SessionContext) //sessionContext := s.Value(key.SessionContext).(*shared.SessionContext)
// Cli // Cli
p.Cli.Ops.Set(sessionContext.Ops) //p.Cli.Ops.Set(sessionContext.Ops)
p.Cli.IsSimulator.Set(sessionContext.IsSimulator) //p.Cli.IsSimulator.Set(sessionContext.IsSimulator)
p.Cli.IsSimulator.Set(sessionContext.IsSimulator) //p.Cli.IsSimulator.Set(sessionContext.IsSimulator)
p.Cli.Ip.Set(sessionContext.Ip) //p.Cli.Ip.Set(sessionContext.Ip)
//
p.Cli.PlayerName.Set(sessionContext.PlayerName) //p.Cli.PlayerName.Set(sessionContext.PlayerName)
} }
func (p *Player) updateChar(s *base.SlotsSession) { func (p *Player) updateChar(s *base.SlotsSession) {

View File

@ -7,14 +7,7 @@ import (
type ( type (
Player struct { Player struct {
Root Root
UID Int64 UID Int64
Cli struct {
Ops String
IsSimulator Bool
Ip String
PlayerName String
LastBetId JSON
}
Char struct { Char struct {
GroupBatch Int64 // 批次AB测试的批次 GroupBatch Int64 // 批次AB测试的批次
Group String // 组(AB测试的组) Group String // 组(AB测试的组)

View File

@ -197,30 +197,8 @@ func (x *Identifier) GetSessionID() int64 {
} }
type Cli struct { type Cli struct {
ThirdName string
Language string
IsSimulator bool IsSimulator bool
Token string
Ip string
Currency string
TokenThird string
Ops string //player
PlayerName string PlayerName string
Lobby string
Game string
}
func (x *Cli) GetThirdName() string {
if x != nil {
return x.ThirdName
}
return ""
}
func (x *Cli) GetLanguage() string {
if x != nil {
return x.Language
}
return ""
} }
type User struct { type User struct {
@ -2032,7 +2010,6 @@ func (x *LiteNodeTree) GetFeatures() []*LiteFeature {
type SessionContext struct { type SessionContext struct {
UID int64 UID int64
*Cli
} }
func (x *SessionContext) GetUID() int64 { func (x *SessionContext) GetUID() int64 {

View File

@ -13,8 +13,8 @@ import (
) )
func (sm *SlotsMgr) Enter(s *base.SlotsSession, gameId int64) (*cli.SlotsEnterResponse, error) { func (sm *SlotsMgr) Enter(s *base.SlotsSession, gameId int64) (*cli.SlotsEnterResponse, error) {
if gid, ok := key.GameKeyMap[uint(gameId)]; ok { if gid, ok := key.GameKeyMap[gameId]; ok {
gameId = gid gameId = int64(gid)
} else { } else {
logger.Logger.Error("[slotsMgr.Enter] gameId not exist") logger.Logger.Error("[slotsMgr.Enter] gameId not exist")
return nil, errors.New("gameId not exist") return nil, errors.New("gameId not exist")
@ -53,8 +53,8 @@ func (sm *SlotsMgr) Enter(s *base.SlotsSession, gameId int64) (*cli.SlotsEnterRe
} }
func (sm *SlotsMgr) Play(s *base.SlotsSession, req *base.SpinReq) (*cli.SlotsPlayResponse, error) { func (sm *SlotsMgr) Play(s *base.SlotsSession, req *base.SpinReq) (*cli.SlotsPlayResponse, error) {
if gameId, ok := key.GameKeyMap[uint(req.GameId)]; ok { if gameId, ok := key.GameKeyMap[req.GameId]; ok {
req.GameId = gameId req.GameId = int64(gameId)
} else { } else {
logger.Logger.Error("[slotsMgr.play] gameId not exist") logger.Logger.Error("[slotsMgr.play] gameId not exist")
return nil, errors.New("gameId not exist") return nil, errors.New("gameId not exist")
@ -130,6 +130,12 @@ func (*SlotsMgr) PushPlayer(s *base.SlotsSession) map[string]string {
func (*SlotsMgr) PullPlayer(s *base.SlotsSession, data map[string]string) { func (*SlotsMgr) PullPlayer(s *base.SlotsSession, data map[string]string) {
player.PullPlayer(s, data) player.PullPlayer(s, data)
} }
func (*SlotsMgr) SetSessionContext(s *base.SlotsSession) {
sessionContext := &shared.SessionContext{
UID: int64(s.UID()),
}
s.Set(key.SessionContext, sessionContext)
}
func (*SlotsMgr) Leave(s *base.SlotsSession) (*cli.SlotsLeaveResponse, error) { func (*SlotsMgr) Leave(s *base.SlotsSession) (*cli.SlotsLeaveResponse, error) {
m := machine.NewMachine(s, "s.Theme", DataSet(s).Shell, false) m := machine.NewMachine(s, "s.Theme", DataSet(s).Shell, false)