-
Notifications
You must be signed in to change notification settings - Fork 0
/
getBoxInfo.go
53 lines (44 loc) · 1 KB
/
getBoxInfo.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
package htb
import (
"../config"
"fmt"
"math"
)
func GetBoxInfo(box config.Box) map[string]string{
/*
Get info on box (difficulty, difficultyRating, status)
*/
// status
var status string
if box.Retired == true{
status = "Retired"
}else{
status = "Active"
}
var difficulty string
switch box.Points{
case 20:
difficulty = "Easy"
case 30:
difficulty = "Medium"
case 40:
difficulty = "Hard"
case 50:
difficulty = "Insane"
default:
difficulty = "?"
}
var difficultyRating float64
var count int
for i, d := range box.Difficulty{
difficultyRating += float64(i) * float64(d)
count += d
}
difficultyRating /= float64(count)
info := map[string]string{
"status" : status,
"difficulty" : difficulty,
"difficultyRating" : fmt.Sprintf("%.1f", math.Round(difficultyRating*10)/10),
}
return info
}