-
Notifications
You must be signed in to change notification settings - Fork 2
/
scan.go
60 lines (48 loc) · 1.28 KB
/
scan.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
package cmd
import (
"context"
"fmt"
cfg "github.com/slotopol/server/config"
"github.com/slotopol/server/config/links"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
var scanflags *pflag.FlagSet
var (
fReels string
)
const scanShort = "Slots reels scanning"
const scanLong = `Calculate RTP (Return to Player) percentage for specified slot game reels.`
const scanExmp = `Scan reels for 'Slotopol' game:
%s scan --slotopol --reels=100`
// scanCmd represents the scan command
var scanCmd = &cobra.Command{
Use: "scan",
Aliases: []string{"calc"},
Short: scanShort,
Long: scanLong,
Example: fmt.Sprintf(scanExmp, cfg.AppName),
RunE: func(cmd *cobra.Command, args []string) (err error) {
var exitctx context.Context
if exitctx, err = Init(); err != nil {
return
}
for _, iter := range links.ScanIters {
iter(scanflags, exitctx)
}
return
},
}
func init() {
rootCmd.AddCommand(scanCmd)
scanflags = scanCmd.Flags()
scanflags.StringVarP(&fReels, "reels", "r", "", "name of reels set to use")
for _, gi := range links.GameList {
for _, ga := range gi.Aliases {
scanflags.Bool(ga.ID, false, fmt.Sprintf("'%s' %s %dx%d videoslot", ga.Name, gi.Provider, gi.ScrnX, gi.ScrnY))
}
}
for _, setter := range links.FlagsSetters {
setter(scanflags)
}
}