-
Notifications
You must be signed in to change notification settings - Fork 1
/
base.go
71 lines (57 loc) · 1.32 KB
/
base.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package sgc7plugin
import (
sgc7utils "github.com/zhs007/slotsgamecore7/utils"
)
// PluginBase - base
type PluginBase struct {
RngUsed []*sgc7utils.RngInfo
Cache []int
Tag int
ScenePool any
}
// GetUsedRngs - get used rngs
func (bp *PluginBase) GetUsedRngs() []*sgc7utils.RngInfo {
return bp.RngUsed
}
// ClearUsedRngs - clear used rngs
func (bp *PluginBase) ClearUsedRngs() {
bp.Tag = -1
bp.RngUsed = nil
}
// AddRngUsed - added used rngs
func (bp *PluginBase) AddRngUsed(ri *sgc7utils.RngInfo) {
bp.RngUsed = append(bp.RngUsed, ri)
}
// SetCache - set cache
func (bp *PluginBase) SetCache(arr []int) {
bp.Cache = arr
}
// ClearCache - clear cached rngs
func (bp *PluginBase) ClearCache() {
bp.Cache = nil
}
// TagUsedRngs - new a tag for current UsedRngs
func (bp *PluginBase) TagUsedRngs() {
bp.Tag = len(bp.RngUsed)
}
// RollbackUsedRngs - rollback UsedRngs with a tag
func (bp *PluginBase) RollbackUsedRngs() error {
if bp.Tag >= 0 && bp.Tag <= len(bp.RngUsed) {
bp.RngUsed = bp.RngUsed[0:bp.Tag]
return nil
}
return ErrInvalidTag
}
// SetScenePool - set scene pool
func (bp *PluginBase) SetScenePool(pool any) {
bp.ScenePool = pool
}
// GetScenePool - get scene pool
func (bp *PluginBase) GetScenePool() any {
return bp.ScenePool
}
func NewPluginBase() PluginBase {
return PluginBase{
Tag: -1,
}
}