JianKangLogic.py 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import Common
  2. from LocalModel import BaZi
  3. def check_jiankang(bazi: BaZi):
  4. __check_shui_ruo_tu_wang(bazi)
  5. __check_jinshuiruo_fengshishang(bazi)
  6. __check_gaoneng(bazi)
  7. def __check_shui_ruo_tu_wang(bazi: BaZi):
  8. key = "水弱土旺"
  9. p1 = bazi.getPowerOfWuXing("水")
  10. p2 = bazi.getPowerOfWuXing("土")
  11. if p1 < p2:
  12. tip = "女命输卵管容易堵塞;男命容易精子存活率低。"
  13. key += "(" + str(p1) + "," + str(p2) + ")"
  14. bazi.jiankang[key] = tip
  15. def __check_jinshuiruo_fengshishang(bazi: BaZi):
  16. key = "金水弱且落于食伤"
  17. s1 = bazi.getWuXingState("金")
  18. s2 = bazi.getWuXingState("水")
  19. lst1 = bazi.getShiShensByWuXing("金")
  20. lst2 = bazi.getShiShensByWuXing("水")
  21. trigger = False
  22. if s1 == "衰" and s2 == "衰":
  23. if "食" in lst1:
  24. trigger = True
  25. elif "食" in lst2:
  26. trigger = True
  27. if trigger is True:
  28. tip = "不易生育"
  29. bazi.jiankang[key] = tip
  30. def __check_gaoneng(bazi: BaZi):
  31. __check_gaoneng_by_args("午", "丑", "穿", "容易糖尿病", bazi)
  32. __check_gaoneng_by_args("申", "亥", "穿", "容易消化道不好,容易吃安眠药或服毒", bazi)
  33. __check_gaoneng_by_args("申", "寅", "冲", "肝胆肠容易有急症", bazi)
  34. __check_gaoneng_by_args("甲", "庚", "冲", "容易破相、外伤", bazi)
  35. __check_gaoneng_by_args("巳", "亥", "冲", "容易患癌症", bazi)
  36. __check_gaoneng_by_args("卯", "辰", "穿", "容易出现脾胃伤、肠胃穿孔", bazi)
  37. __check_gaoneng_by_args("酉", "戌", "穿", "容易出现脾胃伤、肠胃穿孔", bazi)
  38. __check_gaoneng_and_shang("子", "未", "穿", "未", "牙齿容易不好(上火等)", bazi, "(丁火伤)")
  39. __check_gaoneng_and_shang("午", "丑", "穿", "午", "牙齿容易不好(上火等)", bazi, "(丁火伤)")
  40. __check_gaoneng_and_power("辰", "戌", "冲", "癸", "丁", "牙齿容易不好(上火等)", bazi, "(丁火伤)")
  41. __check_gaoneng_and_power("丑", "未", "冲", "癸", "丁", "牙齿容易不好(上火等)", bazi, "(丁火伤)")
  42. __check_tiangan_and_dizhi_by_wuxing("木", "土", "木克土", "皮肤容易不好", bazi)
  43. __check_gaoneng_by_args("申", "卯", "暗合", "自缢之相", bazi)
  44. __check_shishen_and_text("枭", "酉", "酉金为枭", "容易跳楼、自杀、自残", bazi)
  45. __check_shishen_and_wuxing("枭", "火", "火为枭", "容易卧轨、烧炭、自焚、坠崖", bazi)
  46. __check_riyuan_jian_zhu("庚", "壬", "戌", "庚金日元见壬戌", "容易煤炭、煤气自杀", bazi)
  47. __check_shishen_and_text("枭", "壬", "壬水为枭", "容易投河、跳海", bazi)
  48. def __check_gaoneng_by_args(arg1: str, arg2: str, guanxi: str, tip: str, bazi: BaZi):
  49. key = arg1 + arg2 + guanxi
  50. lst = bazi.findGaoNengByArgs(arg1, arg2, guanxi)
  51. if len(lst) > 0:
  52. bazi.jiankang[key] = tip
  53. # 检查高能关系,并且指定弱势方
  54. def __check_gaoneng_and_shang(arg1: str, arg2: str, guanxi: str, shang: str, tip: str, bazi: BaZi,
  55. additionKey: str = ""):
  56. key = arg1 + arg2 + guanxi + additionKey
  57. lst = bazi.findGaoNengByArgs(arg1, arg2, guanxi)
  58. trigger = False
  59. if len(lst) > 0:
  60. p1 = lst[0].power1
  61. p2 = lst[0].power2
  62. if p1 > p2 and lst[0].arg2 == shang:
  63. trigger = True
  64. if p1 < p2 and lst[0].arg1 == shang:
  65. trigger = True
  66. if trigger is True:
  67. bazi.jiankang[key] = tip
  68. # 比如辰戌冲,对比藏干中癸水和丁火的力量对比,如果强弱符合条件则触发
  69. def __check_gaoneng_and_power(arg1: str, arg2: str, guanxi: str, qiangText: str, ruoText: str, tip: str, bazi: BaZi,
  70. additionKey: str = ""):
  71. key = arg1 + arg2 + guanxi + additionKey
  72. lst = bazi.findGaoNengByArgs(arg1, arg2, guanxi)
  73. trigger = False
  74. if len(lst) > 0:
  75. ss1 = Common.get_shishen(qiangText, bazi.riGan.text)
  76. ss2 = Common.get_shishen(ruoText, bazi.riGan.text)
  77. p1 = bazi.getPowerOfShiShen(ss1)
  78. p2 = bazi.getPowerOfShiShen(ss2)
  79. if p1 > p2:
  80. trigger = True
  81. if trigger is True:
  82. bazi.jiankang[key] = tip
  83. def __check_tiangan_and_dizhi_by_wuxing(tianganWuXing: str, dizhiWuXing: str, key: str, tip: str, bazi: BaZi):
  84. trigger = False
  85. if bazi.nianGan.wuXing == tianganWuXing and bazi.nianZhi.wuXing == dizhiWuXing:
  86. trigger = True
  87. elif bazi.yueGan.wuXing == tianganWuXing and bazi.yueZhi.wuXing == dizhiWuXing:
  88. trigger = True
  89. elif bazi.riGan.wuXing == tianganWuXing and bazi.riZhi.wuXing == dizhiWuXing:
  90. trigger = True
  91. elif bazi.shiGan.wuXing == tianganWuXing and bazi.shiZhi.wuXing == dizhiWuXing:
  92. trigger = True
  93. if trigger is True:
  94. bazi.jiankang[key] = tip
  95. def __check_shishen_and_text(shishen: str, text: str, key: str, tip: str, bazi: BaZi):
  96. ss = Common.get_shishen(text, bazi.riGan.text)
  97. if ss == shishen:
  98. bazi.jiankang[key] = tip
  99. def __check_shishen_and_wuxing(shishen: str, wuxing: str, key: str, tip: str, bazi: BaZi):
  100. if bazi.guanxiInfo.shishen.keys().__contains__(wuxing):
  101. lst = bazi.guanxiInfo.shishen.get(wuxing)
  102. if shishen in lst:
  103. bazi.jiankang[key] = tip
  104. def __check_riyuan_jian_zhu(riyuan: str, jianTianGan: str, jianDiZhi: str, key: str, tip: str, bazi: BaZi):
  105. if bazi.riGan.text == riyuan:
  106. lst = bazi.findTianGanDiZhiInZhu(jianTianGan, jianDiZhi)
  107. if len(lst) > 0:
  108. bazi.jiankang[key] = tip