-
Notifications
You must be signed in to change notification settings - Fork 9
/
dayan.go
78 lines (63 loc) · 1.17 KB
/
dayan.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
package yi
import (
"math/bits"
"strconv"
"strings"
)
// DaYan ...
type DaYan struct {
Number int
Lucky string
NvMing string
Max bool
SkyNine string
Comment string
}
var daYanList map[int]*DaYan
func init() {
daYanList = make(map[int]*DaYan)
file81shu, err := DataFiles.Open("data/81shu.csv")
if err != nil {
panic(err)
}
records, err := readData(file81shu)
if err != nil {
panic(err)
}
for _, record := range records {
bihua, err := strconv.ParseInt(record[0], 10, bits.UintSize)
if err != nil {
panic(err)
}
var max bool = false
maxstr := strings.TrimSpace(record[3])
if maxstr == "最吉" {
max = true
}
dayan := DaYan{
Number: int(bihua),
Lucky: record[1],
NvMing: record[2],
Max: max,
SkyNine: record[5],
Comment: record[6],
}
daYanList[dayan.Number-1] = &dayan
}
}
// IsNotSuitableGirl 女性不宜此数
func (dy DaYan) IsNotSuitableGirl() bool {
return dy.NvMing == "凶"
}
//IsMax 是否最大好运数
func (dy DaYan) IsMax() bool {
return dy.Max
}
//GetDaYan 获取大衍之数
func GetDaYan(idx int) DaYan {
if idx <= 0 {
panic("wrong idx")
}
i := (idx - 1) % 81
return *daYanList[i]
}