-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderers.gno
39 lines (34 loc) · 969 Bytes
/
renderers.gno
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
package shiken
import (
leaderboard "gno.land/p/dev/shiken_leaderboards"
shiken_problems "gno.land/p/dev/shiken_problems"
)
func RenderScores(id int) string {
// Tree{problemId -> Tree{Address -> score}}
lbInterface, ok := leaderboardsKeyToScore.Get(getStringFromInt(id))
if !ok {
panic(ErrNoProblemId)
}
lb := lbInterface.(*leaderboard.BTree)
output := "{"
output += `"problem":` + RenderProblem(id) + ","
output += `"scores":[` + readScores(lb) + "]"
output += "}"
return output
}
func RenderProblems() string {
output := shiken_problems.ReadProblems(Problems)
return output
}
func RenderProblem(problemId int) string {
idString := getStringFromInt(problemId)
problemInterface, ok := Problems.Get(idString)
breakIfNotOk(ok, ErrNoProblemId)
problem := problemInterface.(*shiken_problems.Problem)
output := problem.ReadProblem()
return output
}
func RenderUser(address string) string {
output := renderUserRegister(address)
return output
}