add dd
This commit is contained in:
parent
bc81ecdfed
commit
497be310b3
|
@ -1,359 +0,0 @@
|
|||
package fortunedragon
|
||||
|
||||
func (w *WinResult) Init() {
|
||||
w.EleValue = make([]int32, 15)
|
||||
w.WinLine = nil
|
||||
}
|
||||
|
||||
// 玛丽游戏
|
||||
func (w *WinResult) InitMary() {
|
||||
w.MaryOutSide = -1
|
||||
w.MaryMidArray = nil
|
||||
w.MaryOutRate = 0
|
||||
w.MaryMidRate = 0
|
||||
w.MaryLianXu = 0
|
||||
}
|
||||
|
||||
// 正常游戏 免费游戏
|
||||
func (w *WinResult) CreateLine(ele [][]int32, free bool) {
|
||||
w.Init()
|
||||
w.result(ele, free)
|
||||
//Print(w.EleValue)
|
||||
}
|
||||
func (w *WinResult) Win() {
|
||||
w.getWinLine()
|
||||
}
|
||||
|
||||
// 玛丽游戏
|
||||
func (w *WinResult) CreateMary(maryGame [][]int32) {
|
||||
w.InitMary()
|
||||
w.MaryOutSide = RandSliceInt32IndexByWightN(maryGame[0])
|
||||
for i := 0; i < 4; i++ {
|
||||
ele := RandSliceInt32IndexByWightN(maryGame[1])
|
||||
w.MaryMidArray = append(w.MaryMidArray, ele)
|
||||
}
|
||||
//fmt.Println("外圈元素", w.MaryOutSide)
|
||||
//fmt.Println("内圈元素", w.MaryMidArray)
|
||||
w.MaryWin()
|
||||
}
|
||||
func (w *WinResult) MaryWin() {
|
||||
var outRate int64
|
||||
switch w.MaryOutSide {
|
||||
case Watermelon:
|
||||
outRate += 200
|
||||
case Grape:
|
||||
outRate += 100
|
||||
case Lemon:
|
||||
outRate += 70
|
||||
case Cherry:
|
||||
outRate += 50
|
||||
case Banana:
|
||||
outRate += 20
|
||||
case Apple:
|
||||
outRate += 10
|
||||
case Pineapple:
|
||||
outRate += 5
|
||||
}
|
||||
var flag = w.MaryMidArray[0]
|
||||
var n int32
|
||||
for _, v := range w.MaryMidArray {
|
||||
if flag != v {
|
||||
break
|
||||
}
|
||||
n++
|
||||
}
|
||||
for _, v := range w.MaryMidArray {
|
||||
if w.MaryOutSide == v {
|
||||
w.MaryOutRate = outRate
|
||||
break
|
||||
}
|
||||
}
|
||||
if n >= 3 {
|
||||
if n == 3 {
|
||||
w.MaryMidRate = 20
|
||||
} else if n == 4 {
|
||||
w.MaryMidRate = 500
|
||||
}
|
||||
w.MaryLianXu = n
|
||||
}
|
||||
//fmt.Println("外圈倍率:", w.MaryOutRate)
|
||||
//fmt.Println("内圈倍率", w.MaryMidRate)
|
||||
}
|
||||
|
||||
func (w *WinResult) result(ele [][]int32, free bool) {
|
||||
sl1 := make(map[int]bool)
|
||||
sl2 := make(map[int]bool)
|
||||
sl3 := make(map[int]bool)
|
||||
n := 0
|
||||
for i := 0; i < Column; i++ {
|
||||
for j := 0; j < Row; j++ {
|
||||
val := RandSliceInt32IndexByWightN(ele[j])
|
||||
if val == Scatter {
|
||||
if !sl1[j] {
|
||||
sl1[j] = true
|
||||
} else {
|
||||
noScatter := make([]int32, len(ele[j]))
|
||||
copy(noScatter, ele[j])
|
||||
noScatter[Scatter] = 0
|
||||
noScatter[Bonus] = 0
|
||||
noScatter[Wild] = 0
|
||||
val = RandSliceInt32IndexByWightN(noScatter)
|
||||
}
|
||||
} else if val == Bonus {
|
||||
if !sl2[j] {
|
||||
sl2[j] = true
|
||||
} else {
|
||||
noBonus := make([]int32, len(ele[j]))
|
||||
copy(noBonus, ele[j])
|
||||
noBonus[Scatter] = 0
|
||||
noBonus[Bonus] = 0
|
||||
noBonus[Wild] = 0
|
||||
val = RandSliceInt32IndexByWightN(noBonus)
|
||||
}
|
||||
} else if val == Wild {
|
||||
if !sl3[j] {
|
||||
sl3[j] = true
|
||||
} else {
|
||||
noWild := make([]int32, len(ele[j]))
|
||||
copy(noWild, ele[j])
|
||||
noWild[Scatter] = 0
|
||||
noWild[Bonus] = 0
|
||||
noWild[Wild] = 0
|
||||
val = RandSliceInt32IndexByWightN(noWild)
|
||||
}
|
||||
}
|
||||
w.EleValue[n] = val
|
||||
n++
|
||||
}
|
||||
}
|
||||
|
||||
if free {
|
||||
//免费 不中 玛丽游戏和奖池
|
||||
eleVal := make([]int32, len(w.EleValue))
|
||||
copy(eleVal, w.EleValue)
|
||||
var wls WinResult
|
||||
wls.Init()
|
||||
wls.EleValue = eleVal
|
||||
wls.Win()
|
||||
for _, v := range wls.WinLine {
|
||||
flag := v.Lines[0]
|
||||
if flag == Scatter {
|
||||
noScatter := make([]int32, len(ele[2]))
|
||||
copy(noScatter, ele[2])
|
||||
noScatter[Wild] = 0
|
||||
noScatter[Scatter] = 0
|
||||
vv := RandSliceInt32IndexByWightN(noScatter)
|
||||
w.EleValue[v.Poss[2]] = vv
|
||||
} else {
|
||||
wildNum := 0
|
||||
for _, el := range v.Lines {
|
||||
if el == Wild {
|
||||
wildNum++
|
||||
} else {
|
||||
wildNum = 0
|
||||
}
|
||||
}
|
||||
if wildNum >= 3 {
|
||||
noWild := make([]int32, len(ele[2]))
|
||||
copy(noWild, ele[2])
|
||||
noWild[Wild] = 0
|
||||
noWild[Scatter] = 0
|
||||
w.EleValue[v.Poss[2]] = RandSliceInt32IndexByWightN(noWild)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WinResult) getWinLine() {
|
||||
n := 0
|
||||
var flag int32 = -1
|
||||
for k, cols := range LineWinNum {
|
||||
flag = w.EleValue[cols[0]]
|
||||
//Bonus Scatter 不参与线数 Bonus下班单独计算
|
||||
if flag == Bonus || flag == Scatter {
|
||||
continue
|
||||
}
|
||||
var line []int32
|
||||
var pos []int32
|
||||
for _, key := range cols {
|
||||
//不计算 Bonus
|
||||
if (flag == w.EleValue[key] || Wild == w.EleValue[key] || flag == Wild) && w.EleValue[key] != Bonus &&
|
||||
w.EleValue[key] != Scatter {
|
||||
if Wild != w.EleValue[key] {
|
||||
flag = w.EleValue[key]
|
||||
}
|
||||
n++
|
||||
line = append(line, w.EleValue[key])
|
||||
pos = append(pos, int32(key))
|
||||
} else {
|
||||
if n >= 3 || (flag == Banana && n >= 2) {
|
||||
w.WinLine = append(w.WinLine, WinLine{
|
||||
Lines: line,
|
||||
Poss: pos,
|
||||
LineId: k + 1,
|
||||
Rate: GetRate(flag, n),
|
||||
})
|
||||
}
|
||||
n = 0
|
||||
pos = nil
|
||||
line = nil
|
||||
break
|
||||
}
|
||||
if n == 5 {
|
||||
w.WinLine = append(w.WinLine, WinLine{
|
||||
Lines: line,
|
||||
Poss: pos,
|
||||
LineId: k + 1,
|
||||
Rate: GetRate(flag, n),
|
||||
})
|
||||
n = 0
|
||||
pos = nil
|
||||
line = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
w.getBonusAndScatter()
|
||||
|
||||
//test code
|
||||
//if len(w.WinLine) > 0 {
|
||||
// fmt.Println("====== 赢的总线数 =======", len(w.WinLine))
|
||||
// for k, v := range w.WinLine {
|
||||
// fmt.Print(k+1, " ")
|
||||
// PrintWin(v.Lines)
|
||||
// fmt.Println(k+1, "位置 ", v.Poss, " 中奖线号:", v.LineId, " 线元素:", v.Lines, " 倍率:", v.Rate)
|
||||
// }
|
||||
//}
|
||||
}
|
||||
func (w *WinResult) getBonusAndScatter() {
|
||||
//只计算Bonus和Scatter
|
||||
for k, cols := range LineWinNum {
|
||||
var n int
|
||||
var line []int32
|
||||
var pos []int32
|
||||
for l, key := range cols {
|
||||
if w.EleValue[key] == Bonus {
|
||||
n++
|
||||
line = append(line, w.EleValue[key])
|
||||
pos = append(pos, int32(key))
|
||||
} else {
|
||||
if n >= 3 {
|
||||
w.WinLine = append(w.WinLine, WinLine{
|
||||
Lines: line,
|
||||
Poss: pos,
|
||||
LineId: k + 1,
|
||||
Rate: GetRate(Bonus, n),
|
||||
})
|
||||
}
|
||||
n = 0
|
||||
pos = nil
|
||||
line = nil
|
||||
continue
|
||||
}
|
||||
if l == 4 {
|
||||
if n >= 3 {
|
||||
w.WinLine = append(w.WinLine, WinLine{
|
||||
Lines: line,
|
||||
Poss: pos,
|
||||
LineId: k + 1,
|
||||
Rate: GetRate(Bonus, n),
|
||||
})
|
||||
n = 0
|
||||
pos = nil
|
||||
line = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
n = 0
|
||||
pos = nil
|
||||
line = nil
|
||||
for l, key := range cols {
|
||||
if w.EleValue[key] == Scatter {
|
||||
n++
|
||||
line = append(line, w.EleValue[key])
|
||||
pos = append(pos, int32(key))
|
||||
} else {
|
||||
if n >= 3 {
|
||||
w.WinLine = append(w.WinLine, WinLine{
|
||||
Lines: line,
|
||||
Poss: pos,
|
||||
LineId: k + 1,
|
||||
Rate: GetRate(Scatter, n),
|
||||
})
|
||||
}
|
||||
n = 0
|
||||
pos = nil
|
||||
line = nil
|
||||
continue
|
||||
}
|
||||
if l == 4 {
|
||||
if n >= 3 {
|
||||
w.WinLine = append(w.WinLine, WinLine{
|
||||
Lines: line,
|
||||
Poss: pos,
|
||||
LineId: k + 1,
|
||||
Rate: GetRate(Scatter, n),
|
||||
})
|
||||
n = 0
|
||||
pos = nil
|
||||
line = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
n = 0
|
||||
pos = nil
|
||||
line = nil
|
||||
for l, key := range cols {
|
||||
if w.EleValue[key] == Wild {
|
||||
n++
|
||||
line = append(line, w.EleValue[key])
|
||||
pos = append(pos, int32(key))
|
||||
} else {
|
||||
if n >= 3 {
|
||||
isHave := false
|
||||
for _, i2 := range w.WinLine {
|
||||
if i2.LineId == k+1 {
|
||||
isHave = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !isHave {
|
||||
w.WinLine = append(w.WinLine, WinLine{
|
||||
Lines: line,
|
||||
Poss: pos,
|
||||
LineId: k + 1,
|
||||
Rate: GetRate(Wild, n),
|
||||
})
|
||||
}
|
||||
}
|
||||
n = 0
|
||||
pos = nil
|
||||
line = nil
|
||||
continue
|
||||
}
|
||||
if l == 4 {
|
||||
if n >= 3 {
|
||||
isHave := false
|
||||
for _, i2 := range w.WinLine {
|
||||
if i2.LineId == k+1 {
|
||||
isHave = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !isHave {
|
||||
w.WinLine = append(w.WinLine, WinLine{
|
||||
Lines: line,
|
||||
Poss: pos,
|
||||
LineId: k + 1,
|
||||
Rate: GetRate(Wild, n),
|
||||
})
|
||||
}
|
||||
n = 0
|
||||
pos = nil
|
||||
line = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
package fortunedragon
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func GetLineEleVal(gameState int, needRate int64, eleLineAppearRate [][]int32, isLow bool) (WinResult, []int, [][]int32) {
|
||||
var preInt [][]int32
|
||||
for i := 0; i < 1000; i++ {
|
||||
var wls WinResult
|
||||
wls.CreateLine(eleLineAppearRate, false)
|
||||
wls.Win()
|
||||
var rate int64
|
||||
var bonusNum int
|
||||
var wildNum int
|
||||
for _, v := range wls.WinLine {
|
||||
if len(v.Lines) == 0 {
|
||||
continue
|
||||
}
|
||||
rate += v.Rate
|
||||
if v.Lines[0] == Bonus {
|
||||
bonusNum += len(v.Lines)
|
||||
} else if v.Lines[0] == Wild {
|
||||
wildNum += len(v.Lines)
|
||||
}
|
||||
NowWildNum := 0
|
||||
for _, l := range v.Lines {
|
||||
if l != Wild && NowWildNum > 0 {
|
||||
if NowWildNum < 3 {
|
||||
NowWildNum = 0
|
||||
}
|
||||
} else if l == Wild {
|
||||
NowWildNum++
|
||||
}
|
||||
}
|
||||
if NowWildNum >= 3 {
|
||||
wildNum += NowWildNum
|
||||
}
|
||||
}
|
||||
|
||||
//fmt.Printf("%v || rate %v", wls.EleValue, rate)
|
||||
//fmt.Println()
|
||||
var n int64 = 5
|
||||
if gameState == FreeGame {
|
||||
n = 50
|
||||
}
|
||||
if wildNum >= 3 || bonusNum >= 3 {
|
||||
continue
|
||||
}
|
||||
if isLow {
|
||||
continue
|
||||
}
|
||||
if rate >= needRate-n && rate <= needRate+n {
|
||||
var poss []int32
|
||||
for _, v := range wls.WinLine {
|
||||
poss = append(poss, v.Poss...)
|
||||
}
|
||||
var noPoss []int
|
||||
for k := range wls.EleValue {
|
||||
isF := false
|
||||
for _, pn := range poss {
|
||||
if k == int(pn) {
|
||||
isF = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !isF {
|
||||
noPoss = append(noPoss, k)
|
||||
}
|
||||
}
|
||||
//fmt.Println("...........find rate: ", rate, " 第 ", i+1, " 次.")
|
||||
return wls, noPoss, nil
|
||||
}
|
||||
if rate != 0 && rate < 50 && len(preInt) < 10 {
|
||||
preInt = append(preInt, wls.EleValue)
|
||||
}
|
||||
}
|
||||
return WinResult{}, nil, preInt
|
||||
}
|
||||
func GetLinePos(lineId int) []int {
|
||||
if lineId <= 9 || lineId >= 1 {
|
||||
return LineWinNum[lineId-1]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func GetRate(ele int32, num int) int64 {
|
||||
if data, ok := EleNumRate[ele]; ok {
|
||||
if r, ok2 := data[num]; ok2 {
|
||||
return r
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func RandSliceInt32IndexByWightN(s1 []int32) int32 {
|
||||
total := 0
|
||||
for _, v := range s1 {
|
||||
total += int(v)
|
||||
}
|
||||
if total <= 0 {
|
||||
return 0
|
||||
}
|
||||
random := rand.Intn(total)
|
||||
total = 0
|
||||
for i, v := range s1 {
|
||||
total += int(v)
|
||||
if random < total {
|
||||
return int32(i)
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func PrintFruit(idx int32) (str string) {
|
||||
switch idx {
|
||||
case Wild:
|
||||
str += "Wild"
|
||||
case Bonus:
|
||||
str += "Bonus"
|
||||
case Scatter:
|
||||
str += "SCATTER"
|
||||
case Bar:
|
||||
str += "Bar"
|
||||
case Cherry:
|
||||
str += "樱桃"
|
||||
case Bell:
|
||||
str += "铃铛"
|
||||
case Pineapple:
|
||||
str += "菠萝"
|
||||
case Grape:
|
||||
str += "葡萄"
|
||||
case Lemon:
|
||||
str += "柠檬"
|
||||
case Watermelon:
|
||||
str += "西瓜"
|
||||
case Banana:
|
||||
str += "香蕉"
|
||||
case Apple:
|
||||
str += "苹果"
|
||||
case Bomb:
|
||||
str += "炸弹"
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
func Print(res []int32) {
|
||||
fmt.Println(res, len(res))
|
||||
str := ""
|
||||
for k, ele := range res {
|
||||
switch ele {
|
||||
case Wild:
|
||||
str += "Wild,"
|
||||
case Bonus:
|
||||
str += "Bonus,"
|
||||
case Scatter:
|
||||
str += "Scatter,"
|
||||
case Bar:
|
||||
str += "Bar,"
|
||||
case Cherry:
|
||||
str += "樱桃,"
|
||||
case Bell:
|
||||
str += "铃铛,"
|
||||
case Pineapple:
|
||||
str += "菠萝,"
|
||||
case Grape:
|
||||
str += "葡萄,"
|
||||
case Lemon:
|
||||
str += "柠檬,"
|
||||
case Watermelon:
|
||||
str += "西瓜,"
|
||||
case Apple:
|
||||
str += "苹果,"
|
||||
case Banana:
|
||||
str += "香蕉,"
|
||||
}
|
||||
if (k+1)%5 == 0 {
|
||||
fmt.Println("第", strconv.Itoa((k+1)/5), "行 ", str)
|
||||
str = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
func PrintWin(lines []int32) {
|
||||
str := ""
|
||||
for _, ele := range lines {
|
||||
switch ele {
|
||||
case Wild:
|
||||
str += "Wild,"
|
||||
case Bonus:
|
||||
str += "Bonus,"
|
||||
case Scatter:
|
||||
str += "Scatter,"
|
||||
case Bar:
|
||||
str += "Bar,"
|
||||
case Cherry:
|
||||
str += "樱桃,"
|
||||
case Bell:
|
||||
str += "铃铛,"
|
||||
case Pineapple:
|
||||
str += "菠萝,"
|
||||
case Grape:
|
||||
str += "葡萄,"
|
||||
case Lemon:
|
||||
str += "柠檬,"
|
||||
case Watermelon:
|
||||
str += "西瓜,"
|
||||
case Banana:
|
||||
str += "香蕉,"
|
||||
case Apple:
|
||||
str += "苹果,"
|
||||
case Bomb:
|
||||
str += "炸弹,"
|
||||
}
|
||||
}
|
||||
fmt.Println(str)
|
||||
}
|
|
@ -52,17 +52,17 @@ type BaseAI struct {
|
|||
attribute map[interface{}]interface{}
|
||||
}
|
||||
|
||||
//挂载玩家
|
||||
// 挂载玩家
|
||||
func (b *BaseAI) SetOwner(p *Player) {
|
||||
b.owner = p
|
||||
}
|
||||
|
||||
//获取挂载玩家
|
||||
// 获取挂载玩家
|
||||
func (b *BaseAI) GetOwner() *Player {
|
||||
return b.owner
|
||||
}
|
||||
|
||||
//获取属性
|
||||
// 获取属性
|
||||
func (b *BaseAI) GetAttribute(key interface{}) (interface{}, bool) {
|
||||
if b.attribute != nil {
|
||||
v, ok := b.attribute[key]
|
||||
|
@ -71,29 +71,29 @@ func (b *BaseAI) GetAttribute(key interface{}) (interface{}, bool) {
|
|||
return nil, false
|
||||
}
|
||||
|
||||
//设置属性
|
||||
// 设置属性
|
||||
func (b *BaseAI) SetAttribute(key, val interface{}) {
|
||||
if b.attribute != nil {
|
||||
b.attribute[key] = val
|
||||
}
|
||||
}
|
||||
|
||||
//开启事件
|
||||
// 开启事件
|
||||
func (b *BaseAI) OnStart() {
|
||||
|
||||
}
|
||||
|
||||
//关闭事件
|
||||
// 关闭事件
|
||||
func (b *BaseAI) OnStop() {
|
||||
|
||||
}
|
||||
|
||||
//心跳事件
|
||||
// 心跳事件
|
||||
func (b *BaseAI) OnTick(s *Scene) {
|
||||
|
||||
}
|
||||
|
||||
//自己进入事件
|
||||
// 自己进入事件
|
||||
func (b *BaseAI) OnSelfEnter(s *Scene, p *Player) {
|
||||
if !p.IsLocal {
|
||||
return
|
||||
|
@ -108,72 +108,72 @@ func (b *BaseAI) OnSelfEnter(s *Scene, p *Player) {
|
|||
p.LastSyncCoin = p.Coin
|
||||
}
|
||||
|
||||
//自己离开事件
|
||||
// 自己离开事件
|
||||
func (b *BaseAI) OnSelfLeave(s *Scene, p *Player, reason int) {
|
||||
|
||||
}
|
||||
|
||||
//其他玩家进入事件
|
||||
// 其他玩家进入事件
|
||||
func (b *BaseAI) OnPlayerEnter(s *Scene, p *Player) {
|
||||
|
||||
}
|
||||
|
||||
//其他玩家离开事件
|
||||
// 其他玩家离开事件
|
||||
func (b *BaseAI) OnPlayerLeave(s *Scene, p *Player, reason int) {
|
||||
|
||||
}
|
||||
|
||||
//其他玩家掉线
|
||||
// 其他玩家掉线
|
||||
func (b *BaseAI) OnPlayerDropLine(s *Scene, p *Player) {
|
||||
|
||||
}
|
||||
|
||||
//其他玩家重连
|
||||
// 其他玩家重连
|
||||
func (b *BaseAI) OnPlayerRehold(s *Scene, p *Player) {
|
||||
|
||||
}
|
||||
|
||||
//其他玩家 返回房间
|
||||
// 其他玩家 返回房间
|
||||
func (b *BaseAI) OnPlayerReturn(s *Scene, p *Player) {
|
||||
|
||||
}
|
||||
|
||||
//其他玩家操作事件
|
||||
// 其他玩家操作事件
|
||||
func (b *BaseAI) OnPlayerOp(s *Scene, p *Player, opcode int, params []int64) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
//其他玩家操作事件
|
||||
// 其他玩家操作事件
|
||||
func (b *BaseAI) OnPlayerOperate(s *Scene, p *Player, params interface{}) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
//其他玩家事件
|
||||
// 其他玩家事件
|
||||
func (b *BaseAI) OnPlayerEvent(s *Scene, p *Player, evtcode int, params []int64) {
|
||||
|
||||
}
|
||||
|
||||
//观众进入事件
|
||||
// 观众进入事件
|
||||
func (b *BaseAI) OnAudienceEnter(s *Scene, p *Player) {
|
||||
|
||||
}
|
||||
|
||||
//观众离开事件
|
||||
// 观众离开事件
|
||||
func (b *BaseAI) OnAudienceLeave(s *Scene, p *Player, reason int) {
|
||||
|
||||
}
|
||||
|
||||
//观众坐下事件
|
||||
// 观众坐下事件
|
||||
func (b *BaseAI) OnAudienceSit(s *Scene, p *Player) {
|
||||
|
||||
}
|
||||
|
||||
//观众掉线事件
|
||||
// 观众掉线事件
|
||||
func (b *BaseAI) OnAudienceDropLine(s *Scene, p *Player) {
|
||||
|
||||
}
|
||||
|
||||
//房间状态变化事件
|
||||
// 房间状态变化事件
|
||||
func (b *BaseAI) OnChangeSceneState(s *Scene, oldstate, newstate int) {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package session
|
||||
package base
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Session struct {
|
||||
type SlotsSession struct {
|
||||
sync.RWMutex
|
||||
uid uint64 // binding user id
|
||||
coin int64
|
||||
|
@ -17,14 +15,14 @@ type Session struct {
|
|||
connectNum uint64
|
||||
}
|
||||
|
||||
func NewSession(uid uint64, coin int64) *Session {
|
||||
return &Session{
|
||||
func NewSession(uid uint64, coin int64) *SlotsSession {
|
||||
return &SlotsSession{
|
||||
uid: uid,
|
||||
coin: coin,
|
||||
data: make(map[string]interface{}),
|
||||
}
|
||||
}
|
||||
func (s *Session) SetLastConnectTime() bool {
|
||||
func (s *SlotsSession) SetLastConnectTime() bool {
|
||||
if time.Now().Sub(s.lastConnectTime) > time.Second {
|
||||
s.connectNum = 1
|
||||
s.lastConnectTime = time.Now()
|
||||
|
@ -36,19 +34,16 @@ func (s *Session) SetLastConnectTime() bool {
|
|||
}
|
||||
return true
|
||||
}
|
||||
func (s *Session) GetLastConnectTime() time.Time {
|
||||
func (s *SlotsSession) GetLastConnectTime() time.Time {
|
||||
return s.lastConnectTime
|
||||
}
|
||||
func (s *Session) UID() uint64 {
|
||||
func (s *SlotsSession) UID() uint64 {
|
||||
return atomic.LoadUint64(&s.uid)
|
||||
}
|
||||
func (s *Session) Coin() int64 {
|
||||
func (s *SlotsSession) Coin() int64 {
|
||||
return atomic.LoadInt64(&s.coin)
|
||||
}
|
||||
func (s *Session) SetSessionContext(sessionContext *shared.SessionContext) {
|
||||
s.Set(key.SessionContext, sessionContext)
|
||||
}
|
||||
func (s *Session) Set(key string, value interface{}) {
|
||||
func (s *SlotsSession) Set(key string, value interface{}) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
||||
|
@ -57,20 +52,20 @@ func (s *Session) Set(key string, value interface{}) {
|
|||
}
|
||||
s.data[key] = value
|
||||
}
|
||||
func (s *Session) Remove(key string) {
|
||||
func (s *SlotsSession) Remove(key string) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
||||
delete(s.data, key)
|
||||
}
|
||||
|
||||
func (s *Session) Value(key string) interface{} {
|
||||
func (s *SlotsSession) Value(key string) interface{} {
|
||||
s.RLock()
|
||||
defer s.RUnlock()
|
||||
|
||||
return s.data[key]
|
||||
}
|
||||
func (s *Session) Bool(key string) bool {
|
||||
func (s *SlotsSession) Bool(key string) bool {
|
||||
s.RLock()
|
||||
defer s.RUnlock()
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package _struct
|
||||
package base
|
||||
|
||||
type EnterReq struct {
|
||||
TraceId string `form:"tid"`
|
|
@ -2,11 +2,18 @@ package fortunedragon
|
|||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots"
|
||||
)
|
||||
|
||||
type FortuneDragonPlayerData struct {
|
||||
*base.Player
|
||||
leaveTime int32 //离开时间
|
||||
SlotsSession *base.SlotsSession
|
||||
|
||||
BetSizeIndex int64 `json:"bsi"` //选中的单注下标
|
||||
BetLevelIndex int64 `json:"bli"` //选中的等级下标
|
||||
BetLineIndex int64 `json:"bii"` //选中的线数下标
|
||||
BetMode int64 `json:"bm,optional"` //0.常规 1.必中
|
||||
}
|
||||
|
||||
func (p *FortuneDragonPlayerData) init() {
|
||||
|
@ -14,3 +21,14 @@ func (p *FortuneDragonPlayerData) init() {
|
|||
func (p *FortuneDragonPlayerData) Clear() {
|
||||
|
||||
}
|
||||
|
||||
// 需要带到world上进行数据处理
|
||||
func (p *FortuneDragonPlayerData) PushPlayer() map[string]string {
|
||||
cache := slots.SlotsMgrSington.PushPlayer(p.SlotsSession)
|
||||
return cache
|
||||
}
|
||||
|
||||
// 进房的时候需要带进来
|
||||
func (p *FortuneDragonPlayerData) PullPlayer(data map[string]string) {
|
||||
slots.SlotsMgrSington.PullPlayer(p.SlotsSession, data)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package fortunedragon
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
)
|
||||
import "mongo.games.com/game/gamesrv/base"
|
||||
|
||||
type FortuneDragonSceneData struct {
|
||||
*base.Scene //场景
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package fortunedragon
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"mongo.games.com/game/gamerule/fortunedragon"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/assemble"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots"
|
||||
"time"
|
||||
|
||||
"mongo.games.com/goserver/core"
|
||||
|
@ -174,6 +177,16 @@ 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)
|
||||
if err == nil {
|
||||
data := assemble.DataToCli(Response).(assemble.TableInfo)
|
||||
pi, _ := json.Marshal(data)
|
||||
pack.PlayerInfo = string(pi)
|
||||
} else {
|
||||
logger.Logger.Error("slots enter err:", err)
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
return pack
|
||||
|
@ -313,11 +326,35 @@ func (this *SceneStateStartFortuneDragon) OnPlayerOp(s *base.Scene, p *base.Play
|
|||
if this.SceneBaseStateFortuneDragon.OnPlayerOp(s, p, opcode, params) {
|
||||
return true
|
||||
}
|
||||
if _, ok := s.GetExtraData().(*FortuneDragonSceneData); ok {
|
||||
if sceneEx, ok := s.GetExtraData().(*FortuneDragonSceneData); ok {
|
||||
if playerEx, ok := p.GetExtraData().(*FortuneDragonPlayerData); ok {
|
||||
switch opcode {
|
||||
case fortunedragon.FortuneDragonPlayerOpStart:
|
||||
playerEx.Clear()
|
||||
//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
|
||||
if err == nil {
|
||||
data := assemble.DataToCli(Response).(assemble.TableInfo)
|
||||
pi, _ := json.Marshal(data)
|
||||
gameEndStr = string(pi)
|
||||
playerEx.Coin = Response.Coin
|
||||
} else {
|
||||
logger.Logger.Error("slots enter err:", err)
|
||||
}
|
||||
pack := &protocol.SCFortuneDragonBilled{
|
||||
GameEndStr: proto.String(gameEndStr),
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
logger.Logger.Trace("SCFortuneDragonBilled", pack.String())
|
||||
playerEx.SendToClient(int(protocol.FortuneDragonPID_PACKET_FORTUNEDRAGON_SCFORTUNEDRAGONOP), pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,11 @@ import (
|
|||
_ "mongo.games.com/game/gamesrv/avengers"
|
||||
_ "mongo.games.com/game/gamesrv/caishen"
|
||||
_ "mongo.games.com/game/gamesrv/easterisland"
|
||||
_ "mongo.games.com/game/gamesrv/fortunedragon"
|
||||
_ "mongo.games.com/game/gamesrv/fruits"
|
||||
_ "mongo.games.com/game/gamesrv/iceage"
|
||||
_ "mongo.games.com/game/gamesrv/richblessed"
|
||||
_ "mongo.games.com/game/gamesrv/slotspkg/slots"
|
||||
_ "mongo.games.com/game/gamesrv/tamquoc"
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
package assemble
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/types/cli"
|
||||
"sort"
|
||||
)
|
||||
|
||||
var CoinRate float64 = 10000
|
||||
|
||||
func DataToCli(response any) interface{} {
|
||||
switch Response := response.(type) {
|
||||
case *cli.SlotsEnterResponse:
|
||||
tableInfo := TableInfo{}
|
||||
var BetSizes []float64
|
||||
for _, size := range Response.BetSizes {
|
||||
BetSizes = append(BetSizes, float64(size)/10000)
|
||||
}
|
||||
sort.Slice(Response.BetChangeList, func(i, j int) bool { return Response.BetChangeList[i] < Response.BetChangeList[j] })
|
||||
sort.Slice(Response.BetLevels, func(i, j int) bool { return Response.BetLevels[i] < Response.BetLevels[j] })
|
||||
sort.Slice(BetSizes, func(i, j int) bool { return BetSizes[i] < BetSizes[j] })
|
||||
tableInfo.BetConfig = BetConfig{
|
||||
BetChangeList: Response.BetChangeList,
|
||||
BetSize: BetSizes,
|
||||
BetLevel: Response.BetLevels,
|
||||
BetLines: Response.BetLines,
|
||||
BetType: 1,
|
||||
BetSizeIndex: Response.BetSizeIndex,
|
||||
BetLevelIndex: Response.BetLevelIndex,
|
||||
BetLineIndex: Response.BetLineIndex,
|
||||
}
|
||||
tableInfo.Coin = float64(Response.Coin) / CoinRate
|
||||
//////////////////////////////////////////////////////////////
|
||||
res := response2NodeTree(Response.NodeTree)
|
||||
ress := []*shared.Result{res}
|
||||
gameEnd := shared.GameEndDto{
|
||||
Results: ress,
|
||||
RoundReward: Response.NodeTree.Nodes[0].ChildrenTotalWin,
|
||||
TotalBet: Response.NodeTree.BetCoin.GetCoin(),
|
||||
//BetBeforeCoin: Response.Coin - Response.ActualWin + Response.ActualBet,
|
||||
//BetAfterCoin: Response.Coin - Response.ActualWin,
|
||||
FinalCoin: Response.Coin,
|
||||
ActualBet: Response.NodeTree.Nodes[0].Bet,
|
||||
ActualWin: Response.Coin,
|
||||
}
|
||||
tableInfo.SpinResult = SpinRes2Dto(gameEnd)
|
||||
return tableInfo
|
||||
case *cli.SlotsPlayResponse:
|
||||
res := response2NodeTree(Response.NodeTree)
|
||||
ress := []*shared.Result{res}
|
||||
GameEnd := shared.GameEndDto{
|
||||
Results: ress,
|
||||
RoundReward: Response.NodeTree.Nodes[0].ChildrenTotalWin,
|
||||
TotalBet: Response.NodeTree.BetCoin.GetCoin(),
|
||||
BetBeforeCoin: Response.Coin - Response.ActualWin + Response.ActualBet,
|
||||
BetAfterCoin: Response.Coin - Response.ActualWin,
|
||||
FinalCoin: Response.Coin,
|
||||
ActualBet: Response.ActualBet,
|
||||
ActualWin: Response.ActualWin,
|
||||
}
|
||||
//a, _ := json.Marshal(GameEnd)
|
||||
//logx.Error("GameEnd:", string(a))
|
||||
return GameEnd
|
||||
default:
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func response2NodeTree(NodeTree *shared.LiteNodeTree) *shared.Result {
|
||||
Special, customFortune, featureTotalWin := getDataByTheme(NodeTree)
|
||||
var ass []*shared.ArrSpins
|
||||
for _, formation := range NodeTree.Formations {
|
||||
item := formation.DisplaySymbols
|
||||
spinType := formation.NodeType
|
||||
indexs := formation.RandPositions
|
||||
//win := formation.Win
|
||||
items := cli.ToItems(formation.MatrixForm, item)
|
||||
var lineReward float64
|
||||
for _, info := range formation.RewardInfo {
|
||||
lineReward += info.Reward
|
||||
}
|
||||
if formation.NewNodeType != "" {
|
||||
spinType = formation.NewNodeType
|
||||
}
|
||||
spin := &shared.ArrSpins{
|
||||
GearID: spinType,
|
||||
Items: items,
|
||||
Index: indexs,
|
||||
Reward: float64(featureTotalWin) + lineReward, ///total_win
|
||||
LineReward: lineReward, ///line_win
|
||||
RewardInfo: formation.RewardInfo,
|
||||
FinalSymbols: cli.ToItems(formation.MatrixForm, formation.GetFinalSymbols()),
|
||||
}
|
||||
if Special[formation.NodeID] != nil {
|
||||
spin.Special = Special[formation.NodeID]
|
||||
}
|
||||
ass = append(ass, spin)
|
||||
}
|
||||
res := &shared.Result{
|
||||
ArrSpins: ass,
|
||||
}
|
||||
|
||||
res.TotalRewardBase = ass[0].LineReward ///line_win
|
||||
res.TotalReward = ass[0].Reward ///total_win
|
||||
|
||||
res.FreeNumTrigger = customFortune.FreeNumTrigger
|
||||
res.FreeNumMax = customFortune.FreeNumMax
|
||||
res.FreeNum = customFortune.FreeSpinNum
|
||||
|
||||
return res
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package assemble
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type CustomFortune struct {
|
||||
FreeSpinNum int64 `json:"fsn"` //剩余freespin
|
||||
FreeNumMax int64 `json:"fnm"` //总次数
|
||||
FreeNumTrigger int64 `json:"fnt"` //新增freespin
|
||||
ForceRound int64 `json:"fr"` //第n次
|
||||
}
|
||||
|
||||
func getDataByTheme(NodeTree *shared.LiteNodeTree) (map[int64]*shared.SpinLock, CustomFortune, int64) {
|
||||
var Special = make(map[int64]*shared.SpinLock)
|
||||
var customFortune CustomFortune
|
||||
var FeatureTotalWin int64
|
||||
for _, feature := range NodeTree.Features {
|
||||
if strings.Contains(feature.Type, "Special") && len(feature.Custom) > 2 {
|
||||
sp := shared.SpinLock{}
|
||||
json.Unmarshal([]byte(feature.Custom), &sp)
|
||||
Special[feature.NodeID] = &sp
|
||||
json.Unmarshal([]byte(feature.Custom), &customFortune)
|
||||
}
|
||||
FeatureTotalWin += feature.Win
|
||||
}
|
||||
return Special, customFortune, FeatureTotalWin
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package assemble
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
)
|
||||
|
||||
func SpinRes2Dto(spinRes shared.GameEndDto) (spinResDto GameEnd) {
|
||||
////////////////////////////////////
|
||||
//数据组装
|
||||
spinResDto.Results = make([]Result, len(spinRes.Results))
|
||||
for i, result := range spinRes.Results {
|
||||
spinResDto.Results[i].WinStatus = result.WinStatus
|
||||
spinResDto.Results[i].FreeStatus = result.FreeStatus
|
||||
spinResDto.Results[i].FreeNum = result.FreeNum
|
||||
spinResDto.Results[i].FreeNumMax = result.FreeNumMax
|
||||
spinResDto.Results[i].FreeNumTrigger = result.FreeNumTrigger
|
||||
spinResDto.Results[i].TotalReward = result.TotalReward / CoinRate
|
||||
spinResDto.Results[i].TotalRewardBase = result.TotalRewardBase / CoinRate
|
||||
spinResDto.Results[i].BetMode = result.BetMode
|
||||
spinResDto.Results[i].ArrSpins = make([]ArrSpins, len(result.ArrSpins))
|
||||
for i2, spin := range result.ArrSpins {
|
||||
spinResDto.Results[i].ArrSpins[i2].GearID = spin.GearID
|
||||
spinResDto.Results[i].ArrSpins[i2].Items = spin.Items
|
||||
spinResDto.Results[i].ArrSpins[i2].FinalSymbols = spin.FinalSymbols
|
||||
spinResDto.Results[i].ArrSpins[i2].Index = spin.Index
|
||||
spinResDto.Results[i].ArrSpins[i2].Reward = spin.Reward / CoinRate
|
||||
spinResDto.Results[i].ArrSpins[i2].LineReward = spin.LineReward / CoinRate
|
||||
spinResDto.Results[i].ArrSpins[i2].Special = spin.Special
|
||||
spinResDto.Results[i].ArrSpins[i2].RewardInfo = make([]RewardInfo, len(spin.RewardInfo))
|
||||
for i3, info := range spin.RewardInfo {
|
||||
spinResDto.Results[i].ArrSpins[i2].RewardInfo[i3].Type = info.Type
|
||||
spinResDto.Results[i].ArrSpins[i2].RewardInfo[i3].Index = info.Index
|
||||
spinResDto.Results[i].ArrSpins[i2].RewardInfo[i3].Item = info.Item
|
||||
spinResDto.Results[i].ArrSpins[i2].RewardInfo[i3].Reward = info.Reward / CoinRate
|
||||
spinResDto.Results[i].ArrSpins[i2].RewardInfo[i3].Pos = info.Pos
|
||||
}
|
||||
}
|
||||
}
|
||||
spinResDto.RoundReward = float64(spinRes.RoundReward) / CoinRate
|
||||
spinResDto.BetSizeIndex = spinRes.BetSizeIndex
|
||||
spinResDto.BetLevelIndex = spinRes.BetLevelIndex
|
||||
spinResDto.LinesIndex = spinRes.LinesIndex
|
||||
spinResDto.TotalBet = float64(spinRes.TotalBet) / CoinRate
|
||||
spinResDto.BetBeforeCoin = float64(spinRes.BetBeforeCoin) / CoinRate
|
||||
spinResDto.BetAfterCoin = float64(spinRes.BetAfterCoin) / CoinRate
|
||||
spinResDto.FinalCoin = float64(spinRes.FinalCoin) / CoinRate
|
||||
spinResDto.ActualBet = float64(spinRes.ActualBet) / CoinRate
|
||||
spinResDto.ActualWin = float64(spinRes.ActualWin) / CoinRate
|
||||
////////////////////////////////////
|
||||
return
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package assemble
|
||||
|
||||
type RewardInfo struct {
|
||||
Type int `json:"type"` //0.指定线的数量 1.全线
|
||||
Index int `json:"index"` //线的id
|
||||
Item int64 `json:"item"` //图标id
|
||||
Reward float64 `json:"reward"` //单线奖励
|
||||
Pos [][]int `json:"pos"` //位置
|
||||
}
|
||||
type ArrSpins struct {
|
||||
GearID string `json:"gear_id"` //"base","respin"
|
||||
Items [][]int64 `json:"items"` //当前元素
|
||||
FinalSymbols [][]int64 `json:"final_symbols"` //最终元素
|
||||
Index []int64 `json:"index"` //reel索引
|
||||
Reward float64 `json:"reward"` //总奖
|
||||
LineReward float64 `json:"line_reward"` //线的总奖
|
||||
RewardInfo []RewardInfo `json:"reward_info"`
|
||||
Special interface{} `json:"special"` //null
|
||||
}
|
||||
type Result struct {
|
||||
ArrSpins []ArrSpins `json:"arr_spins"`
|
||||
WinStatus int `json:"win_status"` //0.无特效 1.bigWin(5) 2.megaWin(10) 3.superWin(20) 4.epicWin(1000000000)
|
||||
FreeStatus int `json:"free_status"` //0.none trigger = 1, retrigger = 2, over = 3,
|
||||
FreeNum int64 `json:"free_num"` //剩余free数量
|
||||
FreeNumMax int64 `json:"free_num_max"` //最大的free数量
|
||||
FreeNumTrigger int64 `json:"free_num_trigger"` //新增的free数量
|
||||
TotalReward float64 `json:"total_reward"` //总奖
|
||||
TotalRewardBase float64 `json:"total_reward_base"` //基础奖
|
||||
BetMode int64 `json:"bet_mode"` //0.常规 1.必中
|
||||
}
|
||||
type GameEnd struct {
|
||||
Results []Result `json:"results"`
|
||||
RoundReward float64 `json:"round_reward"` //总奖
|
||||
BetSizeIndex int64 `json:"bet_size_index"` //选中的单注下标
|
||||
BetLevelIndex int64 `json:"bet_level_index"` //选中的等级下标
|
||||
LinesIndex int64 `json:"lines_index"` //选中的线数下标
|
||||
TotalBet float64 `json:"total_bet"` //下注
|
||||
BetBeforeCoin float64 `json:"bet_before_coin"` //下注前
|
||||
BetAfterCoin float64 `json:"bet_after_coin"` //下注后
|
||||
FinalCoin float64 `json:"final_coin"` //结束
|
||||
ActualBet float64 `json:"-"`
|
||||
ActualWin float64 `json:"-"`
|
||||
}
|
||||
type BetConfig struct {
|
||||
BetChangeList []float64 `json:"bet_change_list"`
|
||||
BetSize []float64 `json:"bet_size"` //单注
|
||||
BetLevel []int64 `json:"bet_level"` //下注线数
|
||||
BetLines []int64 `json:"bet_lines"` //可选线数
|
||||
BetType int `json:"bet_type"` //total计算方式 1.显示成Lines betSize*betLevel*lines (lines)
|
||||
BetSizeIndex int64 `json:"bet_size_index"` //选中的单注下标
|
||||
BetLevelIndex int64 `json:"bet_level_index"` //选中的等级下标
|
||||
BetLineIndex int64 `json:"bet_line_index"` //选中的线数下标
|
||||
}
|
||||
type TableInfo struct {
|
||||
SpinResult GameEnd `json:"spin_result"`
|
||||
Coin float64 `json:"coin"`
|
||||
BetConfig BetConfig `json:"bet_config"`
|
||||
}
|
|
@ -3,7 +3,7 @@ package storage
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"qstar_server/internal/exported/excel2go/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/exported/excel2go/base"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -720,4 +720,3 @@ func Load(dataMap map[string]string, name string, v interface{}) {
|
|||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
package ddb
|
||||
|
||||
import "github.com/tomas-qstarrs/boost/config"
|
||||
|
||||
type Table struct {
|
||||
TableName string
|
||||
IndexName string
|
||||
PartitionKey string
|
||||
SortKey string
|
||||
SortKeyNum string
|
||||
}
|
||||
|
||||
type Provisioned struct {
|
||||
ReadCapacityUnits int64
|
||||
WriteCapacityUnits int64
|
||||
}
|
||||
|
||||
type Endpoint struct {
|
||||
PartitionID string
|
||||
URL string
|
||||
SigningRegion string
|
||||
}
|
||||
|
||||
type Credentials struct {
|
||||
AccessKeyID string
|
||||
SecretAccessKey string
|
||||
SessionToken string
|
||||
Source string
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Table Table
|
||||
Provisioned Provisioned
|
||||
Endpoint Endpoint
|
||||
Credentials Credentials
|
||||
TransactionSize int
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
return &Config{
|
||||
Table: Table{
|
||||
TableName: config.GetString("ddb.table.tableName"),
|
||||
IndexName: config.GetString("ddb.table.indexName"),
|
||||
PartitionKey: config.GetString("ddb.table.partitionKey"),
|
||||
SortKey: config.GetString("ddb.table.sortKey"),
|
||||
SortKeyNum: config.GetString("ddb.table.sortKeyNum"),
|
||||
},
|
||||
Provisioned: Provisioned{
|
||||
ReadCapacityUnits: config.GetInt64("ddb.provisioned.readCapacityUnits"),
|
||||
WriteCapacityUnits: config.GetInt64("ddb.provisioned.writeCapacityUnits"),
|
||||
},
|
||||
Endpoint: Endpoint{
|
||||
PartitionID: config.GetString("ddb.endpoint.partitionID"),
|
||||
URL: config.GetString("ddb.endpoint.url"),
|
||||
SigningRegion: config.GetString("ddb.endpoint.signingRegion"),
|
||||
},
|
||||
Credentials: Credentials{
|
||||
AccessKeyID: config.GetString("ddb.credentials.accessKeyID"),
|
||||
SecretAccessKey: config.GetString("ddb.credentials.secretAccessKey"),
|
||||
SessionToken: config.GetString("ddb.credentials.sessionToken"),
|
||||
Source: config.GetString("ddb.credentials.source"),
|
||||
},
|
||||
TransactionSize: config.GetInt("ddb.transactionSize"),
|
||||
}
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
package ddb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
|
||||
"github.com/tomas-qstarrs/redimo"
|
||||
)
|
||||
|
||||
type DDB struct {
|
||||
*Config
|
||||
dynamodbClient *dynamodb.Client
|
||||
redimoClient *redimo.Client
|
||||
}
|
||||
|
||||
func Init() {
|
||||
ddb.init()
|
||||
}
|
||||
|
||||
var ddb = &DDB{}
|
||||
|
||||
func (ddb *DDB) init() {
|
||||
ddb.initConfig()
|
||||
ddb.initClient()
|
||||
ddb.initTable()
|
||||
}
|
||||
|
||||
func (ddb *DDB) initConfig() {
|
||||
ddb.Config = NewConfig()
|
||||
}
|
||||
|
||||
func (ddb *DDB) initClient() {
|
||||
var (
|
||||
sdkConfig aws.Config
|
||||
err error
|
||||
)
|
||||
var options []func(*config.LoadOptions) error
|
||||
|
||||
if ddb.Endpoint.URL != "" || ddb.Endpoint.PartitionID != "" ||
|
||||
ddb.Endpoint.SigningRegion != "" {
|
||||
options = append(options, config.WithEndpointResolverWithOptions(
|
||||
aws.EndpointResolverWithOptionsFunc(
|
||||
func(service, region string, _ ...interface{}) (
|
||||
aws.Endpoint, error) {
|
||||
if service == dynamodb.ServiceID {
|
||||
return aws.Endpoint{
|
||||
URL: ddb.Endpoint.URL,
|
||||
PartitionID: ddb.Endpoint.PartitionID,
|
||||
SigningRegion: ddb.Endpoint.SigningRegion,
|
||||
}, nil
|
||||
}
|
||||
return aws.Endpoint{}, &aws.EndpointNotFoundError{}
|
||||
},
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
if ddb.Credentials.AccessKeyID != "" || ddb.Credentials.SecretAccessKey != "" ||
|
||||
ddb.Credentials.SessionToken != "" || ddb.Credentials.Source != "" {
|
||||
options = append(options, config.WithCredentialsProvider(
|
||||
aws.CredentialsProviderFunc(
|
||||
func(_ context.Context) (aws.Credentials, error) {
|
||||
return aws.Credentials{
|
||||
AccessKeyID: ddb.Credentials.AccessKeyID,
|
||||
SecretAccessKey: ddb.Credentials.SecretAccessKey,
|
||||
SessionToken: ddb.Credentials.SessionToken,
|
||||
Source: ddb.Credentials.Source,
|
||||
}, nil
|
||||
},
|
||||
),
|
||||
))
|
||||
}
|
||||
sdkConfig, err = config.LoadDefaultConfig(context.Background(), options...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ddb.dynamodbClient = dynamodb.NewFromConfig(sdkConfig)
|
||||
|
||||
redimoClientStruct := redimo.NewClient(
|
||||
ddb.dynamodbClient,
|
||||
).Table(
|
||||
ddb.Table.TableName,
|
||||
).Index(
|
||||
ddb.Table.IndexName,
|
||||
).Attributes(
|
||||
ddb.Table.PartitionKey,
|
||||
ddb.Table.SortKey,
|
||||
ddb.Table.SortKeyNum,
|
||||
).TransactionActions(
|
||||
ddb.TransactionSize,
|
||||
)
|
||||
ddb.redimoClient = &redimoClientStruct
|
||||
}
|
||||
|
||||
func (ddb *DDB) initTable() {
|
||||
if ok, err := ddb.redimoClient.ExistsTable(); err != nil {
|
||||
panic(err)
|
||||
} else if !ok {
|
||||
if err := ddb.redimoClient.CreateTable(ddb.Provisioned.ReadCapacityUnits, ddb.Provisioned.WriteCapacityUnits); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func DynamoDBClient() *dynamodb.Client {
|
||||
return ddb.dynamodbClient
|
||||
}
|
||||
|
||||
func RedimoClient() *redimo.Client {
|
||||
return ddb.redimoClient
|
||||
}
|
|
@ -2,13 +2,10 @@ package global
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
logger2 "github.com/breezedup/goserver/core/logger"
|
||||
"github.com/go-redis/redis"
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/gogo/protobuf/codec"
|
||||
"github.com/sirupsen/logrus"
|
||||
"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"
|
||||
|
@ -16,9 +13,6 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"qstar_server/internal/exported/resource"
|
||||
"qstar_server/internal/generic/ddb"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
@ -98,7 +92,6 @@ var (
|
|||
)
|
||||
|
||||
func init() {
|
||||
InitGeneric()
|
||||
Project = getProject()
|
||||
Game = getGame()
|
||||
Process = getProcess()
|
||||
|
@ -110,18 +103,15 @@ func init() {
|
|||
WorkingDirectory = getWorkingDirectory()
|
||||
ProjectDirectory = getProjectDirectory()
|
||||
ConfigDirectory = getConfigDirectory()
|
||||
Configs = getConfig()
|
||||
Timex = getTimex()
|
||||
//Timex = getTimex()
|
||||
//Logger = getLogger()
|
||||
ProcessTime = getProcessTime()
|
||||
Mock = getMock()
|
||||
HTTPClient = getHTTPClient()
|
||||
RedisClient = getRedisClient()
|
||||
ddb.Init()
|
||||
}
|
||||
|
||||
func getProject() string {
|
||||
return "qstar_server"
|
||||
return "server"
|
||||
}
|
||||
|
||||
func getGame() string {
|
||||
|
@ -145,24 +135,17 @@ func getProcessTime() int64 {
|
|||
}
|
||||
|
||||
func getRuntime() string {
|
||||
s := os.Getenv("QSTAR_SERVER_RUNTIME")
|
||||
logger2.Logger.Infof("QSTAR_SERVER_RUNTIME--------- [%v]", s)
|
||||
if s == "" {
|
||||
logger2.Logger.Info("Please set environment variable QSTAR_SERVER_RUNTIME, " +
|
||||
"now temporarily use QSTAR_SERVER_RUNTIME=Default.")
|
||||
s := os.Getenv("SERVER_RUNTIME")
|
||||
s = config.GetString("runtime")
|
||||
} else {
|
||||
logger2.Logger.Infof("Use QSTAR_SERVER_RUNTIME=%s", s)
|
||||
}
|
||||
return strings.ToLower(s)
|
||||
}
|
||||
|
||||
func getCluster() string {
|
||||
return os.Getenv("qstar_server_CLUSTER")
|
||||
return os.Getenv("server_CLUSTER")
|
||||
}
|
||||
|
||||
func getInstance() string {
|
||||
return os.Getenv("qstar_server_INSTANCE")
|
||||
return os.Getenv("server_INSTANCE")
|
||||
}
|
||||
|
||||
func getExecutableDirectory() string {
|
||||
|
@ -222,65 +205,12 @@ func getProjectDirectory() string {
|
|||
func getConfigDirectory() string {
|
||||
return filepath.Join(ProjectDirectory, "resource/config")
|
||||
}
|
||||
func InitGeneric() {
|
||||
config.ReadBinary(func() []string {
|
||||
var assetNames = make([]string, 0)
|
||||
for _, assetName := range resource.AssetNames() {
|
||||
if strings.HasPrefix(assetName, "resource/config/generic") {
|
||||
assetNames = append(assetNames, assetName)
|
||||
}
|
||||
}
|
||||
sort.Strings(assetNames)
|
||||
return assetNames
|
||||
}, resource.Asset)
|
||||
}
|
||||
func getConfig() *config.Config {
|
||||
config.SetRuntimeEnv(Runtime).ReadBinary(func() []string {
|
||||
var assetNames = make([]string, 0)
|
||||
for _, assetName := range resource.AssetNames() {
|
||||
/*if strings.HasPrefix(assetName, "resource/config/generic") {
|
||||
assetNames = append(assetNames, assetName)
|
||||
} else*/if strings.HasPrefix(assetName, "resource/config/runtime/"+Runtime) {
|
||||
assetNames = append(assetNames, assetName)
|
||||
}
|
||||
}
|
||||
sort.Strings(assetNames)
|
||||
return assetNames
|
||||
}, resource.Asset)
|
||||
|
||||
config.Default().AutomaticEnv()
|
||||
config.Default().SetEnvPrefix("qstar_server")
|
||||
config.Default().SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||
config.Default().AutoParse(1)
|
||||
|
||||
return config.Default()
|
||||
}
|
||||
|
||||
func getTimex() *timex.Timex {
|
||||
tm := timex.Init(config.JSON("timex"))
|
||||
dogfish.LocateAt(timex.TimeLocation())
|
||||
return tm
|
||||
}
|
||||
func getLogger() *logrus.Logger {
|
||||
logger, err := logger.New(config.Parse(config.JSON("logger.default")))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
//log.Use(logger)
|
||||
return logger
|
||||
}
|
||||
func getMock() bool {
|
||||
s := os.Getenv("qstar_server_MOCK")
|
||||
logger2.Logger.Infof("qstar_server_MOCK--------- [%v]", s)
|
||||
if s != "" {
|
||||
if s == "true" {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return config.GetBool("mock")
|
||||
}
|
||||
//func getTimex() *timex.Timex {
|
||||
// tm := timex.Init(config.JSON("timex"))
|
||||
// dogfish.LocateAt(timex.TimeLocation())
|
||||
// return tm
|
||||
//}
|
||||
|
||||
func getHTTPClient() *httpx.Client {
|
||||
c := httpx.NewClient(httpx.ClientConfig{
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package global_test
|
||||
|
||||
import (
|
||||
"qstar_server/internal/generic/global"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestVars(t *testing.T) {
|
||||
t.Log(global.Runtime)
|
||||
t.Log(global.ExecutableDirectory)
|
||||
t.Log(global.WorkingDirectory)
|
||||
t.Log(global.ProjectDirectory)
|
||||
t.Log(global.ConfigDirectory)
|
||||
t.Log(global.HTTPClient)
|
||||
t.Log(global.Mock)
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
package global
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/idealeak/goserver/core/logger"
|
||||
"github.com/tomas-qstarrs/redimo"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/ddb"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var GlobalMgrSington = &GlobalMgr{
|
||||
globalUUID: make(map[string]uint64),
|
||||
}
|
||||
var rwMu sync.RWMutex
|
||||
|
||||
const (
|
||||
GLOBAL_PLAYERUUID = "GLOBAL:PLAYERUUID"
|
||||
)
|
||||
|
||||
type GlobalMgr struct {
|
||||
*redimo.Client
|
||||
globalUUID map[string]uint64
|
||||
dirty bool
|
||||
}
|
||||
|
||||
func (r *GlobalMgr) ModuleName() string {
|
||||
return "GlobalMgr"
|
||||
}
|
||||
func (r *GlobalMgr) getKey(key string) string {
|
||||
return fmt.Sprintf("%s:%s:%s", Project, Game, key)
|
||||
}
|
||||
func (r *GlobalMgr) Init() {
|
||||
r.Client = ddb.RedimoClient()
|
||||
|
||||
key := r.getKey(GLOBAL_PLAYERUUID)
|
||||
val, err := r.GET(key)
|
||||
if err != nil {
|
||||
logger.Logger.Warnf("GlobalMgr Init err: %v", err)
|
||||
//这里表示表不存在,不影响后续执行
|
||||
//return
|
||||
}
|
||||
oldUid := val.Int()
|
||||
if oldUid == 0 {
|
||||
r.globalUUID[key] = 1000000000
|
||||
r.dirty = true
|
||||
} else {
|
||||
r.globalUUID[key] = uint64(oldUid)
|
||||
}
|
||||
}
|
||||
func (r *GlobalMgr) GetUUID() uint64 {
|
||||
rwMu.Lock()
|
||||
defer rwMu.Unlock()
|
||||
key := r.getKey(GLOBAL_PLAYERUUID)
|
||||
r.globalUUID[key]++
|
||||
r.dirty = true
|
||||
newUid := r.globalUUID[key]
|
||||
_, err := r.SET(key, newUid)
|
||||
if err != nil {
|
||||
logger.Logger.Warnf("GlobalMgr GetUUID err: %v", err)
|
||||
}
|
||||
return newUid
|
||||
}
|
||||
func (r *GlobalMgr) saveUUID() {
|
||||
if r.dirty {
|
||||
r.dirty = false
|
||||
key := r.getKey(GLOBAL_PLAYERUUID)
|
||||
if oldUid, ok := r.globalUUID[key]; ok {
|
||||
_, err := r.SET(key, oldUid)
|
||||
if err != nil {
|
||||
r.dirty = true
|
||||
logger.Logger.Errorf("GlobalMgr SET redimoClient error: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
func (r *GlobalMgr) Update() {
|
||||
//r.saveUUID()
|
||||
}
|
||||
func (r *GlobalMgr) Shutdown() {
|
||||
//logger.Logger.Infof("===== saveData ======== [%v] Shutdown", r.ModuleName())
|
||||
//r.saveUUID()
|
||||
}
|
||||
|
||||
func init() {
|
||||
module.RegisteModule(GlobalMgrSington, time.Hour, 0)
|
||||
}
|
|
@ -40,3 +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,
|
||||
}
|
||||
|
|
|
@ -2,13 +2,12 @@ package player
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"qstar_server/internal/dao/thinkingdata"
|
||||
"qstar_server/internal/generic/global"
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/internal/module/shared"
|
||||
"strings"
|
||||
|
||||
"github.com/tomas-qstarrs/boost/cast"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/dao/thinkingdata"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/global"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (b *Bet) Clear() {
|
||||
|
|
|
@ -2,10 +2,10 @@ package player
|
|||
|
||||
import (
|
||||
"github.com/tomas-qstarrs/boost/timex"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/dao/thinkingdata"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/session"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
"sync"
|
||||
)
|
||||
|
@ -28,7 +28,7 @@ func (c *coinCenter) Get(v any) CoinCart {
|
|||
}
|
||||
|
||||
// Dec 下注 必须在线
|
||||
func (c *coinCenter) Dec(s *session.Session, game *shared.Game, reason key.Reason, decCoin DecCoin) {
|
||||
func (c *coinCenter) Dec(s *base.SlotsSession, game *shared.Game, reason key.Reason, decCoin DecCoin) {
|
||||
p := Get(s)
|
||||
if p.GM.LockCoin.Get() {
|
||||
return
|
||||
|
@ -53,7 +53,7 @@ func (c *coinCenter) Dec(s *session.Session, game *shared.Game, reason key.Reaso
|
|||
}
|
||||
|
||||
// Inc 结算 必须在线
|
||||
func (c *coinCenter) Inc(s *session.Session, game *shared.Game, reason key.Reason, incCoin IncCoin) {
|
||||
func (c *coinCenter) Inc(s *base.SlotsSession, game *shared.Game, reason key.Reason, incCoin IncCoin) {
|
||||
p := Get(s)
|
||||
if p.GM.LockCoin.Get() {
|
||||
return
|
||||
|
@ -76,12 +76,12 @@ func (c *coinCenter) Inc(s *session.Session, game *shared.Game, reason key.Reaso
|
|||
|
||||
c.commit(s, c.fetch(s).inc(incCoin))
|
||||
}
|
||||
func (c *coinCenter) Reset(s *session.Session, coinCart CoinCart) {
|
||||
func (c *coinCenter) Reset(s *base.SlotsSession, coinCart CoinCart) {
|
||||
rp := Get(s)
|
||||
rp.Book.Coin.Set(coinCart.Coin)
|
||||
c.commit(s, c.fetch(s))
|
||||
}
|
||||
func (c *coinCenter) Sync(s *session.Session) {
|
||||
func (c *coinCenter) Sync(s *base.SlotsSession) {
|
||||
c.commit(s, c.fetch(s))
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ func (c *coinCenter) fetch(v any) CoinCart {
|
|||
panic(errors.CoinBagNotFound.Error())
|
||||
}
|
||||
return vv.(CoinCart)
|
||||
case *session.Session:
|
||||
case *base.SlotsSession:
|
||||
s := v
|
||||
rp := Get(s)
|
||||
return CoinCart{
|
||||
|
@ -106,7 +106,7 @@ func (c *coinCenter) fetch(v any) CoinCart {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *coinCenter) commit(s *session.Session, cb CoinCart) {
|
||||
func (c *coinCenter) commit(s *base.SlotsSession, cb CoinCart) {
|
||||
rp := Get(s)
|
||||
rp.Book.Coin.Set(cb.Coin)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package player
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/session"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shell"
|
||||
)
|
||||
|
||||
|
@ -13,7 +13,7 @@ func DataSetName() string {
|
|||
return "Player"
|
||||
}
|
||||
|
||||
func DataSet(s *session.Session) *dataSet {
|
||||
func DataSet(s *base.SlotsSession) *dataSet {
|
||||
return &dataSet{
|
||||
Shell: shell.Session(s, DataSetName(), CategoryName(s)),
|
||||
}
|
||||
|
|
|
@ -1,217 +0,0 @@
|
|||
package player
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/tomas-qstarrs/boost/cast"
|
||||
"github.com/tomas-qstarrs/boost/mathx"
|
||||
"github.com/tomas-qstarrs/boost/mjson"
|
||||
"github.com/tomas-qstarrs/boost/timex"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/ddb"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/global"
|
||||
)
|
||||
|
||||
type DB struct {
|
||||
}
|
||||
|
||||
var db DB
|
||||
|
||||
func (db DB) PushPlayer(uid uint64, data map[string]string) {
|
||||
if len(data) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
c := ddb.RedimoClient()
|
||||
if err := c.HMSET(global.DDB.GamePlayer(uid), data); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (db DB) PullPlayer(uid uint64) map[string]string {
|
||||
c := ddb.RedimoClient()
|
||||
var (
|
||||
err error
|
||||
playerMap = make(map[string]string)
|
||||
rocksMap = make(map[string]string)
|
||||
gameMap = make(map[string]string)
|
||||
)
|
||||
|
||||
// Get game map
|
||||
gameValMap, err := c.HGETALL(global.DDB.GamePlayer(uid))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for k, v := range gameValMap {
|
||||
gameMap[k] = v.String()
|
||||
}
|
||||
|
||||
// Merge
|
||||
mergeFields := []string{
|
||||
"Char.TagHub",
|
||||
}
|
||||
mergeField := func(m map[string]string, k string, v string) {
|
||||
if mathx.In(k, mergeFields) {
|
||||
srcData := []byte(m[k])
|
||||
dstData := []byte(v)
|
||||
if json.Valid(srcData) && json.Valid(dstData) {
|
||||
srcData, err := mjson.Merge(srcData, dstData)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
m[k] = string(srcData)
|
||||
return
|
||||
}
|
||||
}
|
||||
m[k] = v
|
||||
}
|
||||
|
||||
// merge game map
|
||||
for k, v := range gameMap {
|
||||
mergeField(playerMap, k, v)
|
||||
}
|
||||
|
||||
// merge rocks map
|
||||
for k, v := range rocksMap {
|
||||
mergeField(playerMap, k, v)
|
||||
}
|
||||
|
||||
return playerMap
|
||||
}
|
||||
|
||||
// 按key存储
|
||||
func (db DB) SaveHashTarget(k, f, v string) {
|
||||
value := make(map[string]interface{})
|
||||
value[f] = v
|
||||
c := ddb.RedimoClient()
|
||||
_, err := c.HSET(k, value)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// 按key获取
|
||||
func (db DB) GetHashTarget(k, f string) string {
|
||||
c := ddb.RedimoClient()
|
||||
val, err := c.HGET(k, f)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return val.String()
|
||||
}
|
||||
|
||||
// 判断是否存在key
|
||||
func (db DB) Exist(k string) bool {
|
||||
c := ddb.RedimoClient()
|
||||
val, err := c.EXISTS(k)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
func (db DB) QueryPermission(keyType string, keys ...any) bool {
|
||||
var strs []string
|
||||
for _, key := range keys {
|
||||
str := cast.ToString(key)
|
||||
if len(str) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
strs = append(strs, str)
|
||||
}
|
||||
c := ddb.RedimoClient()
|
||||
valMap, err := c.HMGET(keyType, strs...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, val := range valMap {
|
||||
if val.Present() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (db DB) IncrCustomerServiceIDTimes(id int64) {
|
||||
c := ddb.RedimoClient()
|
||||
_, err := c.HINCRBY(global.DDB.SystemCustomerServiceTotal(), cast.ToString(id), 1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
_, err = c.HINCRBY(global.DDB.SystemCustomerServiceDaily(timex.Now().Format("2006-01-02")), cast.ToString(id), 1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (db DB) GetCustomerServiceIDTimes(id int64) (int64, int64) {
|
||||
c := ddb.RedimoClient()
|
||||
total, err := c.HGET(global.DDB.SystemCustomerServiceTotal(), cast.ToString(id))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
daily, err := c.HGET(global.DDB.SystemCustomerServiceDaily(timex.Now().Format("2006-01-02")), cast.ToString(id))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return total.Int(), daily.Int()
|
||||
}
|
||||
|
||||
// incrMailID 获取全局自增id
|
||||
func (db DB) IncrMailID() int64 {
|
||||
c := ddb.RedimoClient()
|
||||
res, err := c.INCR(global.DDB.SystemMailSN())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// 获取list长度
|
||||
func (db DB) LLen(k string) int64 {
|
||||
c := ddb.RedimoClient()
|
||||
l, err := c.LLEN(k)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
// 获取List全部数据
|
||||
func (db DB) LAll(k string) []string {
|
||||
c := ddb.RedimoClient()
|
||||
vs, err := c.LRANGE(k, 0, -1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
var res []string
|
||||
for _, v := range vs {
|
||||
res = append(res, v.String())
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// 移除list 指定数量成员
|
||||
func (db DB) LPop(k string, n int64) {
|
||||
c := ddb.RedimoClient()
|
||||
for n > 0 {
|
||||
_, err := c.LPOP(k)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
n--
|
||||
}
|
||||
}
|
||||
|
||||
// list 新增item
|
||||
func (db DB) RPush(k string, v string) {
|
||||
c := ddb.RedimoClient()
|
||||
_, err := c.RPUSH(k, v)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
|
@ -4,16 +4,15 @@ import (
|
|||
"fmt"
|
||||
"github.com/tomas-qstarrs/boost/dogfish"
|
||||
"github.com/tomas-qstarrs/boost/timex"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/global"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/session"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
)
|
||||
|
||||
// Get gets player from session
|
||||
func Get(s *session.Session) *Player {
|
||||
func Get(s *base.SlotsSession) *Player {
|
||||
if s == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -24,23 +23,26 @@ func Get(s *session.Session) *Player {
|
|||
return v.(*Player)
|
||||
}
|
||||
|
||||
func Set(s *session.Session, p *Player) {
|
||||
func Set(s *base.SlotsSession, p *Player) {
|
||||
s.Set(key.SessionPlayer, p)
|
||||
}
|
||||
func GetOldPlayer(s *session.Session) *Player {
|
||||
|
||||
func PushPlayer(s *base.SlotsSession) map[string]string {
|
||||
p := Get(s)
|
||||
if p == nil {
|
||||
hash := db.PullPlayer(s.UID())
|
||||
if hash == nil {
|
||||
return nil
|
||||
|
||||
Set(s, p)
|
||||
|
||||
hash, err := p.Dump()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
return PullPlayer(s)
|
||||
|
||||
return hash
|
||||
}
|
||||
func PullPlayer(s *session.Session) *Player {
|
||||
func PullPlayer(s *base.SlotsSession, hash map[string]string) *Player {
|
||||
p := Get(s)
|
||||
if p == nil {
|
||||
hash := db.PullPlayer(s.UID())
|
||||
//hash := db.PullPlayer(s.UID())
|
||||
|
||||
// Create a new player from hash strings
|
||||
p = &Player{}
|
||||
|
@ -56,7 +58,7 @@ func PullPlayer(s *session.Session) *Player {
|
|||
|
||||
if s.Bool(key.SessionReloadPlayer) {
|
||||
s.Set(key.SessionReloadPlayer, false)
|
||||
hash := db.PullPlayer(s.UID())
|
||||
//hash := db.PullPlayer(s.UID())
|
||||
|
||||
// Reload old player from hash strings
|
||||
err := p.Load(p, hash)
|
||||
|
@ -69,19 +71,7 @@ func PullPlayer(s *session.Session) *Player {
|
|||
|
||||
return p
|
||||
}
|
||||
|
||||
func PushPlayer(s *session.Session) {
|
||||
p := Get(s)
|
||||
|
||||
hash, err := p.Dump()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
db.PushPlayer(s.UID(), hash)
|
||||
}
|
||||
|
||||
func Init(s *session.Session) {
|
||||
func Init(s *base.SlotsSession) {
|
||||
p := Get(s)
|
||||
if p == nil {
|
||||
panic(errors.UIDInvalid.Error())
|
||||
|
@ -90,7 +80,7 @@ func Init(s *session.Session) {
|
|||
p.Init(s)
|
||||
}
|
||||
|
||||
func (p *Player) Init(s *session.Session) {
|
||||
func (p *Player) Init(s *base.SlotsSession) {
|
||||
if p.UID.Get() == 0 {
|
||||
p.handleCreate(s)
|
||||
}
|
||||
|
@ -101,7 +91,7 @@ func (p *Player) Init(s *session.Session) {
|
|||
|
||||
}
|
||||
|
||||
func (p *Player) handleCreate(s *session.Session) {
|
||||
func (p *Player) handleCreate(s *base.SlotsSession) {
|
||||
uid := s.UID()
|
||||
if uid == 0 {
|
||||
panic(errors.UIDInvalid.Error())
|
||||
|
@ -110,85 +100,24 @@ func (p *Player) handleCreate(s *session.Session) {
|
|||
p.UID.Set(int64(uid))
|
||||
p.Char.CreateTime.Set(timex.Now().Unix())
|
||||
}
|
||||
func (p *Player) MarkBlack(flag int64) {
|
||||
f := p.Cli.Black.Get()
|
||||
f |= flag
|
||||
p.Cli.Black.Set(f)
|
||||
}
|
||||
func (p *Player) UnmarkBlack(flag int64) {
|
||||
f := p.Cli.Black.Get()
|
||||
f &= ^flag
|
||||
p.Cli.Black.Set(f)
|
||||
}
|
||||
func (p *Player) IsMarkBlack(flag int64) bool {
|
||||
if (p.Cli.Black.Get() & flag) != 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
func (p *Player) CheckBlack() bool {
|
||||
for i := key.BlackMin; i <= key.BlackMax; i <<= 1 {
|
||||
if p.IsMarkBlack(i) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
func (p *Player) handleLogin(s *session.Session) {
|
||||
func (p *Player) handleLogin(s *base.SlotsSession) {
|
||||
p.updateCli(s)
|
||||
p.updateChar(s)
|
||||
p.updateOthers(s)
|
||||
}
|
||||
func UpdateToken(s *session.Session, token string) {
|
||||
if token == "" {
|
||||
return
|
||||
}
|
||||
p := Get(s)
|
||||
if p == nil {
|
||||
panic(errors.UIDInvalid.Error())
|
||||
}
|
||||
logger.Logger.Infof("player UpdateToken %v-%v", s.UID(), token)
|
||||
p.Cli.Token.Set(token)
|
||||
}
|
||||
func GetToken(s *session.Session) string {
|
||||
p := Get(s)
|
||||
if p == nil {
|
||||
panic(errors.UIDInvalid.Error())
|
||||
}
|
||||
return p.Cli.Token.Get()
|
||||
}
|
||||
func GetOps(s *session.Session) string {
|
||||
p := Get(s)
|
||||
if p == nil {
|
||||
panic(errors.UIDInvalid.Error())
|
||||
}
|
||||
return p.Cli.Ops.Get()
|
||||
}
|
||||
func GetIp(s *session.Session) string {
|
||||
p := Get(s)
|
||||
if p == nil {
|
||||
panic(errors.UIDInvalid.Error())
|
||||
}
|
||||
return p.Cli.Ip.Get()
|
||||
}
|
||||
func (p *Player) updateCli(s *session.Session) {
|
||||
|
||||
func (p *Player) updateCli(s *base.SlotsSession) {
|
||||
sessionContext := s.Value(key.SessionContext).(*shared.SessionContext)
|
||||
// Cli
|
||||
p.Cli.ThirdName.Set(sessionContext.ThirdName)
|
||||
p.Cli.Language.Set(sessionContext.Language)
|
||||
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.Currency.Set(sessionContext.Currency)
|
||||
p.Cli.TokenThird.Set(sessionContext.TokenThird)
|
||||
p.Cli.PlayerName.Set(sessionContext.PlayerName)
|
||||
p.Cli.Lobby.Set(sessionContext.Lobby)
|
||||
p.Cli.Game.Set(sessionContext.Game)
|
||||
}
|
||||
|
||||
func (p *Player) updateChar(s *session.Session) {
|
||||
func (p *Player) updateChar(s *base.SlotsSession) {
|
||||
DataSet(s).Update()
|
||||
|
||||
p.Char.LastLoginTime.Set(p.Char.LoginTime.Get())
|
||||
|
@ -209,7 +138,7 @@ func (p *Player) updateChar(s *session.Session) {
|
|||
DataSet(s).Update()
|
||||
}
|
||||
|
||||
func (p *Player) updateOthers(s *session.Session) {
|
||||
func (p *Player) updateOthers(s *base.SlotsSession) {
|
||||
if !timex.IsSameDay(p.Char.LoginTime.Get(), p.Char.LastLoginTime.Get()) {
|
||||
p.Agg.SlotsDailyBet.Set(0)
|
||||
p.Agg.SlotsDailyWin.Set(0)
|
||||
|
@ -221,14 +150,7 @@ func (p *Player) GetTheme(theme string) *dogfish.JSON {
|
|||
return (*dogfish.JSON)(p.Field("Slots", theme))
|
||||
}
|
||||
|
||||
func (p *Player) GetCli() *shared.Cli {
|
||||
return &shared.Cli{
|
||||
ThirdName: p.Cli.ThirdName.Get(),
|
||||
Language: p.Cli.Language.Get(),
|
||||
}
|
||||
}
|
||||
|
||||
func GetChar(s *session.Session) *shared.Char {
|
||||
func GetChar(s *base.SlotsSession) *shared.Char {
|
||||
p := Get(s)
|
||||
if p == nil {
|
||||
panic(errors.UIDInvalid.Error())
|
||||
|
@ -253,7 +175,7 @@ func (p *Player) GetChar() *shared.Char {
|
|||
}
|
||||
}
|
||||
|
||||
func GetBook(s *session.Session) *shared.Book {
|
||||
func GetBook(s *base.SlotsSession) *shared.Book {
|
||||
p := Get(s)
|
||||
if p == nil {
|
||||
panic(errors.UIDInvalid.Error())
|
||||
|
@ -281,11 +203,7 @@ func (p *Player) Coin() int64 {
|
|||
return p.Book.Coin.Get()
|
||||
}
|
||||
|
||||
func (p *Player) QueryPermission(keyType string, info ...any) bool {
|
||||
return db.QueryPermission(keyType, info...)
|
||||
}
|
||||
|
||||
func CategoryName(s *session.Session) string {
|
||||
func CategoryName(s *base.SlotsSession) string {
|
||||
p := Get(s)
|
||||
if p == nil {
|
||||
return key.Base
|
||||
|
@ -297,7 +215,7 @@ func (p *Player) CategoryName() string {
|
|||
return p.Char.Category.Get()
|
||||
}
|
||||
|
||||
func BetWin(s *session.Session, betCoin DecCoin, winCoin IncCoin) {
|
||||
func BetWin(s *base.SlotsSession, betCoin DecCoin, winCoin IncCoin) {
|
||||
p := Get(s)
|
||||
if p == nil {
|
||||
panic(errors.UIDInvalid.Error())
|
||||
|
@ -305,7 +223,7 @@ func BetWin(s *session.Session, betCoin DecCoin, winCoin IncCoin) {
|
|||
p.BetWin(s, betCoin, winCoin)
|
||||
}
|
||||
|
||||
func (p *Player) BetWin(s *session.Session, betCoin DecCoin, winCoin IncCoin) {
|
||||
func (p *Player) BetWin(s *base.SlotsSession, betCoin DecCoin, winCoin IncCoin) {
|
||||
if betCoin.GetCoin() > 0 {
|
||||
//总统计
|
||||
p.Agg.BetSum.Set(p.Agg.BetSum.Get() + betCoin.GetCoin())
|
||||
|
|
|
@ -9,18 +9,10 @@ type (
|
|||
Root
|
||||
UID Int64
|
||||
Cli struct {
|
||||
ThirdName String
|
||||
Language String
|
||||
Ops String
|
||||
IsSimulator Bool
|
||||
Token String
|
||||
Ip String
|
||||
Currency String
|
||||
TokenThird String
|
||||
PlayerName String
|
||||
Lobby String
|
||||
Game String
|
||||
Black Int64
|
||||
LastBetId JSON
|
||||
}
|
||||
Char struct {
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
package player
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/go-redis/redis"
|
||||
"github.com/tomas-qstarrs/redimo"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/ddb"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
var PlayerMgrSington = &PlayerMgr{
|
||||
Client: ddb.RedimoClient(),
|
||||
}
|
||||
|
||||
const (
|
||||
PLAYER_INFO = "PLAYERINFO[%v-%v]"
|
||||
)
|
||||
|
||||
type PlayerMgr struct {
|
||||
*redimo.Client
|
||||
Redis *redis.Client
|
||||
}
|
||||
|
||||
func (p *PlayerMgr) ModuleName() string {
|
||||
return "PlayerMgr"
|
||||
}
|
||||
func (p *PlayerMgr) Init() {
|
||||
p.Redis = global.RedisClient
|
||||
}
|
||||
func (p *PlayerMgr) getKey(tn string) string {
|
||||
return fmt.Sprintf("%v.%v.Platform[%v]", global.Project, global.Game, tn)
|
||||
}
|
||||
func (p *PlayerMgr) GetPlayerUid(tn, ops string) uint64 {
|
||||
val, err := p.HGET(p.getKey(tn), ops)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("get player info error: %v", err)
|
||||
return 0
|
||||
}
|
||||
return uint64(val.Int())
|
||||
}
|
||||
func (p *PlayerMgr) SetPlayer(tn, ops string, uid uint64) bool {
|
||||
_, err := p.HSETNX(p.getKey(tn), ops, redimo.IntValue{I: int64(uid)})
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("set player err:%v", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (p *PlayerMgr) Update() {
|
||||
|
||||
}
|
||||
|
||||
func (p *PlayerMgr) Shutdown() {
|
||||
|
||||
}
|
||||
func init() {
|
||||
module.RegisteModule(PlayerMgrSington, time.Hour, 0)
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package shell
|
||||
|
||||
import "sync"
|
||||
|
||||
type MonoShell struct {
|
||||
sync.Map
|
||||
}
|
||||
|
||||
var monoShell = &MonoShell{}
|
||||
|
||||
func Mono(name string) *Shell {
|
||||
v, ok := monoShell.Load(name)
|
||||
if ok {
|
||||
return v.(*Shell)
|
||||
}
|
||||
|
||||
shell := Base()
|
||||
monoShell.Store(name, shell)
|
||||
return shell
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package shell
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/session"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func Session(s *session.Session, key string, category string) *Shell {
|
||||
func Session(s *base.SlotsSession, key string, category string) *Shell {
|
||||
var m *sync.Map
|
||||
v := s.Value(key)
|
||||
if v == nil {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package slots
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/player"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/session"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shell"
|
||||
)
|
||||
|
||||
|
@ -10,7 +10,7 @@ type dataSet struct {
|
|||
*shell.Shell
|
||||
}
|
||||
|
||||
func DataSet(s *session.Session) *dataSet {
|
||||
func DataSet(s *base.SlotsSession) *dataSet {
|
||||
return &dataSet{
|
||||
Shell: shell.Session(s, ServiceName(), player.CategoryName(s)),
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package entity
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
)
|
||||
|
||||
// CheatFormations replaces formation's symbols when its length is valid
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
package entity
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/ddb"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/global"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DB struct{}
|
||||
|
||||
var db DB
|
||||
|
||||
func (DB) GetCheatData(uid int64, theme string) map[string]interface{} {
|
||||
c := ddb.RedimoClient()
|
||||
|
||||
result, err := c.HGETALL(global.DDB.CheatSlots(uid))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
data := make(map[string]interface{})
|
||||
for key, value := range result {
|
||||
index := strings.Index(key, theme)
|
||||
if index != 0 {
|
||||
continue
|
||||
}
|
||||
dataKey := key[len(theme)+1:]
|
||||
if value.Present() {
|
||||
data[dataKey] = value.Interface()
|
||||
}
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package entity
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/player"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/session"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shell"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/desc"
|
||||
|
@ -20,7 +20,7 @@ type Entity struct {
|
|||
NextNodeDesc *desc.NodeDesc
|
||||
NodeTree *shared.NodeTree
|
||||
OriginFormations []*formation.Formation // for storing origin formation.Formation
|
||||
Session *session.Session
|
||||
Session *base.SlotsSession
|
||||
Player *player.Player
|
||||
Customs map[int64]interface{}
|
||||
Callback intf.Callback
|
||||
|
@ -30,7 +30,7 @@ type Entity struct {
|
|||
}
|
||||
|
||||
// NewEntity creates a new entity
|
||||
func NewEntity(s *session.Session, theme string, callback intf.Callback, shell *shell.Shell, isFree bool) *Entity {
|
||||
func NewEntity(s *base.SlotsSession, theme string, callback intf.Callback, shell *shell.Shell, isFree bool) *Entity {
|
||||
return &Entity{
|
||||
Theme: theme,
|
||||
Shell: shell,
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"math/rand"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
)
|
||||
|
||||
type RandState struct {
|
||||
|
|
|
@ -2,18 +2,26 @@ package slots
|
|||
|
||||
import (
|
||||
"github.com/idealeak/goserver/core/logger"
|
||||
_struct "mongo.games.com/game/gamesrv/slotspkg/internal/dao/struct"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/global"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/player"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/session"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/machine"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/types/cli"
|
||||
)
|
||||
|
||||
func (sm *SlotsMgr) Enter(s *session.Session, 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 {
|
||||
gameId = gid
|
||||
} else {
|
||||
logger.Logger.Error("[slotsMgr.Enter] gameId not exist")
|
||||
return nil, errors.New("gameId not exist")
|
||||
}
|
||||
|
||||
player.Init(s)
|
||||
|
||||
theme := key.GameMap[uint(gameId)]
|
||||
|
||||
m := machine.NewMachine(s, theme, DataSet(s).Shell, false)
|
||||
|
@ -38,11 +46,20 @@ func (sm *SlotsMgr) Enter(s *session.Session, gameId int64) (*cli.SlotsEnterResp
|
|||
BetLines: m.BetLines(),
|
||||
BetChangeList: m.BetChangeList(),
|
||||
}
|
||||
|
||||
player.PushPlayer(s)
|
||||
|
||||
return Response, nil
|
||||
}
|
||||
|
||||
func (sm *SlotsMgr) Play(uid uint64, req *_struct.SpinReq) (*cli.SlotsPlayResponse, error) {
|
||||
s := sm.GetSession(uid)
|
||||
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
|
||||
} else {
|
||||
logger.Logger.Error("[slotsMgr.play] gameId not exist")
|
||||
return nil, errors.New("gameId not exist")
|
||||
}
|
||||
//s := sm.GetSession(uid)
|
||||
if s == nil {
|
||||
logger.Logger.Error("[slotsMgr.play] session is nil")
|
||||
return nil, errors.New("session is nil")
|
||||
|
@ -102,12 +119,18 @@ func (sm *SlotsMgr) Play(uid uint64, req *_struct.SpinReq) (*cli.SlotsPlayRespon
|
|||
Coin: player.CoinCenter.Get(s).GetCoin(),
|
||||
IsEnd: m.Next().GetType() == key.BaseSpin,
|
||||
}
|
||||
//if !global.Mock {
|
||||
// defer player.PushPlayer(s)
|
||||
//}
|
||||
if !global.Mock {
|
||||
defer player.PushPlayer(s)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
func (*SlotsMgr) Leave(s *session.Session) (*cli.SlotsLeaveResponse, error) {
|
||||
func (*SlotsMgr) PushPlayer(s *base.SlotsSession) map[string]string {
|
||||
return player.PushPlayer(s)
|
||||
}
|
||||
func (*SlotsMgr) PullPlayer(s *base.SlotsSession, data map[string]string) {
|
||||
player.PullPlayer(s, data)
|
||||
}
|
||||
func (*SlotsMgr) Leave(s *base.SlotsSession) (*cli.SlotsLeaveResponse, error) {
|
||||
|
||||
m := machine.NewMachine(s, "s.Theme", DataSet(s).Shell, false)
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package machine
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/player"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/session"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shell"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/entity"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
|
@ -16,7 +16,7 @@ type Machine struct {
|
|||
}
|
||||
|
||||
// NewMachine creates a new machine with Spinner interface
|
||||
func NewMachine(s *session.Session, theme string, shell *shell.Shell, isFree bool) intf.Spinner {
|
||||
func NewMachine(s *base.SlotsSession, theme string, shell *shell.Shell, isFree bool) intf.Spinner {
|
||||
p := player.Get(s)
|
||||
if theme == "" {
|
||||
panic(errors.LeakTheme.ErrorWith(p.UID.Get()))
|
||||
|
|
|
@ -5,14 +5,14 @@ import (
|
|||
"github.com/tomas-qstarrs/boost/randx"
|
||||
"math"
|
||||
"math/rand"
|
||||
"mongo.games.com/game/gamesrv/base"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/session"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/machine"
|
||||
)
|
||||
|
||||
func PlayAsRecorder(s *session.Session, betSizeIndex, betLevelIndex, betLineIndex int64) (r *shared.RecorderResult) {
|
||||
func PlayAsRecorder(s *base.SlotsSession, betSizeIndex, betLevelIndex, betLineIndex int64) (r *shared.RecorderResult) {
|
||||
r = &shared.RecorderResult{}
|
||||
|
||||
var m intf.Spinner
|
||||
|
@ -76,7 +76,7 @@ func PlayAsRecorder(s *session.Session, betSizeIndex, betLevelIndex, betLineInde
|
|||
update()
|
||||
return
|
||||
}
|
||||
func NewPlayAsRecorder(s *session.Session) (r *shared.RecorderResult) {
|
||||
func NewPlayAsRecorder(s *base.SlotsSession) (r *shared.RecorderResult) {
|
||||
r = &shared.RecorderResult{}
|
||||
r.VectorIndex = 0
|
||||
r.Vector = []int64{rand.NewSource(randx.Int63n(math.MaxInt64)).Int63()}
|
||||
|
|
|
@ -2,10 +2,10 @@ package fortunemouse
|
|||
|
||||
import (
|
||||
"github.com/tomas-qstarrs/boost/randx"
|
||||
"qstar_server/internal/exported/excel2go/structs"
|
||||
"qstar_server/internal/generic/errors"
|
||||
"qstar_server/service/slots/desc"
|
||||
"qstar_server/service/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/exported/excel2go/structs"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/desc"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
)
|
||||
|
||||
type descx struct {
|
||||
|
|
|
@ -2,9 +2,9 @@ package fortunemouse
|
|||
|
||||
import (
|
||||
"github.com/tomas-qstarrs/boost/mathx"
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
)
|
||||
|
||||
type CustomSuperStack struct {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package fortunemouse
|
||||
|
||||
import (
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
)
|
||||
|
||||
type PluginSpecial struct {
|
||||
|
|
|
@ -2,9 +2,9 @@ package fortuneox
|
|||
|
||||
import (
|
||||
"github.com/tomas-qstarrs/boost/randx"
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
)
|
||||
|
||||
type PluginBase struct {
|
||||
|
|
|
@ -2,10 +2,10 @@ package fortuneox
|
|||
|
||||
import (
|
||||
"github.com/tomas-qstarrs/boost/randx"
|
||||
"qstar_server/internal/exported/excel2go/structs"
|
||||
"qstar_server/internal/generic/errors"
|
||||
"qstar_server/service/slots/desc"
|
||||
"qstar_server/service/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/exported/excel2go/structs"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/desc"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
)
|
||||
|
||||
type descx struct {
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"github.com/tomas-qstarrs/boost/mathx"
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
)
|
||||
|
||||
// PluginSimulator is derived from generic.PluginBase
|
||||
|
|
|
@ -2,9 +2,9 @@ package fortuneox
|
|||
|
||||
import (
|
||||
"github.com/tomas-qstarrs/boost/mathx"
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
)
|
||||
|
||||
type CustomSuperStack struct {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package fortuneox
|
||||
|
||||
import (
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
)
|
||||
|
||||
type PluginSpecial struct {
|
||||
|
|
|
@ -2,11 +2,11 @@ package fortunerabbit
|
|||
|
||||
import (
|
||||
"github.com/tomas-qstarrs/boost/randx"
|
||||
"qstar_server/internal/exported/excel2go/structs"
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"qstar_server/service/slots/types/cli"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/exported/excel2go/structs"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/types/cli"
|
||||
)
|
||||
|
||||
type PluginBase struct {
|
||||
|
|
|
@ -2,10 +2,10 @@ package fortunerabbit
|
|||
|
||||
import (
|
||||
"github.com/tomas-qstarrs/boost/randx"
|
||||
"qstar_server/internal/exported/excel2go/structs"
|
||||
"qstar_server/internal/generic/errors"
|
||||
"qstar_server/service/slots/desc"
|
||||
"qstar_server/service/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/exported/excel2go/structs"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/desc"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
)
|
||||
|
||||
type descx struct {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package fortunerabbit
|
||||
|
||||
import (
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
)
|
||||
|
||||
type PluginSpecial struct {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package fortunetiger
|
||||
|
||||
import (
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"qstar_server/service/slots/types/cli"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/types/cli"
|
||||
)
|
||||
|
||||
type PluginBase struct {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package fortunetiger
|
||||
|
||||
import "qstar_server/service/slots/intf"
|
||||
import "mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
|
||||
// 图标
|
||||
const (
|
||||
|
|
|
@ -2,10 +2,10 @@ package fortunetiger
|
|||
|
||||
import (
|
||||
"github.com/tomas-qstarrs/boost/randx"
|
||||
"qstar_server/internal/exported/excel2go/structs"
|
||||
"qstar_server/internal/generic/errors"
|
||||
"qstar_server/service/slots/desc"
|
||||
"qstar_server/service/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/exported/excel2go/structs"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/desc"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
)
|
||||
|
||||
type descx struct {
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"github.com/tomas-qstarrs/boost/mathx"
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
)
|
||||
|
||||
// PluginSimulator is derived from generic.PluginBase
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package fortunetiger
|
||||
|
||||
import (
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"qstar_server/service/slots/types/cli"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/types/cli"
|
||||
)
|
||||
|
||||
type PluginSpecialRespin struct {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package fortunetiger
|
||||
|
||||
import (
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
)
|
||||
|
||||
type PluginSpecial struct {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package generic
|
||||
|
||||
import (
|
||||
"qstar_server/service/slots/intf"
|
||||
)
|
||||
import "mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
|
||||
// PluginBase implements a default plugin for Plugin.
|
||||
type PluginBase struct{}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package generic
|
||||
|
||||
import (
|
||||
"qstar_server/service/slots/desc"
|
||||
"qstar_server/service/slots/intf"
|
||||
|
||||
"github.com/tomas-qstarrs/boost/randx"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/desc"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
)
|
||||
|
||||
type descx struct {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package generic
|
||||
|
||||
import (
|
||||
"qstar_server/internal/exported/excel2go/structs"
|
||||
"qstar_server/internal/generic/errors"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/exported/excel2go/structs"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
)
|
||||
|
||||
func (n descx) JackpotBaseWin(typ int64, bet int64) int64 {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package generic
|
||||
|
||||
import (
|
||||
"qstar_server/internal/exported/excel2go/structs"
|
||||
"qstar_server/internal/generic/errors"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/exported/excel2go/structs"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -2,11 +2,9 @@ package generic
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"qstar_server/internal/exported/excel2go/structs"
|
||||
"qstar_server/internal/generic/errors"
|
||||
|
||||
"github.com/tomas-qstarrs/boost/randx"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/exported/excel2go/structs"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
)
|
||||
|
||||
func (n descx) SuperStackSymbol(status string) int64 {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package generic
|
||||
|
||||
import (
|
||||
"qstar_server/service/slots/intf"
|
||||
)
|
||||
import "mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
|
||||
// PluginJackpot is derived from generic.PluginBase
|
||||
type PluginJackpot struct {
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package generic
|
||||
|
||||
import (
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
|
||||
"github.com/tomas-qstarrs/boost/mathx"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
)
|
||||
|
||||
// PluginScatter is derived from generic.PluginBase
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package generic
|
||||
|
||||
import (
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
|
||||
"github.com/tomas-qstarrs/boost/mathx"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"qstar_server/internal/generic/global"
|
||||
"qstar_server/service/slots/plugin/cashmania"
|
||||
"qstar_server/service/slots/plugin/fortunedragon"
|
||||
"qstar_server/service/slots/plugin/fortunemouse"
|
||||
"qstar_server/service/slots/plugin/fortuneox"
|
||||
"qstar_server/service/slots/plugin/fortunerabbit"
|
||||
"qstar_server/service/slots/plugin/fortunetiger"
|
||||
"qstar_server/service/slots/plugin/test"
|
||||
"qstar_server/service/slots/reg"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/global"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/cashmania"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/fortunedragon"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/fortunemouse"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/fortuneox"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/fortunerabbit"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/fortunetiger"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/test"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/reg"
|
||||
)
|
||||
|
||||
// Init registers all theme plugins to machine
|
||||
|
|
|
@ -3,10 +3,10 @@ package test
|
|||
import (
|
||||
"github.com/tomas-qstarrs/boost/randx"
|
||||
"math"
|
||||
"qstar_server/internal/exported/excel2go/structs"
|
||||
"qstar_server/internal/generic/key"
|
||||
"qstar_server/service/slots/intf"
|
||||
"qstar_server/service/slots/plugin/generic"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/exported/excel2go/structs"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/key"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin/generic"
|
||||
)
|
||||
|
||||
// PluginBase is derived from generic.PluginBase
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package reg
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"reflect"
|
||||
|
||||
"qstar_server/service/slots/intf"
|
||||
)
|
||||
|
||||
// Plugins stores plugins mapped by theme name
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package reg
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/generic/errors"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
||||
"reflect"
|
||||
|
||||
"qstar_server/internal/generic/errors"
|
||||
"qstar_server/service/slots/intf"
|
||||
)
|
||||
|
||||
// Register register multiple plugins to global map
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package slots
|
||||
|
||||
import (
|
||||
"mongo.games.com/game/gamesrv/slotspkg/internal/module/session"
|
||||
"mongo.games.com/game/gamesrv/slotspkg/slots/plugin"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -20,15 +20,6 @@ func ServiceName() string {
|
|||
func (sm *SlotsMgr) Init() {
|
||||
plugin.Init()
|
||||
}
|
||||
|
||||
func (sm *SlotsMgr) GetSession(uid uint64) *session.Session {
|
||||
s := managermgr.SessionMgrSington.GetSession(uid)
|
||||
return s
|
||||
}
|
||||
func (sm *SlotsMgr) GetSessionSimulator(uid uint64) *session.Session {
|
||||
s := managermgr.SessionMgrSington.GetSessionSimulator(uid)
|
||||
return s
|
||||
}
|
||||
func (sm *SlotsMgr) Update() {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"qstar_server/internal/module/shared"
|
||||
)
|
||||
import "mongo.games.com/game/gamesrv/slotspkg/internal/module/shared"
|
||||
|
||||
type SlotsEnterRequest struct {
|
||||
Theme string
|
||||
|
|
2
public
2
public
|
@ -1 +1 @@
|
|||
Subproject commit d789cca81a36ddbaf30e5414b6c4fe530e0631f6
|
||||
Subproject commit 8b212c07c9d4299fe75cd785dad9cc17b05734cf
|
Loading…
Reference in New Issue