22285461@qq.com пре 3 месеци
родитељ
комит
ad48ab1e97
4 измењених фајлова са 1620 додато и 1 уклоњено
  1. 2 1
      wx/logic.py
  2. 1474 0
      yixue/Configs.py
  3. 125 0
      yixue/MBTILogic.py
  4. 19 0
      yixue/Models.py

+ 2 - 1
wx/logic.py

@@ -1,5 +1,5 @@
 from wx.dbTools import DB_WX_GZH_User
-from yixue import SiZhuLogic, GeJuLogic, ZhenDuanLogic
+from yixue import SiZhuLogic, GeJuLogic, ZhenDuanLogic, MBTILogic
 from yixue.Models import BaZi, SiZhuResult
 from yixue.other import CalcNongLi
 from yixue.sizhu import CalcSiZhuByTexts
@@ -126,5 +126,6 @@ def build_bazi(sizhuResult: SiZhuResult, isMan: bool):
     ZhenDuanLogic.about_yinyuan(bazi)
 
     # QuShiLogic.calc_qushi(bazi)
+    MBTILogic.calc(bazi)
 
     return bazi

+ 1474 - 0
yixue/Configs.py

@@ -26,6 +26,7 @@ config_shishen_list = ["官", "杀", "比", "劫", "食", "伤", "印", "枭", "
 config_muku_list = ["辰", "戌", "丑", "未"]
 config_tongdang_list = ["印", "枭", "比", "劫"]
 config_yidang_list = ["官", "杀", "财", "才"]
+config_mbti_key_list = ["外向", "内向", "感觉", "直觉", "思考", "情感", "判断", "知觉"]
 config_wuxing = {
     "甲": "木",
     "乙": "木",
@@ -5349,6 +5350,1479 @@ config_zhenduan_dayun = {
     "劫": "带来更多人际关系的实践,也是对财富管理的考验。",
 }
 
+config_mbti = {
+    "官": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 10,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 5,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 0,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 5,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 0,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 0,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 0,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 0,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 0,
+            },
+            {
+                "desc": "创新思维",
+                "state": 0,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 7,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 7,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 3,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 3,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 10,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 10,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 0,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 0,
+            },
+        ],
+    },
+    "杀": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 10,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 5,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 0,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 5,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 0,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 0,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 0,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 0,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 0,
+            },
+            {
+                "desc": "创新思维",
+                "state": 0,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 7,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 7,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 3,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 3,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 10,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 10,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 0,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 0,
+            },
+        ],
+    },
+    "财": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 0,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 0,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 0,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 0,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 0,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 0,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 7,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 7,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 10,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 3,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 3,
+            },
+            {
+                "desc": "创新思维",
+                "state": 0,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 10,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 0,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 0,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 0,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 10,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 10,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 0,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 0,
+            },
+        ],
+    },
+    "才": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 0,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 0,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 0,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 0,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 0,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 0,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 7,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 7,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 10,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 3,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 3,
+            },
+            {
+                "desc": "创新思维",
+                "state": 0,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 10,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 0,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 0,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 0,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 10,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 10,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 0,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 0,
+            },
+        ],
+    },
+    "印": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 5,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 3,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 5,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 7,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 0,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 7,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 7,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 0,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 3,
+            },
+            {
+                "desc": "创新思维",
+                "state": 3,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 0,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 7,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 0,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 3,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 0,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 7,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 0,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 3,
+            },
+        ],
+    },
+    "枭": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 5,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 3,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 5,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 7,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 0,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 3,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 3,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 0,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 7,
+            },
+            {
+                "desc": "创新思维",
+                "state": 7,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 0,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 7,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 0,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 3,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 0,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 3,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 0,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 7,
+            },
+        ],
+    },
+    "食": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 0,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 7,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 10,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 3,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 3,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 3,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 7,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 7,
+            },
+            {
+                "desc": "创新思维",
+                "state": 7,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 0,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 0,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 0,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 0,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 7,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 7,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 3,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 3,
+            },
+        ],
+    },
+    "伤": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 10,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 3,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 0,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 7,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 7,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 7,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 3,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 3,
+            },
+            {
+                "desc": "创新思维",
+                "state": 3,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 0,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 0,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 0,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 0,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 3,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 3,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 7,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 7,
+            },
+        ],
+    },
+    "比": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 0,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 3,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 0,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 0,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 0,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 0,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 0,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 0,
+            },
+            {
+                "desc": "创新思维",
+                "state": 0,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 3,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 3,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 7,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 7,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 3,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 0,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 7,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 0,
+            },
+        ],
+    },
+    "劫": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 0,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 3,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 0,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 0,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 0,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 0,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 0,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 0,
+            },
+            {
+                "desc": "创新思维",
+                "state": 0,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 3,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 3,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 7,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 7,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 3,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 0,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 7,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 0,
+            },
+        ],
+    },
+    "木": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 5,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 5,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 5,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 5,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 5,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 5,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 3,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 3,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 3,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 7,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 7,
+            },
+            {
+                "desc": "创新思维",
+                "state": 7,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 3,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 3,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 7,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 7,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 7,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 7,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 3,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 3,
+            },
+        ],
+    },
+    "火": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 7,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 3,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 3,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 7,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 7,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 7,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 3,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 3,
+            },
+            {
+                "desc": "创新思维",
+                "state": 3,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 3,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 3,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 7,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 7,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 5,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 5,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 5,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 5,
+            },
+        ],
+    },
+    "土": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 3,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 7,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 7,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 7,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 7,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 7,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 3,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 3,
+            },
+            {
+                "desc": "创新思维",
+                "state": 3,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 5,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 5,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 5,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 5,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 7,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 7,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 3,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 3,
+            },
+        ],
+    },
+    "金": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 7,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 3,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 3,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 5,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 5,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 5,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 5,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 5,
+            },
+            {
+                "desc": "创新思维",
+                "state": 5,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 7,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 7,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 3,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 3,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 3,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 3,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 7,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 7,
+            },
+        ],
+    },
+    "水": {
+        "外向": [
+            {
+                "desc": "从外界获取能量",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢与人互动",
+                "state": 3,
+            },
+            {
+                "desc": "喜欢行动和实践",
+                "state": 3,
+            }
+        ],
+        "内向": [
+            {
+                "desc": "从内心获得能量",
+                "state": 7,
+            },
+            {
+                "desc": "喜欢独处",
+                "state": 7,
+            },
+            {
+                "desc": "更注重思考",
+                "state": 7,
+            },
+        ],
+        "感觉": [
+            {
+                "desc": "注重现实、细节",
+                "state": 3,
+            },
+            {
+                "desc": "依赖经验",
+                "state": 3,
+            },
+            {
+                "desc": "务实主义、现实主义",
+                "state": 3,
+            },
+        ],
+        "直觉": [
+            {
+                "desc": "注重全局、未来",
+                "state": 7,
+            },
+            {
+                "desc": "依赖推演、想象",
+                "state": 7,
+            },
+            {
+                "desc": "创新思维",
+                "state": 7,
+            },
+        ],
+        "思考": [
+            {
+                "desc": "注重逻辑、客观性",
+                "state": 7,
+            },
+            {
+                "desc": "强调事实、原则",
+                "state": 7,
+            },
+        ],
+        "情感": [
+            {
+                "desc": "个人情感、价值观主导判断",
+                "state": 3,
+            },
+            {
+                "desc": "注重关系和谐",
+                "state": 3,
+            },
+        ],
+        "判断": [
+            {
+                "desc": "重视计划、结构",
+                "state": 3,
+            },
+            {
+                "desc": "有条理的进行决策",
+                "state": 3,
+            },
+        ],
+        "知觉": [
+            {
+                "desc": "灵活、开放",
+                "state": 7,
+            },
+            {
+                "desc": "适应力和探索欲",
+                "state": 7,
+            },
+        ],
+    },
+}
+
 
 def get_value(obj: {}, key, default=None):
     result = default

+ 125 - 0
yixue/MBTILogic.py

@@ -0,0 +1,125 @@
+from yixue import Configs
+from yixue.Models import BaZi, MBTIItem, MBTISet
+
+
+def calc(bazi: BaZi):
+    ss_per = __calc_shishen_power_percentage__(bazi)
+    wx_per = __calc_wuxing_power_percentage__(bazi)
+    bazi.mbti = {}
+    for key in Configs.config_mbti_key_list:  # key=外向、内向
+        st = MBTISet()
+        st.key = key
+        st.items = []
+        for ss in Configs.config_shishen_list:
+            power = ss_per[ss]
+            items = Configs.get_value2(Configs.config_mbti, ss, key)
+            for item in items:
+                mbti = MBTIItem()
+                mbti.key = key
+                mbti.shishen = ss
+                mbti.wuxing = None
+                mbti.desc = item["desc"]
+                mbti.state = item["state"]
+                param = item["state"]
+                mbti.power = power
+                mbti.score = power * param
+                st.items.append(mbti)
+
+        for wx in Configs.config_wuxing_list:
+            power = wx_per[wx]
+            items = Configs.get_value2(Configs.config_mbti, wx, key)
+            for item in items:
+                mbti = MBTIItem()
+                mbti.key = key
+                mbti.wuxing = wx
+                mbti.shishen = None
+                mbti.desc = item["desc"]
+                mbti.state = item["state"]
+                param = item["state"]
+                mbti.power = power
+                mbti.score = power * param
+                st.items.append(mbti)
+
+        __calc_score_in_set__(st)
+        bazi.mbti[key] = st
+    __calc_percentages__(["外向", "内向"], bazi)
+    __calc_percentages__(["感觉", "直觉"], bazi)
+    __calc_percentages__(["思考", "情感"], bazi)
+    __calc_percentages__(["判断", "知觉"], bazi)
+
+
+def __calc_percentages__(keys: [str], bazi: BaZi):
+    total = 0
+    for key in keys:
+        st = bazi.mbti[key]
+        total += st.total_score
+
+    for key in keys:
+        st = bazi.mbti[key]
+        st.percentage = round(st.total_score * 100 / total, 0)
+
+
+def __calc_score_in_set__(st: MBTISet):
+    st.total_score = 0
+    st.score_detail = {}
+    for ss in Configs.config_shishen_list:
+        st.score_detail[ss] = 0
+    for wx in Configs.config_wuxing_list:
+        st.score_detail[wx] = 0
+    for item in st.items:
+        st.total_score += item.score
+        if item.shishen is not None:
+            st.score_detail[item.shishen] += item.score
+        if item.wuxing is not None:
+            st.score_detail[item.wuxing] += item.score
+
+
+def __calc_shishen_power_percentage__(bazi: BaZi):
+    total = 0
+    ss_power = {}
+    ss_per = {}
+    keys = [ss for ss in Configs.config_shishen_list]
+    for key in ["官杀", "财星", "印绶", "食伤", "比劫"]:
+        keys.append(key)
+
+    for key in keys:
+        ss_power[key] = 0
+        ss_per[key] = 0
+
+    for ss in Configs.config_shishen_list:
+        step = bazi.power_steps[ss]
+        amount = bazi.counter.power_raw[ss]
+        power = step * amount
+        total += power
+        ss_power[ss] = power
+        if ss in ["官", "杀"]:
+            ss_power["官杀"] += power
+        elif ss in ["财", "才"]:
+            ss_power["财星"] += power
+        elif ss in ["印", "枭"]:
+            ss_power["印绶"] += power
+        elif ss in ["食", "伤"]:
+            ss_power["食伤"] += power
+        elif ss in ["比", "劫"]:
+            ss_power["比劫"] += power
+
+    for ss in keys:
+        ss_per[ss] = round(ss_power[ss] * 100 / total, 0)
+    return ss_per
+
+
+def __calc_wuxing_power_percentage__(bazi: BaZi):
+    total = 0
+    wx_power = {}
+    wx_per = {}
+    for wx in Configs.config_wuxing_list:
+        step = bazi.power_steps[wx]
+        amount = bazi.counter.power_raw[wx]
+        power = step * amount
+        total += power
+        wx_power[wx] = power
+
+    for wx in Configs.config_wuxing_list:
+        wx_per[wx] = round(wx_power[wx] * 100 / total, 0)
+
+    return wx_per

+ 19 - 0
yixue/Models.py

@@ -445,6 +445,24 @@ class QuShiSet(BaseYiXue):
     liunian: [LiuNianQuShi]
 
 
+class MBTIItem(BaseYiXue):
+    key: str
+    desc: str
+    state: int
+    shishen: str
+    wuxing: str
+    power: int
+    score: int
+
+
+class MBTISet(BaseYiXue):
+    key: str
+    items: [MBTIItem]
+    total_score: int
+    score_detail: {}
+    percentage: int
+
+
 class BaZi(BaseYiXue):
     is_man: bool
     tai_yang_shi: datetime
@@ -475,6 +493,7 @@ class BaZi(BaseYiXue):
     liunian_geju_score: {}
     zhenduan: ZhenDuanSet
     qushi: QuShiSet
+    mbti: {}
 
     @staticmethod
     def build(sizhu: SiZhuResult):