-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.go
More file actions
155 lines (132 loc) · 3.11 KB
/
util.go
File metadata and controls
155 lines (132 loc) · 3.11 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package showgone
import (
"io"
"fmt"
"reflect"
)
func convId(str string) reflect.Value {
return reflect.ValueOf(String(str))
}
func convNum(num string) reflect.Value {
var val uint8
fmt.Sscan(num, &val)
return reflect.ValueOf(val)
}
func convShiny(shiny string) reflect.Value {
if shiny == "Yes" {
return reflect.ValueOf(true)
}
return reflect.ValueOf(false)
}
func (p *Pokemon) fieldSpecies(w io.Writer) (int, error) {
if p.Item != "" {
if p.Gender != 0 {
return fmt.Fprintf(w, "%s (%c) @ %s\n", p.Species, p.Gender, p.Item)
}
return fmt.Fprintf(w, "%s @ %s\n", p.Species, p.Item)
}
if p.Gender != 0 {
return fmt.Fprintf(w, "%s (%c)\n", p.Species, p.Gender)
}
return fmt.Fprintf(w, "%s\n", p.Species)
}
func (p *Pokemon) fieldAbility(w io.Writer) (int, error) {
if p.Ability != "" {
return fmt.Fprintf(w, "Ability: %s\n", p.Ability)
}
return 0, nil
}
func (p *Pokemon) fieldLevel(w io.Writer) (int, error) {
if p.Level != 100 {
return fmt.Fprintf(w, "Level: %d\n", p.Level)
}
return 0, nil
}
func (p *Pokemon) fieldShiny(w io.Writer) (int, error) {
if p.Shiny {
return fmt.Fprintln(w, "Shiny: Yes")
}
return 0, nil
}
func (p *Pokemon) fieldHappiness(w io.Writer) (int, error) {
if p.Happiness != 255 {
return fmt.Fprintf(w, "Happiness: %d\n", p.Happiness)
}
return 0, nil
}
func (p *Pokemon) fieldVs(w io.Writer, v byte) (int, error) {
var vs []uint8
var def uint8
var n, wrote int
var err error
var one bool
if v == 'E' {
vs = p.EVs[:]
def = 0
} else {
vs = p.IVs[:]
def = 31
}
for i := 0; i < 6; i++ {
if vs[i] != def {
if one {
n, err = fmt.Fprintf(w, "/ %d %s ", vs[i], statStr[i])
} else {
n, err = fmt.Fprintf(w, "%cVs: %d %s ", v, vs[i], statStr[i])
one = true
}
wrote += n
if err != nil {
return wrote, err
}
}
}
if one {
n, err = w.Write([]byte("\n"))
wrote += n
if err != nil {
return wrote, err
}
}
return wrote, nil
}
func (p *Pokemon) fieldNature(w io.Writer) (int, error) {
if p.Nature != 0 {
return fmt.Fprintf(w, "%s Nature\n", p.Nature)
}
return 0, nil
}
func (p *Pokemon) fieldMoves(w io.Writer) (int, error) {
var wrote int
for i := 0; i < 4; i++ {
if p.Moves[i] != "" {
n, err := fmt.Fprintf(w, "- %s\n", p.Moves[i])
wrote += n
if err != nil {
return wrote, err
}
}
}
return wrote, nil
}
func (n Nature) String() string {
return natStr[n]
}
func (g Gender) String() string {
switch g {
default:
return "Random"
case 'M':
return "Male"
case 'F':
return "Female"
case 'G':
return "Genderless"
}
}
func (s String) String() string {
if s == "" {
return "None"
}
return string(s)
}