- 八卦基础数据(先天数/五行/方位/生克关系) - 六十四卦完整数据(卦名/卦辞/象辞/吉凶/关键词) - 体用分析引擎(动爻→体用→五行生克→旺衰判定) - 变卦/互卦计算 - 三种起卦方式:数字法、时间法、外应法(梅花心易) - CLI入口:JSON/文本双格式输出 - 断卦分析 prompt + 梅花心易 prompt + 海报版 prompt - HTML海报模板(古风暗色系)
38 lines
2.2 KiB
JavaScript
38 lines
2.2 KiB
JavaScript
// 先天八卦数:乾1 兑2 离3 震4 巽5 坎6 艮7 坤8
|
|
export const TRIGRAMS = {
|
|
1: { number: 1, name: '乾', symbol: '☰', element: '金', direction: '西北', attribute: '天', bodyPart: '头/骨/肺', family: '父', nature: '刚健' },
|
|
2: { number: 2, name: '兑', symbol: '☱', element: '金', direction: '西', attribute: '泽', bodyPart: '口/肺', family: '少女', nature: '喜悦' },
|
|
3: { number: 3, name: '离', symbol: '☲', element: '火', direction: '南', attribute: '火', bodyPart: '目/心', family: '中女', nature: '文明' },
|
|
4: { number: 4, name: '震', symbol: '☳', element: '木', direction: '东', attribute: '雷', bodyPart: '足/肝', family: '长男', nature: '动' },
|
|
5: { number: 5, name: '巽', symbol: '☴', element: '木', direction: '东南', attribute: '风', bodyPart: '股/胆', family: '长女', nature: '入' },
|
|
6: { number: 6, name: '坎', symbol: '☵', element: '水', direction: '北', attribute: '水', bodyPart: '耳/肾', family: '中男', nature: '陷' },
|
|
7: { number: 7, name: '艮', symbol: '☶', element: '土', direction: '东北', attribute: '山', bodyPart: '手/脾', family: '少男', nature: '止' },
|
|
8: { number: 8, name: '坤', symbol: '☷', element: '土', direction: '西南', attribute: '地', bodyPart: '腹/胃', family: '母', nature: '顺' },
|
|
};
|
|
// 五行生克
|
|
export const WUXING_SHENG = {
|
|
'木': '火', '火': '土', '土': '金', '金': '水', '水': '木'
|
|
};
|
|
export const WUXING_KE = {
|
|
'木': '土', '土': '水', '水': '火', '火': '金', '金': '木'
|
|
};
|
|
// 判断生克关系
|
|
export function getRelation(a, b) {
|
|
if (WUXING_SHENG[a] === b)
|
|
return `${a}生${b}(我生)`;
|
|
if (WUXING_SHENG[b] === a)
|
|
return `${b}生${a}(生我)`;
|
|
if (WUXING_KE[a] === b)
|
|
return `${a}克${b}(我克)`;
|
|
if (WUXING_KE[b] === a)
|
|
return `${b}克${a}(克我)`;
|
|
return `${a}与${b}比和`;
|
|
}
|
|
// 获取卦象(上卦+下卦 → 卦名)
|
|
export function getTrigramByNumber(n) {
|
|
// 数字取卦:除8取余,整除取8(坤)
|
|
const remainder = n % 8;
|
|
const key = remainder === 0 ? 8 : remainder;
|
|
return TRIGRAMS[key];
|
|
}
|