game_sync/gamesrv/slotspkg/slots/plugin/test/base.go

70 lines
1.7 KiB
Go

package test
import (
"github.com/tomas-qstarrs/boost/randx"
"math"
"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
type PluginBase struct {
generic.PluginBase
}
const (
PrizeTypeNormal = 1
PrizeTypeJackpot = 2
)
// Theme implements generic.PluginBase.Theme
func (p *PluginBase) Theme() string {
return key.Test
}
// Customs implements generic.PluginBase.Customs
func (p *PluginBase) Customs() []interface{} {
return append(p.PluginBase.Customs(),
&Test{})
}
// OnInit implements generic.PluginBase.OnInit
func (p *PluginBase) OnInit(m intf.Master) {
}
// BeforeSpin implements generic.PluginBase.BeforeSpin
func (p *PluginBase) BeforeSpin(m intf.Master) {
}
func (p *PluginBase) BeforeDisplay(m intf.Master) {
}
func (p *PluginBase) AfterDisplay(m intf.Master) {
}
// AfterSpin implements generic.PluginBase.AfterSpin
func (p *PluginBase) AfterSpin(m intf.Master) {
var M float64 = 1.087
var win float64 = 0
TestRandomWeight := m.Desc().Sheet("Random", "Weight").([]*structs.TestRandomWeight)
var weight []float64
for _, randomWeight := range TestRandomWeight {
weight = append(weight, randomWeight.Weight)
}
idx := randx.RandWeight(m.Randx(), weight)
var tx float64 = float64(m.Randx().Intn(500)+1) / 10
if tx <= TestRandomWeight[idx].Time {
win = math.Pow(M, tx) * float64(m.Cursor().GetBet())
}
m.AddCursorFeature(&Test{}).SetWin(int64(win))
}
type Test struct {
}
func (p *PluginBase) OnStepEnd(m intf.Master) {
}