-
Notifications
You must be signed in to change notification settings - Fork 0
/
wxStruct.go
195 lines (174 loc) · 3.3 KB
/
wxStruct.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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
package wxXunHuan
import (
"fmt"
// "time"
)
type taiji interface {
xchange() interface{}
}
type YinYang struct {
id int
name string
cname string
}
func (y *YinYang) String() string {
str := fmt.Sprintf("id=[%d] cname=[%s]", y.id, y.cname)
return str
}
//构造函数
func newYinYang(id int) YinYang {
return YinYang{id: id, name: dYYnameList[id], cname: dYYcnameList[id]}
}
//集成taiji的xchange接口
func (y *YinYang) xchange() YinYang {
return yinyang[(y.id+1)%2]
}
type SiXiang struct {
id int
name string
cname string
}
func (sx *SiXiang) String() string {
str := fmt.Sprintf("id=[%d] cname=[%s]", sx.id, sx.cname)
return str
}
//构造函数
func newSiXiang(id int) SiXiang {
return SiXiang{id: id, name: dSXnameList[id], cname: dSXcnameList[id]}
}
//集成taiji的xchange接口
func (sx *SiXiang) xchange() SiXiang {
return sixiang[(sx.id+1)%4]
}
type WuXing struct {
id int
name string
cname string
}
func (wx *WuXing) String() string {
str := fmt.Sprintf("id=[%d] cname=[%s]", wx.id, wx.cname)
return str
}
//构造函数
func newWuXing(id int, name string, cname string) WuXing {
return WuXing{id: id, name: name, cname: cname}
}
//集成taiji的xchange接口
func (wx *WuXing) xchange() WuXing {
return wuxing[(wx.id+1)%5]
}
type TianGan struct {
id int
name string
cname string
wx WuXing
yy YinYang
}
func (tg *TianGan) String() string {
str := fmt.Sprintf("id=[%d] cname=[%s]", tg.id, tg.cname)
return str
}
//构造函数
func newTianGan(id int) TianGan {
tgwx := wuxing[((id-id%2)/2)%5]
tgyy := yinyang[(id+1)%2]
return TianGan{id: id, name: dTGnameList[id], cname: dTGcnameList[id], wx: tgwx, yy: tgyy}
}
type DiZhi struct {
id int
name string
cname string
wx WuXing
yy YinYang
canggan []TianGan
}
func (dz *DiZhi) String() string {
str := fmt.Sprintf("id=[%d] cname=[%s]", dz.id, dz.cname)
return str
}
func (dz *DiZhi) GetShengXiao() string {
return Animals[dz.id]
}
func newDiZhi(id int) DiZhi {
dzwx := WuXing{}
dzyy := yinyang[(id+1)%2]
dzcg := []TianGan{}
switch id {
case 0:
{
dzwx = shui
dzcg = []TianGan{tgGui}
}
case 1:
{
dzwx = tu
dzcg = []TianGan{tgJi, tgGui, tgXin}
}
case 2:
{
dzwx = mu
dzcg = []TianGan{tgJia, tgBing, tgWu}
}
case 3:
{
dzwx = mu
dzcg = []TianGan{tgYi}
}
case 4:
{
dzwx = tu
dzcg = []TianGan{tgWu, tgJi, tgGui}
}
case 5:
{
dzwx = huo
dzcg = []TianGan{tgBing, tgWu, tgGeng}
}
case 6:
{
dzwx = huo
dzcg = []TianGan{tgDing, tgJi}
}
case 7:
{
dzwx = tu
dzcg = []TianGan{tgJi, tgDing, tgYi}
}
case 8:
{
dzwx = jin
dzcg = []TianGan{tgGeng, tgRen, tgWu}
}
case 9:
{
dzwx = jin
dzcg = []TianGan{tgXin}
}
case 10:
{
dzwx = tu
dzcg = []TianGan{tgWu, tgXin, tgDing}
}
case 11:
{
dzwx = shui
dzcg = []TianGan{tgRen, tgJia}
}
}
return DiZhi{id: id, name: dDZnameList[id], cname: dDZcnameList[id], wx: dzwx, yy: dzyy, canggan: dzcg}
}
//干支纪年法,六十甲子
type GanZhi struct {
id int
//cname string
tg TianGan
dz DiZhi
}
//干支的id是从0到59的一个循环。
func newGanZhi(id int) GanZhi {
return GanZhi{id: id, tg: tiangan[id%10], dz: dizhi[id%12]}
}
func (gz *GanZhi) String() string {
str := fmt.Sprintf("id=[%d] cname=[%s%s]", gz.id, gz.tg.cname, gz.dz.cname)
return str
}