add slots
This commit is contained in:
parent
da9efde313
commit
e61cc19bce
|
|
@ -17,6 +17,7 @@ type FortuneDragonPlayerData struct {
|
|||
}
|
||||
|
||||
func (p *FortuneDragonPlayerData) init() {
|
||||
p.SlotsSession = base.NewSession(uint64(p.SnId), p.Coin)
|
||||
}
|
||||
func (p *FortuneDragonPlayerData) Clear() {
|
||||
|
||||
|
|
|
|||
|
|
@ -79,14 +79,19 @@ func (this *ScenePolicyFortuneDragon) OnPlayerEnter(s *base.Scene, p *base.Playe
|
|||
if sceneEx, ok := s.GetExtraData().(*FortuneDragonSceneData); ok {
|
||||
playerEx := &FortuneDragonPlayerData{Player: p}
|
||||
|
||||
playerEx.init()
|
||||
|
||||
d := p.GameData[fortunedragon.GameDataKey]
|
||||
if d != nil {
|
||||
m := map[string]string{}
|
||||
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.init()
|
||||
playerEx.Clear()
|
||||
|
||||
sceneEx.players[p.SnId] = playerEx
|
||||
|
|
@ -203,10 +208,10 @@ func FortuneDragonCreateRoomInfoPacket(s *base.Scene, sceneEx *FortuneDragonScen
|
|||
VIP: proto.Int32(playerEx.VIP),
|
||||
}
|
||||
pack.Player = pd
|
||||
playerEx.SlotsSession = base.NewSession(uint64(playerEx.SnId), playerEx.Coin)
|
||||
}
|
||||
|
||||
//get data
|
||||
Response, err := slots.SlotsMgrSington.Enter(playerEx.SlotsSession, 0)
|
||||
Response, err := slots.SlotsMgrSington.Enter(playerEx.SlotsSession, int64(s.GameId))
|
||||
if err == nil {
|
||||
data := assemble.DataToCli(Response).(assemble.TableInfo)
|
||||
pi, _ := json.Marshal(data)
|
||||
|
|
|
|||
|
|
@ -174,9 +174,9 @@ func (f *Formatter) FormatSuper(ctx *shared.LogContext) *Super {
|
|||
SessionBranch: ctx.Srv.GetSessionBranch(),
|
||||
Cluster: ctx.Srv.GetCluster(),
|
||||
|
||||
// Cli
|
||||
CliPlatform: ctx.Cli.GetThirdName(),
|
||||
CliLanguage: ctx.Cli.GetLanguage(),
|
||||
//// Cli
|
||||
//CliPlatform: ctx.Cli.GetThirdName(),
|
||||
//CliLanguage: ctx.Cli.GetLanguage(),
|
||||
|
||||
// User
|
||||
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 {
|
||||
return &UserBase{
|
||||
// Cli
|
||||
CliPlatform: ctx.Cli.GetThirdName(),
|
||||
CliLanguage: ctx.Cli.GetLanguage(),
|
||||
//CliPlatform: ctx.Cli.GetThirdName(),
|
||||
//CliLanguage: ctx.Cli.GetLanguage(),
|
||||
|
||||
// User
|
||||
Nickname: ctx.User.GetNickname(),
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/gofrs/uuid"
|
||||
"github.com/gogo/protobuf/codec"
|
||||
"github.com/tomas-qstarrs/boost/config"
|
||||
"github.com/tomas-qstarrs/boost/dogfish"
|
||||
"github.com/tomas-qstarrs/boost/httpx"
|
||||
"github.com/tomas-qstarrs/boost/logger"
|
||||
"github.com/tomas-qstarrs/boost/regexp"
|
||||
|
|
@ -103,7 +104,7 @@ func init() {
|
|||
WorkingDirectory = getWorkingDirectory()
|
||||
ProjectDirectory = getProjectDirectory()
|
||||
ConfigDirectory = getConfigDirectory()
|
||||
//Timex = getTimex()
|
||||
Timex = getTimex()
|
||||
//Logger = getLogger()
|
||||
ProcessTime = getProcessTime()
|
||||
HTTPClient = getHTTPClient()
|
||||
|
|
@ -206,11 +207,12 @@ func getConfigDirectory() string {
|
|||
return filepath.Join(ProjectDirectory, "resource/config")
|
||||
}
|
||||
|
||||
//func getTimex() *timex.Timex {
|
||||
// tm := timex.Init(config.JSON("timex"))
|
||||
// dogfish.LocateAt(timex.TimeLocation())
|
||||
// return tm
|
||||
//}
|
||||
func getTimex() *timex.Timex {
|
||||
timexJson := "{\"timex\":{\"zone\":\"UTC+8\",\"delta\":3600,\"fake\":0}}"
|
||||
tm := timex.Init(timexJson)
|
||||
dogfish.LocateAt(timex.TimeLocation())
|
||||
return tm
|
||||
}
|
||||
|
||||
func getHTTPClient() *httpx.Client {
|
||||
c := httpx.NewClient(httpx.ClientConfig{
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ var GameMapTheme = map[string]uint{
|
|||
CashMania: GameId_Cash_Mania,
|
||||
Test: GameId_Test,
|
||||
}
|
||||
var GameKeyMap = map[uint]int64{
|
||||
GameId_Min: 0,
|
||||
GameId_Tiger: 308,
|
||||
GameId_Dragon: 309,
|
||||
GameId_Rabbit: 310,
|
||||
GameId_OX: 311,
|
||||
GameId_Mouse: 312,
|
||||
GameId_Max: 999,
|
||||
var GameKeyMap = map[int64]uint{
|
||||
0: GameId_Min,
|
||||
308: GameId_Tiger,
|
||||
309: GameId_Dragon,
|
||||
310: GameId_Rabbit,
|
||||
311: GameId_OX,
|
||||
312: GameId_Mouse,
|
||||
999: GameId_Max,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
}
|
||||
|
|
@ -107,14 +107,14 @@ func (p *Player) handleLogin(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
|
||||
p.Cli.Ops.Set(sessionContext.Ops)
|
||||
p.Cli.IsSimulator.Set(sessionContext.IsSimulator)
|
||||
p.Cli.IsSimulator.Set(sessionContext.IsSimulator)
|
||||
p.Cli.Ip.Set(sessionContext.Ip)
|
||||
|
||||
p.Cli.PlayerName.Set(sessionContext.PlayerName)
|
||||
//p.Cli.Ops.Set(sessionContext.Ops)
|
||||
//p.Cli.IsSimulator.Set(sessionContext.IsSimulator)
|
||||
//p.Cli.IsSimulator.Set(sessionContext.IsSimulator)
|
||||
//p.Cli.Ip.Set(sessionContext.Ip)
|
||||
//
|
||||
//p.Cli.PlayerName.Set(sessionContext.PlayerName)
|
||||
}
|
||||
|
||||
func (p *Player) updateChar(s *base.SlotsSession) {
|
||||
|
|
|
|||
|
|
@ -7,14 +7,7 @@ import (
|
|||
type (
|
||||
Player struct {
|
||||
Root
|
||||
UID Int64
|
||||
Cli struct {
|
||||
Ops String
|
||||
IsSimulator Bool
|
||||
Ip String
|
||||
PlayerName String
|
||||
LastBetId JSON
|
||||
}
|
||||
UID Int64
|
||||
Char struct {
|
||||
GroupBatch Int64 // 批次(AB测试的批次)
|
||||
Group String // 组(AB测试的组)
|
||||
|
|
|
|||
|
|
@ -197,30 +197,8 @@ func (x *Identifier) GetSessionID() int64 {
|
|||
}
|
||||
|
||||
type Cli struct {
|
||||
ThirdName string
|
||||
Language string
|
||||
IsSimulator bool
|
||||
Token string
|
||||
Ip string
|
||||
Currency string
|
||||
TokenThird string
|
||||
Ops string //player
|
||||
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 {
|
||||
|
|
@ -2032,7 +2010,6 @@ func (x *LiteNodeTree) GetFeatures() []*LiteFeature {
|
|||
|
||||
type SessionContext struct {
|
||||
UID int64
|
||||
*Cli
|
||||
}
|
||||
|
||||
func (x *SessionContext) GetUID() int64 {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import (
|
|||
)
|
||||
|
||||
func (sm *SlotsMgr) Enter(s *base.SlotsSession, gameId int64) (*cli.SlotsEnterResponse, error) {
|
||||
if gid, ok := key.GameKeyMap[uint(gameId)]; ok {
|
||||
gameId = gid
|
||||
if gid, ok := key.GameKeyMap[gameId]; ok {
|
||||
gameId = int64(gid)
|
||||
} else {
|
||||
logger.Logger.Error("[slotsMgr.Enter] 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) {
|
||||
if gameId, ok := key.GameKeyMap[uint(req.GameId)]; ok {
|
||||
req.GameId = gameId
|
||||
if gameId, ok := key.GameKeyMap[req.GameId]; ok {
|
||||
req.GameId = int64(gameId)
|
||||
} else {
|
||||
logger.Logger.Error("[slotsMgr.play] 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) {
|
||||
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) {
|
||||
|
||||
m := machine.NewMachine(s, "s.Theme", DataSet(s).Shell, false)
|
||||
|
|
|
|||
Loading…
Reference in New Issue