123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- import Common
- from DataCenter import DataCenter
- from LocalModel import BaZi, JieGou
- def calc_jiegou(bazi: BaZi, dc: DataCenter):
- guanxis = ["合", "暗合", "冲", "穿", "破"]
- for ss in Common.shishen_ary:
- for guanxi in guanxis:
- lst = __get_jiegou_list_in_bazi(ss, guanxi, bazi)
- tg = dc.get_tiangan_by_shishen(ss)
- dz = dc.get_dizhi_by_shishen(ss)
- __build_jiegou_data([tg], ss, guanxi, lst, bazi, dc)
- __build_jiegou_data(dz, ss, guanxi, lst, bazi, dc)
- def __build_jiegou_data(texts: [str], shishen: str, guanxi: str, lst: [JieGou], bazi: BaZi, dc: DataCenter):
- for key in texts:
- data = Common.find_gaoneng_by_key_and_guanxi(key, guanxi)
- bh = __find_baohu_in_bazi(key, bazi)
- bazi.jiegouInfo.baohu[shishen] = bh
- for dt in data:
- other = Common.get_other_arg_in_gaoneng(key, guanxi, dt["name"])
- otherShiShen = Common.get_shishen(other, bazi.riGan.text)
- hasGaoneng = dc.has_gaoneng(dt["name"])
- level = 1 if hasGaoneng else 0
- if key in Common.muku_ary and other in Common.muku_ary:
- continue
- jg = JieGou(key, other, guanxi, level, shishen, otherShiShen, Common.is_tiangan(key))
- if guanxi in ["冲", "穿", "破"]:
- jg.baohu = __find_baohu_in_bazi(other, bazi)
- if not __has_data_in_list(shishen, otherShiShen, lst):
- lst.append(jg)
- def __has_data_in_list(shishen1: str, shishen2: str, lst: [JieGou]):
- result = False
- for dt in lst:
- if dt.shishen1 == shishen1 and dt.shishen2 == shishen2:
- result = True
- break
- return result
- def __find_baohu_in_bazi(arg: str, bazi: BaZi):
- found = False
- for dt in bazi.gaonengInfo.heList:
- if dt.leibie == "地支合":
- if dt.arg1 == arg or dt.arg2 == arg:
- found = True
- break
- return found
- def __get_jiegou_list_in_bazi(key: str, guanxi: str, bazi: BaZi):
- if key == "官":
- if guanxi == "合":
- return bazi.jiegouInfo.guanHe
- if guanxi == "暗合":
- return bazi.jiegouInfo.guanAnHe
- if guanxi == "冲":
- return bazi.jiegouInfo.guanChong
- if guanxi == "穿":
- return bazi.jiegouInfo.guanChuan
- if guanxi == "破":
- return bazi.jiegouInfo.guanPo
- elif key == "杀":
- if guanxi == "合":
- return bazi.jiegouInfo.shaHe
- if guanxi == "暗合":
- return bazi.jiegouInfo.shaAnHe
- if guanxi == "冲":
- return bazi.jiegouInfo.shaChong
- if guanxi == "穿":
- return bazi.jiegouInfo.shaChuan
- if guanxi == "破":
- return bazi.jiegouInfo.shaPo
- elif key == "财":
- if guanxi == "合":
- return bazi.jiegouInfo.cai1He
- if guanxi == "暗合":
- return bazi.jiegouInfo.cai1AnHe
- if guanxi == "冲":
- return bazi.jiegouInfo.cai1Chong
- if guanxi == "穿":
- return bazi.jiegouInfo.cai1Chuan
- if guanxi == "破":
- return bazi.jiegouInfo.cai1Po
- elif key == "才":
- if guanxi == "合":
- return bazi.jiegouInfo.cai2He
- if guanxi == "暗合":
- return bazi.jiegouInfo.cai2AnHe
- if guanxi == "冲":
- return bazi.jiegouInfo.cai2Chong
- if guanxi == "穿":
- return bazi.jiegouInfo.cai2Chuan
- if guanxi == "破":
- return bazi.jiegouInfo.cai2Po
- elif key == "印":
- if guanxi == "合":
- return bazi.jiegouInfo.yinHe
- if guanxi == "暗合":
- return bazi.jiegouInfo.yinAnHe
- if guanxi == "冲":
- return bazi.jiegouInfo.yinChong
- if guanxi == "穿":
- return bazi.jiegouInfo.yinChuan
- if guanxi == "破":
- return bazi.jiegouInfo.yinPo
- elif key == "枭":
- if guanxi == "合":
- return bazi.jiegouInfo.xiaoHe
- if guanxi == "暗合":
- return bazi.jiegouInfo.xiaoAnHe
- if guanxi == "冲":
- return bazi.jiegouInfo.xiaoChong
- if guanxi == "穿":
- return bazi.jiegouInfo.xiaoChuan
- if guanxi == "破":
- return bazi.jiegouInfo.xiaoPo
- elif key == "食":
- if guanxi == "合":
- return bazi.jiegouInfo.shiHe
- if guanxi == "暗合":
- return bazi.jiegouInfo.shiAnHe
- if guanxi == "冲":
- return bazi.jiegouInfo.shiChong
- if guanxi == "穿":
- return bazi.jiegouInfo.shiChuan
- if guanxi == "破":
- return bazi.jiegouInfo.shiPo
- elif key == "伤":
- if guanxi == "合":
- return bazi.jiegouInfo.shangHe
- if guanxi == "暗合":
- return bazi.jiegouInfo.shangAnHe
- if guanxi == "冲":
- return bazi.jiegouInfo.shangChong
- if guanxi == "穿":
- return bazi.jiegouInfo.shangChuan
- if guanxi == "破":
- return bazi.jiegouInfo.shangPo
- elif key == "比":
- if guanxi == "合":
- return bazi.jiegouInfo.biHe
- if guanxi == "暗合":
- return bazi.jiegouInfo.biAnHe
- if guanxi == "冲":
- return bazi.jiegouInfo.biChong
- if guanxi == "穿":
- return bazi.jiegouInfo.biChuan
- if guanxi == "破":
- return bazi.jiegouInfo.biPo
- elif key == "劫":
- if guanxi == "合":
- return bazi.jiegouInfo.jieHe
- if guanxi == "暗合":
- return bazi.jiegouInfo.jieAnHe
- if guanxi == "冲":
- return bazi.jiegouInfo.jieChong
- if guanxi == "穿":
- return bazi.jiegouInfo.jieChuan
- if guanxi == "破":
- return bazi.jiegouInfo.jiePo
- return []
|