123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- import Common
- from DataCenter import DataCenter
- from LocalModel import BaZi, SiZhuWeiZhi, GeJu, SiZhu, ZhenJia, ShiShenXiongJi, MangPaiGong
- def fill_geju(bazi: BaZi, dc: DataCenter):
- __fill_lushen(bazi)
- __check_zhenjia(bazi, dc)
- bazi.gejuInfo.shishen = []
- # 坐支
- __check_zuozhi(bazi)
- # 计算盲派功
- __check_mangpaigong(bazi)
- # buf
- __check_yinluxiangsui(bazi, dc)
- __check_shishenzhisha(bazi, dc)
- __check_shishangheyin(bazi, dc)
- __check_caiheyin(bazi, dc)
- __check_guanzhijiecai(bazi, dc)
- __check_guanyinxiangsheng(bazi, dc)
- __check_shayinxiangsheng(bazi, dc)
- __check_zihecaiguan(bazi, dc)
- # debuf
- __check_jiecaijiancai(bazi, dc)
- __check_jiecaiheqisha(bazi, dc)
- __check_shangguanjianguan(bazi, dc)
- __check_xiaoshenduoshi(bazi, dc)
- __check_qishagongshen(bazi, dc)
- __check_caisunyin(bazi, dc)
- __check_shangguanheqisha(bazi, dc)
- __check_shaxiaoxiangsha(bazi, dc)
- __check_durenfengchong(bazi, dc)
- def __fill_lushen(bazi: BaZi):
- for sz in bazi.sizhu_dizhis():
- if sz.isLuShen or sz.isBanLu:
- info = GeJu()
- if sz.weiZhi == SiZhuWeiZhi.nianzhi.value:
- info.key = "年禄"
- bazi.gejuInfo.nianlu = info
- elif sz.weiZhi == SiZhuWeiZhi.yuezhi.value:
- info.key = "建禄"
- bazi.gejuInfo.jianlu = info
- elif sz.weiZhi == SiZhuWeiZhi.rizhi.value:
- info.key = "专禄"
- bazi.gejuInfo.zhuanlu = info
- elif sz.weiZhi == SiZhuWeiZhi.shizhi.value:
- info.key = "归禄"
- bazi.gejuInfo.guiLu = info
- info.tip = Common.get_lushen_tip(info.key)
- if sz.findGaoNeng("冲") is not None:
- info.isChong = True
- if sz.findGaoNeng("穿") is not None:
- info.isChuan = True
- if sz.findGaoNeng("破") is not None:
- info.isPo = True
- if sz.findGaoNeng("合") is not None:
- info.isBaoHu = True
- if sz.isBanLu and bazi.gejuInfo.banlu is None:
- info1 = GeJu()
- info1.key = "半禄"
- info1.tip = Common.get_lushen_tip(info1.key)
- bazi.gejuInfo.banlu = info1
- def __check_zhenjia(bazi: BaZi, dc: DataCenter):
- # 虚实
- bazi.gejuInfo.xushi = Common.has_genqi(bazi.riGan.wuXing, bazi.riZhi.wuXing)
- # 真假
- bazi.gejuInfo.zhenjia = []
- for tg in bazi.sizhu_tiangans():
- zj = dc.genqi[tg.weiZhi]
- zhenjia = ZhenJia()
- zhenjia.key = tg.shiShen
- zhenjia.zhenValue = zj[0]
- zhenjia.jiaValue = zj[1]
- tips = Common.get_zhenjia(zhenjia.key)
- zhenjia.zhenTip = tips["真"]
- zhenjia.jiaTip = tips["假"]
- if not bazi.gejuInfo.hasKeyInZhenJiaList(zhenjia.key):
- bazi.gejuInfo.zhenjia.append(zhenjia)
- def __create_xiongji(key: str):
- data = Common.get_xiongji(key)
- obj = ShiShenXiongJi()
- obj.key = key
- obj.eft = data["eft"]
- obj.solve = data["solve"]
- return obj
- def __check_zuozhi(bazi: BaZi):
- ss = bazi.riZhi.getCangGanShiShens()
- if "劫" in ss:
- bazi.gejuInfo.zuozhi = "自坐劫财,易在配偶宫破财。劫财容易见利忘义,可共患难,不能同富贵。"
- elif "比" in ss:
- bazi.gejuInfo.zuozhi = "自坐比肩,得配偶真心相助。"
- def __check_mangpaigong(bazi: BaZi):
- bazi.gejuInfo.gong = MangPaiGong()
- bazi.gejuInfo.gong.he = bazi.countGaoNeng("合")
- bazi.gejuInfo.gong.po = bazi.countGaoNeng("破")
- # 计算日柱上自合产生的功
- # 注意,这里产生的自合仅用于计算盲派功,因此这个系数是固定的,和藏干那边的系数无关
- zihe = 0
- if bazi.riGan.text == "甲" and bazi.riZhi.text == "午":
- zihe = 0.5
- elif bazi.riGan.text == "戊" and bazi.riZhi.text == "子":
- zihe = 1
- elif bazi.riGan.text == "己" and bazi.riZhi.text == "亥":
- zihe = 0.5
- elif bazi.riGan.text == "辛" and bazi.riZhi.text == "巳":
- zihe = 0.7
- elif bazi.riGan.text == "壬" and bazi.riZhi.text == "午":
- zihe = 0.5
- elif bazi.riGan.text == "癸" and bazi.riZhi.text == "巳":
- zihe = 0.5
- elif bazi.riGan.text == "丙" and bazi.riZhi.text == "戌":
- if bazi.riZhi.muku is not None and bazi.riZhi.muku.isOpen is True:
- zihe = 0.2
- elif bazi.riGan.text == "壬" and bazi.riZhi.text == "戌":
- if bazi.riZhi.muku is not None and bazi.riZhi.muku.isOpen is True:
- zihe = 0.6
- bazi.gejuInfo.gong.zihe = zihe
- bazi.gejuInfo.gong.calcTotal()
- def __check_yinluxiangsui(bazi: BaZi, dc: DataCenter):
- # 有禄神,并且地支有印或枭
- key = "印禄相随"
- if dc.lushenAmount > 0 or dc.banluAmount > 0:
- if dc.has_shishen_in_dizhi(["印", "枭"]):
- xj = __create_xiongji(key)
- xj.isGood = True
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_shishenzhisha(bazi: BaZi, dc: DataCenter):
- # 八字中带食神和七杀
- key = "食神制杀"
- if dc.has_all_shishen(["食", "杀"]):
- xj = __create_xiongji(key)
- xj.isGood = True
- p1 = dc.get_shishen_power("食")
- p2 = dc.get_shishen_power("杀")
- xj.tip = "食(" + str(p1) + ") 杀(" + str(p2) + ")"
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_shishangheyin(bazi: BaZi, dc: DataCenter):
- # 八字中食伤和印枭相合
- key = "食伤合印"
- tips = []
- found = False
- if len(bazi.findGaoNengByGuanXis("食", "印", ["合", "半合", "拱合", "暗合"])) > 0:
- tips.append("食神合正印")
- found = True
- if len(bazi.findGaoNengByGuanXis("伤", "印", ["合", "半合", "拱合", "暗合"])) > 0:
- tips.append("伤官合正印")
- found = True
- if len(bazi.findGaoNengByGuanXis("食", "枭", ["合", "半合", "拱合", "暗合"])) > 0:
- tips.append("食神合偏印")
- found = True
- if len(bazi.findGaoNengByGuanXis("伤", "枭", ["合", "半合", "拱合", "暗合"])) > 0:
- tips.append("伤官合偏印")
- found = True
- if found is True:
- xj = __create_xiongji(key)
- xj.isGood = True
- xj.tip = ""
- for tp in tips:
- xj.tip += tp + " "
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_caiheyin(bazi: BaZi, dc: DataCenter):
- # 八字中正偏财合正偏印
- key = "财合印"
- tips = []
- found = False
- if len(bazi.findGaoNengByGuanXis("财", "印", ["合", "半合", "拱合", "暗合"])) > 0:
- tips.append("正财合正印")
- found = True
- if len(bazi.findGaoNengByGuanXis("才", "印", ["合", "半合", "拱合", "暗合"])) > 0:
- tips.append("偏财合正印")
- found = True
- if len(bazi.findGaoNengByGuanXis("财", "枭", ["合", "半合", "拱合", "暗合"])) > 0:
- tips.append("正财合偏印")
- found = True
- if len(bazi.findGaoNengByGuanXis("才", "枭", ["合", "半合", "拱合", "暗合"])) > 0:
- tips.append("偏财合偏印")
- found = True
- if found is True:
- xj = __create_xiongji(key)
- xj.isGood = True
- xj.tip = ""
- for tp in tips:
- xj.tip += tp + " "
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_guanzhijiecai(bazi: BaZi, dc: DataCenter):
- key = "官制劫财"
- if dc.has_all_shishen(["官", "劫"]):
- xj = __create_xiongji(key)
- xj.isGood = True
- p1 = dc.get_shishen_power("官")
- p2 = dc.get_shishen_power("劫")
- xj.tip = "官(" + str(p1) + ") 劫(" + str(p2) + ")"
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_guanyinxiangsheng(bazi: BaZi, dc: DataCenter):
- key = "官印相生"
- tips = []
- found = False
- if len(bazi.findGaoNengByGuanXis("官", "印", ["合", "半合", "拱合", "暗合"])) > 0:
- tips.append("合正印")
- found = True
- if len(bazi.findGaoNengByGuanXis("官", "枭", ["合", "半合", "拱合", "暗合"])) > 0:
- tips.append("合偏印")
- found = True
- if found is True:
- xj = __create_xiongji(key)
- xj.isGood = True
- xj.tip = ""
- for tp in tips:
- xj.tip += tp + " "
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_shayinxiangsheng(bazi: BaZi, dc: DataCenter):
- key = "杀印相生"
- tips = []
- found = False
- if len(bazi.findGaoNengByGuanXis("杀", "印", ["合", "半合", "拱合", "暗合"])) > 0:
- tips.append("合正印")
- found = True
- if len(bazi.findGaoNengByGuanXis("杀", "枭", ["合", "半合", "拱合", "暗合"])) > 0:
- tips.append("合偏印")
- found = True
- if found is True:
- xj = __create_xiongji(key)
- xj.isGood = True
- xj.tip = ""
- for tp in tips:
- xj.tip += tp + " "
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_zihecaiguan(bazi: BaZi, dc: DataCenter):
- key = "自合财官"
- found = False
- tip = ""
- for gn in bazi.riGan.gaonengs:
- if gn.guanxi in ["合", "半合", "拱合", "暗合"]:
- if gn.shishen1 in ["官", "财", "才"]:
- found = True
- tip = "合" + gn.shishen1
- break
- if gn.shishen2 in ["官", "财", "才"]:
- found = True
- tip = "合" + gn.shishen2
- break
- if found is True:
- xj = __create_xiongji(key)
- xj.isGood = True
- xj.tip = tip
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_jiecaijiancai(bazi: BaZi, dc: DataCenter):
- key = "劫财见财"
- if dc.has_shishen("劫"):
- if dc.has_shishen("财") or dc.has_shishen("才"):
- xj = __create_xiongji(key)
- xj.isGood = False
- if dc.has_xiongji("官制劫财"):
- xj.tip = " 官制劫财缓解"
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_jiecaiheqisha(bazi: BaZi, dc: DataCenter):
- key = "劫财合七杀"
- lst = bazi.findGaoNengByShiShen("劫", "杀", "合")
- if len(lst):
- xj = __create_xiongji(key)
- xj.isGood = False
- xj.tip = ""
- if dc.has_xiongji("印禄相随"):
- xj.tip += " 印禄相随化解"
- if dc.has_xiongji("官制劫财"):
- xj.tip += " 官制劫财缓解"
- # 食神化杀
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_shangguanjianguan(bazi: BaZi, dc: DataCenter):
- key = "伤官见官"
- if bazi.hasShiShen("伤"):
- if bazi.hasShiShen("官"):
- xj = __create_xiongji(key)
- xj.isGood = False
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_xiaoshenduoshi(bazi: BaZi, dc: DataCenter):
- key = "枭神夺食"
- if bazi.hasShiShen("枭") and bazi.hasShiShen("食"):
- xj = __create_xiongji(key)
- xj.isGood = False
- p1 = bazi.getPowerOfShiShen("枭")
- p2 = bazi.getPowerOfShiShen("食")
- xj.tip = "枭(" + str(p1) + ") 食(" + str(p2) + ") "
- lst = bazi.findGaoNengByGuanXis("枭", "食", ["合", "半合", "拱合", "暗合"])
- if len(lst) > 0:
- xj.tip += " ,当前存在枭神合食神"
- if dc.has_xiongji("印禄相随"):
- xj.tip += " 印禄相随化解"
- dc.xiongjiTexts.append(key)
- bazi.gejuInfo.shishen.append(xj)
- def __check_qishagongshen(bazi: BaZi, dc: DataCenter):
- key = "七杀攻身"
- found = False
- for gn in bazi.riGan.gaonengs:
- if gn.shishen1 == "杀" or gn.shishen2 == "杀":
- found = True
- break
- if found is True:
- xj = __create_xiongji(key)
- xj.isGood = False
- p1 = dc.get_shishen_power("印")
- p2 = dc.get_shishen_power("食")
- p3 = dc.get_shishen_power("伤")
- p4 = dc.get_shishen_power("杀")
- xj.tip = "印(" + str(p1) + ") 食(" + str(p2) + ") 伤(" + str(p3) + ") 杀(" + str(p4) + ")"
- if dc.has_xiongji("印禄相随"):
- xj.tip += " 印禄相随化解"
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_caisunyin(bazi: BaZi, dc: DataCenter):
- key = "财损印"
- p1 = bazi.getPowerOfShiShen("财")
- p2 = bazi.getPowerOfShiShen("才")
- p3 = bazi.getPowerOfShiShen("印")
- p4 = bazi.getPowerOfShiShen("枭")
- if p1 + p2 == 0:
- return
- if (p1 + p2) < (p3 + p4):
- xj = __create_xiongji(key)
- xj.isGood = False
- xj.tip = "财(" + str(p1) + ") 才(" + str(p2) + ") 印(" + str(p3) + ") 枭(" + str(p4) + ")"
- if dc.has_xiongji("财合印"):
- xj.tip += " 财合印化解"
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_shangguanheqisha(bazi: BaZi, dc: DataCenter):
- key = "伤官合七杀"
- lst = bazi.findGaoNengByGuanXis("伤", "杀", ["合", "半合", "拱合", "暗合"])
- if len(lst) > 0:
- xj = __create_xiongji(key)
- xj.isGood = False
- p1 = dc.get_shishen_power("伤")
- p2 = dc.get_shishen_power("杀")
- xj.tip = "伤(" + str(p1) + ") 杀(" + str(p2) + ")"
- if dc.has_xiongji("印禄相随"):
- xj.tip += " 印禄相随化解"
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_shaxiaoxiangsha(bazi: BaZi, dc: DataCenter):
- key = "杀枭相杀"
- if dc.has_xiongji("枭神夺食") and dc.has_xiongji("七杀攻身"):
- xj = __create_xiongji(key)
- xj.isGood = False
- if dc.has_xiongji("印禄相随"):
- xj.tip = " 印禄相随化解"
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __check_durenfengchong(bazi: BaZi, dc: DataCenter):
- key = "独刃逢冲"
- tip = ""
- sz: SiZhu = None
- found = False
- for wz in bazi.shenshaInfo.fenbu:
- lst = bazi.shenshaInfo.fenbu[wz]
- for dt in lst:
- if dt.name == "羊刃":
- dz = __get_dizhi_weizhi(wz)
- if dz != SiZhuWeiZhi.unknown.value:
- gns = bazi.getZhuByWeiZhi(dz).gaonengs
- for gn in gns:
- if gn.guanxi == "冲":
- found = True
- sz = bazi.getZhuByWeiZhi(dz)
- if dz == SiZhuWeiZhi.nianzhi.value:
- tip += "年上犯冲 "
- elif dz == SiZhuWeiZhi.yuezhi.value:
- tip += "月上犯冲 "
- elif dz == SiZhuWeiZhi.rizhi.value:
- tip += "坐支犯冲 "
- elif dz == SiZhuWeiZhi.shizhi.value:
- tip += "时上犯冲 "
- if found is True and sz is not None:
- xj = __create_xiongji(key)
- xj.isGood = False
- xj.tip = tip
- bazi.gejuInfo.shishen.append(xj)
- dc.xiongjiTexts.append(key)
- def __get_dizhi_weizhi(zhuWeiZhi: int):
- if zhuWeiZhi == SiZhuWeiZhi.nianzhu.value:
- return SiZhuWeiZhi.nianzhi.value
- if zhuWeiZhi == SiZhuWeiZhi.yuezhu.value:
- return SiZhuWeiZhi.yuezhi.value
- if zhuWeiZhi == SiZhuWeiZhi.rizhu.value:
- return SiZhuWeiZhi.rizhi.value
- if zhuWeiZhi == SiZhuWeiZhi.shizhu.value:
- return SiZhuWeiZhi.shizhi.value
- return SiZhuWeiZhi.unknown.value
|