206 lines
5.0 KiB
Go
206 lines
5.0 KiB
Go
package cashmania
|
|
|
|
import (
|
|
"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"
|
|
"mongo.games.com/game/gamesrv/slotspkg/slots/desc"
|
|
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
|
)
|
|
|
|
type descx struct {
|
|
*randx.Randx
|
|
*desc.NodeDesc
|
|
}
|
|
|
|
func Descx(m intf.Master) *descx {
|
|
return &descx{
|
|
Randx: m.Randx(),
|
|
NodeDesc: m.Desc(),
|
|
}
|
|
}
|
|
func (n descx) GetItemInfo() map[int64]*structs.CashManiaItemInfo {
|
|
sheet := n.DefaultSheet("ItemInfo")
|
|
rows, ok := sheet.(map[int64]*structs.CashManiaItemInfo)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "CashMania", "S_ItemInfo"))
|
|
}
|
|
return rows
|
|
}
|
|
|
|
// 判断是否触发respin
|
|
func (n descx) CheckWin(isFreeSpin bool) bool {
|
|
// 读取配置
|
|
sheet := n.DefaultSheet("Others")
|
|
// 转化数据
|
|
rows, ok := sheet.([]*structs.CashManiaOthers)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "CashMania", "Others"))
|
|
}
|
|
|
|
if isFreeSpin {
|
|
return randx.RandPR(n.Randx, rows[0].FreeWinPro)
|
|
} else {
|
|
return randx.RandPR(n.Randx, rows[0].BaseWinPro)
|
|
}
|
|
}
|
|
|
|
// 获取中奖图标id
|
|
func (n descx) GetWinItem(isFreeSpin bool) int64 {
|
|
// 读取配置
|
|
sheet := n.Sheet("WinItem", "Weight")
|
|
// 转化数据
|
|
rows, ok := sheet.([]*structs.CashManiaWinItemWeight)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "CashMania", "WinItem"))
|
|
}
|
|
|
|
weights := make([]float64, 0)
|
|
for _, v := range rows {
|
|
var weight float64
|
|
if isFreeSpin {
|
|
weight = v.FreeWeight
|
|
} else {
|
|
weight = v.BaseWeight
|
|
}
|
|
weights = append(weights, weight)
|
|
}
|
|
index := randx.RandWeight(n.Randx, weights)
|
|
|
|
return rows[index].ItemID
|
|
}
|
|
|
|
func (n descx) RandomItems(isFreeSpin bool, num int) []int64 {
|
|
// 读取配置
|
|
sheet := n.Sheet("RandomItem", "Weight")
|
|
// 转化数据
|
|
rows, ok := sheet.([]*structs.CashManiaRandomItemWeight)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "CashMania", "RandomItem"))
|
|
}
|
|
|
|
weights := make([]float64, 0)
|
|
for _, v := range rows {
|
|
var weight float64
|
|
if isFreeSpin {
|
|
weight = v.FreeWeight
|
|
} else {
|
|
weight = v.BaseWeight
|
|
}
|
|
weights = append(weights, weight)
|
|
}
|
|
var items []int64
|
|
for i := 0; i < num; i++ {
|
|
index := randx.RandWeight(n.Randx, weights)
|
|
items = append(items, rows[index].ItemID)
|
|
}
|
|
return items
|
|
}
|
|
|
|
// 随机图标id
|
|
func (n descx) RandomTwoDifItem(isFreeSpin bool) []int64 {
|
|
// 读取配置
|
|
sheet := n.Sheet("RandomItem", "Weight")
|
|
// 转化数据
|
|
rows, ok := sheet.([]*structs.CashManiaRandomItemWeight)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "CashMania", "RandomItem"))
|
|
}
|
|
|
|
weights := make([]float64, 0)
|
|
for _, v := range rows {
|
|
var weight float64
|
|
if isFreeSpin {
|
|
weight = v.FreeWeight
|
|
} else {
|
|
weight = v.BaseWeight
|
|
}
|
|
weights = append(weights, weight)
|
|
}
|
|
indices := randx.RandShuffleWeights(n.Randx, 2, weights)
|
|
var vals = make([]int64, len(indices))
|
|
for i, v := range indices {
|
|
vals[i] = rows[v].ItemID
|
|
}
|
|
return vals
|
|
}
|
|
func (n descx) GetWinMidItem(isFreeSpin bool) int64 {
|
|
// 读取配置
|
|
sheet := n.Sheet("WinMid", "Weight")
|
|
// 转化数据
|
|
rows, ok := sheet.([]*structs.CashManiaWinMidWeight)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "CashMania", "WinMid"))
|
|
}
|
|
|
|
weights := make([]float64, 0)
|
|
for _, v := range rows {
|
|
var weight float64
|
|
if isFreeSpin {
|
|
weight = v.FreeWeight
|
|
} else {
|
|
weight = v.BaseWeight
|
|
}
|
|
weights = append(weights, weight)
|
|
}
|
|
index := randx.RandWeight(n.Randx, weights)
|
|
|
|
return rows[index].ItemID
|
|
}
|
|
func (n descx) RandomMidItems(isFreeSpin bool, num int) []int64 {
|
|
// 读取配置
|
|
sheet := n.Sheet("RandomMid", "Weight")
|
|
// 转化数据
|
|
rows, ok := sheet.([]*structs.CashManiaRandomMidWeight)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "CashMania", "RandomMid"))
|
|
}
|
|
|
|
weights := make([]float64, 0)
|
|
for _, v := range rows {
|
|
var weight float64
|
|
if isFreeSpin {
|
|
weight = v.FreeWeight
|
|
} else {
|
|
weight = v.BaseWeight
|
|
}
|
|
weights = append(weights, weight)
|
|
}
|
|
var items []int64
|
|
for i := 0; i < num; i++ {
|
|
index := randx.RandWeight(n.Randx, weights)
|
|
items = append(items, rows[index].ItemID)
|
|
}
|
|
return items
|
|
}
|
|
func (n descx) GetMidItemInfo(itemId int64) (int64, int64) {
|
|
// 读取配置
|
|
sheet := n.DefaultSheet("MidItemInfo")
|
|
// 转化数据
|
|
rows, ok := sheet.(map[int64]*structs.CashManiaMidItemInfo)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "CashMania", "MidItemInfo"))
|
|
}
|
|
|
|
row, ok := rows[itemId]
|
|
if !ok {
|
|
panic(errors.ConfigKeyNotFound.ErrorWith(n.Theme, "CashMania", itemId))
|
|
}
|
|
|
|
return row.Multi, row.FreeSpinCount
|
|
}
|
|
func (n descx) GetNudgeAndReSpin(isWin bool) (bool, bool) {
|
|
// 读取配置
|
|
sheet := n.DefaultSheet("Others")
|
|
// 转化数据
|
|
rows, ok := sheet.([]*structs.CashManiaOthers)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "CashMania", "Others"))
|
|
}
|
|
if isWin {
|
|
return randx.RandPR(n.Randx, rows[0].WinNudgePro), randx.RandPR(n.Randx, rows[0].WinRespinPro)
|
|
} else {
|
|
return randx.RandPR(n.Randx, rows[0].NoWinNudgePro), randx.RandPR(n.Randx, rows[0].NoWinRespinPro)
|
|
}
|
|
}
|