@gracefullight/saju 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +314 -28
- package/README.md +314 -28
- package/dist/__tests__/four-pillars.test.js +52 -40
- package/dist/__tests__/luck.test.d.ts +2 -0
- package/dist/__tests__/luck.test.d.ts.map +1 -0
- package/dist/__tests__/luck.test.js +33 -0
- package/dist/__tests__/lunar.test.d.ts +2 -0
- package/dist/__tests__/lunar.test.d.ts.map +1 -0
- package/dist/__tests__/lunar.test.js +83 -0
- package/dist/__tests__/relations.test.d.ts +2 -0
- package/dist/__tests__/relations.test.d.ts.map +1 -0
- package/dist/__tests__/relations.test.js +90 -0
- package/dist/__tests__/saju.test.d.ts +2 -0
- package/dist/__tests__/saju.test.d.ts.map +1 -0
- package/dist/__tests__/saju.test.js +133 -0
- package/dist/__tests__/solar-terms.test.d.ts +2 -0
- package/dist/__tests__/solar-terms.test.d.ts.map +1 -0
- package/dist/__tests__/solar-terms.test.js +121 -0
- package/dist/__tests__/strength.test.d.ts +2 -0
- package/dist/__tests__/strength.test.d.ts.map +1 -0
- package/dist/__tests__/strength.test.js +44 -0
- package/dist/__tests__/ten-gods.test.d.ts +2 -0
- package/dist/__tests__/ten-gods.test.d.ts.map +1 -0
- package/dist/__tests__/ten-gods.test.js +119 -0
- package/dist/__tests__/yongshen.test.d.ts +2 -0
- package/dist/__tests__/yongshen.test.d.ts.map +1 -0
- package/dist/__tests__/yongshen.test.js +62 -0
- package/dist/core/four-pillars.d.ts +2 -0
- package/dist/core/four-pillars.d.ts.map +1 -1
- package/dist/core/four-pillars.js +7 -4
- package/dist/core/luck.d.ts +41 -0
- package/dist/core/luck.d.ts.map +1 -0
- package/dist/core/luck.js +96 -0
- package/dist/core/lunar.d.ts +13 -0
- package/dist/core/lunar.d.ts.map +1 -0
- package/dist/core/lunar.js +24 -0
- package/dist/core/relations.d.ts +94 -0
- package/dist/core/relations.d.ts.map +1 -0
- package/dist/core/relations.js +305 -0
- package/dist/core/solar-terms.d.ts +155 -0
- package/dist/core/solar-terms.d.ts.map +1 -0
- package/dist/core/solar-terms.js +266 -0
- package/dist/core/strength.d.ts +18 -0
- package/dist/core/strength.d.ts.map +1 -0
- package/dist/core/strength.js +255 -0
- package/dist/core/ten-gods.d.ts +130 -0
- package/dist/core/ten-gods.d.ts.map +1 -0
- package/dist/core/ten-gods.js +335 -0
- package/dist/core/yongshen.d.ts +20 -0
- package/dist/core/yongshen.d.ts.map +1 -0
- package/dist/core/yongshen.js +216 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -0
- package/package.json +15 -12
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 십신(十神) 분석 모듈
|
|
3
|
+
* Ten Gods analysis based on the relationship between Day Master and other elements
|
|
4
|
+
*/
|
|
5
|
+
import { STEMS, BRANCHES } from "./four-pillars";
|
|
6
|
+
export const ELEMENTS = ["wood", "fire", "earth", "metal", "water"];
|
|
7
|
+
export const TEN_GODS = [
|
|
8
|
+
"비견",
|
|
9
|
+
"겁재",
|
|
10
|
+
"식신",
|
|
11
|
+
"상관",
|
|
12
|
+
"편재",
|
|
13
|
+
"정재",
|
|
14
|
+
"편관",
|
|
15
|
+
"정관",
|
|
16
|
+
"편인",
|
|
17
|
+
"정인",
|
|
18
|
+
];
|
|
19
|
+
// 십신 한자 매핑
|
|
20
|
+
export const TEN_GOD_HANJA = {
|
|
21
|
+
비견: "比肩",
|
|
22
|
+
겁재: "劫財",
|
|
23
|
+
식신: "食神",
|
|
24
|
+
상관: "傷官",
|
|
25
|
+
편재: "偏財",
|
|
26
|
+
정재: "正財",
|
|
27
|
+
편관: "偏官",
|
|
28
|
+
정관: "正官",
|
|
29
|
+
편인: "偏印",
|
|
30
|
+
정인: "正印",
|
|
31
|
+
};
|
|
32
|
+
// 십신 영문 매핑
|
|
33
|
+
export const TEN_GOD_ENGLISH = {
|
|
34
|
+
비견: "Companion",
|
|
35
|
+
겁재: "Rob Wealth",
|
|
36
|
+
식신: "Eating God",
|
|
37
|
+
상관: "Hurting Officer",
|
|
38
|
+
편재: "Indirect Wealth",
|
|
39
|
+
정재: "Direct Wealth",
|
|
40
|
+
편관: "Seven Killings",
|
|
41
|
+
정관: "Direct Officer",
|
|
42
|
+
편인: "Indirect Seal",
|
|
43
|
+
정인: "Direct Seal",
|
|
44
|
+
};
|
|
45
|
+
// 천간별 오행
|
|
46
|
+
const STEM_ELEMENT = {
|
|
47
|
+
甲: "wood",
|
|
48
|
+
乙: "wood",
|
|
49
|
+
丙: "fire",
|
|
50
|
+
丁: "fire",
|
|
51
|
+
戊: "earth",
|
|
52
|
+
己: "earth",
|
|
53
|
+
庚: "metal",
|
|
54
|
+
辛: "metal",
|
|
55
|
+
壬: "water",
|
|
56
|
+
癸: "water",
|
|
57
|
+
};
|
|
58
|
+
// 천간별 음양
|
|
59
|
+
const STEM_POLARITY = {
|
|
60
|
+
甲: "yang",
|
|
61
|
+
乙: "yin",
|
|
62
|
+
丙: "yang",
|
|
63
|
+
丁: "yin",
|
|
64
|
+
戊: "yang",
|
|
65
|
+
己: "yin",
|
|
66
|
+
庚: "yang",
|
|
67
|
+
辛: "yin",
|
|
68
|
+
壬: "yang",
|
|
69
|
+
癸: "yin",
|
|
70
|
+
};
|
|
71
|
+
// 지지별 오행
|
|
72
|
+
const BRANCH_ELEMENT = {
|
|
73
|
+
子: "water",
|
|
74
|
+
丑: "earth",
|
|
75
|
+
寅: "wood",
|
|
76
|
+
卯: "wood",
|
|
77
|
+
辰: "earth",
|
|
78
|
+
巳: "fire",
|
|
79
|
+
午: "fire",
|
|
80
|
+
未: "earth",
|
|
81
|
+
申: "metal",
|
|
82
|
+
酉: "metal",
|
|
83
|
+
戌: "earth",
|
|
84
|
+
亥: "water",
|
|
85
|
+
};
|
|
86
|
+
// 지지별 음양
|
|
87
|
+
const BRANCH_POLARITY = {
|
|
88
|
+
子: "yang",
|
|
89
|
+
丑: "yin",
|
|
90
|
+
寅: "yang",
|
|
91
|
+
卯: "yin",
|
|
92
|
+
辰: "yang",
|
|
93
|
+
巳: "yin",
|
|
94
|
+
午: "yang",
|
|
95
|
+
未: "yin",
|
|
96
|
+
申: "yang",
|
|
97
|
+
酉: "yin",
|
|
98
|
+
戌: "yang",
|
|
99
|
+
亥: "yin",
|
|
100
|
+
};
|
|
101
|
+
// 장간(藏干) - 지지 속에 숨은 천간들
|
|
102
|
+
// 순서: [본기(本氣), 중기(中氣)?, 여기(餘氣)?]
|
|
103
|
+
export const HIDDEN_STEMS = {
|
|
104
|
+
子: ["癸"],
|
|
105
|
+
丑: ["己", "癸", "辛"],
|
|
106
|
+
寅: ["甲", "丙", "戊"],
|
|
107
|
+
卯: ["乙"],
|
|
108
|
+
辰: ["戊", "乙", "癸"],
|
|
109
|
+
巳: ["丙", "庚", "戊"],
|
|
110
|
+
午: ["丁", "己"],
|
|
111
|
+
未: ["己", "丁", "乙"],
|
|
112
|
+
申: ["庚", "壬", "戊"],
|
|
113
|
+
酉: ["辛"],
|
|
114
|
+
戌: ["戊", "辛", "丁"],
|
|
115
|
+
亥: ["壬", "甲"],
|
|
116
|
+
};
|
|
117
|
+
// 오행 상생 관계 (A가 B를 생함)
|
|
118
|
+
// 목생화, 화생토, 토생금, 금생수, 수생목
|
|
119
|
+
const GENERATES = {
|
|
120
|
+
wood: "fire",
|
|
121
|
+
fire: "earth",
|
|
122
|
+
earth: "metal",
|
|
123
|
+
metal: "water",
|
|
124
|
+
water: "wood",
|
|
125
|
+
};
|
|
126
|
+
// 오행 상극 관계 (A가 B를 극함)
|
|
127
|
+
// 목극토, 토극수, 수극화, 화극금, 금극목
|
|
128
|
+
const CONTROLS = {
|
|
129
|
+
wood: "earth",
|
|
130
|
+
earth: "water",
|
|
131
|
+
water: "fire",
|
|
132
|
+
fire: "metal",
|
|
133
|
+
metal: "wood",
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* 천간의 오행을 반환
|
|
137
|
+
*/
|
|
138
|
+
export function getStemElement(stem) {
|
|
139
|
+
const element = STEM_ELEMENT[stem];
|
|
140
|
+
if (!element)
|
|
141
|
+
throw new Error(`Invalid stem: ${stem}`);
|
|
142
|
+
return element;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 천간의 음양을 반환
|
|
146
|
+
*/
|
|
147
|
+
export function getStemPolarity(stem) {
|
|
148
|
+
const polarity = STEM_POLARITY[stem];
|
|
149
|
+
if (!polarity)
|
|
150
|
+
throw new Error(`Invalid stem: ${stem}`);
|
|
151
|
+
return polarity;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* 지지의 오행을 반환
|
|
155
|
+
*/
|
|
156
|
+
export function getBranchElement(branch) {
|
|
157
|
+
const element = BRANCH_ELEMENT[branch];
|
|
158
|
+
if (!element)
|
|
159
|
+
throw new Error(`Invalid branch: ${branch}`);
|
|
160
|
+
return element;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 지지의 음양을 반환
|
|
164
|
+
*/
|
|
165
|
+
export function getBranchPolarity(branch) {
|
|
166
|
+
const polarity = BRANCH_POLARITY[branch];
|
|
167
|
+
if (!polarity)
|
|
168
|
+
throw new Error(`Invalid branch: ${branch}`);
|
|
169
|
+
return polarity;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* 지지의 장간(숨은 천간들)을 반환
|
|
173
|
+
*/
|
|
174
|
+
export function getHiddenStems(branch) {
|
|
175
|
+
const hidden = HIDDEN_STEMS[branch];
|
|
176
|
+
if (!hidden)
|
|
177
|
+
throw new Error(`Invalid branch: ${branch}`);
|
|
178
|
+
return [...hidden];
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* 일간(Day Master)과 다른 천간의 관계에서 십신을 판정
|
|
182
|
+
* @param dayMaster 일간 (예: "甲")
|
|
183
|
+
* @param targetStem 비교 대상 천간
|
|
184
|
+
* @returns 십신
|
|
185
|
+
*/
|
|
186
|
+
export function getTenGod(dayMaster, targetStem) {
|
|
187
|
+
const dmElement = getStemElement(dayMaster);
|
|
188
|
+
const dmPolarity = getStemPolarity(dayMaster);
|
|
189
|
+
const targetElement = getStemElement(targetStem);
|
|
190
|
+
const targetPolarity = getStemPolarity(targetStem);
|
|
191
|
+
const samePolarity = dmPolarity === targetPolarity;
|
|
192
|
+
// 같은 오행
|
|
193
|
+
if (dmElement === targetElement) {
|
|
194
|
+
return samePolarity ? "비견" : "겁재";
|
|
195
|
+
}
|
|
196
|
+
// 내가 생하는 오행 (식상)
|
|
197
|
+
if (GENERATES[dmElement] === targetElement) {
|
|
198
|
+
return samePolarity ? "식신" : "상관";
|
|
199
|
+
}
|
|
200
|
+
// 내가 극하는 오행 (재성)
|
|
201
|
+
if (CONTROLS[dmElement] === targetElement) {
|
|
202
|
+
return samePolarity ? "편재" : "정재";
|
|
203
|
+
}
|
|
204
|
+
// 나를 극하는 오행 (관성)
|
|
205
|
+
if (CONTROLS[targetElement] === dmElement) {
|
|
206
|
+
return samePolarity ? "편관" : "정관";
|
|
207
|
+
}
|
|
208
|
+
// 나를 생하는 오행 (인성)
|
|
209
|
+
if (GENERATES[targetElement] === dmElement) {
|
|
210
|
+
return samePolarity ? "편인" : "정인";
|
|
211
|
+
}
|
|
212
|
+
throw new Error(`Unable to determine ten god relationship: ${dayMaster} -> ${targetStem}`);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 지지에 대한 십신 판정 (본기 기준)
|
|
216
|
+
*/
|
|
217
|
+
export function getTenGodForBranch(dayMaster, branch) {
|
|
218
|
+
const hiddenStems = getHiddenStems(branch);
|
|
219
|
+
// 본기(첫 번째 장간)를 기준으로 판정
|
|
220
|
+
return getTenGod(dayMaster, hiddenStems[0]);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* 지지의 모든 장간에 대한 십신 분석
|
|
224
|
+
*/
|
|
225
|
+
export function getTenGodsForBranch(dayMaster, branch) {
|
|
226
|
+
const hiddenStems = getHiddenStems(branch);
|
|
227
|
+
const types = ["본기", "중기", "여기"];
|
|
228
|
+
return hiddenStems.map((stem, i) => ({
|
|
229
|
+
stem,
|
|
230
|
+
tenGod: getTenGod(dayMaster, stem),
|
|
231
|
+
type: types[i],
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* 사주 팔자에서 십신 분석
|
|
236
|
+
* @param yearPillar 연주 (예: "甲子")
|
|
237
|
+
* @param monthPillar 월주
|
|
238
|
+
* @param dayPillar 일주
|
|
239
|
+
* @param hourPillar 시주
|
|
240
|
+
*/
|
|
241
|
+
export function analyzeTenGods(yearPillar, monthPillar, dayPillar, hourPillar) {
|
|
242
|
+
const dayMaster = dayPillar[0];
|
|
243
|
+
const analyzePillar = (pillar, isDayPillar = false) => {
|
|
244
|
+
const stem = pillar[0];
|
|
245
|
+
const branch = pillar[1];
|
|
246
|
+
const hiddenStems = getHiddenStems(branch).map((hs) => ({
|
|
247
|
+
stem: hs,
|
|
248
|
+
tenGod: getTenGod(dayMaster, hs),
|
|
249
|
+
}));
|
|
250
|
+
return {
|
|
251
|
+
stem: {
|
|
252
|
+
char: stem,
|
|
253
|
+
tenGod: isDayPillar ? "일간" : getTenGod(dayMaster, stem),
|
|
254
|
+
},
|
|
255
|
+
branch: {
|
|
256
|
+
char: branch,
|
|
257
|
+
tenGod: getTenGod(dayMaster, hiddenStems[0].stem),
|
|
258
|
+
hiddenStems,
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
return {
|
|
263
|
+
year: analyzePillar(yearPillar),
|
|
264
|
+
month: analyzePillar(monthPillar),
|
|
265
|
+
day: analyzePillar(dayPillar, true),
|
|
266
|
+
hour: analyzePillar(hourPillar),
|
|
267
|
+
dayMaster,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* 십신 통계 (각 십신이 몇 개 있는지)
|
|
272
|
+
*/
|
|
273
|
+
export function countTenGods(analysis) {
|
|
274
|
+
const counts = {
|
|
275
|
+
비견: 0,
|
|
276
|
+
겁재: 0,
|
|
277
|
+
식신: 0,
|
|
278
|
+
상관: 0,
|
|
279
|
+
편재: 0,
|
|
280
|
+
정재: 0,
|
|
281
|
+
편관: 0,
|
|
282
|
+
정관: 0,
|
|
283
|
+
편인: 0,
|
|
284
|
+
정인: 0,
|
|
285
|
+
};
|
|
286
|
+
// 천간 십신 카운트 (일간 제외)
|
|
287
|
+
const stems = [analysis.year.stem, analysis.month.stem, analysis.hour.stem];
|
|
288
|
+
for (const s of stems) {
|
|
289
|
+
counts[s.tenGod]++;
|
|
290
|
+
}
|
|
291
|
+
// 지지 본기 십신 카운트
|
|
292
|
+
const branches = [
|
|
293
|
+
analysis.year.branch,
|
|
294
|
+
analysis.month.branch,
|
|
295
|
+
analysis.day.branch,
|
|
296
|
+
analysis.hour.branch,
|
|
297
|
+
];
|
|
298
|
+
for (const b of branches) {
|
|
299
|
+
counts[b.tenGod]++;
|
|
300
|
+
}
|
|
301
|
+
return counts;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* 오행별 개수 (천간 + 지지 본기)
|
|
305
|
+
*/
|
|
306
|
+
export function countElements(analysis) {
|
|
307
|
+
const counts = {
|
|
308
|
+
wood: 0,
|
|
309
|
+
fire: 0,
|
|
310
|
+
earth: 0,
|
|
311
|
+
metal: 0,
|
|
312
|
+
water: 0,
|
|
313
|
+
};
|
|
314
|
+
// 모든 천간의 오행
|
|
315
|
+
const stems = [
|
|
316
|
+
analysis.year.stem.char,
|
|
317
|
+
analysis.month.stem.char,
|
|
318
|
+
analysis.day.stem.char,
|
|
319
|
+
analysis.hour.stem.char,
|
|
320
|
+
];
|
|
321
|
+
for (const s of stems) {
|
|
322
|
+
counts[getStemElement(s)]++;
|
|
323
|
+
}
|
|
324
|
+
// 모든 지지의 오행
|
|
325
|
+
const branches = [
|
|
326
|
+
analysis.year.branch.char,
|
|
327
|
+
analysis.month.branch.char,
|
|
328
|
+
analysis.day.branch.char,
|
|
329
|
+
analysis.hour.branch.char,
|
|
330
|
+
];
|
|
331
|
+
for (const b of branches) {
|
|
332
|
+
counts[getBranchElement(b)]++;
|
|
333
|
+
}
|
|
334
|
+
return counts;
|
|
335
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Element } from "./ten-gods";
|
|
2
|
+
export type YongShenMethod = "격국" | "억부" | "조후" | "통관" | "병약";
|
|
3
|
+
export interface YongShenResult {
|
|
4
|
+
primary: Element;
|
|
5
|
+
secondary: Element | null;
|
|
6
|
+
method: YongShenMethod;
|
|
7
|
+
reasoning: string;
|
|
8
|
+
allElements: Record<Element, {
|
|
9
|
+
isYongShen: boolean;
|
|
10
|
+
isKiShen: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
johuAdjustment: Element | null;
|
|
13
|
+
}
|
|
14
|
+
export declare function analyzeYongShen(yearPillar: string, monthPillar: string, dayPillar: string, hourPillar: string): YongShenResult;
|
|
15
|
+
export declare function getElementRecommendations(yongShen: YongShenResult): {
|
|
16
|
+
colors: string[];
|
|
17
|
+
directions: string[];
|
|
18
|
+
numbers: number[];
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=yongshen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yongshen.d.ts","sourceRoot":"","sources":["../../src/core/yongshen.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAKb,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9D,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE;QAAE,UAAU,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACzE,cAAc,EAAE,OAAO,GAAG,IAAI,CAAC;CAChC;AAmJD,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,cAAc,CA+EhB;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,cAAc,GAAG;IACnE,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CA0BA"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { getStemElement, getBranchElement, getHiddenStems, ELEMENTS, } from "./ten-gods";
|
|
2
|
+
import { analyzeStrength } from "./strength";
|
|
3
|
+
const SEASON_MONTH_BRANCHES = {
|
|
4
|
+
spring: ["寅", "卯", "辰"],
|
|
5
|
+
summer: ["巳", "午", "未"],
|
|
6
|
+
autumn: ["申", "酉", "戌"],
|
|
7
|
+
winter: ["亥", "子", "丑"],
|
|
8
|
+
};
|
|
9
|
+
function getSeason(monthBranch) {
|
|
10
|
+
for (const [season, branches] of Object.entries(SEASON_MONTH_BRANCHES)) {
|
|
11
|
+
if (branches.includes(monthBranch)) {
|
|
12
|
+
return season;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return "spring";
|
|
16
|
+
}
|
|
17
|
+
const JOHU_YONGSHEN = {
|
|
18
|
+
spring: {
|
|
19
|
+
wood: ["fire", "water"],
|
|
20
|
+
fire: ["water", "wood"],
|
|
21
|
+
earth: ["fire", "wood"],
|
|
22
|
+
metal: ["fire", "earth"],
|
|
23
|
+
water: ["fire", "metal"],
|
|
24
|
+
},
|
|
25
|
+
summer: {
|
|
26
|
+
wood: ["water", "metal"],
|
|
27
|
+
fire: ["water", "metal"],
|
|
28
|
+
earth: ["water", "metal"],
|
|
29
|
+
metal: ["water", "earth"],
|
|
30
|
+
water: ["metal", "water"],
|
|
31
|
+
},
|
|
32
|
+
autumn: {
|
|
33
|
+
wood: ["water", "fire"],
|
|
34
|
+
fire: ["wood", "earth"],
|
|
35
|
+
earth: ["fire", "water"],
|
|
36
|
+
metal: ["fire", "water"],
|
|
37
|
+
water: ["fire", "metal"],
|
|
38
|
+
},
|
|
39
|
+
winter: {
|
|
40
|
+
wood: ["fire", "earth"],
|
|
41
|
+
fire: ["wood", "earth"],
|
|
42
|
+
earth: ["fire", "wood"],
|
|
43
|
+
metal: ["fire", "earth"],
|
|
44
|
+
water: ["fire", "earth"],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const GENERATES = {
|
|
48
|
+
wood: "fire",
|
|
49
|
+
fire: "earth",
|
|
50
|
+
earth: "metal",
|
|
51
|
+
metal: "water",
|
|
52
|
+
water: "wood",
|
|
53
|
+
};
|
|
54
|
+
const GENERATED_BY = {
|
|
55
|
+
fire: "wood",
|
|
56
|
+
earth: "fire",
|
|
57
|
+
metal: "earth",
|
|
58
|
+
water: "metal",
|
|
59
|
+
wood: "water",
|
|
60
|
+
};
|
|
61
|
+
const CONTROLS = {
|
|
62
|
+
wood: "earth",
|
|
63
|
+
earth: "water",
|
|
64
|
+
water: "fire",
|
|
65
|
+
fire: "metal",
|
|
66
|
+
metal: "wood",
|
|
67
|
+
};
|
|
68
|
+
const CONTROLLED_BY = {
|
|
69
|
+
earth: "wood",
|
|
70
|
+
water: "earth",
|
|
71
|
+
fire: "water",
|
|
72
|
+
metal: "fire",
|
|
73
|
+
wood: "metal",
|
|
74
|
+
};
|
|
75
|
+
function getYokbuYongShen(dayMasterElement, strengthLevel) {
|
|
76
|
+
const isStrong = ["신강", "태강", "극왕", "중화신강"].includes(strengthLevel);
|
|
77
|
+
if (isStrong) {
|
|
78
|
+
const primary = CONTROLS[dayMasterElement];
|
|
79
|
+
const secondary = GENERATES[dayMasterElement];
|
|
80
|
+
return { primary, secondary };
|
|
81
|
+
}
|
|
82
|
+
const primary = GENERATED_BY[dayMasterElement];
|
|
83
|
+
const secondary = dayMasterElement;
|
|
84
|
+
return { primary, secondary };
|
|
85
|
+
}
|
|
86
|
+
function hasSpecialFormation(dayMasterElement, strengthLevel, allElements) {
|
|
87
|
+
const isExtreme = ["극약", "극왕"].includes(strengthLevel);
|
|
88
|
+
if (strengthLevel === "극약") {
|
|
89
|
+
const elementCounts = {
|
|
90
|
+
wood: 0,
|
|
91
|
+
fire: 0,
|
|
92
|
+
earth: 0,
|
|
93
|
+
metal: 0,
|
|
94
|
+
water: 0,
|
|
95
|
+
};
|
|
96
|
+
for (const elem of allElements) {
|
|
97
|
+
elementCounts[elem]++;
|
|
98
|
+
}
|
|
99
|
+
let dominantElement = null;
|
|
100
|
+
let maxCount = 0;
|
|
101
|
+
for (const [elem, count] of Object.entries(elementCounts)) {
|
|
102
|
+
if (count > maxCount && elem !== dayMasterElement) {
|
|
103
|
+
maxCount = count;
|
|
104
|
+
dominantElement = elem;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (dominantElement && maxCount >= 3) {
|
|
108
|
+
return { isSpecial: true, type: "종격", followElement: dominantElement };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return { isSpecial: false, type: null, followElement: null };
|
|
112
|
+
}
|
|
113
|
+
function getJohuAdjustment(dayMasterElement, season, yokbuPrimary) {
|
|
114
|
+
const johuElements = JOHU_YONGSHEN[season][dayMasterElement];
|
|
115
|
+
const johuPrimary = johuElements[0];
|
|
116
|
+
if (johuPrimary !== yokbuPrimary) {
|
|
117
|
+
return johuPrimary;
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
export function analyzeYongShen(yearPillar, monthPillar, dayPillar, hourPillar) {
|
|
122
|
+
const dayMaster = dayPillar[0];
|
|
123
|
+
const dayMasterElement = getStemElement(dayMaster);
|
|
124
|
+
const monthBranch = monthPillar[1];
|
|
125
|
+
const season = getSeason(monthBranch);
|
|
126
|
+
const strength = analyzeStrength(yearPillar, monthPillar, dayPillar, hourPillar);
|
|
127
|
+
const allBranches = [yearPillar[1], monthPillar[1], dayPillar[1], hourPillar[1]];
|
|
128
|
+
const allBranchElements = allBranches.map((b) => getBranchElement(b));
|
|
129
|
+
const specialFormation = hasSpecialFormation(dayMasterElement, strength.level, allBranchElements);
|
|
130
|
+
let primary;
|
|
131
|
+
let secondary = null;
|
|
132
|
+
let method;
|
|
133
|
+
let reasoning;
|
|
134
|
+
let johuAdjustment = null;
|
|
135
|
+
if (specialFormation.isSpecial && specialFormation.followElement) {
|
|
136
|
+
primary = specialFormation.followElement;
|
|
137
|
+
secondary = GENERATES[specialFormation.followElement];
|
|
138
|
+
method = "격국";
|
|
139
|
+
reasoning = `${specialFormation.type} 성립. ${specialFormation.followElement} 세력을 따름`;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
const yokbu = getYokbuYongShen(dayMasterElement, strength.level);
|
|
143
|
+
primary = yokbu.primary;
|
|
144
|
+
secondary = yokbu.secondary;
|
|
145
|
+
method = "억부";
|
|
146
|
+
const isStrong = ["신강", "태강", "극왕", "중화신강"].includes(strength.level);
|
|
147
|
+
if (isStrong) {
|
|
148
|
+
reasoning = `${strength.level} 상태로 설기(洩氣) 필요. ${primary}로 기운을 발산`;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
reasoning = `${strength.level} 상태로 부조(扶助) 필요. ${primary}로 일간을 생조`;
|
|
152
|
+
}
|
|
153
|
+
johuAdjustment = getJohuAdjustment(dayMasterElement, season, primary);
|
|
154
|
+
if (johuAdjustment) {
|
|
155
|
+
reasoning += `. 조후 보정: ${season} 계절에 ${johuAdjustment} 참고`;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const allElements = {
|
|
159
|
+
wood: { isYongShen: false, isKiShen: false },
|
|
160
|
+
fire: { isYongShen: false, isKiShen: false },
|
|
161
|
+
earth: { isYongShen: false, isKiShen: false },
|
|
162
|
+
metal: { isYongShen: false, isKiShen: false },
|
|
163
|
+
water: { isYongShen: false, isKiShen: false },
|
|
164
|
+
};
|
|
165
|
+
allElements[primary].isYongShen = true;
|
|
166
|
+
if (secondary)
|
|
167
|
+
allElements[secondary].isYongShen = true;
|
|
168
|
+
const isStrong = ["신강", "태강", "극왕", "중화신강"].includes(strength.level);
|
|
169
|
+
if (method !== "격국") {
|
|
170
|
+
if (isStrong) {
|
|
171
|
+
allElements[dayMasterElement].isKiShen = true;
|
|
172
|
+
allElements[GENERATED_BY[dayMasterElement]].isKiShen = true;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
allElements[CONTROLS[dayMasterElement]].isKiShen = true;
|
|
176
|
+
allElements[CONTROLLED_BY[dayMasterElement]].isKiShen = true;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
for (const elem of ELEMENTS) {
|
|
180
|
+
if (allElements[elem].isYongShen) {
|
|
181
|
+
allElements[elem].isKiShen = false;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
primary,
|
|
186
|
+
secondary,
|
|
187
|
+
method,
|
|
188
|
+
reasoning,
|
|
189
|
+
allElements,
|
|
190
|
+
johuAdjustment,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
export function getElementRecommendations(yongShen) {
|
|
194
|
+
const elementData = {
|
|
195
|
+
wood: { colors: ["청색", "녹색"], direction: "동", numbers: [3, 8] },
|
|
196
|
+
fire: { colors: ["적색", "자주색"], direction: "남", numbers: [2, 7] },
|
|
197
|
+
earth: { colors: ["황색", "갈색"], direction: "중앙", numbers: [5, 10] },
|
|
198
|
+
metal: { colors: ["백색", "금색"], direction: "서", numbers: [4, 9] },
|
|
199
|
+
water: { colors: ["흑색", "남색"], direction: "북", numbers: [1, 6] },
|
|
200
|
+
};
|
|
201
|
+
const primary = elementData[yongShen.primary];
|
|
202
|
+
const colors = [...primary.colors];
|
|
203
|
+
const directions = [primary.direction];
|
|
204
|
+
const numbers = [...primary.numbers];
|
|
205
|
+
if (yongShen.secondary) {
|
|
206
|
+
const secondary = elementData[yongShen.secondary];
|
|
207
|
+
colors.push(...secondary.colors);
|
|
208
|
+
directions.push(secondary.direction);
|
|
209
|
+
numbers.push(...secondary.numbers);
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
colors: [...new Set(colors)],
|
|
213
|
+
directions: [...new Set(directions)],
|
|
214
|
+
numbers: [...new Set(numbers)].sort((a, b) => a - b),
|
|
215
|
+
};
|
|
216
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
1
|
export type { DateAdapter } from "@/adapters/date-adapter";
|
|
2
|
+
export { getLunarDate, getSolarDate, type LunarDate } from "@/core/lunar";
|
|
2
3
|
export { applyMeanSolarTime, BRANCHES, dayPillarFromDate, effectiveDayDate, getFourPillars, hourPillar, monthPillar, presetA, presetB, STANDARD_PRESET, STEMS, TRADITIONAL_PRESET, yearPillar, } from "@/core/four-pillars";
|
|
4
|
+
export { type Element, type Polarity, type TenGod, ELEMENTS, TEN_GODS, TEN_GOD_HANJA, TEN_GOD_ENGLISH, HIDDEN_STEMS, getStemElement, getStemPolarity, getBranchElement, getBranchPolarity, getHiddenStems, getTenGod, getTenGodForBranch, getTenGodsForBranch, analyzeTenGods, countTenGods, countElements, type FourPillarsTenGods, } from "@/core/ten-gods";
|
|
5
|
+
export { type StrengthLevel, STRENGTH_LEVELS, analyzeStrength, type StrengthFactors, type StrengthResult, } from "@/core/strength";
|
|
6
|
+
export { STEM_COMBINATIONS, BRANCH_SIX_COMBINATIONS, BRANCH_TRIPLE_COMBINATIONS, BRANCH_DIRECTIONAL_COMBINATIONS, BRANCH_CLASHES, BRANCH_HARMS, BRANCH_PUNISHMENTS, BRANCH_DESTRUCTIONS, analyzeRelations, findStemCombination, findBranchClash, findBranchSixCombination, type StemCombination, type BranchSixCombination, type BranchTripleCombination, type BranchDirectionalCombination, type BranchClash, type BranchHarm, type BranchPunishment, type BranchDestruction, type Relation, type RelationsResult, } from "@/core/relations";
|
|
7
|
+
export { type Gender, type LuckPillar, type MajorLuckResult, type YearlyLuckResult, type StartAgeDetail, calculateMajorLuck, calculateYearlyLuck, getYearPillar, getCurrentMajorLuck, } from "@/core/luck";
|
|
8
|
+
export { type YongShenMethod, type YongShenResult, analyzeYongShen, getElementRecommendations, } from "@/core/yongshen";
|
|
9
|
+
export { SOLAR_TERMS, type SolarTerm, type SolarTermName, type SolarTermHanja, type SolarTermInfo, type SolarTermDateInfo, analyzeSolarTerms, getSolarTermsForYear, } from "@/core/solar-terms";
|
|
10
|
+
import type { DateAdapter } from "@/adapters/date-adapter";
|
|
11
|
+
import { type presetA } from "@/core/four-pillars";
|
|
12
|
+
import { type FourPillarsTenGods } from "@/core/ten-gods";
|
|
13
|
+
import { type StrengthResult } from "@/core/strength";
|
|
14
|
+
import { type RelationsResult } from "@/core/relations";
|
|
15
|
+
import { type YongShenResult } from "@/core/yongshen";
|
|
16
|
+
import { type Gender, type MajorLuckResult, type YearlyLuckResult } from "@/core/luck";
|
|
17
|
+
import type { LunarDate } from "@/core/lunar";
|
|
18
|
+
import { type SolarTermInfo } from "@/core/solar-terms";
|
|
19
|
+
export interface SajuResult {
|
|
20
|
+
pillars: {
|
|
21
|
+
year: string;
|
|
22
|
+
month: string;
|
|
23
|
+
day: string;
|
|
24
|
+
hour: string;
|
|
25
|
+
};
|
|
26
|
+
lunar: LunarDate;
|
|
27
|
+
tenGods: FourPillarsTenGods;
|
|
28
|
+
strength: StrengthResult;
|
|
29
|
+
relations: RelationsResult;
|
|
30
|
+
yongShen: YongShenResult;
|
|
31
|
+
solarTerms: SolarTermInfo;
|
|
32
|
+
majorLuck: MajorLuckResult;
|
|
33
|
+
yearlyLuck: YearlyLuckResult[];
|
|
34
|
+
meta: {
|
|
35
|
+
solarYearUsed: number;
|
|
36
|
+
sunLonDeg: number;
|
|
37
|
+
effectiveDayDate: {
|
|
38
|
+
year: number;
|
|
39
|
+
month: number;
|
|
40
|
+
day: number;
|
|
41
|
+
};
|
|
42
|
+
adjustedDtForHour: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface GetSajuOptions {
|
|
46
|
+
longitudeDeg: number;
|
|
47
|
+
gender: Gender;
|
|
48
|
+
tzOffsetHours?: number;
|
|
49
|
+
preset?: typeof presetA;
|
|
50
|
+
currentYear?: number;
|
|
51
|
+
yearlyLuckRange?: {
|
|
52
|
+
from: number;
|
|
53
|
+
to: number;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export declare function getSaju<T>(adapter: DateAdapter<T>, dtLocal: T, options: GetSajuOptions): SajuResult;
|
|
3
57
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACP,eAAe,EACf,KAAK,EACL,kBAAkB,EAClB,UAAU,GACX,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1,49 @@
|
|
|
1
|
+
export { getLunarDate, getSolarDate } from "@/core/lunar";
|
|
1
2
|
export { applyMeanSolarTime, BRANCHES, dayPillarFromDate, effectiveDayDate, getFourPillars, hourPillar, monthPillar, presetA, presetB, STANDARD_PRESET, STEMS, TRADITIONAL_PRESET, yearPillar, } from "@/core/four-pillars";
|
|
3
|
+
export { ELEMENTS, TEN_GODS, TEN_GOD_HANJA, TEN_GOD_ENGLISH, HIDDEN_STEMS, getStemElement, getStemPolarity, getBranchElement, getBranchPolarity, getHiddenStems, getTenGod, getTenGodForBranch, getTenGodsForBranch, analyzeTenGods, countTenGods, countElements, } from "@/core/ten-gods";
|
|
4
|
+
export { STRENGTH_LEVELS, analyzeStrength, } from "@/core/strength";
|
|
5
|
+
export { STEM_COMBINATIONS, BRANCH_SIX_COMBINATIONS, BRANCH_TRIPLE_COMBINATIONS, BRANCH_DIRECTIONAL_COMBINATIONS, BRANCH_CLASHES, BRANCH_HARMS, BRANCH_PUNISHMENTS, BRANCH_DESTRUCTIONS, analyzeRelations, findStemCombination, findBranchClash, findBranchSixCombination, } from "@/core/relations";
|
|
6
|
+
export { calculateMajorLuck, calculateYearlyLuck, getYearPillar, getCurrentMajorLuck, } from "@/core/luck";
|
|
7
|
+
export { analyzeYongShen, getElementRecommendations, } from "@/core/yongshen";
|
|
8
|
+
export { SOLAR_TERMS, analyzeSolarTerms, getSolarTermsForYear, } from "@/core/solar-terms";
|
|
9
|
+
import { getFourPillars } from "@/core/four-pillars";
|
|
10
|
+
import { analyzeTenGods } from "@/core/ten-gods";
|
|
11
|
+
import { analyzeStrength } from "@/core/strength";
|
|
12
|
+
import { analyzeRelations } from "@/core/relations";
|
|
13
|
+
import { analyzeYongShen } from "@/core/yongshen";
|
|
14
|
+
import { calculateMajorLuck, calculateYearlyLuck, } from "@/core/luck";
|
|
15
|
+
import { analyzeSolarTerms } from "@/core/solar-terms";
|
|
16
|
+
export function getSaju(adapter, dtLocal, options) {
|
|
17
|
+
const fourPillars = getFourPillars(adapter, dtLocal, {
|
|
18
|
+
longitudeDeg: options.longitudeDeg,
|
|
19
|
+
tzOffsetHours: options.tzOffsetHours,
|
|
20
|
+
preset: options.preset,
|
|
21
|
+
});
|
|
22
|
+
const { year, month, day, hour } = fourPillars;
|
|
23
|
+
const tenGods = analyzeTenGods(year, month, day, hour);
|
|
24
|
+
const strength = analyzeStrength(year, month, day, hour);
|
|
25
|
+
const relations = analyzeRelations(year, month, day, hour);
|
|
26
|
+
const yongShen = analyzeYongShen(year, month, day, hour);
|
|
27
|
+
const solarTerms = analyzeSolarTerms(adapter, dtLocal);
|
|
28
|
+
const result = {
|
|
29
|
+
pillars: { year, month, day, hour },
|
|
30
|
+
lunar: fourPillars.lunar,
|
|
31
|
+
tenGods,
|
|
32
|
+
strength,
|
|
33
|
+
relations,
|
|
34
|
+
yongShen,
|
|
35
|
+
solarTerms,
|
|
36
|
+
majorLuck: calculateMajorLuck(adapter, dtLocal, options.gender, year, month, {
|
|
37
|
+
nextJieMillis: solarTerms.nextJieMillis,
|
|
38
|
+
prevJieMillis: solarTerms.prevJieMillis,
|
|
39
|
+
}),
|
|
40
|
+
yearlyLuck: calculateYearlyLuck(fourPillars.meta.solarYearUsed, options.yearlyLuckRange?.from ?? (options.currentYear ?? new Date().getFullYear()) - 5, options.yearlyLuckRange?.to ?? (options.currentYear ?? new Date().getFullYear()) + 10),
|
|
41
|
+
meta: {
|
|
42
|
+
solarYearUsed: fourPillars.meta.solarYearUsed,
|
|
43
|
+
sunLonDeg: fourPillars.meta.sunLonDeg,
|
|
44
|
+
effectiveDayDate: fourPillars.meta.effectiveDayDate,
|
|
45
|
+
adjustedDtForHour: fourPillars.meta.adjustedDtForHour,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
return result;
|
|
49
|
+
}
|