12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- import Common
- from LocalModel import BaZi, XingGeDesc
- def fill_xingge(bazi: BaZi):
- # > 50% strong
- # < 18% low
- # 18% - 50% middle
- # 五行性格
- bazi.xinggeInfo["wuxing"] = []
- bazi.xinggeInfo["shishen"] = []
- zuozhiFullName = __get_shishen_full_name(bazi.riZhi.shiShen)
- zuozhiSimpleName = __get_shishen_simple_name(bazi.riZhi.shiShen)
- for wsp in bazi.powerInfo.wangShuaiPowers:
- wx = __build_xingge_desc(wsp.wuxing, wsp.percentage)
- fullShiShen = __get_shishen_full_name(wsp.shishen1)
- name1 = __get_shishen_simple_name(wsp.shishen1)
- name2 = __get_shishen_simple_name(wsp.shishen2)
- ssMain = __build_xingge_desc(fullShiShen, wsp.percentage)
- ss1 = __build_xingge_desc(name1, wsp.shishenPercentage1InTotal)
- ss2 = __build_xingge_desc(name2, wsp.shishenPercentage2InTotal)
- if fullShiShen == zuozhiFullName:
- ssMain.zuozhi = True
- if name1 == zuozhiSimpleName:
- ss1.zuozhi = True
- if name2 == zuozhiSimpleName:
- ss2.zuozhi = True
- bazi.xinggeInfo["wuxing"].append(wx)
- bazi.xinggeInfo["shishen"].append(ssMain)
- bazi.xinggeInfo["shishen"].append(ss1)
- bazi.xinggeInfo["shishen"].append(ss2)
- def __build_xingge_desc(key: str, value: int):
- desc = XingGeDesc()
- desc.key = key
- desc.value = value
- xg = Common.get_xingge(desc.key)
- desc.low = xg["low"]
- desc.middle = xg["middle"]
- desc.strong = xg["strong"]
- if desc.value >= 50:
- desc.state = "过旺"
- elif desc.value < 18:
- desc.state = "衰"
- else:
- desc.state = "旺"
- return desc
- def __get_shishen_simple_name(shishen: str):
- if shishen == "官":
- return "正官"
- if shishen == "杀":
- return "七杀"
- if shishen == "比":
- return "比肩"
- if shishen == "劫":
- return "劫财"
- if shishen == "印":
- return "正印"
- if shishen == "枭":
- return "偏印"
- if shishen == "食":
- return "食神"
- if shishen == "伤":
- return "伤官"
- if shishen == "财":
- return "正财"
- if shishen == "才":
- return "偏财"
- return "未知"
- def __get_shishen_full_name(shishen: str):
- if shishen in ["官", "杀"]:
- return "官杀"
- if shishen in ["比", "劫"]:
- return "比劫"
- if shishen in ["食", "伤"]:
- return "食伤"
- if shishen in ["印", "枭"]:
- return "印绶"
- if shishen in ["财", "才"]:
- return "财星"
- return "未知"
|