166 lines
3.6 KiB
Go
166 lines
3.6 KiB
Go
package sugarrush
|
|
|
|
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) GetOtherConfig() *structs.SugarRushOthers {
|
|
v := n.DefaultSheet("Others")
|
|
|
|
values, ok := v.([]*structs.SugarRushOthers)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.Error())
|
|
}
|
|
return values[0]
|
|
}
|
|
|
|
func (n descx) GetMulti(count int64) int64 {
|
|
v := n.DefaultSheet("Multiplier")
|
|
values, ok := v.([]*structs.SugarRushMultiplier)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.Error())
|
|
}
|
|
for _, v := range values {
|
|
if v.MatchTimes == count {
|
|
return v.Multiple
|
|
}
|
|
}
|
|
// return last one
|
|
return values[len(values)-1].Multiple
|
|
}
|
|
|
|
func (n descx) RandScatterCount() int64 {
|
|
v := n.Sheet("BuyFreeScatterShow", "Weight")
|
|
|
|
values, ok := v.([]*structs.SugarRushBuyFreeScatterShowWeight)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.Error())
|
|
}
|
|
|
|
weights := make([]float64, 0)
|
|
for _, v := range values {
|
|
weights = append(weights, v.Weight)
|
|
}
|
|
index := randx.RandWeight(n.Randx, weights)
|
|
|
|
return values[index].ScatterCount
|
|
}
|
|
|
|
func (n descx) RandItemID(topItemID int64, isFree bool, isTop bool) int64 {
|
|
if isFree {
|
|
v := n.Sheet("FreeSymbolShow", "Weight")
|
|
|
|
values, ok := v.([]*structs.SugarRushFreeSymbolShowWeight)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.Error())
|
|
}
|
|
|
|
typeWeights := make([]float64, 0)
|
|
|
|
for _, v := range values {
|
|
if v.ItemID == topItemID {
|
|
if isTop {
|
|
typeWeights = append(typeWeights, v.Weight*float64(n.GetOtherConfig().FallWeightMultiplier))
|
|
} else {
|
|
typeWeights = append(typeWeights, 0)
|
|
}
|
|
} else {
|
|
typeWeights = append(typeWeights, v.Weight)
|
|
}
|
|
}
|
|
|
|
value := randx.RandWeight(n.Randx, typeWeights)
|
|
return values[value].ItemID
|
|
}
|
|
|
|
v := n.Sheet("BaseSymbolShow", "Weight")
|
|
|
|
values, ok := v.([]*structs.SugarRushBaseSymbolShowWeight)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.Error())
|
|
}
|
|
|
|
typeWeights := make([]float64, 0)
|
|
|
|
for _, v := range values {
|
|
if v.ItemID == topItemID {
|
|
if isTop {
|
|
typeWeights = append(typeWeights, v.Weight*float64(n.GetOtherConfig().FallWeightMultiplier))
|
|
} else {
|
|
typeWeights = append(typeWeights, 0)
|
|
}
|
|
} else {
|
|
typeWeights = append(typeWeights, v.Weight)
|
|
}
|
|
}
|
|
|
|
value := randx.RandWeight(n.Randx, typeWeights)
|
|
return values[value].ItemID
|
|
}
|
|
|
|
func (n descx) RandItemCount(itemID int64, left int64, isFree bool) int64 {
|
|
if isFree {
|
|
v := n.Sheet("FreeSymbolShowNumber", "Weight")
|
|
|
|
values, ok := v.([]*structs.SugarRushFreeSymbolShowNumberWeight)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.Error())
|
|
}
|
|
|
|
for _, v := range values {
|
|
if v.ItemID == itemID {
|
|
typeWeights := make([]float64, 0)
|
|
typeWeights = append(typeWeights, v.ShowNumberWeight...)
|
|
|
|
value := randx.RandWeight(n.Randx, typeWeights)
|
|
count := int64(value) + 1
|
|
if count > left {
|
|
return left
|
|
}
|
|
return count
|
|
}
|
|
}
|
|
|
|
return 0
|
|
}
|
|
|
|
v := n.Sheet("BaseSymbolShowNumber", "Weight")
|
|
|
|
values, ok := v.([]*structs.SugarRushBaseSymbolShowNumberWeight)
|
|
if !ok {
|
|
panic(errors.ConfigTypeError.Error())
|
|
}
|
|
|
|
for _, v := range values {
|
|
if v.ItemID == itemID {
|
|
typeWeights := make([]float64, 0)
|
|
typeWeights = append(typeWeights, v.ShowNumberWeight...)
|
|
|
|
value := randx.RandWeight(n.Randx, typeWeights)
|
|
count := int64(value) + 1
|
|
if count > left {
|
|
return left
|
|
}
|
|
return count
|
|
}
|
|
}
|
|
|
|
return 0
|
|
}
|