liuyao 0.5.1 → 1.0.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.md CHANGED
@@ -1,123 +1,97 @@
1
1
  # liuyao
2
2
 
3
- Metadata and utility classes for Chinese Liu Yao divination. This package provides typed models for yao lines and hexagrams, along with traditional metadata derived from sources such as Zeng Shan Bu Yi.
3
+ 六爻卦象元数据与装卦工具。数据取自《增删卜易》等著作,只做数据建模,不包含解卦逻辑。
4
4
 
5
- For more packages, see [my homepage](https://baendlorel.github.io/?repoType=npm).
5
+ 更多包见[我的主页💛](https://baendlorel.github.io/?repoType=npm)
6
6
 
7
- ## Features
7
+ _受@lsby的启发_ 现已重写为中文版,并进行了极大简化,仍然高效地保持了原有功能。
8
8
 
9
- - Create a yao from its Yang-count representation, quaternary or various arguments.
10
- - Build a hexagram from six Yao lines or from a known hexagram name.
11
- - Inspect hexagram metadata such as its name, palace, phase, and setup information.
12
- - Derive the changed hexagram for dynamic lines.
13
- - Access Six God ordering data for different heavenly stems.
9
+ **语义更加清晰,但所有api均已破坏性变更,并发布v1.0**
14
10
 
15
- ## Skill Pack
16
- This packages includes a 'liuyao-skill' directory that can parse a hexagram string and date into a structured JSON output. It is used for agents to divination and interpretation. See the [SKILL.md](./src/SKILL.md) for details.
17
- > I tried it, very handy.
18
-
19
- ## Installation
11
+ ## 安装
20
12
 
21
13
  ```bash
22
14
  pnpm add liuyao
23
15
  ```
24
16
 
25
- ## Quick Start
17
+ ## 快速开始
26
18
 
27
19
  ```ts
28
- import { Hexagram, Yao, SixGodList } from 'liuyao';
20
+ import { 六爻卦, 爻 } from 'liuyao';
29
21
 
30
- const hexagram = Hexagram.fromQuaternary('111222'); // gets a Hexagram instance of '地天泰'
22
+ const 卦 = 六爻卦.从卦名创建('天风姤');
31
23
 
32
- if (hexagram === null) {
33
- throw new Error('Invalid hexagram');
24
+ if (卦) {
25
+ console.log(卦.全名); // 天风姤
26
+ console.log(卦.宫位信息); // 乾宫(金)一世卦
27
+ console.log(卦.六亲干支五行); // ['父母辛丑土', '子孙辛亥水', ...]
28
+ console.log(卦.六冲六合); // undefined(不是六冲也不是六合)
29
+ console.log(卦.变().全名); // 动爻变化后的卦,静卦返回自身
30
+ console.log(卦.世爻, 卦.应爻); // 世应所在的爻index,0 为初爻
34
31
  }
35
-
36
- console.log(hexagram.info.id);
37
- console.log(hexagram.toDescriptionEn());
38
- console.log(hexagram.toChanged()?.info.id);
39
- console.log(SixGodList[0]);
40
32
  ```
41
33
 
42
- ## Core Concepts
43
-
44
- ### Yao
34
+ ## 核心概念
45
35
 
46
- A yao is one line in a hexagram. The constructor accepts a yang count from `0` to `3`:
36
+ ### 爻
47
37
 
48
- - `0`: old yin, dynamic
49
- - `1`: young yang, static
50
- - `2`: young yin, static
51
- - `3`: old yang, dynamic
52
-
53
- Example:
38
+ 一个爻由「阳数」0–3 表示,对应老阴、少阳、少阴、老阳;0 和 3 是动爻。
54
39
 
55
40
  ```ts
56
- import { Yao } from 'liuyao';
57
-
58
- const yao = new Yao(3);
59
-
60
- console.log(yao.name);
61
- console.log(yao.symbol);
62
- console.log(yao.isDynamic);
41
+ const 爻1 = new 爻(3);
42
+ 爻1.名称; // 老阳
43
+ 爻1.阴阳; // 阳
44
+ 爻1.符号; // 重
45
+ 爻1.动静状态; // 动未变
46
+ 爻1.变().名称; // 少阴
63
47
  ```
64
48
 
65
- ### Hexagram
49
+ ### 六爻卦
66
50
 
67
- A hexagram contains six yao lines ordered from bottom to top.
51
+ 六个爻从初爻到上爻排列。构造时自动完成装六亲、装天干、装世应、判六冲六合。
68
52
 
69
53
  ```ts
70
- import { Hexagram } from 'liuyao';
71
-
72
- const qian = Hexagram.fromId('乾为天');
73
-
74
- if (qian) {
75
- console.log(qian.info.sign);
76
- console.log(qian.info.phase);
77
- console.log(qian.dynamicInner);
78
- }
54
+ const 卦 = 六爻卦.从阳数字符串创建('112233'); // '单单拆拆重重' 等价
55
+ 卦?.全名; // 风泽中孚
56
+ 卦?.二进制表示; // '110011',1 为阳爻,0 为阴爻
79
57
  ```
80
58
 
81
- Useful instance members:
59
+ ## API
82
60
 
83
- - `info`: metadata for the current hexagram
84
- - `isDynamic`: whether any line is dynamic
85
- - `isChanged`: whether the current hexagram is already a changed hexagram
86
- - `toChanged()`: returns the changed hexagram when dynamic lines exist
87
- - `toDescription()`: Chinese description
88
- - `toDescriptionEn()`: English description
61
+ ### 爻
89
62
 
90
- Useful factory methods:
63
+ | 静态方法 | 说明 |
64
+ | --------------------- | --------------------------------------------- |
65
+ | `从阳数字符串创建(s)` | `'0'`–`'3'` |
66
+ | `从单拆重交创建(s)` | `'交'` `'单'` `'拆'` `'重'` |
67
+ | `从名称创建(s)` | `'老阴'` `'少阳'` `'少阴'` `'老阳'` |
68
+ | `从八卦字段创建(v)` | 八卦的卦名、二进制、阳数、符号均可,如 `'乾'` |
91
69
 
92
- - `Hexagram.fromYaos(yaos)`
93
- - `Hexagram.fromyangs(counts)`
94
- - `Hexagram.fromId(id)`
95
- - `Hexagram.fromPalace(palace)`
70
+ 实例:`阳数`、`阴阳`、`名称`、`符号`、`动静状态`、`变()`、`克隆()`。
96
71
 
97
- ## Exported API
72
+ ### 六爻卦
98
73
 
99
- The package currently exports:
74
+ | 静态方法 | 说明 |
75
+ | --------------------- | --------------------------------------------- |
76
+ | `从阳数字符串创建(s)` | 如 `'112233'` |
77
+ | `从单拆重交创建(s)` | 如 `'单单拆拆重重'` |
78
+ | `从阳数创建(counts)` | 阳数数组,非法时返回 `null` |
79
+ | `从卦名创建(name)` | 全名、卦名或唯一前缀,如 `'天火同人'`、`'姤'` |
100
80
 
101
- **Classes:**
102
- - `Hexagram`
103
- - `Yao`
81
+ 实例:`六爻`、`阳数`、`二进制表示`、`卦名`、`全名`、`符号`、`五行`、`宫`、`八宫卦位`、`宫位信息`、`动静状态`、`六亲干支五行`、`世爻`、`应爻`、`六冲六合`、`是否为八纯卦`、`内卦`、`外卦`、`变()`、`克隆()`。
104
82
 
105
- **Data Lists:**
106
- - `HexagramList`(六十四卦): Includes 64 static hexagram info objects with traditional metadata.
107
- - `HexagramYaoIndex`(六十四卦爻位名)
108
- - `TrigramList`(八卦): Includes 8 static trigram info objects with traditional metadata.
109
- - `SixGodList`(六神表)
83
+ ### 数据表
110
84
 
111
- **Types:**
112
- - type `SixGod`
113
- - type `SixGodInfo`
114
- - type `SetupGramInfo`
85
+ `六十四卦表`、`八卦表`、`八宫卦位顺序表`、`六神表`、`爻位`。
115
86
 
116
- ## Notes
87
+ ## 技能包
117
88
 
118
- - Traditional names and metadata values are kept in Chinese.
119
- - The package focuses on data modeling and lookup. It does not implement a full divination workflow by itself.
89
+ 包内附带 `liuyao-skill`,供 AI 用脚本把卦象字符串装成结构化数据,详见 [SKILL.md](./src/SKILL.md)。
90
+
91
+ ```bash
92
+ node parser.skill.mjs <卦象字符串> [--date=<日期>] [--format=<格式>]
93
+ ```
120
94
 
121
- ## License
95
+ `--format` 可选 `json`(默认,紧凑)、`pretty-json`(缩进 2 格)、`yaml`、`md`(排盘表格)。卦象字符串支持六位阳数 `112233`、六位单拆重交 `单单拆拆重重`、卦名或全名 `天风姤`。日期用 `--date` 传入,如 `--date=2026-10-31T13:00`(`new Date` 对纯日期按 UTC 零点解析,会固定成辰时、UTC 以西还会退一天,请写全时间)。参数不合法时会打印具体原因和用法并以非 0 退出。
122
96
 
123
- MIT
97
+ `src/lib` 下的 `toJSON`、`toYAML`、`toMarkdown` 即上述三种结构化输出的实现。
package/dist/index.d.mts CHANGED
@@ -1,45 +1,40 @@
1
1
  //#region src/core/common.d.ts
2
- declare const PalaceOrderTable: string[];
3
- type BranchPhase = '子水' | '寅木' | '辰土' | '午火' | '申金' | '戌土' | '寅木' | '辰土' | '午火' | '申金' | '戌土' | '子水' | '辰土' | '午火' | '申金' | '戌土' | '子水' | '寅木' | '子水' | '寅木' | '辰土' | '午火' | '申金' | '戌土' | '丑土' | '亥水' | '酉金' | '未土' | '巳火' | '卯木' | '卯木' | '丑土' | '亥水' | '酉金' | '未土' | '巳火' | '未土' | '巳火' | '卯木' | '丑土' | '亥水' | '酉金' | '巳火' | '卯木' | '丑土' | '亥水' | '酉金' | '未土';
4
- type Phase = '金' | '木' | '水' | '火' | '土';
5
- type TrigramName = '乾' | '兑' | '离' | '震' | '巽' | '坎' | '艮' | '坤';
6
- interface HexagramInfo {
2
+ declare const 八宫卦位顺序表: readonly ["本宫卦", "一世卦", "二世卦", "三世卦", "四世卦", "五世卦", "游魂卦", "归魂卦"];
3
+ type 地支五行 = '子水' | '丑土' | '寅木' | '卯木' | '辰土' | '巳火' | '午火' | '未土' | '申金' | '酉金' | '戌土' | '亥水';
4
+ type 五行 = '金' | '木' | '水' | '火' | '土';
5
+ type 八卦名 = '乾' | '兑' | '离' | '震' | '巽' | '坎' | '艮' | '坤';
6
+ interface 六十四卦 {
7
7
  /**
8
8
  * Binary representation of the hexagram, where 0 image a yin line and 1 image a yang line. The lines are ordered from the bottom (first line) to the top (sixth line).
9
9
  */
10
- binary: string;
11
- /**
12
- * Binary to yangs.
13
- * e.g. `'000000'` 坤为地 -> `[2, 2, 2, 2, 2, 2]`, 2 means Shao Yin.
14
- */
15
- yangs: number[];
10
+ 二进制表示: string;
16
11
  /**
17
12
  * Full name of the hexagram, which includes the names of the upper and lower trigrams.
18
13
  *
19
14
  * For example, "坤为地", "地雷复", "地水师", etc.
20
15
  */
21
- id: string;
16
+ 全名: string;
22
17
  /**
23
18
  * Name of the hexagram.
24
19
  *
25
20
  * For example, "地", "复", "师", etc.
26
21
  */
27
- name: string;
22
+ 卦名: string;
28
23
  /**
29
24
  * 64 hexagrams correspond to Unicode characters.
30
25
  * For example, "䷁" (U+4DC1) image the hexagram "坤为地".
31
26
  */
32
- sign: string;
27
+ 符号: string;
33
28
  /**
34
29
  * Five Phases (五行) associated with the hexagram, which can be one of "金" (Metal), "木" (Wood), "水" (Water), "火" (Fire), or "土" (Earth).
35
30
  * It indicates the development and state of things.
36
31
  */
37
- phase: Phase;
32
+ 五行: 五行;
38
33
  /**
39
34
  * Eight Palaces (八宫) to which the hexagram belongs.
40
35
  * 'Palace' is not a physical palace, but rather a category or family of hexagrams.
41
36
  */
42
- palace: TrigramName;
37
+ 宫: 八卦名;
43
38
  /**
44
39
  * Index of the hexagram within its palace, ranging from 0 to 7. This index helps to identify the specific hexagram within the context of its palace.
45
40
  *
@@ -52,88 +47,67 @@ interface HexagramInfo {
52
47
  * - 游魂卦 Wandering Soul, restores 4th yao of Fifth Generation
53
48
  * - 归魂卦 Returning Soul, restores lower 3 yaos of Fifth Generation
54
49
  */
55
- generation: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
50
+ 八宫卦位: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
56
51
  }
57
- declare const HexagramInfoTable: readonly HexagramInfo[];
58
- interface TrigramInfo {
52
+ /**
53
+ * 包含丰富信息的表,已冻结无法修改,字段如下:
54
+ * - 二进制表示: '000000'
55
+ * - 全名: '坤为地'
56
+ * - 符号: '䷁'
57
+ * - 五行: '土'
58
+ * - 宫: '坤'
59
+ * - 卦位: 0
60
+ * - 卦名: '坤'
61
+ */
62
+ declare const 六十四卦表: readonly 六十四卦[];
63
+ interface 八卦 {
59
64
  /**
60
65
  * Presents the trigram as a 3-digit binary string. 1 image a Yang line and 0 image a Yin line.
61
66
  *
62
67
  * For example, "111" for 乾, "100" for 震, etc.
63
68
  */
64
- binary: `${0 | 1}${0 | 1}${0 | 1}`;
69
+ 二进制表示: `${0 | 1}${0 | 1}${0 | 1}`;
65
70
  /**
66
71
  * How many Yang Yaos are in the trigram, such as 0 for 坤, 1 for 震, 2 for 兑, etc.
67
72
  */
68
- yangs: 0 | 1 | 2 | 3;
73
+ 阳数: 0 | 1 | 2 | 3;
69
74
  /**
70
75
  * Name of the trigram in Chinese, such as "乾", "坤", "震", etc.
71
76
  */
72
- id: string;
77
+ 卦名: string;
73
78
  /**
74
79
  * "象", means what the trigram represents in Chinese, such as "天", "地", "水", etc.
75
80
  */
76
- image: string;
81
+ 象: string;
77
82
  /**
78
83
  * Unicode character representing the trigram, such as "☰" for 乾, "☷" for 坤, etc.
79
84
  */
80
- sign: string;
85
+ 符号: string;
81
86
  /**
82
87
  * Earth Stem and Five Phases when this gram performs a inner gram of a hexagram.
83
88
  * @see 《增删卜易·浑天甲子章》
84
89
  */
85
- inner: BranchPhase[];
90
+ 内卦地支五行: 地支五行[];
86
91
  /**
87
92
  * Earth Stem and Five Phases when this gram performs a outer gram of a hexagram.
88
93
  * @see 《增删卜易·浑天甲子章》
89
94
  */
90
- outer: BranchPhase[];
95
+ 外卦地支五行: 地支五行[];
91
96
  }
92
97
  /**
93
98
  * List of all trigrams in the I Ching, with their binary representation, number of yang lines, name, what they represent, and their corresponding sign.
94
99
  */
95
- declare const TrigramInfoTable: readonly TrigramInfo[];
96
- //#endregion
97
- //#region src/core/setup-gram.d.ts
98
- /**
99
- * Kins and their corresponding earthly branches in the Liu Yao divination system, along with the type of relation (世 or 应).
100
- * This information is crucial for interpreting the hexagrams and their changing lines in the context of a divination reading.
101
- *
102
- * @deprecated This is for beginners.
103
- */
104
- interface SetupGramInfo {
105
- /**
106
- * There are 5 kins in total.
107
- *
108
- * - 兄弟 (Brothers): Representing peers, friends, or competitors.
109
- * - 妻财 (Wife/Wealth): Representing spouse, wealth, or resources.
110
- * - 子孙 (Children/Descendants): Representing offspring, students, or followers.
111
- * - 官鬼 (Officials/Ghosts): Representing authority figures, adversaries, or hidden factors.
112
- * - 父母 (Parents): Representing parents, mentors, or foundational influences.
113
- *
114
- * Each kin is associated with one of the twelve earthly branches (地支), which adds another layer of meaning to the hexagram lines.
115
- */
116
- kin: '兄弟丑土' | '兄弟亥水' | '兄弟午火' | '兄弟卯木' | '兄弟子水' | '兄弟寅木' | '兄弟巳火' | '兄弟戌土' | '兄弟未土' | '兄弟申金' | '兄弟辰土' | '兄弟酉金' | '妻财丑土' | '妻财亥水' | '妻财午火' | '妻财卯木' | '妻财子水' | '妻财寅木' | '妻财巳火' | '妻财戌土' | '妻财未土' | '妻财申金' | '妻财辰土' | '妻财酉金' | '子孙丑土' | '子孙亥水' | '子孙午火' | '子孙卯木' | '子孙子水' | '子孙寅木' | '子孙巳火' | '子孙戌土' | '子孙未土' | '子孙申金' | '子孙辰土' | '子孙酉金' | '官鬼丑土' | '官鬼亥水' | '官鬼午火' | '官鬼卯木' | '官鬼子水' | '官鬼寅木' | '官鬼巳火' | '官鬼戌土' | '官鬼未土' | '官鬼申金' | '官鬼辰土' | '官鬼酉金' | '父母丑土' | '父母亥水' | '父母午火' | '父母卯木' | '父母子水' | '父母寅木' | '父母巳火' | '父母戌土' | '父母未土' | '父母申金' | '父母辰土' | '父母酉金';
117
- /**
118
- * Host(世)is the augur and Guest(应) is the person or things which to ask about.
119
- *
120
- * Indexes of Host and Guest satisfies this formula:
121
- * ```js
122
- * index_guest = (index_host + 3) % 6
123
- * ```
124
- */
125
- hostGuest?: '世' | '应';
126
- }
100
+ declare const 八卦表: readonly 八卦[];
127
101
  //#endregion
128
102
  //#region src/core/six-gods.d.ts
129
- type SixGod = '玄武' | '白虎' | '螣蛇' | '勾陈' | '朱雀' | '青龙';
130
- interface SixGodInfo {
103
+ type 六神 = '玄武' | '白虎' | '螣蛇' | '勾陈' | '朱雀' | '青龙';
104
+ interface 六神信息 {
131
105
  /**
132
106
  * The Heavenly Stem associated with the Six Gods in this order.
133
107
  * They are '甲乙丙丁戊己庚辛壬癸' in sequence.
134
108
  * Different Heavenly Stems correspond to different orders of Six Gods.
135
109
  */
136
- heavenlyStem: string;
110
+ 天干: string;
137
111
  /**
138
112
  * Six Gods contains '青龙', '朱雀', '勾陈', '螣蛇', '白虎', '玄武'.
139
113
  * Different Heavenly Stems correspond to different orders of Six Gods.
@@ -146,53 +120,47 @@ interface SixGodInfo {
146
120
  * - 螣蛇: Flying Serpent, a limbless divine serpent that can summon clouds and mist and roam within them.
147
121
  * - 勾陈: Gouchen, Also considered as 麒麟 Kylin. It has a body like a musk deer, a tail like that of a dragon, dragon scales, and a single horn.
148
122
  */
149
- gods: SixGod[];
123
+ 六神: 六神[];
150
124
  }
151
125
  /**
152
126
  * @see 《增删卜易·六神章》
153
127
  */
154
- declare const SixGodTable: readonly SixGodInfo[];
128
+ declare const 六神表: readonly 六神信息[];
155
129
  //#endregion
156
130
  //#region src/classes/yao.d.ts
157
- declare class Yao {
158
- /**
159
- * Returns 老阴、老阳、少阴、少阳
160
- */
161
- static getName(yangs: number): "老阴" | "少阳" | "少阴" | "老阳";
162
- /**
163
- * Support creating a Yao from various types of input:
164
- * - A symbol representing the Yao (e.g. '交', '单', '拆', '重')
165
- * - A name representing the Yao (e.g. '老阴', '少阳', '少阴', '老阳')
166
- * - A digit representing the count of yang (e.g. '0', '1', '2', '3')
167
- * - Symbols in ancient books representing a Yao ()
168
- * - A field of a TrigramInfo object (e.g. id, binary, nameEn, represents, representsEn, sign)
169
- * If the input matches any of these, a corresponding Yao will be created.
170
- * Otherwise, null will be returned.
171
- */
172
- /**
173
- * Creating a Yao from symbol.
174
- * @param symbol e.g. '×' for 0, '’' for 1, '”' for 2, '○' for 3.
175
- */
176
- static fromSymbol(symbol: string): Yao | null;
131
+ /**
132
+ * 描述卦和爻的动静变化,分为'静'、'动卦/爻但还没变'、'动卦/爻已经变了'3个状态
133
+ */
134
+ declare const enum 动静状态 {
135
+ 静 = 0,
136
+ 动未变 = 1,
137
+ 动已变 = 2
138
+ }
139
+ declare class 爻 {
140
+ #private;
177
141
  /**
178
142
  * Creating a Yao from symbolName.
179
143
  * @param symbolName e.g. '交' for 0, '单' for 1, '拆' for 2, '重' for 3.
144
+ * @returns 如果入参符合就返回,如果不符合就返回`null`
180
145
  */
181
- static fromSymbolName(symbolName: string): Yao | null;
146
+ static 从单拆重交创建(symbolName: string): 爻 | null;
182
147
  /**
183
148
  * Creating a Yao from name.
184
149
  * @param name e.g. '老阴', '少阳', '少阴', '老阳'.
150
+ * @returns 如果入参符合就返回,如果不符合就返回`null`
185
151
  */
186
- static fromName(name: string): Yao | null;
152
+ static 从名称创建(name: string): 爻 | null;
187
153
  /**
188
- * Create a Yao from a digit string representing the count of yang.
154
+ * @param digit e.g. '0', '1', '2', '3'.
155
+ * @returns 如果入参符合就返回,如果不符合就返回`null`
189
156
  */
190
- static fromDigitString(digit: string): Yao | null;
157
+ static 从阳数字符串创建(digit: string): 爻 | null;
191
158
  /**
192
159
  * Create a Yao from any Trigram field value.
193
160
  * @param value `{id: '坤', binary: '000', yangs: 0}`, so `'坤'`, `'000'` and `0` can all be used.
161
+ * @returns 如果入参符合就返回,如果不符合就返回`null`
194
162
  */
195
- static fromTrigramField(value: string | number): Yao | null;
163
+ static 从八卦字段创建(value: string | number): 爻 | null;
196
164
  /**
197
165
  * How many faces of character of 3 coins in this Yao.
198
166
  * It can only be 0, 1, 2 or 3, which corresponds to 老阴、少阳、少阴、老阳 respectively.
@@ -201,134 +169,111 @@ declare class Yao {
201
169
  * - 2: 少阴 (two coins are 阳面, one coin is 阴面)
202
170
  * - 3: 老阳 (all three coins are 阳面)
203
171
  */
204
- readonly yangs: 0 | 1 | 2 | 3;
172
+ get 阳数(): 0 | 1 | 2 | 3;
173
+ get 动静状态(): 动静状态;
205
174
  /**
206
175
  * 两仪, aka 阴阳
207
176
  */
208
- readonly polar: 0 | 1;
177
+ get 阴阳(): '阴' | '阳';
178
+ get 名称(): '老阴' | '少阳' | '少阴' | '老阳';
179
+ get 符号(): '单' | '拆' | '重' | '交';
180
+ constructor(阳数: number, 状态?: 动静状态);
209
181
  /**
210
- * If this Yao is dynamic, which means it can change to another Yao. In LiuYao, only 老阴 and 老阳 are dynamic.
211
- * - 老阴 (0) can change to 少阳 (1)
212
- * - 老阳 (3) can change to 少阴 (2)
213
- * - 少阳 (1) and 少阴 (2) cannot change, so they are static.
182
+ * 判断是否同为阴爻或同为阳爻
214
183
  */
215
- readonly dynamic: boolean;
184
+ 是否阳数相等(other: 爻): boolean;
216
185
  /**
217
- * Whether this Yao has already changed to another Yao. Once a Yao is changed, it cannot change again.
186
+ * 判断是否同为阴爻或同为阳爻,且是否变过的状态也相同
187
+ * - 阳数和状态相同视为全同
218
188
  */
219
- readonly changed: boolean;
220
- /**
221
- * The symbol representing this Yao, which is one of '×', '’', '”', '○'.
222
- */
223
- readonly pattern: '×' | '’' | '”' | '○';
224
- readonly name: '老阴' | '少阳' | '少阴' | '老阳';
225
- readonly symbol: '单' | '拆' | '重' | '交';
226
- constructor(yangs: number, isChanged?: boolean);
189
+ 是否全同(other: 爻): boolean;
227
190
  /**
228
- * Consider the Yaos are same if `this.yangs` is same
191
+ * 克隆一个全新的和本身一样的爻对象
229
192
  */
230
- eq(other: Yao): boolean;
193
+ 克隆(): 爻;
231
194
  /**
232
- * Consider the Yaos are `===` if:
233
- * 1. `this.yangs` is same
234
- * 2. `this.isChanged` is same
195
+ * 得到新的爻对象,这个爻是变过的。
196
+ * @returns 如果是静爻或者已变过,则返回它自己
235
197
  */
236
- eqeqeq(other: Yao): boolean;
237
- clone(): Yao;
238
- toChanged(): Yao;
198
+ 变(): 爻;
239
199
  }
240
200
  //#endregion
241
201
  //#region src/classes/hexagram.d.ts
242
- type LiuYao = [Yao, Yao, Yao, Yao, Yao, Yao];
243
- declare const HexagramYaoOrder: readonly ["初爻", "二爻", "三爻", "四爻", "五爻", "上爻"];
202
+ declare const 爻位: readonly ["初爻", "二爻", "三爻", "四爻", "五爻", "上爻"];
244
203
  /**
245
204
  * Hexagram class represents a hexagram, which consists of 6 Yao.
246
205
  * - Each Yao can be either yin or yang, and can be changing or not.
247
206
  * - The hexagram can be constructed from an array of Yao or an array of counts of yang.
248
207
  * - Creates “乾为天” by default.
249
208
  */
250
- declare class Hexagram implements HexagramInfo {
209
+ declare class 六爻卦 implements 六十四卦 {
210
+ #private;
251
211
  /**
252
212
  * Use tokens like `'012132'` to create a Hexagram, where each digit represents the count of Yang in the corresponding Yao (0 for 老阴, 1 for 少阳, 2 for 少阴, 3 for 老阳). The first digit represents the first Yao (初爻) and the last digit represents the sixth Yao (上爻).
253
213
  */
254
- static fromQuaternary(quaternary: string): Hexagram | null;
214
+ static 从阳数字符串创建(quaternary: string): 六爻卦 | null;
255
215
  /**
256
216
  * Use tokens like `'单单拆拆重重'` to create a Hexagram.
257
217
  *
258
218
  * Since 交 is 0, 单 is 1, 拆 is 2, and 重 is 3, the above token is equivalent to '112233'.
259
219
  * Which returns '风泽中孚' with its 5th and 6th Yao being dynamic.
260
220
  */
261
- static fromSymbolName(symbolNames: string): Hexagram | null;
221
+ static 从单拆重交创建(symbolNames: string): 六爻卦 | null;
262
222
  /**
263
223
  * Try to create a Hexagram from an array of counts of Yang. If the input is invalid, null will be returned.
264
224
  */
265
- static fromYangCounts(counts: number[]): Hexagram | null;
225
+ static 从阳数创建(counts: number[]): 六爻卦 | null;
266
226
  /**
267
227
  * Create a Hexagram from its id, which is the name of the hexagram without the palace name.
268
- * @param id "坤为地", "地雷复", "地水师"
269
- */
270
- static fromId(id: string): Hexagram | null;
271
- /**
272
- * Find Original Palace Hexagram by the palace name, which is the last character of the hexagram id. For example, '天' for '乾为天', '地' for '坤为地', etc.
273
- */
274
- static fromPalace(palace: string): Hexagram | null;
275
- /**
276
- * 6 Yao positions, indexed from bottom to top.
277
- * Index from 0 to 5, where 0 is the first Yao (初爻) and 5 is the sixth Yao (上爻).
278
- */
279
- readonly yaos: LiuYao;
280
- readonly yangs: number[];
281
- readonly binary: string;
282
- readonly id: string;
283
- readonly name: string;
284
- readonly sign: string;
285
- readonly palace: '乾' | '坤' | '震' | '巽' | '坎' | '离' | '艮' | '兑';
286
- readonly phase: '金' | '木' | '水' | '火' | '土';
287
- readonly generation: 0 | 6 | 1 | 2 | 3 | 4 | 5 | 7;
288
- readonly palaceInfo: string;
289
- /**
290
- * Whether the 6 Yaos of this hexagram contain any dynamic Yao.
291
- */
292
- readonly dynamic: boolean;
293
- /**
294
- * Whether this hexagram has already changed to another hexagram. Once a hexagram is changed, it cannot change again.
295
- */
296
- readonly changed: boolean;
297
- readonly inner: TrigramInfo;
298
- readonly outer: TrigramInfo;
299
- /**
300
- * Whether this gram is 六冲、六合
228
+ * @param name "坤为地", "地雷复", "地水师"
301
229
  */
302
- readonly specialType?: '六冲' | '六合';
230
+ static 从卦名创建(name: string): 六爻卦 | null;
303
231
  /**
304
- * Whether this gram is "八纯卦"
305
- */
306
- readonly pure: boolean;
307
- /**
308
- * Includes 六亲、天干、地支、五行. Looks like "兄弟癸丑土" "官鬼辛卯木"
232
+ * Create a Hexagram from an array of Yao with length 6.
233
+ * @param 六爻 从初爻到上爻6个爻组成的数组
234
+ * @param 状态 动静状态,不传则由爻推断
235
+ * @param 本卦 仅变卦需要传入。六亲在构造时就要按本卦的宫装好,所以不能等构造完再赋值
309
236
  */
310
- readonly kins: string[];
237
+ constructor(六爻: 爻[], 状态?: 动静状态, 本卦?: 六爻卦);
238
+ get 六爻(): [爻, 爻, 爻, 爻, 爻, 爻];
239
+ get 阳数(): number[];
240
+ get 宫位信息(): string;
241
+ get 动静状态(): 动静状态;
311
242
  /**
312
- * Index of the 世爻
243
+ * 若是变卦,则返回本卦。
244
+ *
245
+ * 若是静卦或者本来就是本卦,则返回自身。
313
246
  */
314
- readonly host: number;
247
+ get 本卦(): 六爻卦;
248
+ get 六亲干支五行(): string[];
315
249
  /**
316
- * Index of the 应爻
250
+ * 返回世爻所在的index(0表示初爻,5表示上爻)
317
251
  */
318
- readonly guest: number;
252
+ get 世爻(): 0 | 1 | 2 | 3 | 4 | 5;
319
253
  /**
320
- * if it is a changed gram, this points to the primary one.
254
+ * 返回应爻所在的index(0表示初爻,5表示上爻)
321
255
  */
322
- readonly primary: Hexagram | null;
256
+ get 应爻(): 0 | 1 | 2 | 3 | 4 | 5;
257
+ get 六冲六合(): '六冲' | '六合' | undefined;
258
+ get 是否为八纯卦(): boolean;
259
+ get 内卦(): 八卦;
260
+ get 外卦(): 八卦;
261
+ get 二进制表示(): string;
262
+ get 卦名(): string;
263
+ get 全名(): string;
264
+ get 符号(): string;
265
+ get 五行(): 五行;
266
+ get 宫(): 八卦名;
267
+ get 八宫卦位(): 0 | 6 | 1 | 2 | 3 | 4 | 5 | 7;
323
268
  /**
324
- * Create a Hexagram from an array of Yao with length 6.
269
+ * 获得变爻卦象
270
+ * @returns 变爻卦象,如果卦象静则返回它自己
325
271
  */
326
- constructor(yaos: Yao[], primary?: Hexagram | null);
327
- toChanged(): Hexagram | null;
328
- clone(): Hexagram;
272
+ 变(): 六爻卦;
273
+ 克隆(): 六爻卦;
329
274
  toString(): string;
330
275
  [Symbol.toPrimitive](): string;
331
276
  }
332
277
  //#endregion
333
- export { Hexagram, type HexagramInfo, HexagramInfoTable, HexagramYaoOrder, PalaceOrderTable, type SetupGramInfo, type SixGod, type SixGodInfo, SixGodTable, type TrigramInfo, TrigramInfoTable, Yao };
278
+ export { type 八卦, 八卦表, 八宫卦位顺序表, type 六十四卦, 六十四卦表, 六爻卦, type 六神, type 六神信息, 六神表, 爻, 爻位 };
334
279
  //# sourceMappingURL=index.d.mts.map