forked from babyname/fate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zodiac.go
148 lines (136 loc) · 9.9 KB
/
zodiac.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
package fate
import (
"fmt"
"strings"
"github.com/godcong/chronos"
)
// ZodiacPig ...
const (
ZodiacRat = "鼠"
ZodiacCow = "牛"
ZodiacTiger = "虎"
ZodiacRabbit = "兔"
ZodiacDragon = "龙"
ZodiacSnake = "蛇"
ZodiacHorse = "马"
ZodiacSheep = "羊"
ZodiacMonkey = "猴"
ZodiacChicken = "鸡"
ZodiacDog = "狗"
ZodiacPig = "猪"
)
//Zodiac 生肖
type Zodiac struct {
Name string
Xi string //喜
XiRadical string
Ji string //忌
JiRadical string
}
var zodiacList = map[string]Zodiac{
ZodiacRat: {
Name: ZodiacRat,
Xi: "",
XiRadical: "",
Ji: `丁二人士仁仃仇仍今介化午夭孔巴日火以付仕代仙仟卯央平旦未汀伙伊伍休仲件任仰仳份企光全印合地在圭妃寺早旨旬旭朴次竹羊臣行仵价伂位住伫伴佛何估佐佑伺伸似但作伯低伶余佈免坊址坍均坎壮孝宋巫志攸杜赤辛佟抑亚佯依侍佳使供例来佰佩仑佾侑兔味命坪坡坦妹岱幸旺易昌昆昂明昀昏昊昇东杵炎祀卧佼佶侄坵旻炅耵肖拒沫亭亮信侯侠保促俟俊俗俐係俞勉南哇型垠垣垢城姜姿宣封庠律徉春昭映昧是星昱柯柏柳炫为炳炬炯红美订酊香俋昶炷肯洋倍俸倩倖俩值倚倨俱倡候修倪俾伦冤冻卿埂埔埃姬娩宰差徐恙时晋晏晃晁书桓柴氧烊烈留羔耿袁袂酒钉马珋倢埕埒晟邦那迎胡苎苣茉英茆挽珠停假偃偌做伟健偶侦倏冕曼唱域坚堆埠基堵执婚张得从悠教晚晤曹勗欲焉烯瓷祥羚聊袋许顶偈偅偩偮娅欷欸羕邱迪悻傢傅备杰喜尧堪场堤堰报堡复普晰晴晶景智曾棚款焰然善翔贷距辜集冯傌媄焯羢郎郁脩莘莫荷提扬佣傲传仅僇吗塑塘涂塚塔填塌块坞妈微意暗晖暖暄会楠杨歇照煜焕义羡群详路钾铆驰驯渼羟郝连造逢菟署僧像侨境垫墅寿彻榴歌熙熊监绽台赫輓驳墉杩都逸进慢漾漫亿仪僵价侬俭刘墟增坠墩嬉德徵暮样槽楼欧羯蝴卖辉锌养驻驷驶驾驹鲁儆僾儌墡禡羬陈运道达潜骂儒傧壁垦坛壅曆晓昙炽燕熹笃糕羲谘醒骆嶪烨羱阳邹远优偿储壕壑壎曙营灿镁鍚骋骏鲜鲑邬蓨澲燨膳丛垒曜柠欤缮缯题骑镏骐郑邓选薑嚥垄坜曝羶羹辞鹏鄯薘繨邺迈壤曦耀议骞腾骝牺驱蓦欢鑑鞑骄骅惊驿验坝骤驞骥骊`,
JiRadical: "",
},
ZodiacCow: {
Name: ZodiacCow,
Xi: "",
XiRadical: "",
Ji: `丁人刀匕大干仁什仃仇今介化午天夭心戈支斤日月比片牙王爿丙主以付仕代令仙刊加功仟占古召叱央它弗必旦未末玉矛矢示汀伙伊伍休仲件任仰仳份企光全列刑合宇年式戎早旨旭有朱此竹米羊行衣仵价伂忙托位住佇伴佛何估佐佑伺伸佔似但作伯低伶余佈别判君呀吟坎巫希庇弟彤形忌志忍攸杉系赤辛佟礽快玖些佯依侍佳使供例来佰佩仑佾侑刻券刷到制协卓味命奈妹宗冈岱岳幸弦忠忽念或戕旺易昌昆昂明昀昏昕昊昇服朋枝杵欣版状直知社祀祁纠卧初采青忻玕佼佶侄佌旻炘炅耵罕育怔怖怪怕怡性沫玨玟玫玥表亭信侯保促俟俊俗俐係前剋则勇南奎奐姜宣庠弭彦徉思急怎怨春昭映昧是星昱柔架柏矜祉祈祇穿紂红纪纫紇约紆美羿衫订酊玡俋姝昶柰祅紈肯芯恰恢恆恃恬指洋洧珊玲珍珀玳倍俸倩倖俩值倚倨俱倡候修倪俾伦刚夏娥宰峻峰差恙恣恐恕恩时晋晏晃晁书朔朗栩格氧烊矩祕祐祠祟祖神祝秘纺纱纹素索纯纽级紜纳纸纷羔翁耿袂衽託躬钉马倢倧扆晟祜紘紓衿衾邪胖胥胡胞胤苧茅茉苓悄悟悍悔悦悖班琉珮珠停假偃偌做伟健偶侦倏副务勘动曼唱唬国婚将崇崙彬彩彫御悉悠教旋晚晤晨曹勗望桿梧欲烯祥祭絃统扎绍紼细绅组终羚翎习聆彪被袒袖袍袋许责顶珖玼偈偅偩偮崟欷欸紵紾羕袗胭脉能悽情悻惜惟悸掛採捺浅琅球理现傢傅备杰剴创劳胜场堤报彭悲惠斯普晰晴晶景智曾期朝棕椅栈棹棉款牌番短结绒绝紫絮丝络给绚善翔翕裁裂视诊费贷辜集须冯琁珺傌媄斌牋宁矞絪絜羢軫陀郁脩莘莫庄慨惶愉提扬琪琳琥琴琯琦琨佣傲传仅僇勤势吗嗣妈愚意慈感想爱愁愈愍戡暗暉暖暄会业楠杨歇照牒祺禄禁经绢绥义羡群裟裙补裘装裕详试路钾雉零驰驯愃渼琮絻羥郡郝慎慌慄慍愧準瑚瑟瑞瑙瑛瑜署僧像侨划寥廖彰慇态截畅歌碧禎福祸粽绽綰综绰綾绿紧缀网纲綺绸绵綵纶维绪緇綬臧裴裸製褚赫赶驳瑋榪綪緁緆緋綖綦裱魠慷慢惯惭漾漫瑶琐玛瑰亿仪僵价儂俭剧刘剑增嬉审影德慧慰慾暮样槽桨欧奖莹缔练纬緻缄缅编缘缎缓緲緹羯翩褐复褓褊质辉锌养驻駟驶驾驹鲁齿摎漻儆僾儌墡禡緗羬褌褋褙陈达怜憎愤潜澎璋璃璀骂儒儐剂憩战历晓曇炽燕御篤糕縑縈县縝縉羲褪裤褫醒骆璇璉嶪縕羱錼阳胶蒋忆憾璞优偿储励嶸弥应懂恳懋戏戴曙墙矫禧禪绩繆缕总纵縴縵翼褸镁鍚骋骏鲜蓨澲燨蟉襁膳蕙环璨丛断曜柠歟璧礼织缮绕繚绣繒顏题骑鄢蕥騏际臆薑璿嚥坏曝牘璽疆矇祷繫绎绳绘缴羶羹襠襟识辞鄯薘繯繨鄴藏怀琼劝悬曦朧繽继耀议騫腾龄繾瓏儷樱牺缠续驱驀惧瓔弯欢禳衬韃骄驊鷚恋晒缨纤惊驛验襴鷸陇骤鑫驞纘湾驥缆驤驪`,
JiRadical: "",
},
ZodiacTiger: {
Name: ZodiacTiger,
},
ZodiacRabbit: {
Name: ZodiacRabbit,
},
ZodiacDragon: {
Name: ZodiacDragon,
},
ZodiacSnake: {
Name: ZodiacSnake,
},
ZodiacHorse: {
Name: ZodiacHorse,
},
ZodiacSheep: {
Name: ZodiacSheep,
},
ZodiacMonkey: {
Name: ZodiacMonkey,
},
ZodiacChicken: {
Name: ZodiacChicken,
},
ZodiacDog: {
Name: ZodiacDog,
},
ZodiacPig: {
Name: ZodiacPig,
Xi: "",
XiRadical: "",
Ji: `一乙几刀力匕三上凡也土大川己已巳干弓之仁什今天太巴引戈支斤日比片牙王爿主乏代刊加功包卉占古召叱央它市布平弘弗旦玉申皮矛矢石示氾光列刑危夷妃州帆式戎早旨旭朵此虫血衣圮托汎伸佔但伯伶别判君呀坎壮希庇廷弟彤形杉系邑礽玖些依例刻券刷到制协卓卷呻坤奇奈宗宛延弦或戕旺易昌昆昂明昀昏昕昊昇枝欣版状直知社祀祁纠初采长忻玕佌旻炘炅罕泓泡泛玫表亮侯係前剋则勇垣奐宣巷帝帅建弭彦春昭映昧是星昱架柏矜祉祈祇禹穿竿紂红纪纫紇约紆羿虹衫风玡玠柰祅紈迅巡芝芽指珊玲珍珀玳倡候修刚奚孙家差席师庭时晋晏晃晁书核栩矩砷祕祐祠祟祖神祝祚纺纱纹素索纯纽级紜纳纸纷翁蚩袁袂衽讯託起躬珅倧扆祜紘紓衿衾邪邦那迎返近范茅苓班琉珮珠乾健凰副务勘曼唱唬婉婚将崇常张强彬彩彫旋晚晤晨曹勗桿烯祥票祭絃统扎绍紼细绅组终羚翌翎聆彪蛉被袒袖袍袋责玼珩埏紵紾袗邵述迦迪能情掛採捺涎浅琅球理现剴创劳喉场堤堠媛嵐巽帧弼彭斯普晰晴晶景智曾棕牌番短结绒绝紫絮丝络给绚絳翕蛟裁裂视诊费贵须邰琁珺牋矞絪絜軫陀郎郁送迷迺莫庄莉提扬琪琳琥琴琦琨勤势园戡暗暉暖暄会杨枫照煜牒祺禄禁经绢绥群蜀蛾蜕蜂裟裙补裘装裕试钾雉零琬琰琝媴絻郡通连速造透逢途準猿瑚瑟瑞瑙瑛瑜署僎划寥廖彰截畅碧禎福祸粽绽綰综绰綾绿紧缀网纲綺绸绵綵纶维绪緇綬臧蜜蜻裳裴裹裸製褚豪宾赶闽溒瑄瑋榬綪緁緆緋綖綦蜒裱魠郭都週逸进慢漫瑶琐玛瑰剧刘剑增审影暮槽桨毅奖莹稼缔练纬緻缄缅编缘缎缓緲緹翩蝴蝶褐复褓褊诞赏质辉驻鲁齿摎漻褌褋褙陈乡运游道达违遁撰潜澎璋璃瑾璀剂勋战历晓曇炽御縑縈县縝縉萤融褪裤褫讽醒骇璇璉縕螈錼阳邹远逊遣遥递蒋璟璞励弥戏戴曙墙矫禧禪绩繆缕总纵縴縵翼襄褸辕鍚鄔蟉襁适迁环璦璨断曜璧织缮绕繚绣繒蝉顏题蕥鎱际郑邓选迟薑璿嚥曝牘璽疆祷繫绎绳绘缴襠襟识赞譔还迈邀藏琼劝曦繽继耀腾龄繾饌邈瓏樱缠续边瓔弯禳衬鷚晒缨纤襴鷸蛮纘逻湾缆驪別壯協狀糾長則帥彥紅紀紉約風剛孫師時晉書紡紗紋純紐級納紙紛訊務將張強統紮紹細紳組終責淺現創勞場幀結絨絕絲絡給絢視診費貴須莊揚勢園會楊楓祿經絹綏蛻補裝試鉀連劃暢禍綻綜綽綠緊綴網綱綢綿綸維緒賓趕閩進瑤瑣瑪劇劉劍審槳獎瑩締練緯緘緬編緣緞緩複誕賞質輝駐魯齒陳鄉運遊達違潛劑勳戰曆曉熾禦縣螢褲諷駭陽鄒遠遜遙遞蔣勵彌戲牆矯績縷總縱轅適遷環斷織繕繞繡蟬題際鄭鄧選遲禱繹繩繪繳識贊還邁瓊勸繼騰齡櫻纏續邊彎襯曬纓纖蠻邏灣纜`,
JiRadical: "",
},
}
var zodiacSupportList = map[string]bool{
ZodiacRat: true,
ZodiacCow: true,
ZodiacTiger: false,
ZodiacRabbit: false,
ZodiacDragon: false,
ZodiacSnake: false,
ZodiacHorse: false,
ZodiacSheep: false,
ZodiacMonkey: false,
ZodiacChicken: false,
ZodiacDog: false,
ZodiacPig: true,
}
// GetZodiac ...
func GetZodiac(c chronos.Calendar) *Zodiac {
z := chronos.GetZodiac(c.Lunar())
b := zodiacSupportList[z]
if !b {
fmt.Println("[Warning]生肖:", z, ",该生肖库资料尚未补足")
}
if v, b := zodiacList[z]; b {
return &v
}
return nil
}
func (z *Zodiac) zodiacJi(character *Character) int {
if strings.IndexRune(z.Ji, []rune(character.Ch)[0]) != -1 {
return -3
}
return 0
}
func filterZodiac(c chronos.Calendar, chars ...*Character) bool {
return GetZodiac(c).PointCheck(3, chars...)
}
//PointCheck 检查point
func (z *Zodiac) PointCheck(limit int, chars ...*Character) bool {
for _, c := range chars {
if z.Point(c) < limit {
return false
}
}
return true
}
//Point 喜忌对冲,理论上喜忌都有的话,最好不要选给1,忌给0,喜给5,都没有给3
func (z *Zodiac) Point(character *Character) int {
dp := 3
dp += z.zodiacJi(character)
dp += z.zodiacXi(character)
return dp
}
func (z *Zodiac) zodiacXi(character *Character) int {
if strings.IndexRune(z.Xi, []rune(character.Ch)[0]) != -1 {
return 2
}
return 0
}