forked from hpbuniat/teamr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
executable file
·111 lines (98 loc) · 2.79 KB
/
main.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package main
import (
"fmt"
"os"
"github.com/urfave/cli"
)
// team represents all necessary attributes of a football-team
type team struct {
name string
league string
att int
mid int
def int
ovr int
stars float32
}
// draw allows the assignment of a team to each player
type draw map[string]team
// replace in build-process
var Version = "???"
// Enter the cli-program
func main() {
var stars float64
var rateMin int
var rateMax int
var national bool
var women bool
var players int
var groups int
var playerFile string
app := cli.NewApp()
app.Version = Version
app.Name = "teamr"
app.Usage = "football-cup team randomizer"
app.Flags = []cli.Flag {
cli.Float64Flag{
Name: "stars, s",
Value: 0,
Usage: "star selection mode",
Destination: &stars,
},
cli.IntFlag{
Name: "min",
Value: 76,
Usage: "min. rating ovr, att, mid, def",
Destination: &rateMin,
},
cli.IntFlag{
Name: "max",
Value: 80,
Usage: "max. rating ovr, att, mid, def",
Destination: &rateMax,
},
cli.IntFlag{
Name: "players, p",
Value: 8,
Usage: "number of players",
Destination: &players,
},
cli.IntFlag{
Name: "groups, g",
Value: 2,
Usage: "number of groups",
Destination: &groups,
},
cli.StringFlag{
Name: "playerfile, f",
Value: "",
Usage: "read players from file",
Destination: &playerFile,
},
cli.BoolFlag{
Name: "nation, n",
Usage: "only national teams",
Destination: &national,
},
cli.BoolFlag{
Name: "women, w",
Usage: "only women national teams",
Destination: &women,
},
}
app.Action = func(c *cli.Context) error {
println(fmt.Sprintf("stars %.1f, min %d, max %d, nation %t, women %t", stars, rateMin, rateMax, national, women))
teamMap := scrapr(stars, rateMin, rateMax, national, women)
playerMap := playr(players, playerFile)
// re-test amount of players, as one could enter an empty name
players = len(playerMap)
drawn := drawr(playerMap, &teamMap, groups)
printr(drawn)
for playerMap = playr(1, ""); len(playerMap) > 0; playerMap = playr(1, "") {
drawn := drawr(playerMap, &teamMap, 1)
printr(drawn)
}
return nil
}
app.Run(os.Args)
}