91 lines
2.2 KiB
Go
91 lines
2.2 KiB
Go
package generic
|
|
|
|
import (
|
|
"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
|
|
type PluginScatter struct {
|
|
PluginBase
|
|
}
|
|
|
|
// CustomExtraFreeSpin stores extra freespin
|
|
type CustomExtraFreeSpin struct {
|
|
ExtraTimes int64
|
|
}
|
|
|
|
// CustomScatterWin stores scatter win
|
|
type CustomScatterWin struct {
|
|
}
|
|
|
|
// Customs implements generic.PluginBase.Customs
|
|
func (p *PluginScatter) Customs() []interface{} {
|
|
return []interface{}{
|
|
&CustomExtraFreeSpin{},
|
|
&CustomScatterWin{},
|
|
}
|
|
}
|
|
|
|
// AfterBaseSpin is called after base spin
|
|
func (p *PluginScatter) AfterBaseSpin(m intf.Master) {
|
|
addTimes, win := p.GetScatterInfo(m, false)
|
|
if addTimes > 0 {
|
|
m.AddNodeOnCursor(key.FreeSpin, addTimes)
|
|
}
|
|
if win > 0 {
|
|
m.AddCursorFeature(&CustomScatterWin{}).SetWin(win)
|
|
}
|
|
}
|
|
|
|
// AfterSpin implements generic.PluginBase.AfterSpin
|
|
func (p *PluginScatter) AfterSpin(m intf.Master) {
|
|
switch m.Cursor().GetType() {
|
|
case key.BaseSpin:
|
|
p.AfterBaseSpin(m)
|
|
case key.FreeSpin:
|
|
p.AfterFreeSpin(m)
|
|
}
|
|
}
|
|
|
|
// AfterFreeSpin is called after free spin
|
|
func (p *PluginScatter) AfterFreeSpin(m intf.Master) {
|
|
addTimes, win := p.GetScatterInfo(m, true)
|
|
if addTimes > 0 {
|
|
m.AddProgress(addTimes)
|
|
m.AddCursorFeature(&CustomExtraFreeSpin{ExtraTimes: addTimes}).SetLifetime(1)
|
|
}
|
|
if win > 0 {
|
|
m.AddCursorFeature(&CustomScatterWin{}).SetWin(win)
|
|
}
|
|
}
|
|
|
|
// GetScatterInfo gets add free spin times & pay rate
|
|
func (p *PluginScatter) GetScatterInfo(m intf.Master, inFreeSpin bool) (int64, int64) {
|
|
var scatterCount int64
|
|
symbols := m.CursorFormation().GetSymbols()
|
|
scatterSymbols := p.Scatters(m)
|
|
for _, scatterSymbol := range scatterSymbols {
|
|
scatterCount += int64(mathx.Count(scatterSymbol, symbols))
|
|
}
|
|
|
|
if scatterCount == 0 {
|
|
return 0, 0
|
|
}
|
|
|
|
freeSpinCount := Descx(m).FreeSpin(inFreeSpin, scatterCount)
|
|
|
|
payRate := Descx(m).ScatterPayRate(inFreeSpin, scatterCount)
|
|
|
|
win := m.Bet() * payRate
|
|
|
|
return freeSpinCount, win
|
|
}
|
|
|
|
// sscatters sets specific scatter symbols
|
|
// Default is find symbols named Scatter
|
|
func (p *PluginScatter) Scatters(m intf.Master) []int64 {
|
|
return Descx(m).ScatterSymbol()
|
|
}
|