- qimen-data.ts: 九宫/八门/九星/八神/三奇六仪/五行生克 - plate.ts: 时家奇门排盘(阴阳遁/局数/天地盘/八门/九星/八神/空亡/驿马) - run-qimen.ts: CLI入口(九宫格式化输出) - duangua-prompt.md: 断局分析提示词 - SKILL.md: 完整文档
150 lines
7.3 KiB
TypeScript
150 lines
7.3 KiB
TypeScript
// 奇门遁甲基础数据层
|
|
// 九宫、八门、九星、八神、三奇六仪
|
|
|
|
// 十天干
|
|
export const STEMS = ['甲','乙','丙','丁','戊','己','庚','辛','壬','癸'] as const;
|
|
export type Stem = typeof STEMS[number];
|
|
|
|
// 十二地支
|
|
export const BRANCHES = ['子','丑','寅','卯','辰','巳','午','未','申','酉','戌','亥'] as const;
|
|
export type Branch = typeof BRANCHES[number];
|
|
|
|
// ═══════════════════════════════════
|
|
// 九宫(洛书九宫,固定方位)
|
|
// ═══════════════════════════════════
|
|
export interface Palace {
|
|
number: number; // 宫位数 1-9
|
|
name: string; // 宫名
|
|
direction: string; // 方位
|
|
element: string; // 五行
|
|
trigram: string; // 八卦
|
|
earthBranch: Branch; // 地盘地支
|
|
}
|
|
|
|
export const PALACES: Palace[] = [
|
|
{ number: 1, name: '坎一宫', direction: '北', element: '水', trigram: '坎', earthBranch: '子' },
|
|
{ number: 2, name: '坤二宫', direction: '西南', element: '土', trigram: '坤', earthBranch: '未' },
|
|
{ number: 3, name: '震三宫', direction: '东', element: '木', trigram: '震', earthBranch: '卯' },
|
|
{ number: 4, name: '巽四宫', direction: '东南', element: '木', trigram: '巽', earthBranch: '辰' },
|
|
{ number: 5, name: '中五宫', direction: '中', element: '土', trigram: '中', earthBranch: '中' as any },
|
|
{ number: 6, name: '乾六宫', direction: '西北', element: '金', trigram: '乾', earthBranch: '戌' },
|
|
{ number: 7, name: '兑七宫', direction: '西', element: '金', trigram: '兑', earthBranch: '酉' },
|
|
{ number: 8, name: '艮八宫', direction: '东北', element: '土', trigram: '艮', earthBranch: '丑' },
|
|
{ number: 9, name: '离九宫', direction: '南', element: '火', trigram: '离', earthBranch: '午' },
|
|
];
|
|
|
|
// 洛书飞宫顺序(1→8→3→4→9→2→7→6)
|
|
export const LUOSHU_ORDER = [1, 8, 3, 4, 9, 2, 7, 6] as const;
|
|
|
|
// ═══════════════════════════════════
|
|
// 八门
|
|
// ═══════════════════════════════════
|
|
export interface Gate {
|
|
name: string;
|
|
element: string;
|
|
nature: string; // 吉/凶/平
|
|
attribute: string; // 属性
|
|
}
|
|
|
|
export const EIGHT_GATES: Gate[] = [
|
|
{ name: '休门', element: '水', nature: '吉', attribute: '休息、贵人' },
|
|
{ name: '生门', element: '土', nature: '大吉', attribute: '生机、财富' },
|
|
{ name: '伤门', element: '木', nature: '凶', attribute: '伤害、争斗' },
|
|
{ name: '杜门', element: '木', nature: '平', attribute: '闭塞、隐藏' },
|
|
{ name: '景门', element: '火', nature: '平', attribute: '文书、考试' },
|
|
{ name: '死门', element: '土', nature: '大凶', attribute: '死亡、终结' },
|
|
{ name: '惊门', element: '金', nature: '凶', attribute: '惊恐、口舌' },
|
|
{ name: '开门', element: '金', nature: '大吉', attribute: '开启、事业' },
|
|
];
|
|
|
|
// 八门原始宫位(阳遁顺排,阴遁逆排)
|
|
// 休门在坎一宫,顺时针:休(坎1)→死(坤2)→伤(震3)→杜(巽4)→中(中5寄坤2)→开(乾6)→惊(兑7)→生(艮8)
|
|
export const GATE_ORIGIN_PALACE: Record<string, number> = {
|
|
'休门': 1, '死门': 2, '伤门': 3, '杜门': 4,
|
|
'景门': 9, '开门': 6, '惊门': 7, '生门': 8,
|
|
};
|
|
|
|
// ═══════════════════════════════════
|
|
// 九星
|
|
// ═══════════════════════════════════
|
|
export interface Star {
|
|
name: string;
|
|
element: string;
|
|
nature: string; // 吉/凶/平
|
|
attribute: string;
|
|
}
|
|
|
|
export const NINE_STARS: Star[] = [
|
|
{ name: '天蓬', element: '水', nature: '凶', attribute: '盗贼、淫邪' },
|
|
{ name: '天芮', element: '土', nature: '凶', attribute: '疾病、阴人' },
|
|
{ name: '天冲', element: '木', nature: '平', attribute: '冲杀、武勇' },
|
|
{ name: '天辅', element: '木', nature: '大吉', attribute: '文运、辅佐' },
|
|
{ name: '天禽', element: '土', nature: '大吉', attribute: '中央、帝王' },
|
|
{ name: '天心', element: '金', nature: '大吉', attribute: '智慧、医术' },
|
|
{ name: '天柱', element: '金', nature: '凶', attribute: '口舌、破损' },
|
|
{ name: '天任', element: '土', nature: '吉', attribute: '田土、财富' },
|
|
{ name: '天英', element: '火', nature: '平', attribute: '光明、文书' },
|
|
];
|
|
|
|
// 九星原始宫位(与洛书对应)
|
|
export const STAR_ORIGIN_PALACE: Record<string, number> = {
|
|
'天蓬': 1, '天芮': 2, '天冲': 3, '天辅': 4,
|
|
'天禽': 5, '天心': 6, '天柱': 7, '天任': 8, '天英': 9,
|
|
};
|
|
|
|
// ═══════════════════════════════════
|
|
// 八神
|
|
// ═══════════════════════════════════
|
|
export interface Spirit {
|
|
name: string;
|
|
nature: string; // 吉/凶/平
|
|
attribute: string;
|
|
}
|
|
|
|
export const EIGHT_SPIRITS: Spirit[] = [
|
|
{ name: '值符', nature: '大吉', attribute: '首领、贵人' },
|
|
{ name: '腾蛇', nature: '凶', attribute: '惊恐、怪异' },
|
|
{ name: '太阴', nature: '吉', attribute: '阴私、暗助' },
|
|
{ name: '六合', nature: '吉', attribute: '合作、婚姻' },
|
|
{ name: '白虎', nature: '大凶', attribute: '凶险、伤灾' },
|
|
{ name: '玄武', nature: '凶', attribute: '盗贼、暗昧' },
|
|
{ name: '九地', nature: '吉', attribute: '稳固、土地' },
|
|
{ name: '九天', nature: '大吉', attribute: '高远、出行' },
|
|
];
|
|
|
|
// ═══════════════════════════════════
|
|
// 三奇六仪
|
|
// ═══════════════════════════════════
|
|
// 三奇:乙(日奇)、丙(月奇)、丁(星奇)
|
|
// 六仪:戊、己、庚、辛、壬、癸
|
|
// 排列顺序(阳遁):戊→己→庚→辛→壬→癸→丁→丙→乙
|
|
// 排列顺序(阴遁):戊→乙→丙→丁→癸→壬→辛→庚→己
|
|
|
|
export const YANGDUN_ORDER: Stem[] = ['戊','己','庚','辛','壬','癸','丁','丙','乙'];
|
|
export const YINDUN_ORDER: Stem[] = ['戊','乙','丙','丁','癸','壬','辛','庚','己'];
|
|
|
|
// 天干五行
|
|
export const STEM_ELEMENT: Record<Stem, string> = {
|
|
'甲':'木','乙':'木','丙':'火','丁':'火','戊':'土','己':'土','庚':'金','辛':'金','壬':'水','癸':'水'
|
|
};
|
|
|
|
// 地支五行
|
|
export const BRANCH_ELEMENT: Record<string, string> = {
|
|
'子':'水','丑':'土','寅':'木','卯':'木','辰':'土','巳':'火',
|
|
'午':'火','未':'土','申':'金','酉':'金','戌':'土','亥':'水'
|
|
};
|
|
|
|
// 五行生克
|
|
export const WUXING_SHENG: Record<string, string> = { '木':'火','火':'土','土':'金','金':'水','水':'木' };
|
|
export const WUXING_KE: Record<string, string> = { '木':'土','土':'水','水':'火','火':'金','金':'木' };
|
|
|
|
// 判断五行关系
|
|
export function getRelation(a: string, b: string): string {
|
|
if (a === b) return '比和';
|
|
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 '无关系';
|
|
}
|