kentang2017 / kinqimen

A Python package of Qimendunjia, one of the three greatest Ancient Chinese Divination Tools ever. Python 奇門遁甲,占卜用,運籌帷幄。包含金函玉鏡日家奇門、拆補置閏時家奇門、刻家奇門排盤。
https://pypi.org/project/kinqimen
4 stars 0 forks source link

Re: 六仪击刑,入墓,伏吟、天显时格、五不遇时、宫迫 #44

Open jackygu2006 opened 4 months ago

jackygu2006 commented 4 months ago

Hey, guys,

我添加了六仪击刑,入墓,伏吟、天显时格、五不遇时、宫迫等功能,请review下,看是否能合并到你的代码中,我的代码如下,在kinqimen.py中:

    #六仪擊刑 
    def jixing(self, sky):
        jixing_mapping = {"庚":"艮","戊":"震","癸":"巽","壬":"巽","辛":"离","己":"坤"}
        result = {}
        for gong, gan in sky.items():
            if gan in jixing_mapping and gong == jixing_mapping[gan]:
                result[gan] = gong
        return result

        #入墓
    def rumu(self, sky, earth):
        rumu_mapping = {"乙":"坤","癸":"坤","乙":"乾","丙":"乾","戊":"乾","辛":"巽","壬":"巽","丁":"艮","己":"艮","庚":"艮"}
        result = {}
        for gong, gan in sky.items():
            if gan in rumu_mapping and gong == rumu_mapping[gan]:
                result[gan] = gong
        for gong, gan in earth.items():
            if gan in rumu_mapping and gong == rumu_mapping[gan]:
                result[gan] = gong
        return result

    # 伏吟    
    def fuying(self, star, door):
        result = {}
        if door['坎'] == '休':
            result['门伏吟'] = 1
        elif door['坎'] == '景':
            result['门反伏吟'] = 1

        if star['坎'] == '蓬':
            result['星伏吟'] = 1
        elif star['坎'] == '英':
            result['星反伏吟'] = 1

        return result

    # 天显时格
    def tianxian(self, gz):
      ri = gz[2]
      shi = gz[3]
      mapping = {'甲':['甲子','甲戌'],'乙':['甲申'],'丙':['甲午'],'丁':['甲辰'],'戊':['甲寅'],'己':['甲子','甲戌'],'庚':['甲申'],'辛':['甲午'],'壬':['甲辰'],'癸':['甲寅']}
      if shi in mapping[ri[0]]:
        return 1
      else:
        return 0

    # 五不遇时
    def wubuyushi(self, gz):
      ri = gz[2]
      shi = gz[3]
      mapping = {'甲':'庚午','乙':'辛巳','丙':'壬辰','丁':'癸卯','戊':'甲寅','己':'乙丑','庚':'丙子','辛':'丁酉','壬':'戊申','癸':'己未'}
      if mapping[ri[0]] == shi:
        return 1
      else:
        return 0

    # 宫迫 
    def gongpo(self, doors):
      gongpo = {}
      menpo = {}
      for gong, door in doors.items():
        doorWuxing = config.doorWuxing[door]
        gongWuxing = config.gongWuxing[gong]
        # print(gong, door, gongWuxing, doorWuxing)
        if doorWuxing[1] == gongWuxing[0]:
          gongpo[gong] = door
        if gongWuxing[1] == doorWuxing[0]:
          menpo[gong] = door
      return {"宫迫": gongpo, "门迫": menpo}
kentang2017 commented 4 months ago

謝謝建議, 需要再做修改才能放進去