@gracefullight/saju 0.4.1 → 0.5.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.
Files changed (37) hide show
  1. package/dist/__tests__/relations.test.js +6 -6
  2. package/dist/__tests__/saju.test.js +3 -3
  3. package/dist/__tests__/sinsals.test.js +5 -5
  4. package/dist/__tests__/solar-terms.test.js +26 -16
  5. package/dist/__tests__/strength.test.js +2 -2
  6. package/dist/__tests__/ten-gods.test.js +6 -6
  7. package/dist/__tests__/twelve-stages.test.js +6 -6
  8. package/dist/__tests__/yongshen.test.js +3 -3
  9. package/dist/core/relations.d.ts +36 -19
  10. package/dist/core/relations.d.ts.map +1 -1
  11. package/dist/core/relations.js +105 -33
  12. package/dist/core/sinsals.d.ts +16 -6
  13. package/dist/core/sinsals.d.ts.map +1 -1
  14. package/dist/core/sinsals.js +19 -8
  15. package/dist/core/solar-terms.d.ts +19 -105
  16. package/dist/core/solar-terms.d.ts.map +1 -1
  17. package/dist/core/solar-terms.js +56 -29
  18. package/dist/core/strength.d.ts +9 -1
  19. package/dist/core/strength.d.ts.map +1 -1
  20. package/dist/core/strength.js +38 -11
  21. package/dist/core/ten-gods.d.ts +36 -64
  22. package/dist/core/ten-gods.d.ts.map +1 -1
  23. package/dist/core/ten-gods.js +109 -119
  24. package/dist/core/twelve-stages.d.ts +19 -8
  25. package/dist/core/twelve-stages.d.ts.map +1 -1
  26. package/dist/core/twelve-stages.js +34 -24
  27. package/dist/core/yongshen.d.ts +12 -6
  28. package/dist/core/yongshen.d.ts.map +1 -1
  29. package/dist/core/yongshen.js +55 -37
  30. package/dist/index.d.ts +7 -7
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +6 -6
  33. package/dist/types/common.d.ts +8 -0
  34. package/dist/types/common.d.ts.map +1 -1
  35. package/dist/types/index.d.ts +1 -1
  36. package/dist/types/index.d.ts.map +1 -1
  37. package/package.json +1 -1
@@ -1,4 +1,31 @@
1
1
  import { getStemElement, getStemPolarity, getTenGod } from "./ten-gods";
2
+ export const STRENGTH_LEVEL_KEYS = [
3
+ "extremelyWeak",
4
+ "veryWeak",
5
+ "weak",
6
+ "neutralWeak",
7
+ "neutral",
8
+ "neutralStrong",
9
+ "strong",
10
+ "veryStrong",
11
+ "extremelyStrong",
12
+ ];
13
+ const STRENGTH_LEVEL_DATA = {
14
+ extremelyWeak: { korean: "극약", hanja: "極弱" },
15
+ veryWeak: { korean: "태약", hanja: "太弱" },
16
+ weak: { korean: "신약", hanja: "身弱" },
17
+ neutralWeak: { korean: "중화신약", hanja: "中和身弱" },
18
+ neutral: { korean: "중화", hanja: "中和" },
19
+ neutralStrong: { korean: "중화신강", hanja: "中和身強" },
20
+ strong: { korean: "신강", hanja: "身強" },
21
+ veryStrong: { korean: "태강", hanja: "太強" },
22
+ extremelyStrong: { korean: "극왕", hanja: "極旺" },
23
+ };
24
+ export function getStrengthLevelLabel(key) {
25
+ const data = STRENGTH_LEVEL_DATA[key];
26
+ return { key, ...data };
27
+ }
28
+ /** @deprecated Use STRENGTH_LEVEL_KEYS instead */
2
29
  export const STRENGTH_LEVELS = [
3
30
  "극약",
4
31
  "태약",
@@ -215,25 +242,25 @@ export function analyzeStrength(yearPillar, monthPillar, dayPillar, hourPillar)
215
242
  score += helpCount * 5;
216
243
  score -= weakenCount * 6;
217
244
  score = Math.round(score * 10) / 10;
218
- let level;
245
+ let levelKey;
219
246
  if (score <= 10)
220
- level = "극약";
247
+ levelKey = "extremelyWeak";
221
248
  else if (score <= 20)
222
- level = "태약";
249
+ levelKey = "veryWeak";
223
250
  else if (score <= 30)
224
- level = "신약";
251
+ levelKey = "weak";
225
252
  else if (score <= 38)
226
- level = "중화신약";
253
+ levelKey = "neutralWeak";
227
254
  else if (score <= 45)
228
- level = "중화";
255
+ levelKey = "neutral";
229
256
  else if (score <= 55)
230
- level = "중화신강";
257
+ levelKey = "neutralStrong";
231
258
  else if (score <= 70)
232
- level = "신강";
259
+ levelKey = "strong";
233
260
  else if (score <= 85)
234
- level = "태강";
261
+ levelKey = "veryStrong";
235
262
  else
236
- level = "극왕";
263
+ levelKey = "extremelyStrong";
237
264
  const factors = {
238
265
  deukryeong: Math.round(deukryeong * 100) / 100,
239
266
  deukji: Math.round(deukji * 100) / 100,
@@ -247,7 +274,7 @@ export function analyzeStrength(yearPillar, monthPillar, dayPillar, hourPillar)
247
274
  description += tonggeun > 0 ? `, 통근(${Math.round(tonggeun * 100) / 100})` : "";
248
275
  description += deukse > 0 ? `, 득세(${deukse})` : "";
249
276
  return {
250
- level,
277
+ level: getStrengthLevelLabel(levelKey),
251
278
  score,
252
279
  factors,
253
280
  description,
@@ -1,127 +1,99 @@
1
- import type { Element, Polarity } from "../types";
1
+ import type { Element, Label, Polarity } from "../types";
2
2
  import { ELEMENTS } from "../utils";
3
3
  export type { Element, Polarity };
4
4
  export { ELEMENTS };
5
- export type TenGod = "비견" | "겁재" | "식신" | "상관" | "편재" | "정재" | "편관" | "정관" | "편인" | "정인";
6
- export declare const TEN_GODS: TenGod[];
7
- export declare const TEN_GOD_HANJA: Record<TenGod, string>;
8
- export declare const TEN_GOD_ENGLISH: Record<TenGod, string>;
5
+ export interface ElementLabel extends Label<Element> {
6
+ }
7
+ export declare function getElementLabel(key: Element): ElementLabel;
8
+ export declare const TEN_GOD_KEYS: readonly ["companion", "robWealth", "eatingGod", "hurtingOfficer", "indirectWealth", "directWealth", "sevenKillings", "directOfficer", "indirectSeal", "directSeal"];
9
+ export type TenGodKey = (typeof TEN_GOD_KEYS)[number];
10
+ export interface TenGodLabel extends Label<TenGodKey> {
11
+ }
12
+ export declare function getTenGodLabel(key: TenGodKey): TenGodLabel;
9
13
  export declare const HIDDEN_STEMS: Record<string, string[]>;
10
- /**
11
- * 천간의 오행을 반환
12
- */
13
14
  export declare function getStemElement(stem: string): Element;
14
- /**
15
- * 천간의 음양을 반환
16
- */
17
15
  export declare function getStemPolarity(stem: string): Polarity;
18
- /**
19
- * 지지의 오행을 반환
20
- */
21
16
  export declare function getBranchElement(branch: string): Element;
22
- /**
23
- * 지지의 음양을 반환
24
- */
25
17
  export declare function getBranchPolarity(branch: string): Polarity;
26
- /**
27
- * 지지의 장간(숨은 천간들)을 반환
28
- */
29
18
  export declare function getHiddenStems(branch: string): string[];
30
- /**
31
- * 일간(Day Master)과 다른 천간의 관계에서 십신을 판정
32
- * @param dayMaster 일간 (예: "甲")
33
- * @param targetStem 비교 대상 천간
34
- * @returns 십신
35
- */
36
- export declare function getTenGod(dayMaster: string, targetStem: string): TenGod;
37
- /**
38
- * 지지에 대한 십신 판정 (본기 기준)
39
- */
40
- export declare function getTenGodForBranch(dayMaster: string, branch: string): TenGod;
41
- /**
42
- * 지지의 모든 장간에 대한 십신 분석
43
- */
19
+ export declare function getTenGodForBranch(dayMaster: string, branch: string): TenGodLabel;
44
20
  export declare function getTenGodsForBranch(dayMaster: string, branch: string): {
45
21
  stem: string;
46
- tenGod: TenGod;
22
+ tenGod: TenGodLabel;
47
23
  type: "본기" | "중기" | "여기";
48
24
  }[];
49
- /**
50
- * 사주 전체의 십신 분석
51
- */
25
+ export interface DayMasterLabel extends Label<"dayMaster"> {
26
+ }
52
27
  export interface FourPillarsTenGods {
53
28
  year: {
54
29
  stem: {
55
30
  char: string;
56
- tenGod: TenGod;
31
+ tenGod: TenGodLabel;
57
32
  };
58
33
  branch: {
59
34
  char: string;
60
- tenGod: TenGod;
35
+ tenGod: TenGodLabel;
61
36
  hiddenStems: {
62
37
  stem: string;
63
- tenGod: TenGod;
38
+ tenGod: TenGodLabel;
64
39
  }[];
65
40
  };
66
41
  };
67
42
  month: {
68
43
  stem: {
69
44
  char: string;
70
- tenGod: TenGod;
45
+ tenGod: TenGodLabel;
71
46
  };
72
47
  branch: {
73
48
  char: string;
74
- tenGod: TenGod;
49
+ tenGod: TenGodLabel;
75
50
  hiddenStems: {
76
51
  stem: string;
77
- tenGod: TenGod;
52
+ tenGod: TenGodLabel;
78
53
  }[];
79
54
  };
80
55
  };
81
56
  day: {
82
57
  stem: {
83
58
  char: string;
84
- tenGod: "일간";
59
+ tenGod: DayMasterLabel;
85
60
  };
86
61
  branch: {
87
62
  char: string;
88
- tenGod: TenGod;
63
+ tenGod: TenGodLabel;
89
64
  hiddenStems: {
90
65
  stem: string;
91
- tenGod: TenGod;
66
+ tenGod: TenGodLabel;
92
67
  }[];
93
68
  };
94
69
  };
95
70
  hour: {
96
71
  stem: {
97
72
  char: string;
98
- tenGod: TenGod;
73
+ tenGod: TenGodLabel;
99
74
  };
100
75
  branch: {
101
76
  char: string;
102
- tenGod: TenGod;
77
+ tenGod: TenGodLabel;
103
78
  hiddenStems: {
104
79
  stem: string;
105
- tenGod: TenGod;
80
+ tenGod: TenGodLabel;
106
81
  }[];
107
82
  };
108
83
  };
109
84
  dayMaster: string;
110
85
  }
111
- /**
112
- * 사주 팔자에서 십신 분석
113
- * @param yearPillar 연주 (예: "甲子")
114
- * @param monthPillar 월주
115
- * @param dayPillar 일주
116
- * @param hourPillar 시주
117
- */
118
86
  export declare function analyzeTenGods(yearPillar: string, monthPillar: string, dayPillar: string, hourPillar: string): FourPillarsTenGods;
119
- /**
120
- * 십신 통계 (각 십신이 몇 개 있는지)
121
- */
122
- export declare function countTenGods(analysis: FourPillarsTenGods): Record<TenGod, number>;
123
- /**
124
- * 오행별 개수 (천간 + 지지 본기)
125
- */
87
+ export declare function countTenGods(analysis: FourPillarsTenGods): Record<TenGodKey, number>;
126
88
  export declare function countElements(analysis: FourPillarsTenGods): Record<Element, number>;
89
+ /** @deprecated Use TenGodKey instead */
90
+ export type TenGod = "비견" | "겁재" | "식신" | "상관" | "편재" | "정재" | "편관" | "정관" | "편인" | "정인";
91
+ /** @deprecated Use TEN_GOD_KEYS instead */
92
+ export declare const TEN_GODS: TenGod[];
93
+ /** @deprecated Use TEN_GOD_DATA instead */
94
+ export declare const TEN_GOD_HANJA: Record<TenGod, string>;
95
+ /** @deprecated Use TEN_GOD_DATA instead */
96
+ export declare const TEN_GOD_ENGLISH: Record<TenGod, string>;
97
+ /** @deprecated Use getTenGodLabel(getTenGodKey(...)) instead */
98
+ export declare function getTenGod(dayMaster: string, targetStem: string): TenGod;
127
99
  //# sourceMappingURL=ten-gods.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ten-gods.d.ts","sourceRoot":"","sources":["../../src/core/ten-gods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,MAAM,MAAM,MAAM,GACd,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,CAAC;AAET,eAAO,MAAM,QAAQ,EAAE,MAAM,EAW5B,CAAC;AAGF,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAWhD,CAAC;AAGF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAWlD,CAAC;AAgEF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAajD,CAAC;AAsBF;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIpD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAItD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAIxD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAI1D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MA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AAM,EACjB,UAAU,EAAE,MAAM,GACjB,kBAAkB,CA+BpB;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CA8BpF;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CA8BnF;AAED,wCAAwC;AACxC,MAAM,MAAM,MAAM,GACd,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,CAAC;AAET,2CAA2C;AAC3C,eAAO,MAAM,QAAQ,EAAE,MAAM,EAW5B,CAAC;AAEF,2CAA2C;AAC3C,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAWhD,CAAC;AAEF,2CAA2C;AAC3C,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAWlD,CAAC;AAEF,gEAAgE;AAChE,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAGvE"}
@@ -1,44 +1,44 @@
1
1
  import { ELEMENTS } from "../utils";
2
2
  export { ELEMENTS };
3
- export const TEN_GODS = [
4
- "비견",
5
- "겁재",
6
- "식신",
7
- "상관",
8
- "편재",
9
- "정재",
10
- "편관",
11
- "정관",
12
- "편인",
13
- "정인",
14
- ];
15
- // 십신 한자 매핑
16
- export const TEN_GOD_HANJA = {
17
- 비견: "比肩",
18
- 겁재: "劫財",
19
- 식신: "食神",
20
- 상관: "傷官",
21
- 편재: "偏財",
22
- 정재: "正財",
23
- 편관: "偏官",
24
- 정관: "正官",
25
- 편인: "偏印",
26
- 정인: "正印",
3
+ const ELEMENT_DATA = {
4
+ wood: { korean: "", hanja: "木" },
5
+ fire: { korean: "", hanja: "火" },
6
+ earth: { korean: "", hanja: "土" },
7
+ metal: { korean: "", hanja: "金" },
8
+ water: { korean: "", hanja: "水" },
27
9
  };
28
- // 십신 영문 매핑
29
- export const TEN_GOD_ENGLISH = {
30
- 비견: "Companion",
31
- 겁재: "Rob Wealth",
32
- 식신: "Eating God",
33
- 상관: "Hurting Officer",
34
- 편재: "Indirect Wealth",
35
- 정재: "Direct Wealth",
36
- 편관: "Seven Killings",
37
- 정관: "Direct Officer",
38
- 편인: "Indirect Seal",
39
- 정인: "Direct Seal",
10
+ export function getElementLabel(key) {
11
+ const data = ELEMENT_DATA[key];
12
+ return { key, ...data };
13
+ }
14
+ export const TEN_GOD_KEYS = [
15
+ "companion",
16
+ "robWealth",
17
+ "eatingGod",
18
+ "hurtingOfficer",
19
+ "indirectWealth",
20
+ "directWealth",
21
+ "sevenKillings",
22
+ "directOfficer",
23
+ "indirectSeal",
24
+ "directSeal",
25
+ ];
26
+ const TEN_GOD_DATA = {
27
+ companion: { korean: "비견", hanja: "比肩" },
28
+ robWealth: { korean: "겁재", hanja: "劫財" },
29
+ eatingGod: { korean: "식신", hanja: "食神" },
30
+ hurtingOfficer: { korean: "상관", hanja: "傷官" },
31
+ indirectWealth: { korean: "편재", hanja: "偏財" },
32
+ directWealth: { korean: "정재", hanja: "正財" },
33
+ sevenKillings: { korean: "편관", hanja: "偏官" },
34
+ directOfficer: { korean: "정관", hanja: "正官" },
35
+ indirectSeal: { korean: "편인", hanja: "偏印" },
36
+ directSeal: { korean: "정인", hanja: "正印" },
40
37
  };
41
- // 천간별 오행
38
+ export function getTenGodLabel(key) {
39
+ const data = TEN_GOD_DATA[key];
40
+ return { key, ...data };
41
+ }
42
42
  const STEM_ELEMENT = {
43
43
  甲: "wood",
44
44
  乙: "wood",
@@ -51,7 +51,6 @@ const STEM_ELEMENT = {
51
51
  壬: "water",
52
52
  癸: "water",
53
53
  };
54
- // 천간별 음양
55
54
  const STEM_POLARITY = {
56
55
  甲: "yang",
57
56
  乙: "yin",
@@ -64,7 +63,6 @@ const STEM_POLARITY = {
64
63
  壬: "yang",
65
64
  癸: "yin",
66
65
  };
67
- // 지지별 오행
68
66
  const BRANCH_ELEMENT = {
69
67
  子: "water",
70
68
  丑: "earth",
@@ -79,7 +77,6 @@ const BRANCH_ELEMENT = {
79
77
  戌: "earth",
80
78
  亥: "water",
81
79
  };
82
- // 지지별 음양
83
80
  const BRANCH_POLARITY = {
84
81
  子: "yang",
85
82
  丑: "yin",
@@ -94,8 +91,6 @@ const BRANCH_POLARITY = {
94
91
  戌: "yang",
95
92
  亥: "yin",
96
93
  };
97
- // 장간(藏干) - 지지 속에 숨은 천간들
98
- // 순서: [본기(本氣), 중기(中氣)?, 여기(餘氣)?]
99
94
  export const HIDDEN_STEMS = {
100
95
  子: ["癸"],
101
96
  丑: ["己", "癸", "辛"],
@@ -110,8 +105,6 @@ export const HIDDEN_STEMS = {
110
105
  戌: ["戊", "辛", "丁"],
111
106
  亥: ["壬", "甲"],
112
107
  };
113
- // 오행 상생 관계 (A가 B를 생함)
114
- // 목생화, 화생토, 토생금, 금생수, 수생목
115
108
  const GENERATES = {
116
109
  wood: "fire",
117
110
  fire: "earth",
@@ -119,8 +112,6 @@ const GENERATES = {
119
112
  metal: "water",
120
113
  water: "wood",
121
114
  };
122
- // 오행 상극 관계 (A가 B를 극함)
123
- // 목극토, 토극수, 수극화, 화극금, 금극목
124
115
  const CONTROLS = {
125
116
  wood: "earth",
126
117
  earth: "water",
@@ -128,112 +119,77 @@ const CONTROLS = {
128
119
  fire: "metal",
129
120
  metal: "wood",
130
121
  };
131
- /**
132
- * 천간의 오행을 반환
133
- */
134
122
  export function getStemElement(stem) {
135
123
  const element = STEM_ELEMENT[stem];
136
124
  if (!element)
137
125
  throw new Error(`Invalid stem: ${stem}`);
138
126
  return element;
139
127
  }
140
- /**
141
- * 천간의 음양을 반환
142
- */
143
128
  export function getStemPolarity(stem) {
144
129
  const polarity = STEM_POLARITY[stem];
145
130
  if (!polarity)
146
131
  throw new Error(`Invalid stem: ${stem}`);
147
132
  return polarity;
148
133
  }
149
- /**
150
- * 지지의 오행을 반환
151
- */
152
134
  export function getBranchElement(branch) {
153
135
  const element = BRANCH_ELEMENT[branch];
154
136
  if (!element)
155
137
  throw new Error(`Invalid branch: ${branch}`);
156
138
  return element;
157
139
  }
158
- /**
159
- * 지지의 음양을 반환
160
- */
161
140
  export function getBranchPolarity(branch) {
162
141
  const polarity = BRANCH_POLARITY[branch];
163
142
  if (!polarity)
164
143
  throw new Error(`Invalid branch: ${branch}`);
165
144
  return polarity;
166
145
  }
167
- /**
168
- * 지지의 장간(숨은 천간들)을 반환
169
- */
170
146
  export function getHiddenStems(branch) {
171
147
  const hidden = HIDDEN_STEMS[branch];
172
148
  if (!hidden)
173
149
  throw new Error(`Invalid branch: ${branch}`);
174
150
  return [...hidden];
175
151
  }
176
- /**
177
- * 일간(Day Master)과 다른 천간의 관계에서 십신을 판정
178
- * @param dayMaster 일간 (예: "甲")
179
- * @param targetStem 비교 대상 천간
180
- * @returns 십신
181
- */
182
- export function getTenGod(dayMaster, targetStem) {
152
+ function getTenGodKey(dayMaster, targetStem) {
183
153
  const dmElement = getStemElement(dayMaster);
184
154
  const dmPolarity = getStemPolarity(dayMaster);
185
155
  const targetElement = getStemElement(targetStem);
186
156
  const targetPolarity = getStemPolarity(targetStem);
187
157
  const samePolarity = dmPolarity === targetPolarity;
188
- // 같은 오행
189
158
  if (dmElement === targetElement) {
190
- return samePolarity ? "비견" : "겁재";
159
+ return samePolarity ? "companion" : "robWealth";
191
160
  }
192
- // 내가 생하는 오행 (식상)
193
161
  if (GENERATES[dmElement] === targetElement) {
194
- return samePolarity ? "식신" : "상관";
162
+ return samePolarity ? "eatingGod" : "hurtingOfficer";
195
163
  }
196
- // 내가 극하는 오행 (재성)
197
164
  if (CONTROLS[dmElement] === targetElement) {
198
- return samePolarity ? "편재" : "정재";
165
+ return samePolarity ? "indirectWealth" : "directWealth";
199
166
  }
200
- // 나를 극하는 오행 (관성)
201
167
  if (CONTROLS[targetElement] === dmElement) {
202
- return samePolarity ? "편관" : "정관";
168
+ return samePolarity ? "sevenKillings" : "directOfficer";
203
169
  }
204
- // 나를 생하는 오행 (인성)
205
170
  if (GENERATES[targetElement] === dmElement) {
206
- return samePolarity ? "편인" : "정인";
171
+ return samePolarity ? "indirectSeal" : "directSeal";
207
172
  }
208
173
  throw new Error(`Unable to determine ten god relationship: ${dayMaster} -> ${targetStem}`);
209
174
  }
210
- /**
211
- * 지지에 대한 십신 판정 (본기 기준)
212
- */
213
175
  export function getTenGodForBranch(dayMaster, branch) {
214
176
  const hiddenStems = getHiddenStems(branch);
215
- // 본기( 번째 장간)를 기준으로 판정
216
- return getTenGod(dayMaster, hiddenStems[0]);
177
+ return getTenGodLabel(getTenGodKey(dayMaster, hiddenStems[0]));
217
178
  }
218
- /**
219
- * 지지의 모든 장간에 대한 십신 분석
220
- */
221
179
  export function getTenGodsForBranch(dayMaster, branch) {
222
180
  const hiddenStems = getHiddenStems(branch);
223
181
  const types = ["본기", "중기", "여기"];
224
182
  return hiddenStems.map((stem, i) => ({
225
183
  stem,
226
- tenGod: getTenGod(dayMaster, stem),
184
+ tenGod: getTenGodLabel(getTenGodKey(dayMaster, stem)),
227
185
  type: types[i],
228
186
  }));
229
187
  }
230
- /**
231
- * 사주 팔자에서 십신 분석
232
- * @param yearPillar 연주 (예: "甲子")
233
- * @param monthPillar 월주
234
- * @param dayPillar 일주
235
- * @param hourPillar 시주
236
- */
188
+ const DAY_MASTER_LABEL = {
189
+ key: "dayMaster",
190
+ korean: "일간",
191
+ hanja: "日干",
192
+ };
237
193
  export function analyzeTenGods(yearPillar, monthPillar, dayPillar, hourPillar) {
238
194
  const dayMaster = dayPillar[0];
239
195
  const analyzePillar = (pillar, isDayPillar = false) => {
@@ -241,16 +197,16 @@ export function analyzeTenGods(yearPillar, monthPillar, dayPillar, hourPillar) {
241
197
  const branch = pillar[1];
242
198
  const hiddenStems = getHiddenStems(branch).map((hs) => ({
243
199
  stem: hs,
244
- tenGod: getTenGod(dayMaster, hs),
200
+ tenGod: getTenGodLabel(getTenGodKey(dayMaster, hs)),
245
201
  }));
246
202
  return {
247
203
  stem: {
248
204
  char: stem,
249
- tenGod: isDayPillar ? "일간" : getTenGod(dayMaster, stem),
205
+ tenGod: isDayPillar ? DAY_MASTER_LABEL : getTenGodLabel(getTenGodKey(dayMaster, stem)),
250
206
  },
251
207
  branch: {
252
208
  char: branch,
253
- tenGod: getTenGod(dayMaster, hiddenStems[0].stem),
209
+ tenGod: getTenGodLabel(getTenGodKey(dayMaster, hiddenStems[0].stem)),
254
210
  hiddenStems,
255
211
  },
256
212
  };
@@ -263,28 +219,23 @@ export function analyzeTenGods(yearPillar, monthPillar, dayPillar, hourPillar) {
263
219
  dayMaster,
264
220
  };
265
221
  }
266
- /**
267
- * 십신 통계 (각 십신이 몇 개 있는지)
268
- */
269
222
  export function countTenGods(analysis) {
270
223
  const counts = {
271
- 비견: 0,
272
- 겁재: 0,
273
- 식신: 0,
274
- 상관: 0,
275
- 편재: 0,
276
- 정재: 0,
277
- 편관: 0,
278
- 정관: 0,
279
- 편인: 0,
280
- 정인: 0,
224
+ companion: 0,
225
+ robWealth: 0,
226
+ eatingGod: 0,
227
+ hurtingOfficer: 0,
228
+ indirectWealth: 0,
229
+ directWealth: 0,
230
+ sevenKillings: 0,
231
+ directOfficer: 0,
232
+ indirectSeal: 0,
233
+ directSeal: 0,
281
234
  };
282
- // 천간 십신 카운트 (일간 제외)
283
235
  const stems = [analysis.year.stem, analysis.month.stem, analysis.hour.stem];
284
236
  for (const s of stems) {
285
- counts[s.tenGod]++;
237
+ counts[s.tenGod.key]++;
286
238
  }
287
- // 지지 본기 십신 카운트
288
239
  const branches = [
289
240
  analysis.year.branch,
290
241
  analysis.month.branch,
@@ -292,13 +243,10 @@ export function countTenGods(analysis) {
292
243
  analysis.hour.branch,
293
244
  ];
294
245
  for (const b of branches) {
295
- counts[b.tenGod]++;
246
+ counts[b.tenGod.key]++;
296
247
  }
297
248
  return counts;
298
249
  }
299
- /**
300
- * 오행별 개수 (천간 + 지지 본기)
301
- */
302
250
  export function countElements(analysis) {
303
251
  const counts = {
304
252
  wood: 0,
@@ -307,7 +255,6 @@ export function countElements(analysis) {
307
255
  metal: 0,
308
256
  water: 0,
309
257
  };
310
- // 모든 천간의 오행
311
258
  const stems = [
312
259
  analysis.year.stem.char,
313
260
  analysis.month.stem.char,
@@ -317,7 +264,6 @@ export function countElements(analysis) {
317
264
  for (const s of stems) {
318
265
  counts[getStemElement(s)]++;
319
266
  }
320
- // 모든 지지의 오행
321
267
  const branches = [
322
268
  analysis.year.branch.char,
323
269
  analysis.month.branch.char,
@@ -329,3 +275,47 @@ export function countElements(analysis) {
329
275
  }
330
276
  return counts;
331
277
  }
278
+ /** @deprecated Use TEN_GOD_KEYS instead */
279
+ export const TEN_GODS = [
280
+ "비견",
281
+ "겁재",
282
+ "식신",
283
+ "상관",
284
+ "편재",
285
+ "정재",
286
+ "편관",
287
+ "정관",
288
+ "편인",
289
+ "정인",
290
+ ];
291
+ /** @deprecated Use TEN_GOD_DATA instead */
292
+ export const TEN_GOD_HANJA = {
293
+ 비견: "比肩",
294
+ 겁재: "劫財",
295
+ 식신: "食神",
296
+ 상관: "傷官",
297
+ 편재: "偏財",
298
+ 정재: "正財",
299
+ 편관: "偏官",
300
+ 정관: "正官",
301
+ 편인: "偏印",
302
+ 정인: "正印",
303
+ };
304
+ /** @deprecated Use TEN_GOD_DATA instead */
305
+ export const TEN_GOD_ENGLISH = {
306
+ 비견: "Companion",
307
+ 겁재: "Rob Wealth",
308
+ 식신: "Eating God",
309
+ 상관: "Hurting Officer",
310
+ 편재: "Indirect Wealth",
311
+ 정재: "Direct Wealth",
312
+ 편관: "Seven Killings",
313
+ 정관: "Direct Officer",
314
+ 편인: "Indirect Seal",
315
+ 정인: "Direct Seal",
316
+ };
317
+ /** @deprecated Use getTenGodLabel(getTenGodKey(...)) instead */
318
+ export function getTenGod(dayMaster, targetStem) {
319
+ const key = getTenGodKey(dayMaster, targetStem);
320
+ return TEN_GOD_DATA[key].korean;
321
+ }