-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.go
77 lines (66 loc) · 1.69 KB
/
store.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
package main
var Store *Storage
type storeTeam struct {
ID int `json:"id"`
Name string `json:"name"`
Score int `json:"score"`
Special int `json:"special"`
SpecialScore int `json:"special_score"`
Trials []storeTrial `json:"trials"`
Disqualified bool `json:"disqualified"`
setSpecial bool
finished bool
}
type storeTrial struct {
No int `json:"no"`
Passed bool `json:"passed"`
}
type storeProblem struct {
ID int `json:"id"`
Score int `json:"score"`
}
// Storage stores the current state of the contest
type Storage struct {
// Time is in seconds
Time int `json:"time"`
TotalTime int `json:"total_time"`
Running bool `json:"running"`
Teams []storeTeam `json:"teams"`
Problems []storeProblem `json:"problems"`
passed []int
finished int
}
func initStorage(c *Config) {
s := &Storage{
Time: c.Time * 60,
TotalTime: c.Time * 60,
Teams: []storeTeam{},
Problems: []storeProblem{},
passed: make([]int, len(Conf.Solutions)),
finished: 0,
}
for i, t := range c.Teams {
team := storeTeam{
ID: i,
Name: t.Name,
Score: c.DefaultTeamScore,
Special: 0,
SpecialScore: 0,
Trials: []storeTrial{},
Disqualified: false,
setSpecial: false,
finished: false,
}
for i := 0; i < len(c.Solutions); i++ {
team.Trials = append(team.Trials, storeTrial{No: 0, Passed: false})
}
s.Teams = append(s.Teams, team)
}
for i := 0; i < len(c.Solutions); i++ {
s.Problems = append(s.Problems, storeProblem{
ID: i,
Score: c.DefaultProblemScore,
})
}
Store = s
}