-
Notifications
You must be signed in to change notification settings - Fork 5
/
util.go
106 lines (101 loc) · 2.67 KB
/
util.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
package ygo
import (
"strconv"
"strings"
"github.com/jeandeaual/tts-deckconverter/plugins/ygo/api"
)
func buildDescription(apiResponse api.Data) string {
var sb strings.Builder
if apiResponse.Attribute != nil {
switch *apiResponse.Attribute {
case api.AttributeDark:
sb.WriteString("[000000]")
case api.AttributeDivine, api.AttributeLight:
sb.WriteString("[8a7045]")
case api.AttributeEarth:
sb.WriteString("[374231]")
case api.AttributeFire:
sb.WriteString("[fe0d00]")
case api.AttributeWater:
sb.WriteString("[02a2d7]")
case api.AttributeWind:
sb.WriteString("[4d8742]")
case api.AttributeLaugh:
sb.WriteString("[ee8224]")
}
sb.WriteString(string(*apiResponse.Attribute))
sb.WriteString("[ffffff]\n\n")
}
if apiResponse.Level != nil &&
apiResponse.Type.IsMonster() &&
apiResponse.Type != api.TypeLinkMonster {
if apiResponse.Type.IsXYZ() {
sb.WriteString("[b9b959]Rank ")
} else {
sb.WriteString("[ffd33c]Level ")
}
sb.WriteString(strconv.Itoa(*apiResponse.Level))
sb.WriteString("[ffffff]\n\n")
}
if apiResponse.Archetype != nil {
sb.WriteString("[i]")
sb.WriteString(*apiResponse.Archetype)
sb.WriteString("[/i]\n\n")
}
if apiResponse.Scale != nil {
sb.WriteString("[2d68dc]Scale [c2243a]")
sb.WriteString(strconv.Itoa(*apiResponse.Scale))
sb.WriteString("[ffffff]\n\n")
}
if apiResponse.Type.IsMonster() {
sb.WriteString("[b][ ")
sb.WriteString(string(apiResponse.Race))
sb.WriteString(" / ")
sb.WriteString(
strings.Replace(
strings.TrimSuffix(string(apiResponse.Type), " Monster"),
" ",
" / ",
-1,
),
)
sb.WriteString(" ][/b]\n")
} else {
sb.WriteString("[b][ ")
sb.WriteString(string(apiResponse.Type))
if apiResponse.Race != "Normal" {
sb.WriteString(" / ")
sb.WriteString(string(apiResponse.Race))
}
sb.WriteString(" ][/b]\n")
}
sb.WriteString(strings.Replace(apiResponse.Description, "\r\n", "\n", -1))
if apiResponse.Attack != nil || apiResponse.Defense != nil {
sb.WriteString("\n\n")
}
if apiResponse.Attack != nil {
sb.WriteString("[b]ATK/")
sb.WriteString(strconv.Itoa(*apiResponse.Attack))
sb.WriteString("[/b] ")
}
if apiResponse.Defense != nil {
sb.WriteString("[b]DEF/")
sb.WriteString(strconv.Itoa(*apiResponse.Defense))
sb.WriteString("[/b]")
}
if apiResponse.LinkValue != nil {
sb.WriteString("[b]LINK-")
sb.WriteString(strconv.Itoa(*apiResponse.LinkValue))
sb.WriteString("[/b]")
}
if apiResponse.LinkMarkers != nil {
sb.WriteString("\n")
for i, linkmarker := range apiResponse.LinkMarkers {
sb.WriteString(string(linkmarker))
if i < len(apiResponse.LinkMarkers)-1 {
sb.WriteString(", ")
}
}
}
return sb.String()
}