85 lines
2.1 KiB
Go
85 lines
2.1 KiB
Go
package gatesofolympus
|
|
|
|
import (
|
|
"encoding/json"
|
|
"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) RandWheel(isFreeSpin bool, typ int64) string {
|
|
sheet := n.DefaultSheet("ReelChoose")
|
|
rows, ok := sheet.([]*structs.GatesOfOlympusReelChoose)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "ReelChoose"))
|
|
}
|
|
|
|
var weights = make(map[int]int64, 0)
|
|
for idx, row := range rows {
|
|
if row.IsFreeSpin == isFreeSpin {
|
|
weights[idx] = row.Weights[int(typ)]
|
|
}
|
|
}
|
|
|
|
idx := randx.RandWeightMap(n.Randx, weights)
|
|
return rows[idx].NodeType
|
|
}
|
|
|
|
func (n descx) RandMultiplier(typ int64) int64 {
|
|
sheet := n.DefaultSheet("Multiplier")
|
|
rows, ok := sheet.([]*structs.GatesOfOlympusMultiplier)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "Multiplier"))
|
|
}
|
|
|
|
var weights = make([]int64, 0, len(rows))
|
|
for _, row := range rows {
|
|
weights = append(weights, row.Weights[typ])
|
|
}
|
|
|
|
idx := randx.RandWeight(n.Randx, weights)
|
|
return rows[idx].ID
|
|
}
|
|
|
|
func (n descx) GetMultiBySymbol(symbol int64) int64 {
|
|
sheet := n.KeySheet("Multiplier", "Default", "ID")
|
|
rows, ok := sheet.(map[int64]*structs.GatesOfOlympusMultiplier)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "Multiplier"))
|
|
}
|
|
|
|
row, ok := rows[symbol]
|
|
if !ok {
|
|
return 0
|
|
}
|
|
|
|
return row.Multiple
|
|
}
|
|
func (n descx) GetMultiStr() string {
|
|
sheet := n.KeySheet("Multiplier", "Default", "ID")
|
|
rows, ok := sheet.(map[int64]*structs.GatesOfOlympusMultiplier)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.ErrorWith(n.Theme, "Multiplier"))
|
|
}
|
|
var multiples = make(map[int64]int64)
|
|
for _, v := range rows {
|
|
multiples[v.ID] = v.Multiple
|
|
}
|
|
multiplesByte, _ := json.Marshal(multiples)
|
|
return string(multiplesByte)
|
|
}
|