-
Notifications
You must be signed in to change notification settings - Fork 462
/
yao.go
38 lines (34 loc) · 914 Bytes
/
yao.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
package fate
import "github.com/godcong/yi"
// GuaYao ...
type GuaYao struct {
Yao string `bson:"er_yao"` // 二爻
JiXiong string `bson:"er_yao_ji_xiong"` // 二爻吉凶
}
func getYao(xiang *yi.GuaXiang, yao int) GuaYao {
switch yao {
case 0:
return GuaYao{Yao: xiang.ChuYao, JiXiong: xiang.ChuYaoJiXiong}
case 1:
return GuaYao{Yao: xiang.ErYao, JiXiong: xiang.ErYaoJiXiong}
case 2:
return GuaYao{Yao: xiang.SanYao, JiXiong: xiang.SanYaoJiXiong}
case 3:
return GuaYao{Yao: xiang.SiYao, JiXiong: xiang.SiYaoJiXiong}
case 4:
return GuaYao{Yao: xiang.WuYao, JiXiong: xiang.WuYaoJiXiong}
case 5:
return GuaYao{Yao: xiang.ShangYao, JiXiong: xiang.ShangYaoJiXiong}
default:
panic("wrong yao")
}
}
func filterYao(y *yi.Yi, fs ...string) bool {
yao := getYao(y.Get(yi.BianGua), y.BianYao())
for _, s := range fs {
if yao.JiXiong == s {
return false
}
}
return true
}