GaoNengLogic.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. import Common
  2. import PowerLogic
  3. import SiZhuLogic
  4. from DataCenter import DataCenter
  5. from LocalModel import BaZi, GaoNeng, SiZhu
  6. gaoneng_tips = [
  7. "合多:喜社交,擅处理人际关系,喜与人为善,不喜争斗;",
  8. "冲多:擅运动,喜欢对抗,喜欢折腾;",
  9. "天干合:合中带克,夫妻关系",
  10. "天干冲:甲庚、乙辛金木冲,意外伤;丙壬、丁癸水火冲,情绪不稳",
  11. "地支合:申子辰合水,寅午戌合火,亥卯未合木,巳酉丑合金",
  12. "地支冲:丑未、寅申、卯酉金木冲,意外伤;子午、辰戌、巳亥水火冲,情绪不稳",
  13. "地支穿:穿又叫害,表达一种不对付的关系,常见于关系被挑拨离间、三角恋等,穿是一种互相伤害的概念。",
  14. "地支刑:刑表示互相折磨互相伤害、较力、掰手腕。子卯刑表示傲慢无礼,不知感恩;申寅巳刑表示不服管教,恃势之刑;丑未戌刑表示家庭不和睦,亲骨无恩,不利亲情。",
  15. "自刑:自我折磨,有精神障碍,心门不开",
  16. "地支暗合:午亥暗合,表示财源来路不明,有婚外情;申卯暗合,表示搞手段,暗箱操作,使阴招;寅丑暗合,表示被偷盗、丢东西、破财。",
  17. "地支破:争吵,多见于婚姻关系中"
  18. ]
  19. def check_gaoneng(bazi: BaZi, dc: DataCenter):
  20. tgs = bazi.sizhu_tiangans()
  21. dzs = bazi.sizhu_dizhis()
  22. for tg in tgs:
  23. __fix_tiangan_gaoneng(tg, tgs, bazi, dc, True)
  24. # 检查三合三会三刑
  25. for dz in dzs:
  26. __fix_dizhi3_gaoneng(dz, dzs, bazi, dc, True)
  27. for dz in dzs:
  28. __fix_dizhi2_gaoneng(dz, dzs, bazi, dc, True)
  29. def update_gaoneng_power(bazi: BaZi, dc: DataCenter):
  30. # 计算刑的力量
  31. for gn in bazi.gaonengInfo.xingList:
  32. __update_power_of_gaoneng_xing(gn, bazi, dc)
  33. # 半合带来的能量增强
  34. for gn in bazi.gaonengInfo.banHeList:
  35. zhu = gn.zhu1
  36. if gn.arg1 == gn.fangxiang:
  37. zhu = gn.zhu2
  38. wx = Common.get_wuxing(gn.fangxiang)
  39. sz = bazi.getZhuByWeiZhi(zhu)
  40. gn.banheZengQiangPower = sz.get_canggan_power_by_wuxing(wx)
  41. dc.shishenZengQiang[gn.banheZengQiangShiShen] += gn.banheZengQiangPower
  42. # 拱合带来的能量变化
  43. for gn in bazi.gaonengInfo.gongHeList:
  44. gn.gongheZengQiangPower = dc.get_power_step(gn.gongheZengQiangWuXing)
  45. dc.shishenZengQiang[gn.gongheZengQiangShiShen] += gn.gongheZengQiangPower
  46. # 三会带来的能量变化(这里其实要看有没有被破坏才决定是否增强)
  47. for gn in bazi.gaonengInfo.sanHuiList:
  48. zhu1 = bazi.getZhuByWeiZhi(gn.zhu1)
  49. zhu2 = bazi.getZhuByWeiZhi(gn.zhu2)
  50. zhu3 = bazi.getZhuByWeiZhi(gn.zhu3)
  51. p1 = zhu1.get_canggan_power_by_wuxing(gn.hehua)
  52. p2 = zhu2.get_canggan_power_by_wuxing(gn.hehua)
  53. p3 = zhu3.get_canggan_power_by_wuxing(gn.hehua)
  54. power = 0
  55. if zhu1.text != gn.fangxiang:
  56. power += p1
  57. if zhu2.text != gn.fangxiang:
  58. power += p2
  59. if zhu3.text != gn.fangxiang:
  60. power += p3
  61. gn.sanhuiZengQiangPower = power
  62. dc.shishenZengQiang[gn.sanhuiZengQiangShiShen] += gn.sanhuiZengQiangPower
  63. # 自刑带来的能量变化
  64. for gn in bazi.gaonengInfo.ziXingList:
  65. if gn.zixingZengQiangWuXing is not None:
  66. zhu1 = bazi.getZhuByWeiZhi(gn.zhu1)
  67. power = zhu1.get_canggan_power_by_wuxing(gn.zixingZengQiangWuXing)
  68. gn.zixingZengQiangPower = power
  69. # 力量变动后,重新计算counter
  70. for ss in Common.shishen_ary:
  71. zq = dc.shishenZengQiang[ss]
  72. if zq > 0:
  73. found = False
  74. for wsp in bazi.powerInfo.wangShuaiPowers:
  75. if wsp.shishen1 == ss:
  76. wsp.shishen1ZengQiang = zq
  77. found = True
  78. elif wsp.shishen2 == ss:
  79. wsp.shishen2ZengQiang = zq
  80. found = True
  81. if found:
  82. break
  83. PowerLogic.calc_percentages(bazi.powerInfo.wangShuaiPowers, True, bazi, dc)
  84. SiZhuLogic.update_powers(bazi, dc)
  85. def __fix_tiangan_gaoneng(zhu: SiZhu, tiangans: [SiZhu], bazi: BaZi, dc: DataCenter, save: bool):
  86. for tg in tiangans:
  87. if zhu.weiZhi == tg.weiZhi:
  88. continue
  89. data = Common.find_gaoneng_by_texts(zhu.text, tg.text)
  90. for temp in data:
  91. gn = __build_gaoneng_object_from_data(temp, zhu, tg, None, bazi, dc, save)
  92. gn1 = gn.copySelf()
  93. __calc_fangxiang(gn1, zhu.weiZhi)
  94. zhu.gaonengs.append(gn1)
  95. if save:
  96. dc.add_gaoneng_in_weizhi(zhu.weiZhi, gn1.text)
  97. dc.add_gaoneng_in_weizhi(tg.weiZhi, gn1.text)
  98. def __fix_dizhi3_gaoneng(zhu: SiZhu, dizhis: [SiZhu], bazi: BaZi, dc: DataCenter, save: bool):
  99. gnMap = {}
  100. for dz2 in dizhis:
  101. for dz3 in dizhis:
  102. if zhu.weiZhi == dz2.weiZhi or zhu.weiZhi == dz3.weiZhi or dz2.weiZhi == dz3.weiZhi:
  103. continue
  104. data = Common.find_gaoneng_by_texts(zhu.text, dz2.text, dz3.text)
  105. for temp in data:
  106. key = __calc_key_of_gaoneng_data(zhu.weiZhi, dz2.weiZhi, dz3.weiZhi, temp["name"])
  107. if not gnMap.keys().__contains__(key):
  108. gnMap[key] = __build_gaoneng_object_from_data(temp, zhu, dz2, dz3, bazi, dc, save)
  109. if save:
  110. dc.add_gaoneng_in_weizhi(zhu.weiZhi, gnMap[key].text)
  111. dc.add_gaoneng_in_weizhi(dz2.weiZhi, gnMap[key].text)
  112. dc.add_gaoneng_in_weizhi(dz3.weiZhi, gnMap[key].text)
  113. for temp in gnMap.values():
  114. gn1 = temp.copySelf()
  115. __calc_fangxiang(gn1, zhu.weiZhi)
  116. zhu.gaonengs.append(gn1)
  117. def __fix_dizhi2_gaoneng(zhu: SiZhu, dizhis: [SiZhu], bazi: BaZi, dc: DataCenter, save: bool):
  118. for dz in dizhis:
  119. if zhu.weiZhi == dz.weiZhi:
  120. continue
  121. data = Common.find_gaoneng_by_texts(zhu.text, dz.text)
  122. for temp in data:
  123. gn = __build_gaoneng_object_from_data(temp, zhu, dz, None, bazi, dc, save)
  124. gn1 = gn.copySelf()
  125. __calc_fangxiang(gn1, zhu.weiZhi)
  126. zhu.gaonengs.append(gn1)
  127. if save:
  128. dc.add_gaoneng_in_weizhi(zhu.weiZhi, gn1.text)
  129. dc.add_gaoneng_in_weizhi(dz.weiZhi, gn1.text)
  130. def __build_gaoneng_object_from_data(data: {}, zhu1: SiZhu, zhu2: SiZhu, zhu3: SiZhu, bazi: BaZi, dc: DataCenter,
  131. save: bool):
  132. gn = GaoNeng()
  133. gn.arg1 = zhu1.text
  134. gn.arg2 = zhu2.text
  135. gn.arg3 = zhu3.text if zhu3 is not None else None
  136. gn.guanxi = data["guanxi"]
  137. gn.text = data["name"]
  138. gn.father = data["father"]
  139. gn.leibie = data["leibie"]
  140. gn.wuxing1 = zhu1.wuXing
  141. gn.wuxing2 = zhu2.wuXing
  142. gn.wuxing3 = zhu3.wuXing if zhu3 is not None else None
  143. gn.hehua = data["hehua"]
  144. gn.shishen1 = zhu1.shiShen
  145. gn.shishen2 = zhu2.shiShen
  146. gn.shishen3 = zhu3.shiShen if zhu3 is not None else None
  147. gn.power1 = dc.get_shishen_power(gn.shishen1)
  148. gn.power2 = dc.get_shishen_power(gn.shishen2)
  149. gn.power3 = dc.get_shishen_power(gn.shishen3)
  150. gn.zhu1 = zhu1.weiZhi
  151. gn.zhu2 = zhu2.weiZhi
  152. gn.zhu3 = zhu3.weiZhi if zhu3 is not None else None
  153. gn.tip = data["tip"]
  154. gn.fangxiang = data["fangxiang"]
  155. gn.key = __calc_key_of_gaoneng_data(gn.zhu1, gn.zhu2, gn.zhu3, gn.text)
  156. if gn.guanxi == "合":
  157. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.heList):
  158. bazi.gaonengInfo.heList.append(gn)
  159. elif gn.guanxi == "冲":
  160. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.chongList):
  161. bazi.gaonengInfo.chongList.append(gn)
  162. elif gn.guanxi == "破":
  163. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.poList):
  164. bazi.gaonengInfo.poList.append(gn)
  165. elif gn.guanxi == "穿":
  166. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.chuanList):
  167. bazi.gaonengInfo.chuanList.append(gn)
  168. elif gn.guanxi == "半合":
  169. gn.banheZengQiang = gn.fangxiang
  170. gn.banheZengQiangWuXing = Common.get_wuxing(gn.banheZengQiang)
  171. gn.banheZengQiangShiShen = Common.get_shishen(gn.banheZengQiang, bazi.riGan.text)
  172. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.banHeList):
  173. bazi.gaonengInfo.banHeList.append(gn)
  174. elif gn.guanxi == "拱合":
  175. gn.gongheZengQiang = gn.fangxiang
  176. gn.gongheZengQiangWuXing = Common.get_wuxing(gn.gongheZengQiang)
  177. gn.gongheZengQiangShiShen = Common.get_shishen(gn.gongheZengQiang, bazi.riGan.text)
  178. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.gongHeList):
  179. bazi.gaonengInfo.gongHeList.append(gn)
  180. elif gn.guanxi == "暗合":
  181. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.anHeList):
  182. bazi.gaonengInfo.anHeList.append(gn)
  183. elif gn.guanxi == "三会":
  184. gn.sanhuiZengQiang = gn.fangxiang
  185. gn.sanhuiQiangWuXing = Common.get_wuxing(gn.sanhuiZengQiang)
  186. gn.sanhuiZengQiangShiShen = Common.get_shishen(gn.sanhuiZengQiang, bazi.riGan.text)
  187. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.sanHuiList):
  188. bazi.gaonengInfo.sanHuiList.append(gn)
  189. elif gn.guanxi == "自刑":
  190. gn.zixingZengQiang = gn.fangxiang
  191. gn.zixingZengQiangWuXing = Common.get_wuxing(gn.zixingZengQiang)
  192. gn.zixingZengQiangShiShen = Common.get_shishen(gn.zixingZengQiang, bazi.riGan.text)
  193. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.ziXingList):
  194. bazi.gaonengInfo.ziXingList.append(gn)
  195. elif gn.guanxi == "刑":
  196. if save:
  197. __fill_data_for_gaoneng_xing(gn, bazi)
  198. if not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.xingList) and gn.arg3 is None:
  199. bazi.gaonengInfo.xingList.append(gn)
  200. return gn
  201. def __build_gaoneng_object_from_data_as_text(data: {}, text: str, zhu2: SiZhu, zhu3: SiZhu, bazi: BaZi, dc: DataCenter,
  202. save: bool):
  203. gn = GaoNeng()
  204. gn.arg1 = text
  205. gn.arg2 = zhu2.text
  206. gn.arg3 = zhu3.text if zhu3 is not None else None
  207. gn.guanxi = data["guanxi"]
  208. gn.text = data["name"]
  209. gn.father = data["father"]
  210. gn.leibie = data["leibie"]
  211. gn.wuxing1 = Common.get_wuxing(text)
  212. gn.wuxing2 = zhu2.wuXing
  213. gn.wuxing3 = zhu3.wuXing if zhu3 is not None else None
  214. gn.hehua = data["hehua"]
  215. gn.shishen1 = Common.get_shishen(text, bazi.riGan.text)
  216. gn.shishen2 = zhu2.shiShen
  217. gn.shishen3 = zhu3.shiShen if zhu3 is not None else None
  218. gn.power1 = dc.get_shishen_power(gn.shishen1)
  219. gn.power2 = dc.get_shishen_power(gn.shishen2)
  220. gn.power3 = dc.get_shishen_power(gn.shishen3)
  221. gn.zhu1 = -1
  222. gn.zhu2 = zhu2.weiZhi
  223. gn.zhu3 = zhu3.weiZhi if zhu3 is not None else None
  224. gn.tip = data["tip"]
  225. gn.fangxiang = data["fangxiang"]
  226. gn.key = __calc_key_of_gaoneng_data(gn.zhu1, gn.zhu2, gn.zhu3, gn.text)
  227. if gn.guanxi == "合":
  228. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.heList):
  229. bazi.gaonengInfo.heList.append(gn)
  230. elif gn.guanxi == "冲":
  231. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.chongList):
  232. bazi.gaonengInfo.chongList.append(gn)
  233. elif gn.guanxi == "破":
  234. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.poList):
  235. bazi.gaonengInfo.poList.append(gn)
  236. elif gn.guanxi == "穿":
  237. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.chuanList):
  238. bazi.gaonengInfo.chuanList.append(gn)
  239. elif gn.guanxi == "半合":
  240. gn.banheZengQiang = gn.fangxiang
  241. gn.banheZengQiangWuXing = Common.get_wuxing(gn.banheZengQiang)
  242. gn.banheZengQiangShiShen = Common.get_shishen(gn.banheZengQiang, bazi.riGan.text)
  243. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.banHeList):
  244. bazi.gaonengInfo.banHeList.append(gn)
  245. elif gn.guanxi == "拱合":
  246. gn.gongheZengQiang = gn.fangxiang
  247. gn.gongheZengQiangWuXing = Common.get_wuxing(gn.gongheZengQiang)
  248. gn.gongheZengQiangShiShen = Common.get_shishen(gn.gongheZengQiang, bazi.riGan.text)
  249. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.gongHeList):
  250. bazi.gaonengInfo.gongHeList.append(gn)
  251. elif gn.guanxi == "暗合":
  252. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.anHeList):
  253. bazi.gaonengInfo.anHeList.append(gn)
  254. elif gn.guanxi == "三会":
  255. gn.sanhuiZengQiang = gn.fangxiang
  256. gn.sanhuiQiangWuXing = Common.get_wuxing(gn.sanhuiZengQiang)
  257. gn.sanhuiZengQiangShiShen = Common.get_shishen(gn.sanhuiZengQiang, bazi.riGan.text)
  258. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.sanHuiList):
  259. bazi.gaonengInfo.sanHuiList.append(gn)
  260. elif gn.guanxi == "自刑":
  261. gn.zixingZengQiang = gn.fangxiang
  262. gn.zixingZengQiangWuXing = Common.get_wuxing(gn.zixingZengQiang)
  263. gn.zixingZengQiangShiShen = Common.get_shishen(gn.zixingZengQiang, bazi.riGan.text)
  264. if save and not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.ziXingList):
  265. bazi.gaonengInfo.ziXingList.append(gn)
  266. elif gn.guanxi == "刑":
  267. if save:
  268. __fill_data_for_gaoneng_xing(gn, bazi)
  269. if not __has_key_in_gaoneng_list(gn, bazi.gaonengInfo.xingList) and gn.arg3 is None:
  270. bazi.gaonengInfo.xingList.append(gn)
  271. return gn
  272. def __calc_key_of_gaoneng_data(zhu1: int, zhu2: int, zhu3: int, text: str):
  273. lst = [zhu1, zhu2]
  274. if zhu3 is not None:
  275. lst.append(zhu3)
  276. lst.sort()
  277. key = text
  278. for v in lst:
  279. key += str(v)
  280. return key
  281. def __has_father(gns: [GaoNeng], gn: GaoNeng):
  282. result = False
  283. if gn.father is None:
  284. return result
  285. for temp in gns:
  286. if temp.text == gn.father:
  287. result = True
  288. break
  289. return result
  290. def __fill_data_for_gaoneng_xing(gn: GaoNeng, bazi: BaZi):
  291. found = False
  292. if gn.text == "寅巳刑":
  293. gn.xingchu1 = "丙"
  294. gn.xingchu2 = "戊"
  295. gn.xingchong = "甲庚冲"
  296. gn.xingchongArg1 = "甲"
  297. gn.xingchongArg2 = "庚"
  298. found = True
  299. elif gn.text == "巳申刑":
  300. gn.xingchu1 = "庚"
  301. gn.xingchu2 = "戊"
  302. gn.xingchong = "丙壬冲"
  303. gn.xingchongArg1 = "丙"
  304. gn.xingchongArg2 = "壬"
  305. found = True
  306. elif gn.text == "戌未刑":
  307. gn.xingchu1 = "丁"
  308. gn.xingchu2 = None
  309. gn.xingchong = "乙辛冲"
  310. gn.xingchongArg1 = "乙"
  311. gn.xingchongArg2 = "辛"
  312. found = True
  313. elif gn.text == "丑戌刑":
  314. gn.xingchu1 = "辛"
  315. gn.xingchu2 = None
  316. gn.xingchong = "丁癸冲"
  317. gn.xingchongArg1 = "丁"
  318. gn.xingchongArg2 = "癸"
  319. found = True
  320. elif gn.text == "子卯刑":
  321. gn.xingchu1 = None
  322. gn.xingchu2 = None
  323. gn.xingchong = None
  324. gn.xingchongArg1 = None
  325. gn.xingchongArg2 = None
  326. found = True
  327. if found:
  328. gn.xingchu1WuXing = Common.get_wuxing(gn.xingchu1)
  329. gn.xingchu2WuXing = Common.get_wuxing(gn.xingchu2)
  330. gn.xingchu1ShiShen = Common.get_shishen(gn.xingchu1, bazi.riGan.text)
  331. gn.xingchu2ShiShen = Common.get_shishen(gn.xingchu2, bazi.riGan.text)
  332. def __update_power_of_gaoneng_xing(gn: GaoNeng, bazi: BaZi, dc: DataCenter):
  333. zhu1 = bazi.getZhuByWeiZhi(gn.zhu1)
  334. zhu2 = bazi.getZhuByWeiZhi(gn.zhu2)
  335. gn.xingchu1Power = zhu1.get_canggan_power_by_wuxing(gn.xingchu1WuXing) + zhu2.get_canggan_power_by_wuxing(
  336. gn.xingchu1WuXing)
  337. gn.xingchu2Power = zhu1.get_canggan_power_by_wuxing(gn.xingchu2WuXing) + zhu2.get_canggan_power_by_wuxing(
  338. gn.xingchu2WuXing)
  339. gn.xingchongArg1ShiShen = Common.get_shishen(gn.xingchongArg1, bazi.riGan.text)
  340. gn.xingchongArg2ShiShen = Common.get_shishen(gn.xingchongArg2, bazi.riGan.text)
  341. gn.xingchongArg1Power = dc.get_shishen_power(gn.xingchongArg1ShiShen)
  342. gn.xingchongArg2Power = dc.get_shishen_power(gn.xingchongArg2ShiShen)
  343. def __has_key_in_gaoneng_list(gn: GaoNeng, list: [GaoNeng]):
  344. result = False
  345. for item in list:
  346. if item.key == gn.key:
  347. result = True
  348. break
  349. return result
  350. def __calc_fangxiang(gn: GaoNeng, selfZhu: int):
  351. if gn.guanxi in ["合", "暗合", "三合", "半合", "三会"]:
  352. fromZhu = selfZhu
  353. toZhu = gn.zhu1
  354. if gn.fangxiang == gn.arg2:
  355. toZhu = gn.zhu2
  356. elif gn.fangxiang == gn.arg3:
  357. toZhu = gn.zhu3
  358. if fromZhu == toZhu:
  359. gn.fangxiangTip = ""
  360. elif fromZhu < toZhu:
  361. gn.fangxiangTip = "→"
  362. elif fromZhu > toZhu:
  363. gn.fangxiangTip = "←"
  364. elif gn.guanxi in ["冲", "穿"]:
  365. if selfZhu == gn.zhu1:
  366. if gn.power1 < gn.power2:
  367. gn.fangxiangTip = "↓"
  368. elif gn.power1 > gn.power2:
  369. gn.fangxiangTip = "↑"
  370. else:
  371. gn.fangxiangTip = "="
  372. else:
  373. if gn.power1 < gn.power2:
  374. gn.fangxiangTip = "↑"
  375. elif gn.power1 > gn.power2:
  376. gn.fangxiangTip = "↓"
  377. else:
  378. gn.fangxiangTip = "="
  379. elif gn.guanxi == "拱合":
  380. gn.fangxiangTip = "(" + gn.fangxiang + ")"
  381. def fix_gaoneng_by_text(text: str, zhus: [SiZhu], bazi: BaZi, weizhi: int, dc: DataCenter):
  382. result: [GaoNeng] = []
  383. tg = Common.is_tiangan(text)
  384. if tg is True:
  385. __fix_gaoneng_for_two(text, zhus, bazi, weizhi, result, dc)
  386. else:
  387. __fix_gaoneng_for_three(text, zhus, bazi, weizhi, result, dc)
  388. __fix_gaoneng_for_two(text, zhus, bazi, weizhi, result, dc)
  389. return result
  390. def __fix_gaoneng_for_two(text: str, zhus: [SiZhu], bazi: BaZi, weizhi: int, list: [GaoNeng], dc: DataCenter):
  391. for sz in zhus:
  392. data = Common.find_gaoneng_by_texts(text, sz.text)
  393. for dt in data:
  394. gn = __build_gaoneng_object_from_data_as_text(dt, text, sz, None, bazi, dc, False)
  395. if __has_key_in_gaoneng_list(gn, list) is False:
  396. list.append(gn)
  397. def __fix_gaoneng_for_three(text: str, zhus: [SiZhu], bazi: BaZi, weizhi: int, list: [GaoNeng], dc: DataCenter):
  398. for sz2 in zhus:
  399. for sz3 in zhus:
  400. if sz2.weiZhi == sz3.weiZhi:
  401. continue
  402. data = Common.find_gaoneng_by_texts(text, sz2.text, sz3.text)
  403. for dt in data:
  404. gn = __build_gaoneng_object_from_data_as_text(dt, text, sz2, sz3, bazi, dc, False)
  405. if __has_key_in_gaoneng_list(gn, list) is False:
  406. list.append(gn)