LocalModel.py 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. from enum import Enum
  2. from typing import List
  3. from pydantic import BaseModel
  4. import Common
  5. class SiZhuWeiZhi(Enum):
  6. extra = -1
  7. unknown = 0
  8. niangan = 1
  9. yuegan = 2
  10. rigan = 3
  11. shigan = 4
  12. nianzhi = 5
  13. yuezhi = 6
  14. rizhi = 7
  15. shizhi = 8
  16. nianzhu = 11
  17. yuezhu = 12
  18. rizhu = 13
  19. shizhu = 14
  20. liu_niangan = 21
  21. liu_yuegan = 22
  22. liu_rigan = 23
  23. liu_shigan = 24
  24. liu_nianzhi = 25
  25. liu_yuezhi = 26
  26. liu_rizhi = 27
  27. liu_shizhi = 28
  28. class SiZhuInfoRequest(BaseModel):
  29. mode: int
  30. texts: List[str]
  31. datetime: str
  32. startDate: str
  33. location: str
  34. sheng: str
  35. shi: str
  36. qu: str
  37. weidu: float
  38. jingdu: float
  39. qiankun: str
  40. class CustomLogin(BaseModel):
  41. user: str
  42. psd: str
  43. class SaveUser(BaseModel):
  44. name: str
  45. beizhu: str
  46. isMan: bool
  47. leibie: int
  48. year: int
  49. month: int
  50. day: int
  51. hour: int
  52. minute: int
  53. sheng: str
  54. shi: str
  55. qu: str
  56. niangan: str
  57. nianzhi: str
  58. yuegan: str
  59. yuezhi: str
  60. rigan: str
  61. rizhi: str
  62. shigan: str
  63. shizhi: str
  64. customer: str
  65. def to_db_data(self):
  66. from datetime import datetime
  67. tm = datetime.now()
  68. return {
  69. "name": self.name,
  70. "beizhu": self.beizhu,
  71. "man": self.isMan,
  72. "leibie": self.leibie,
  73. "year": self.year,
  74. "month": self.month,
  75. "day": self.day,
  76. "hour": self.hour,
  77. "minute": self.minute,
  78. "sheng": self.sheng,
  79. "shi": self.shi,
  80. "qu": self.qu,
  81. "niangan": self.niangan,
  82. "nianzhi": self.nianzhi,
  83. "yuegan": self.yuegan,
  84. "yuezhi": self.yuezhi,
  85. "rigan": self.rigan,
  86. "rizhi": self.rizhi,
  87. "shigan": self.shigan,
  88. "shizhi": self.shizhi,
  89. "customer": self.customer,
  90. "joinTime": tm.strftime("%Y-%m-%d %H:%M:%S"),
  91. "enabled": 1,
  92. }
  93. class QueryUser(BaseModel):
  94. customer: str
  95. filter: str
  96. class DeleteUser(BaseModel):
  97. customer: str
  98. id: int
  99. class LiuZhu():
  100. text: str
  101. weizhi: int
  102. shishen: str
  103. isTianGan: bool
  104. gan1: str
  105. gan2: str
  106. gan3: str
  107. gan1ShiShen: str
  108. gan2ShiShen: str
  109. gan3ShiShen: str
  110. class ContentGaoNeng():
  111. arg1: str
  112. arg2: str
  113. arg3: str
  114. text: str
  115. zhu1: int
  116. zhu2: int
  117. zhu3: int
  118. key: str
  119. shishen1: str
  120. shishen2: str
  121. shishen3: str
  122. guanxi: str
  123. tip: str
  124. fangxiang: str
  125. fromCangGan: bool
  126. fromGongHe: bool
  127. fromXing: bool
  128. def __init__(self):
  129. self.fromCangGan = False
  130. self.fromGongHe = False
  131. self.fromXing = False
  132. class ContentInfo():
  133. year: int
  134. month: int
  135. day: int
  136. riyuan: str
  137. text: str
  138. tip: str
  139. arg1: str
  140. arg2: str
  141. arg3: str
  142. shishen1: str
  143. shishen2: str
  144. shishen3: str
  145. guanxi: str
  146. times: int
  147. jiedu1: str
  148. jiedu2: str
  149. jiedu3: str
  150. jiedu4: str
  151. jiedu5: str
  152. fangxiang: str
  153. fromCangGan: bool
  154. fromGongHe: bool
  155. fromXing: bool
  156. def __init__(self):
  157. self.jiedu1 = None
  158. self.jiedu2 = None
  159. self.jiedu3 = None
  160. self.jiedu4 = None
  161. self.jiedu5 = None
  162. def to_db_data(self):
  163. return {
  164. "year": self.year,
  165. "month": self.month,
  166. "day": self.day,
  167. "riyuan": self.riyuan,
  168. "desc": self.shishen1 + self.shishen2 + self.guanxi,
  169. "tip": self.tip,
  170. "jiedu1": self.jiedu1,
  171. "jiedu2": self.jiedu2,
  172. "jiedu3": self.jiedu3,
  173. "jiedu4": self.jiedu4,
  174. "jiedu5": self.jiedu5,
  175. }
  176. class GaoNeng():
  177. arg1: str
  178. arg2: str
  179. arg3: str
  180. guanxi: str
  181. text: str
  182. father: str
  183. leibie: str
  184. wuxing1: str
  185. wuxing2: str
  186. wuxing3: str
  187. shishen1: str
  188. shishen2: str
  189. shishen3: str
  190. power1: float
  191. power2: float
  192. power3: float
  193. extraPower1: float
  194. extraPower2: float
  195. extraPower3: float
  196. zhu1: int
  197. zhu2: int
  198. zhu3: int
  199. hehua: str
  200. fangxiang: str
  201. fangxiangTip: str
  202. key: str
  203. banheZengQiang: str
  204. banheZengQiangWuXing: str
  205. banheZengQiangShiShen: str
  206. banheZengQiangPower: int
  207. gongheZengQiang: str
  208. gongheZengQiangWuXing: str
  209. gongheZengQiangShiShen: str
  210. gongheZengQiangPower: int
  211. sanhuiZengQiang: str
  212. sanhuiZengQiangWuXing: str
  213. sanhuiZengQiangShiShen: str
  214. sanhuiZengQiangPower: int
  215. zixingZengQiang: str
  216. zixingZengQiangWuXing: str
  217. zixingZengQiangShiShen: str
  218. zixingZengQiangPower: int
  219. xingchu1: str
  220. xingchu2: str
  221. xingchu1WuXing: str
  222. xingchu2WuXing: str
  223. xingchu1ShiShen: str
  224. xingchu2ShiShen: str
  225. xingchu1Power: int
  226. xingchu2Power: int
  227. xingchong: str
  228. xingchongArg1: str
  229. xingchongArg2: str
  230. xingchongArg1ShiShen: str
  231. xingchongArg2ShiShen: str
  232. xingchongArg1Power: int
  233. xingchongArg2Power: int
  234. isFromCangGan: bool
  235. isFromGongHe: bool
  236. tip: str
  237. def __init__(self):
  238. self.isFromGongHe = False
  239. self.isFromCangGan = False
  240. self.extraPower1 = 0
  241. self.extraPower2 = 0
  242. self.extraPower3 = 0
  243. def copySelf(self):
  244. gn = GaoNeng()
  245. for key in dir(self):
  246. if not key.startswith("__"):
  247. value = getattr(self, key)
  248. if not callable(value):
  249. setattr(gn, key, value)
  250. return gn
  251. class MuKu():
  252. text: str
  253. lock: str
  254. isLock: bool
  255. chong: str
  256. gonghe: str
  257. zixing: str
  258. sanhui: str
  259. anhe: str
  260. hasChong: bool
  261. hasGongHe: bool
  262. hasZiXing: bool
  263. hasSanHui: bool
  264. hasAnHe: bool
  265. state: str
  266. isOpen: bool
  267. def __init__(self):
  268. self.isOpen = False
  269. class Score():
  270. key: str
  271. he: int
  272. anHe: int
  273. chong: int
  274. chuan: int
  275. po: int
  276. total: int
  277. def __init__(self, key: str):
  278. self.key = key
  279. self.he = 0
  280. self.anHe = 0
  281. self.chong = 0
  282. self.chuan = 0
  283. self.po = 0
  284. self.total = 0
  285. def calcTotal(self):
  286. if self.he == 0:
  287. self.he = 1
  288. if self.anHe == 0:
  289. self.anHe = 1
  290. if self.chong == 0:
  291. self.chong = 1
  292. if self.chuan == 0:
  293. self.chuan = 1
  294. if self.po == 0:
  295. self.po = 1
  296. self.total = self.he * self.anHe * self.chong * self.chuan * self.po
  297. class PingJia():
  298. mubiao: [Score]
  299. genji: [Score]
  300. zhuli: [Score]
  301. mubiaoScore: int
  302. genjiScore: int
  303. zhuliScore: int
  304. shouhuScore: int
  305. lushenScore: int
  306. totalScore: int
  307. def __init__(self):
  308. self.mubiao = []
  309. self.genji = []
  310. self.zhuli = []
  311. self.mubiaoScore = 0
  312. self.genjiScore = 0
  313. self.zhuliScore = 0
  314. self.shouhuScore = 0
  315. self.lushenScore = 0
  316. self.totalScore = 0
  317. def calc_scores(self):
  318. self.mubiaoScore = 0
  319. self.genjiScore = 0
  320. self.genjiScore = 0
  321. self.totalScore = 0
  322. for mb in self.mubiao:
  323. self.mubiaoScore += mb.total
  324. for gj in self.genji:
  325. self.genjiScore += gj.total
  326. for zl in self.zhuli:
  327. self.zhuliScore += zl.total
  328. self.totalScore = self.mubiaoScore + self.genjiScore + self.zhuliScore + self.shouhuScore + self.lushenScore
  329. class SiZhu():
  330. qiankun: str
  331. text: str
  332. wuXing: str
  333. shiShen: str
  334. yinYang: str
  335. isTianGan: bool
  336. isLuShen: bool
  337. isBanLu: bool
  338. weiZhi: int
  339. cangGan1: str
  340. cangGan2: str
  341. cangGan3: str
  342. gan1WuXing: str
  343. gan2WuXing: str
  344. gan3WuXing: str
  345. gan1ShiShen: str
  346. gan2ShiShen: str
  347. gan3ShiShen: str
  348. tongzhuZhangSheng: str
  349. riyuanZhangSheng: str
  350. gaonengs: [GaoNeng]
  351. power: int # 这个是总力量,用来冲、穿的时候使用
  352. selfPower: int # 这个是单独自身的力量,用来计算半合三会等力量支援
  353. muku: MuKu
  354. # 天干地支共用
  355. muPower: int
  356. huoPower: int
  357. tuPower: int
  358. jinPower: int
  359. shuiPower: int
  360. # 墓库专用
  361. biKuMuPower: int
  362. biKuHuoPower: int
  363. biKuTuPower: int
  364. biKuJinPower: int
  365. biKuShuiPower: int
  366. kaiKuMuPower: int
  367. kaiKuHuoPower: int
  368. kaiKuTuPower: int
  369. kaiKuJinPower: int
  370. kaiKuShuiPower: int
  371. extraGaoNengMap: {}
  372. pingjia: PingJia
  373. def __init__(self, qiankun: str, isTianGan: bool, text: str, weizhi: SiZhuWeiZhi):
  374. self.qiankun = qiankun
  375. self.isTianGan = isTianGan
  376. self.isLuShen = False
  377. self.text = text
  378. self.weiZhi = weizhi.value
  379. self.selfPower = 0
  380. self.tuPower = 0
  381. self.huoPower = 0
  382. self.tuPower = 0
  383. self.jinPower = 0
  384. self.shuiPower = 0
  385. self.biKuMuPower = 0
  386. self.biKuHuoPower = 0
  387. self.biKuTuPower = 0
  388. self.biKuJinPower = 0
  389. self.biKuShuiPower = 0
  390. self.kaiKuMuPower = 0
  391. self.kaiKuHuoPower = 0
  392. self.kaiKuTuPower = 0
  393. self.kaiKuJinPower = 0
  394. self.kaiKuShuiPower = 0
  395. self.gaonengs = []
  396. self.muku = None
  397. self.isBanLu = False
  398. if not isTianGan:
  399. if text == "辰":
  400. self.muku = MuKu()
  401. self.muku.text = text
  402. self.muku.wuxing = "水"
  403. elif text == "戌":
  404. self.muku = MuKu()
  405. self.muku.text = text
  406. self.muku.wuxing = "火"
  407. elif text == "丑":
  408. self.muku = MuKu()
  409. self.muku.text = text
  410. self.muku.wuxing = "金"
  411. elif text == "未":
  412. self.muku = MuKu()
  413. self.muku.text = text
  414. self.muku.wuxing = "木"
  415. def getCangGanShiShens(self):
  416. result = []
  417. if self.cangGan1 is not None:
  418. result.append(self.gan1ShiShen)
  419. if self.cangGan2 is not None:
  420. result.append(self.gan2ShiShen)
  421. if self.cangGan3 is not None:
  422. result.append(self.gan3ShiShen)
  423. return result
  424. def findGaoNeng(self, guanxi: str):
  425. result = None
  426. for gn in self.gaonengs:
  427. if gn.guanxi == guanxi:
  428. result = gn
  429. break
  430. return result
  431. def check_lushen(self, riyuan: str):
  432. self.isLuShen = Common.is_lushen(self.text, riyuan)
  433. self.isBanLu = Common.is_banlu(self.text, riyuan)
  434. def get_weizhi_as_zhu(self):
  435. if self.weiZhi == SiZhuWeiZhi.niangan.value or self.weiZhi == SiZhuWeiZhi.nianzhi.value:
  436. return SiZhuWeiZhi.nianzhu.value
  437. if self.weiZhi == SiZhuWeiZhi.yuegan.value or self.weiZhi == SiZhuWeiZhi.yuezhi.value:
  438. return SiZhuWeiZhi.yuezhu.value
  439. if self.weiZhi == SiZhuWeiZhi.rigan.value or self.weiZhi == SiZhuWeiZhi.rizhi.value:
  440. return SiZhuWeiZhi.rizhu.value
  441. if self.weiZhi == SiZhuWeiZhi.shigan.value or self.weiZhi == SiZhuWeiZhi.shizhi.value:
  442. return SiZhuWeiZhi.shizhu.value
  443. return SiZhuWeiZhi.unknown.value
  444. def update_canggan_powers(self, percentanges: [int]):
  445. if self.isTianGan is True:
  446. self.set_wuxing_power(self.wuXing, self.power)
  447. else:
  448. # 普通地支
  449. if self.muku is None:
  450. self.set_wuxing_power(self.gan1WuXing, self.power * percentanges[0])
  451. self.set_wuxing_power(self.gan2WuXing, self.power * percentanges[1])
  452. self.set_wuxing_power(self.gan3WuXing, self.power * percentanges[2])
  453. else:
  454. # 墓库地支
  455. self.set_wuxing_power_of_muku(self.gan1WuXing, self.power * percentanges[0])
  456. self.set_wuxing_power_of_muku(self.gan2WuXing, self.power * percentanges[1])
  457. self.set_wuxing_power_of_muku(self.gan3WuXing, self.power * percentanges[2])
  458. def set_wuxing_power(self, wuxing: str, value: int):
  459. if wuxing is None:
  460. return
  461. value = round(value, 0)
  462. if wuxing == "木":
  463. self.muPower = value
  464. elif wuxing == "火":
  465. self.huoPower = value
  466. elif wuxing == "土":
  467. self.tuPower = value
  468. elif wuxing == "金":
  469. self.jinPower = value
  470. elif wuxing == "水":
  471. self.shuiPower = value
  472. def set_wuxing_power_of_muku(self, wuxing: str, value: int):
  473. if self.muku is None:
  474. return
  475. value = round(value, 0)
  476. if self.muku.isOpen:
  477. if wuxing == "木":
  478. self.kaiKuMuPower = value
  479. elif wuxing == "火":
  480. self.kaiKuHuoPower = value
  481. elif wuxing == "土":
  482. self.kaiKuTuPower = value
  483. elif wuxing == "金":
  484. self.kaiKuJinPower = value
  485. elif wuxing == "水":
  486. self.kaiKuShuiPower = value
  487. else:
  488. if wuxing == "木":
  489. self.biKuMuPower = value
  490. elif wuxing == "火":
  491. self.biKuHuoPower = value
  492. elif wuxing == "土":
  493. self.biKuTuPower = value
  494. elif wuxing == "金":
  495. self.biKuJinPower = value
  496. elif wuxing == "水":
  497. self.biKuShuiPower = value
  498. def get_canggan_power_by_wuxing(self, wuxing: str):
  499. result = 0
  500. state = 0 # 天干地支 = 0, 1:闭库 2:开库
  501. if self.isTianGan is False:
  502. if self.muku is not None:
  503. if self.muku.isOpen is False:
  504. state = 1
  505. else:
  506. state = 2
  507. if state == 0:
  508. if wuxing == "木":
  509. result = self.muPower
  510. elif wuxing == "火":
  511. result = self.huoPower
  512. elif wuxing == "土":
  513. result = self.tuPower
  514. elif wuxing == "金":
  515. result = self.jinPower
  516. elif wuxing == "水":
  517. result = self.shuiPower
  518. elif state == 1:
  519. if wuxing == "木":
  520. result = self.biKuMuPower
  521. elif wuxing == "火":
  522. result = self.biKuHuoPower
  523. elif wuxing == "土":
  524. result = self.biKuTuPower
  525. elif wuxing == "金":
  526. result = self.biKuJinPower
  527. elif wuxing == "水":
  528. result = self.biKuShuiPower
  529. elif state == 2:
  530. if wuxing == "木":
  531. result = self.kaiKuMuPower
  532. elif wuxing == "火":
  533. result = self.kaiKuHuoPower
  534. elif wuxing == "土":
  535. result = self.kaiKuTuPower
  536. elif wuxing == "金":
  537. result = self.kaiKuJinPower
  538. elif wuxing == "水":
  539. result = self.kaiKuShuiPower
  540. return result
  541. class ShenShaInfo():
  542. fenbu: {} # key 是柱的位置
  543. def __init__(self):
  544. self.fenbu = {}
  545. self.fenbu[SiZhuWeiZhi.nianzhu.value] = []
  546. self.fenbu[SiZhuWeiZhi.yuezhu.value] = []
  547. self.fenbu[SiZhuWeiZhi.rizhu.value] = []
  548. self.fenbu[SiZhuWeiZhi.shizhu.value] = []
  549. class ShenSha():
  550. name: str
  551. tip: str
  552. effect: str
  553. def __init__(self, name: str, tip: str):
  554. self.name = name
  555. self.tip = tip
  556. class GuanXiInfo():
  557. shishen: {}
  558. dizhi: {}
  559. tiangan: {}
  560. def __init__(self):
  561. self.shishen = {}
  562. self.dizhi = {}
  563. self.tiangan = {}
  564. class WangShuaiPower():
  565. text: str
  566. wuxing: str
  567. amount: int
  568. value: int
  569. percentage: float
  570. shishen1: str
  571. shishenAmount1: int
  572. shishenValue1: int
  573. shishenPercentage1: float
  574. shishenPercentage1InTotal: float
  575. shishen2: str
  576. shishenAmount2: int
  577. shishenValue2: int
  578. shishenPercentage2: float
  579. shishenPercentage2InTotal: float
  580. zengqiang: int
  581. shishen1ZengQiang: int
  582. shishen2ZengQiang: int
  583. shishen1ValueAfterZengQiang: int
  584. shishen2ValueAfterZengQiang: int
  585. valueAfterZengQiang: int
  586. def __init__(self, wuxing: str, tag: str):
  587. self.wuxing = wuxing
  588. self.text = self.wuxing + tag
  589. self.zengqiang = 0
  590. self.shishen1ZengQiang = 0
  591. self.shishen2ZengQiang = 0
  592. def calcPercentage(self, count: float):
  593. self.percentage = round(self.valueAfterZengQiang / count * 100, 0)
  594. self.shishenPercentage1InTotal = round(self.shishenPercentage1 * self.percentage / 100, 0)
  595. self.shishenPercentage2InTotal = round(self.shishenPercentage2 * self.percentage / 100, 0)
  596. class PowerInfo():
  597. wangShuaiPowers: [WangShuaiPower]
  598. tongdang: int
  599. yidang: int
  600. def __init__(self):
  601. self.wangShuaiPowers = []
  602. class XingGeDesc():
  603. key: str
  604. state: str
  605. low: str
  606. middle: str
  607. strong: str
  608. value: int
  609. zuozhi: bool
  610. def __init__(self):
  611. self.zuozhi = False
  612. class GeJu():
  613. key: str
  614. tip: str
  615. isChong: bool
  616. isChuan: bool
  617. isPo: bool
  618. isBaoHu: bool
  619. def __init__(self):
  620. self.isChong = False
  621. self.isChuan = False
  622. self.isPo = False
  623. self.isBaoHu = False
  624. class ZhenJia():
  625. key: str
  626. zhenValue: int
  627. jiaValue: int
  628. zhenTip: str
  629. jiaTip: str
  630. class ShiShenXiongJi():
  631. key: str
  632. isGood: bool
  633. eft: str
  634. solve: str
  635. tip: str
  636. class MangPaiGong():
  637. he: int = 0
  638. po: int = 0
  639. total: float = 0
  640. zihe: float
  641. tip: str
  642. def __init__(self):
  643. self.tip = "1层功,1000万-1亿,科级;2层功,1e-10e,处级;3层功,10e-100e,厅级;4层功,100e-1000e,部级;更高功,国级"
  644. def calcTotal(self):
  645. self.total = self.he - self.po * 0.5 + self.zihe
  646. class GeJuInfo():
  647. nianlu: GeJu = None
  648. jianlu: GeJu = None
  649. zhuanlu: GeJu = None
  650. guiLu: GeJu = None
  651. banlu: GeJu = None
  652. zhenjia: [ZhenJia]
  653. xushi: bool = False
  654. shishen: [ShiShenXiongJi]
  655. gong: MangPaiGong
  656. zuozhi: str
  657. def hasKeyInZhenJiaList(self, key: str):
  658. result = False
  659. if self.zhenjia is not None:
  660. for zj in self.zhenjia:
  661. if zj.key == key:
  662. result = True
  663. break
  664. return result
  665. class JieGou():
  666. arg1: str
  667. arg2: str
  668. guanxi: str
  669. level: int
  670. shishen1: str
  671. shishen2: str
  672. isTianGan: bool
  673. baohu: bool
  674. def __init__(self, arg1: str, arg2: str, guanxi: str, level: int, shishen1: str, shishen2: str, isTianGan: bool):
  675. self.arg1 = arg1
  676. self.arg2 = arg2
  677. self.guanxi = guanxi
  678. self.level = level
  679. self.shishen1 = shishen1
  680. self.shishen2 = shishen2
  681. self.isTianGan = isTianGan
  682. self.baohu = False
  683. class JieGouInfo():
  684. guanHe: [JieGou]
  685. guanAnHe: [JieGou]
  686. guanChong: [JieGou]
  687. guanChuan: [JieGou]
  688. guanPo: [JieGou]
  689. shaHe: [JieGou]
  690. shaAnHe: [JieGou]
  691. shaChong: [JieGou]
  692. shaChuan: [JieGou]
  693. shaPo: [JieGou]
  694. cai1He: [JieGou]
  695. cai1AnHe: [JieGou]
  696. cai1Chong: [JieGou]
  697. cai1Chuan: [JieGou]
  698. cai1Po: [JieGou]
  699. cai2He: [JieGou]
  700. cai2AnHe: [JieGou]
  701. cai2Chong: [JieGou]
  702. cai2Chuan: [JieGou]
  703. cai2Po: [JieGou]
  704. yinHe: [JieGou]
  705. yinAnHe: [JieGou]
  706. yinChong: [JieGou]
  707. yinChuan: [JieGou]
  708. yinPo: [JieGou]
  709. xiaoHe: [JieGou]
  710. xiaoAnHe: [JieGou]
  711. xiaoChong: [JieGou]
  712. xiaoChuan: [JieGou]
  713. xiaoPo: [JieGou]
  714. shiHe: [JieGou]
  715. shiAnHe: [JieGou]
  716. shiChong: [JieGou]
  717. shiChuan: [JieGou]
  718. shiPo: [JieGou]
  719. shangHe: [JieGou]
  720. shangAnHe: [JieGou]
  721. shangChong: [JieGou]
  722. shangChuan: [JieGou]
  723. shangPo: [JieGou]
  724. biHe: [JieGou]
  725. biAnHe: [JieGou]
  726. biChong: [JieGou]
  727. biChuan: [JieGou]
  728. biPo: [JieGou]
  729. jieHe: [JieGou]
  730. jieAnHe: [JieGou]
  731. jieChong: [JieGou]
  732. jieChuan: [JieGou]
  733. jiePo: [JieGou]
  734. baohu: {}
  735. def __init__(self):
  736. self.guanHe = []
  737. self.guanAnHe = []
  738. self.guanChong = []
  739. self.guanChuan = []
  740. self.guanPo = []
  741. self.shaHe = []
  742. self.shaAnHe = []
  743. self.shaChong = []
  744. self.shaChuan = []
  745. self.shaPo = []
  746. self.cai1He = []
  747. self.cai1AnHe = []
  748. self.cai1Chong = []
  749. self.cai1Chuan = []
  750. self.cai1Po = []
  751. self.cai2He = []
  752. self.cai2AnHe = []
  753. self.cai2Chong = []
  754. self.cai2Chuan = []
  755. self.cai2Po = []
  756. self.yinHe = []
  757. self.yinAnHe = []
  758. self.yinChong = []
  759. self.yinChuan = []
  760. self.yinPo = []
  761. self.xiaoHe = []
  762. self.xiaoAnHe = []
  763. self.xiaoChong = []
  764. self.xiaoChuan = []
  765. self.xiaoPo = []
  766. self.shiHe = []
  767. self.shiAnHe = []
  768. self.shiChong = []
  769. self.shiChuan = []
  770. self.shiPo = []
  771. self.shangHe = []
  772. self.shangAnHe = []
  773. self.shangChong = []
  774. self.shangChuan = []
  775. self.shangPo = []
  776. self.biHe = []
  777. self.biAnHe = []
  778. self.biChong = []
  779. self.biChuan = []
  780. self.biPo = []
  781. self.jieHe = []
  782. self.jieAnHe = []
  783. self.jieChong = []
  784. self.jieChuan = []
  785. self.jiePo = []
  786. self.baohu = {}
  787. for key in ["官", "杀", "财", "才", "印", "枭", "食", "伤", "比", "劫"]:
  788. self.baohu[key] = False
  789. class GaoNengInfo():
  790. heList: [GaoNeng]
  791. chongList: [GaoNeng]
  792. poList: [GaoNeng]
  793. chuanList: [GaoNeng]
  794. banHeList: [GaoNeng]
  795. gongHeList: [GaoNeng]
  796. anHeList: [GaoNeng]
  797. sanHuiList: [GaoNeng]
  798. ziXingList: [GaoNeng]
  799. xingList: [GaoNeng]
  800. def __init__(self):
  801. self.heList = []
  802. self.chongList = []
  803. self.poList = []
  804. self.chuanList = []
  805. self.banHeList = []
  806. self.gongHeList = []
  807. self.anHeList = []
  808. self.sanHuiList = []
  809. self.ziXingList = []
  810. self.xingList = []
  811. class LuckyDayInfo():
  812. year: int
  813. month: int
  814. day: int
  815. niangan: SiZhu
  816. yuegan: SiZhu
  817. rigan: SiZhu
  818. nianzhi: SiZhu
  819. yuezhi: SiZhu
  820. rizhi: SiZhu
  821. def all_gans(self):
  822. return [self.niangan, self.yuegan, self.rigan]
  823. def all_zhis(self):
  824. return [self.nianzhi, self.yuezhi, self.rizhi]
  825. def all_zhus(self):
  826. return [self.niangan, self.nianzhi, self.yuegan, self.yuezhi, self.rigan, self.rizhi]
  827. class BaZi():
  828. qiankun: str
  829. taiyangshi: str
  830. nianGan: SiZhu
  831. nianZhi: SiZhu
  832. yueGan: SiZhu
  833. yueZhi: SiZhu
  834. riGan: SiZhu
  835. riZhi: SiZhu
  836. shiGan: SiZhu
  837. shiZhi: SiZhu
  838. powerInfo: PowerInfo
  839. shenshaInfo: ShenShaInfo
  840. guanxiInfo: GuanXiInfo
  841. xinggeInfo: {}
  842. gejuInfo: GeJuInfo
  843. fangans: [SiZhu]
  844. gaonengInfo: GaoNengInfo
  845. jiankang: {}
  846. jiegouInfo: JieGouInfo
  847. luckyDays: [LuckyDayInfo]
  848. def __has_shensha(self, wz: SiZhuWeiZhi, name: str):
  849. result = False
  850. lst = self.shenshaInfo.fenbu[wz.value]
  851. for dt in lst:
  852. if dt.name == name:
  853. result = True
  854. break
  855. return result
  856. # 这里传入的wz要转换成柱位置
  857. def add_shensha(self, wz: SiZhuWeiZhi, name: str, tip: str, eft: str = None):
  858. if not self.__has_shensha(wz, name):
  859. info = ShenSha()
  860. info.name = name
  861. info.tip = tip
  862. info.effect = eft
  863. self.shenshaInfo.fenbu[wz.value].append(info)
  864. def sizhu_tiangans(self):
  865. return [self.nianGan, self.yueGan, self.riGan, self.shiGan]
  866. def sizhu_dizhis(self):
  867. return [self.nianZhi, self.yueZhi, self.riZhi, self.shiZhi]
  868. def sizhu_all(self):
  869. return [self.nianGan, self.nianZhi, self.yueGan, self.yueZhi, self.riGan, self.riZhi, self.shiGan, self.shiZhi]
  870. def getTianGanDiZhiByZhu(self, wz: int):
  871. if wz == SiZhuWeiZhi.nianzhu:
  872. return [self.nianGan, self.nianZhi]
  873. if wz == SiZhuWeiZhi.yuezhu:
  874. return [self.yueGan, self.yueZhi]
  875. if wz == SiZhuWeiZhi.rizhu:
  876. return [self.riGan, self.riZhi]
  877. if wz == SiZhuWeiZhi.shizhu:
  878. return [self.shiGan, self.shiZhi]
  879. return None
  880. def findTianGanDiZhiInZhu(self, tiangan: str, dizhi: str):
  881. result = []
  882. if self.nianGan.text == tiangan and self.nianZhi.text == dizhi:
  883. result.append(SiZhuWeiZhi.nianzhu.value)
  884. elif self.yueGan.text == tiangan and self.yueZhi.text == dizhi:
  885. result.append(SiZhuWeiZhi.yuezhu.value)
  886. elif self.riGan.text == tiangan and self.riZhi.text == dizhi:
  887. result.append(SiZhuWeiZhi.rizhu.value)
  888. elif self.shiGan.text == tiangan and self.shiZhi.text == dizhi:
  889. result.append(SiZhuWeiZhi.shizhu.value)
  890. return result
  891. def findGaoNengByShiShen(self, shishen1: str, shishen2: str, guanxi: str):
  892. lst = []
  893. temp = self.__get_gaoneng_list_by_guanxi(guanxi)
  894. for dt in temp:
  895. if dt.shishen1 == shishen1 and dt.shishen2 == shishen2:
  896. lst.append(dt)
  897. elif dt.shishen1 == shishen2 and dt.shishen2 == shishen1:
  898. lst.append(dt)
  899. return lst
  900. def findGaoNengByArgs(self, arg1: str, arg2: str, guanxi: str):
  901. lst = []
  902. temp = self.__get_gaoneng_list_by_guanxi(guanxi)
  903. for dt in temp:
  904. if dt.arg1 == arg1 and dt.arg2 == arg2:
  905. lst.append(dt)
  906. elif dt.arg1 == arg2 and dt.arg2 == arg1:
  907. lst.append(dt)
  908. return lst
  909. def findGaoNengByGuanXis(self, shishen1: str, shishen2: str, guanxis: [str]):
  910. lst = []
  911. for guanxi in guanxis:
  912. temp = self.__get_gaoneng_list_by_guanxi(guanxi)
  913. for dt in temp:
  914. if dt.shishen1 == shishen1 and dt.shishen2 == shishen2:
  915. lst.append(dt)
  916. elif dt.shishen1 == shishen2 and dt.shishen2 == shishen1:
  917. lst.append(dt)
  918. return lst
  919. def hasGaoNeng(self, gaoneng: str, wz: SiZhuWeiZhi):
  920. result = False
  921. zhu = self.getZhuByWeiZhi(wz.value)
  922. if zhu is not None:
  923. for gn in zhu.gaonengs:
  924. if gn.text == gaoneng:
  925. result = True
  926. break
  927. return result
  928. # 用来检查某位置是否包含合、冲、穿、刑等关键字的高能关系
  929. def hasGaoNengKey(self, key: str, wz: SiZhuWeiZhi):
  930. result = False
  931. zhu = self.getZhuByWeiZhi(wz.value)
  932. if zhu is not None:
  933. for gn in zhu.gaonengs:
  934. if gn.guanxi == key:
  935. result = True
  936. break
  937. return result
  938. # 这里的位置是以柱为单位的
  939. def hasShenSha(self, name: str, wz: SiZhuWeiZhi):
  940. result = False
  941. lst = self.shenshaInfo.fenbu[wz]
  942. if lst is not None:
  943. for info in lst:
  944. if info.name == name:
  945. result = True
  946. break
  947. return result
  948. def hasShiShen(self, key: str):
  949. # dc.has_all_shishen 替代
  950. result = False
  951. for sz in self.sizhu_all():
  952. if sz.shiShen == key:
  953. result = True
  954. break
  955. return result
  956. # 通过五行查找对应的2个十神
  957. def getShiShensByWuXing(self, wuxing: str):
  958. result = []
  959. if self.guanxiInfo.shishen.keys().__contains__(wuxing):
  960. result = self.guanxiInfo.shishen.get(wuxing)
  961. return result
  962. def getPowerOfShiShen(self, shishen: str):
  963. # dc.get_shishen_power 替代
  964. result = 0
  965. for wsp in self.powerInfo.wangShuaiPowers:
  966. if wsp.shishen1 == shishen:
  967. result = wsp.shishenValue1
  968. break
  969. elif wsp.shishen2 == shishen:
  970. result = wsp.shishenValue2
  971. break
  972. return round(result)
  973. def getPowerOfWuXing(self, wuxing: str):
  974. result = 0
  975. for wsp in self.powerInfo.wangShuaiPowers:
  976. if wsp.wuxing == wuxing:
  977. result = wsp.value
  978. break
  979. return round(result)
  980. # 从xingge info 中查找五行的状态,返回:过旺、旺、衰
  981. def getWuXingState(self, wuxing: str):
  982. result = None
  983. for xg in self.xinggeInfo["wuxing"]:
  984. if xg.key == wuxing:
  985. result = xg.state
  986. break
  987. return result
  988. def __get_gaoneng_list_by_guanxi(self, guanxi: str):
  989. lst = []
  990. if guanxi == "合":
  991. lst = self.gaonengInfo.heList
  992. elif guanxi == "暗合":
  993. lst = self.gaonengInfo.anHeList
  994. elif guanxi == "半合":
  995. lst = self.gaonengInfo.banHeList
  996. elif guanxi == "拱合":
  997. lst = self.gaonengInfo.gongHeList
  998. elif guanxi == "三会":
  999. lst = self.gaonengInfo.sanHuiList
  1000. elif guanxi == "刑":
  1001. lst = self.gaonengInfo.xingList
  1002. elif guanxi == "自刑":
  1003. lst = self.gaonengInfo.ziXingList
  1004. elif guanxi == "冲":
  1005. lst = self.gaonengInfo.chongList
  1006. elif guanxi == "破":
  1007. lst = self.gaonengInfo.poList
  1008. elif guanxi == "穿":
  1009. lst = self.gaonengInfo.chuanList
  1010. return lst
  1011. def countGaoNeng(self, guanxi: str):
  1012. lst = self.__get_gaoneng_list_by_guanxi(guanxi)
  1013. return len(lst)
  1014. def getZhuByWeiZhi(self, weizhi: int):
  1015. if weizhi == SiZhuWeiZhi.niangan.value:
  1016. return self.nianGan
  1017. if weizhi == SiZhuWeiZhi.nianzhi.value:
  1018. return self.nianZhi
  1019. if weizhi == SiZhuWeiZhi.yuegan.value:
  1020. return self.yueGan
  1021. if weizhi == SiZhuWeiZhi.yuezhi.value:
  1022. return self.yueZhi
  1023. if weizhi == SiZhuWeiZhi.rigan.value:
  1024. return self.riGan
  1025. if weizhi == SiZhuWeiZhi.rizhi.value:
  1026. return self.riZhi
  1027. if weizhi == SiZhuWeiZhi.shigan.value:
  1028. return self.shiGan
  1029. if weizhi == SiZhuWeiZhi.shizhi.value:
  1030. return self.shiZhi
  1031. return None
  1032. def __init__(self, request: SiZhuInfoRequest):
  1033. self.qiankun = request.qiankun
  1034. self.nianGan = SiZhu(request.qiankun, True, request.texts[0], SiZhuWeiZhi.niangan)
  1035. self.yueGan = SiZhu(request.qiankun, True, request.texts[1], SiZhuWeiZhi.yuegan)
  1036. self.riGan = SiZhu(request.qiankun, True, request.texts[2], SiZhuWeiZhi.rigan)
  1037. self.shiGan = SiZhu(request.qiankun, True, request.texts[3], SiZhuWeiZhi.shigan)
  1038. self.nianZhi = SiZhu(request.qiankun, False, request.texts[4], SiZhuWeiZhi.nianzhi)
  1039. self.yueZhi = SiZhu(request.qiankun, False, request.texts[5], SiZhuWeiZhi.yuezhi)
  1040. self.riZhi = SiZhu(request.qiankun, False, request.texts[6], SiZhuWeiZhi.rizhi)
  1041. self.shiZhi = SiZhu(request.qiankun, False, request.texts[7], SiZhuWeiZhi.shizhi)
  1042. self.nianZhi.check_lushen(self.riGan.text)
  1043. self.yueZhi.check_lushen(self.riGan.text)
  1044. self.riZhi.check_lushen(self.riGan.text)
  1045. self.shiZhi.check_lushen(self.riGan.text)
  1046. self.powerInfo = PowerInfo()
  1047. self.guanxiInfo = GuanXiInfo()
  1048. self.shenshaInfo = ShenShaInfo()
  1049. self.xinggeInfo = {}
  1050. self.gejuInfo = GeJuInfo()
  1051. self.fangans = []
  1052. self.gaonengInfo = GaoNengInfo()
  1053. self.jiankang = {}
  1054. self.jiegouInfo = JieGouInfo()