xiaochengtu 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/LICENSE +21 -0
- package/README.md +199 -0
- package/dist/index.d.mts +412 -0
- package/dist/index.d.ts +412 -0
- package/dist/index.js +548 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +520 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# xiaochengtu
|
|
2
|
+
|
|
3
|
+
小成图排盘 TypeScript/JavaScript 库
|
|
4
|
+
|
|
5
|
+
A TypeScript/JavaScript library for XiaoChengTu (小成图) divination, implementing the traditional Chinese Yi-Jing based prediction method.
|
|
6
|
+
|
|
7
|
+
## 安装 / Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# npm
|
|
11
|
+
npm install xiaochengtu
|
|
12
|
+
|
|
13
|
+
# pnpm
|
|
14
|
+
pnpm add xiaochengtu
|
|
15
|
+
|
|
16
|
+
# yarn
|
|
17
|
+
yarn add xiaochengtu
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 快速开始 / Quick Start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { XiaoChengTu, Trigram } from 'xiaochengtu'
|
|
24
|
+
|
|
25
|
+
// 方式1: 使用卦象直接创建
|
|
26
|
+
const xct = new XiaoChengTu({
|
|
27
|
+
baseHexagram: { upper: Trigram.Kan, lower: Trigram.Li }, // 水火既济
|
|
28
|
+
changedHexagram: { upper: Trigram.Dui, lower: Trigram.Gen }, // 泽山咸
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// 执行排盘
|
|
32
|
+
const result = xct.divine()
|
|
33
|
+
console.log(result)
|
|
34
|
+
|
|
35
|
+
// 输出格式化结果
|
|
36
|
+
console.log(xct.toString())
|
|
37
|
+
|
|
38
|
+
// 方式2: 使用数字起卦
|
|
39
|
+
const xct2 = XiaoChengTu.fromNumbers({
|
|
40
|
+
baseUpper: 6, // 坎
|
|
41
|
+
baseLower: 3, // 离
|
|
42
|
+
changedUpper: 2, // 兑
|
|
43
|
+
changedLower: 7, // 艮
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// 方式3: 随机起卦
|
|
47
|
+
const xct3 = XiaoChengTu.random()
|
|
48
|
+
|
|
49
|
+
// 方式4: 时间起卦
|
|
50
|
+
const xct4 = XiaoChengTu.fromTime() // 使用当前时间
|
|
51
|
+
const xct5 = XiaoChengTu.fromTime(new Date('2024-01-15T10:30:00')) // 指定时间
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 八卦编号 / Trigram Numbers
|
|
55
|
+
|
|
56
|
+
使用先天数:
|
|
57
|
+
|
|
58
|
+
| 数字 | 八卦 | Trigram |
|
|
59
|
+
| ---- | ---- | ------- |
|
|
60
|
+
| 1 | 乾 | Qian |
|
|
61
|
+
| 2 | 兑 | Dui |
|
|
62
|
+
| 3 | 离 | Li |
|
|
63
|
+
| 4 | 震 | Zhen |
|
|
64
|
+
| 5 | 巽 | Xun |
|
|
65
|
+
| 6 | 坎 | Kan |
|
|
66
|
+
| 7 | 艮 | Gen |
|
|
67
|
+
| 8 | 坤 | Kun |
|
|
68
|
+
|
|
69
|
+
## API
|
|
70
|
+
|
|
71
|
+
### XiaoChengTu 类
|
|
72
|
+
|
|
73
|
+
主要的排盘类。
|
|
74
|
+
|
|
75
|
+
#### 构造函数
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
new XiaoChengTu(input: XiaoChengTuInput)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### 静态方法
|
|
82
|
+
|
|
83
|
+
- `XiaoChengTu.fromNumbers(input: NumberDivinationInput)` - 从数字创建
|
|
84
|
+
- `XiaoChengTu.random()` - 随机起卦
|
|
85
|
+
- `XiaoChengTu.fromTime(date?: Date)` - 时间起卦
|
|
86
|
+
|
|
87
|
+
#### 实例方法
|
|
88
|
+
|
|
89
|
+
- `divine(): XiaoChengTuResult` - 执行排盘,返回完整结果
|
|
90
|
+
- `getPalaceAnalysis(palace: Palace): PalaceAnalysis | undefined` - 获取指定宫位分析
|
|
91
|
+
- `toString(): string` - 输出格式化的盘面字符串
|
|
92
|
+
|
|
93
|
+
### 类型定义
|
|
94
|
+
|
|
95
|
+
#### Trigram (八卦)
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
enum Trigram {
|
|
99
|
+
Qian = 'qian', // 乾
|
|
100
|
+
Dui = 'dui', // 兑
|
|
101
|
+
Li = 'li', // 离
|
|
102
|
+
Zhen = 'zhen', // 震
|
|
103
|
+
Xun = 'xun', // 巽
|
|
104
|
+
Kan = 'kan', // 坎
|
|
105
|
+
Gen = 'gen', // 艮
|
|
106
|
+
Kun = 'kun', // 坤
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Palace (九宫)
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
enum Palace {
|
|
114
|
+
Kan = 1, // 坎宫 - 正北
|
|
115
|
+
Kun = 2, // 坤宫 - 西南
|
|
116
|
+
Zhen = 3, // 震宫 - 正东
|
|
117
|
+
Xun = 4, // 巽宫 - 东南
|
|
118
|
+
Center = 5, // 中宫 - 中央
|
|
119
|
+
Qian = 6, // 乾宫 - 西北
|
|
120
|
+
Dui = 7, // 兑宫 - 正西
|
|
121
|
+
Gen = 8, // 艮宫 - 东北
|
|
122
|
+
Li = 9, // 离宫 - 正南
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### FourImages (四象)
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
enum FourImages {
|
|
130
|
+
He = 'he', // 阖 - 向心/凝聚
|
|
131
|
+
Pi = 'pi', // 辟 - 离心/发散
|
|
132
|
+
Wang = 'wang', // 往 - 外引
|
|
133
|
+
Lai = 'lai', // 来 - 内引
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 工具函数
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// 数字转八卦
|
|
141
|
+
numberToTrigram(num: number): Trigram
|
|
142
|
+
|
|
143
|
+
// 生成互卦
|
|
144
|
+
generateMutualHexagram(hexagram: Hexagram): Hexagram
|
|
145
|
+
|
|
146
|
+
// 判断是否为八纯卦
|
|
147
|
+
isPureHexagram(hexagram: Hexagram): boolean
|
|
148
|
+
|
|
149
|
+
// 判断是否为同位异性卦
|
|
150
|
+
isOppositeHexagram(hexagram: Hexagram): boolean
|
|
151
|
+
|
|
152
|
+
// 计算中宫
|
|
153
|
+
calculateCenterPalace(baseHexagram: Hexagram, changedHexagram: Hexagram): Trigram
|
|
154
|
+
|
|
155
|
+
// 计算四象
|
|
156
|
+
calculateFourImages(skyTrigram: Trigram, earthTrigram: Trigram): FourImages
|
|
157
|
+
|
|
158
|
+
// 计算配对结果
|
|
159
|
+
calculateMatchResult(skyTrigram: Trigram, earthTrigram: Trigram): MatchResult
|
|
160
|
+
|
|
161
|
+
// 获取八卦中文名
|
|
162
|
+
getTrigramChineseName(trigram: Trigram): string
|
|
163
|
+
|
|
164
|
+
// 获取宫位中文名
|
|
165
|
+
getPalaceChineseName(palace: Palace): string
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 示例输出
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
========================================
|
|
172
|
+
小成图排盘结果
|
|
173
|
+
========================================
|
|
174
|
+
本卦: 坎离
|
|
175
|
+
变卦: 兑艮
|
|
176
|
+
本互卦: 离坎
|
|
177
|
+
变互卦: 乾巽
|
|
178
|
+
|
|
179
|
+
九宫布局:
|
|
180
|
+
----------------------------------------
|
|
181
|
+
| 兑 | 坎 | 坎 |
|
|
182
|
+
| 巽 | 离 | 坤 |
|
|
183
|
+
----------------------------------------
|
|
184
|
+
| 艮 | 乾 | 巽 |
|
|
185
|
+
| 震 | 中 | 兑 |
|
|
186
|
+
----------------------------------------
|
|
187
|
+
| 离 | 离 | 乾 |
|
|
188
|
+
| 艮 | 坎 | 乾 |
|
|
189
|
+
----------------------------------------
|
|
190
|
+
|
|
191
|
+
各宫分析:
|
|
192
|
+
坎宫(正北): 天盘离 地盘坎 → 吉 - 内引得配,宜守成
|
|
193
|
+
坤宫(西南): 天盘坎 地盘坤 → 凶 - 外引失配,奔波徒劳
|
|
194
|
+
...
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## 许可证 / License
|
|
198
|
+
|
|
199
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 八卦枚举
|
|
3
|
+
* Bagua (Eight Trigrams) enumeration
|
|
4
|
+
*/
|
|
5
|
+
declare enum Trigram {
|
|
6
|
+
/** 乾 - Heaven */
|
|
7
|
+
Qian = "qian",
|
|
8
|
+
/** 兑 - Lake */
|
|
9
|
+
Dui = "dui",
|
|
10
|
+
/** 离 - Fire */
|
|
11
|
+
Li = "li",
|
|
12
|
+
/** 震 - Thunder */
|
|
13
|
+
Zhen = "zhen",
|
|
14
|
+
/** 巽 - Wind */
|
|
15
|
+
Xun = "xun",
|
|
16
|
+
/** 坎 - Water */
|
|
17
|
+
Kan = "kan",
|
|
18
|
+
/** 艮 - Mountain */
|
|
19
|
+
Gen = "gen",
|
|
20
|
+
/** 坤 - Earth */
|
|
21
|
+
Kun = "kun"
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 五行枚举
|
|
25
|
+
* Wu Xing (Five Elements) enumeration
|
|
26
|
+
*/
|
|
27
|
+
declare enum WuXing {
|
|
28
|
+
/** 金 - Metal */
|
|
29
|
+
Metal = "metal",
|
|
30
|
+
/** 木 - Wood */
|
|
31
|
+
Wood = "wood",
|
|
32
|
+
/** 水 - Water */
|
|
33
|
+
Water = "water",
|
|
34
|
+
/** 火 - Fire */
|
|
35
|
+
Fire = "fire",
|
|
36
|
+
/** 土 - Earth */
|
|
37
|
+
Earth = "earth"
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 阴阳枚举
|
|
41
|
+
* Yin-Yang enumeration
|
|
42
|
+
*/
|
|
43
|
+
declare enum YinYang {
|
|
44
|
+
/** 阳 */
|
|
45
|
+
Yang = "yang",
|
|
46
|
+
/** 阴 */
|
|
47
|
+
Yin = "yin"
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 动态属性(升/降)
|
|
51
|
+
* Dynamic property (Rising/Falling)
|
|
52
|
+
*/
|
|
53
|
+
declare enum DynamicProperty {
|
|
54
|
+
/** 升 - 外引 (Rising/Outward) */
|
|
55
|
+
Rising = "rising",
|
|
56
|
+
/** 降 - 内引 (Falling/Inward) */
|
|
57
|
+
Falling = "falling"
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 四象类型
|
|
61
|
+
* Four Images type
|
|
62
|
+
*/
|
|
63
|
+
declare enum FourImages {
|
|
64
|
+
/** 阖 - 向心/凝聚 */
|
|
65
|
+
He = "he",
|
|
66
|
+
/** 辟 - 离心/发散 */
|
|
67
|
+
Pi = "pi",
|
|
68
|
+
/** 往 - 外引 */
|
|
69
|
+
Wang = "wang",
|
|
70
|
+
/** 来 - 内引 */
|
|
71
|
+
Lai = "lai"
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 配对结果
|
|
75
|
+
* Matching result
|
|
76
|
+
*/
|
|
77
|
+
declare enum MatchResult {
|
|
78
|
+
/** 得配 - 吉 */
|
|
79
|
+
Match = "match",
|
|
80
|
+
/** 失配 - 凶 */
|
|
81
|
+
Mismatch = "mismatch"
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 九宫位置
|
|
85
|
+
* Nine Palace positions
|
|
86
|
+
*/
|
|
87
|
+
declare enum Palace {
|
|
88
|
+
/** 坎宫 - 正北 */
|
|
89
|
+
Kan = 1,
|
|
90
|
+
/** 坤宫 - 西南 */
|
|
91
|
+
Kun = 2,
|
|
92
|
+
/** 震宫 - 正东 */
|
|
93
|
+
Zhen = 3,
|
|
94
|
+
/** 巽宫 - 东南 */
|
|
95
|
+
Xun = 4,
|
|
96
|
+
/** 中宫 - 中央 */
|
|
97
|
+
Center = 5,
|
|
98
|
+
/** 乾宫 - 西北 */
|
|
99
|
+
Qian = 6,
|
|
100
|
+
/** 兑宫 - 正西 */
|
|
101
|
+
Dui = 7,
|
|
102
|
+
/** 艮宫 - 东北 */
|
|
103
|
+
Gen = 8,
|
|
104
|
+
/** 离宫 - 正南 */
|
|
105
|
+
Li = 9
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 八卦属性
|
|
109
|
+
* Trigram properties
|
|
110
|
+
*/
|
|
111
|
+
interface TrigramProperties {
|
|
112
|
+
/** 卦名 */
|
|
113
|
+
name: string;
|
|
114
|
+
/** 中文名 */
|
|
115
|
+
chineseName: string;
|
|
116
|
+
/** 先天数 */
|
|
117
|
+
priorHeavenNumber: number;
|
|
118
|
+
/** 五行 */
|
|
119
|
+
wuXing: WuXing;
|
|
120
|
+
/** 阴阳 */
|
|
121
|
+
yinYang: YinYang;
|
|
122
|
+
/** 动态属性 */
|
|
123
|
+
dynamicProperty: DynamicProperty;
|
|
124
|
+
/** 对应地盘宫位 */
|
|
125
|
+
palacePosition: Palace;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 六十四卦(重卦)
|
|
129
|
+
* Hexagram (64 hexagrams)
|
|
130
|
+
*/
|
|
131
|
+
interface Hexagram {
|
|
132
|
+
/** 上卦 */
|
|
133
|
+
upper: Trigram;
|
|
134
|
+
/** 下卦 */
|
|
135
|
+
lower: Trigram;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 九宫盘面
|
|
139
|
+
* Nine Palace board
|
|
140
|
+
*/
|
|
141
|
+
interface NinePalaceBoard {
|
|
142
|
+
/** Grid1 - 坎宫 */
|
|
143
|
+
grid1: Trigram;
|
|
144
|
+
/** Grid2 - 坤宫 */
|
|
145
|
+
grid2: Trigram;
|
|
146
|
+
/** Grid3 - 震宫 */
|
|
147
|
+
grid3: Trigram;
|
|
148
|
+
/** Grid4 - 巽宫 */
|
|
149
|
+
grid4: Trigram;
|
|
150
|
+
/** Grid5 - 中宫 */
|
|
151
|
+
grid5: Trigram;
|
|
152
|
+
/** Grid6 - 乾宫 */
|
|
153
|
+
grid6: Trigram;
|
|
154
|
+
/** Grid7 - 兑宫 */
|
|
155
|
+
grid7: Trigram;
|
|
156
|
+
/** Grid8 - 艮宫 */
|
|
157
|
+
grid8: Trigram;
|
|
158
|
+
/** Grid9 - 离宫 */
|
|
159
|
+
grid9: Trigram;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 单宫分析结果
|
|
163
|
+
* Single palace analysis result
|
|
164
|
+
*/
|
|
165
|
+
interface PalaceAnalysis {
|
|
166
|
+
/** 宫位 */
|
|
167
|
+
palace: Palace;
|
|
168
|
+
/** 天盘卦 */
|
|
169
|
+
skyTrigram: Trigram;
|
|
170
|
+
/** 地盘卦 */
|
|
171
|
+
earthTrigram: Trigram;
|
|
172
|
+
/** 四象 */
|
|
173
|
+
fourImage: FourImages;
|
|
174
|
+
/** 配对结果 */
|
|
175
|
+
matchResult: MatchResult;
|
|
176
|
+
/** 综合吉凶描述 */
|
|
177
|
+
fortune: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* 完整排盘结果
|
|
181
|
+
* Complete divination result
|
|
182
|
+
*/
|
|
183
|
+
interface XiaoChengTuResult {
|
|
184
|
+
/** 本卦 */
|
|
185
|
+
baseHexagram: Hexagram;
|
|
186
|
+
/** 变卦 */
|
|
187
|
+
changedHexagram: Hexagram;
|
|
188
|
+
/** 本卦互卦 */
|
|
189
|
+
baseMutualHexagram: Hexagram;
|
|
190
|
+
/** 变卦互卦 */
|
|
191
|
+
changedMutualHexagram: Hexagram;
|
|
192
|
+
/** 九宫天盘 */
|
|
193
|
+
board: NinePalaceBoard;
|
|
194
|
+
/** 各宫分析 */
|
|
195
|
+
palaceAnalyses: PalaceAnalysis[];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 八卦属性表
|
|
200
|
+
* Trigram properties lookup table
|
|
201
|
+
*/
|
|
202
|
+
declare const TRIGRAM_PROPERTIES: Record<Trigram, TrigramProperties>;
|
|
203
|
+
/**
|
|
204
|
+
* 先天数到八卦的映射
|
|
205
|
+
* Prior Heaven number to Trigram mapping
|
|
206
|
+
*/
|
|
207
|
+
declare const NUMBER_TO_TRIGRAM: Record<number, Trigram>;
|
|
208
|
+
/**
|
|
209
|
+
* 宫位到地盘八卦的映射
|
|
210
|
+
* Palace to Earth trigram mapping
|
|
211
|
+
*/
|
|
212
|
+
declare const PALACE_TO_EARTH_TRIGRAM: Record<Palace, Trigram>;
|
|
213
|
+
declare const TRIGRAM_BINARY_CORRECT: Record<Trigram, [number, number, number]>;
|
|
214
|
+
/**
|
|
215
|
+
* 从二进制转换到八卦
|
|
216
|
+
* Binary to Trigram conversion
|
|
217
|
+
*/
|
|
218
|
+
declare const BINARY_TO_TRIGRAM: Record<string, Trigram>;
|
|
219
|
+
/**
|
|
220
|
+
* 同位异性卦列表(用于定中宫判断)
|
|
221
|
+
* Same position, opposite nature hexagrams
|
|
222
|
+
*/
|
|
223
|
+
declare const OPPOSITE_HEXAGRAMS: Array<{
|
|
224
|
+
upper: Trigram;
|
|
225
|
+
lower: Trigram;
|
|
226
|
+
name: string;
|
|
227
|
+
}>;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* 数字取余转换为八卦
|
|
231
|
+
* Convert number to trigram (with modulo 8)
|
|
232
|
+
* @param num - 输入数字
|
|
233
|
+
* @returns 对应的八卦
|
|
234
|
+
*/
|
|
235
|
+
declare function numberToTrigram(num: number): Trigram;
|
|
236
|
+
/**
|
|
237
|
+
* 生成互卦
|
|
238
|
+
* Generate mutual hexagram from a hexagram
|
|
239
|
+
* 互卦:取原卦的 3-5 爻为上卦,2-4 爻为下卦
|
|
240
|
+
* @param hexagram - 原卦
|
|
241
|
+
* @returns 互卦
|
|
242
|
+
*/
|
|
243
|
+
declare function generateMutualHexagram(hexagram: Hexagram): Hexagram;
|
|
244
|
+
/**
|
|
245
|
+
* 判断是否为八纯卦
|
|
246
|
+
* Check if hexagram is pure (upper = lower)
|
|
247
|
+
* @param hexagram - 卦象
|
|
248
|
+
* @returns 是否为八纯卦
|
|
249
|
+
*/
|
|
250
|
+
declare function isPureHexagram(hexagram: Hexagram): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* 判断是否为同位异性卦
|
|
253
|
+
* Check if hexagram is an opposite-nature hexagram
|
|
254
|
+
* @param hexagram - 卦象
|
|
255
|
+
* @returns 是否为同位异性卦
|
|
256
|
+
*/
|
|
257
|
+
declare function isOppositeHexagram(hexagram: Hexagram): boolean;
|
|
258
|
+
/**
|
|
259
|
+
* 归藏算法计算中宫
|
|
260
|
+
* Guicang algorithm for center palace calculation
|
|
261
|
+
* 同性为阴,异性为阳
|
|
262
|
+
* @param upper - 上卦
|
|
263
|
+
* @param lower - 下卦
|
|
264
|
+
* @returns 归藏结果卦
|
|
265
|
+
*/
|
|
266
|
+
declare function guiCangAlgorithm(upper: Trigram, lower: Trigram): Trigram;
|
|
267
|
+
/**
|
|
268
|
+
* 计算中宫
|
|
269
|
+
* Calculate center palace trigram
|
|
270
|
+
* @param baseHexagram - 本卦
|
|
271
|
+
* @param changedHexagram - 变卦
|
|
272
|
+
* @returns 中宫八卦
|
|
273
|
+
*/
|
|
274
|
+
declare function calculateCenterPalace(baseHexagram: Hexagram, changedHexagram: Hexagram): Trigram;
|
|
275
|
+
/**
|
|
276
|
+
* 装天盘
|
|
277
|
+
* Build sky palace board
|
|
278
|
+
* @param baseHexagram - 本卦
|
|
279
|
+
* @param changedHexagram - 变卦
|
|
280
|
+
* @param baseMutualHexagram - 本卦互卦
|
|
281
|
+
* @param changedMutualHexagram - 变卦互卦
|
|
282
|
+
* @param centerTrigram - 中宫卦
|
|
283
|
+
* @returns 九宫天盘
|
|
284
|
+
*/
|
|
285
|
+
declare function buildSkyBoard(baseHexagram: Hexagram, changedHexagram: Hexagram, baseMutualHexagram: Hexagram, changedMutualHexagram: Hexagram, centerTrigram: Trigram): NinePalaceBoard;
|
|
286
|
+
/**
|
|
287
|
+
* 计算四象
|
|
288
|
+
* Calculate four images
|
|
289
|
+
* @param skyTrigram - 天盘卦
|
|
290
|
+
* @param earthTrigram - 地盘卦
|
|
291
|
+
* @returns 四象类型
|
|
292
|
+
*/
|
|
293
|
+
declare function calculateFourImages(skyTrigram: Trigram, earthTrigram: Trigram): FourImages;
|
|
294
|
+
/**
|
|
295
|
+
* 计算配对结果
|
|
296
|
+
* Calculate matching result
|
|
297
|
+
* @param skyTrigram - 天盘卦
|
|
298
|
+
* @param earthTrigram - 地盘卦
|
|
299
|
+
* @returns 配对结果
|
|
300
|
+
*/
|
|
301
|
+
declare function calculateMatchResult(skyTrigram: Trigram, earthTrigram: Trigram): MatchResult;
|
|
302
|
+
/**
|
|
303
|
+
* 生成吉凶描述
|
|
304
|
+
* Generate fortune description
|
|
305
|
+
* @param fourImage - 四象
|
|
306
|
+
* @param matchResult - 配对结果
|
|
307
|
+
* @returns 吉凶描述
|
|
308
|
+
*/
|
|
309
|
+
declare function generateFortuneDescription(fourImage: FourImages, matchResult: MatchResult): string;
|
|
310
|
+
/**
|
|
311
|
+
* 分析单宫
|
|
312
|
+
* Analyze single palace
|
|
313
|
+
* @param palace - 宫位
|
|
314
|
+
* @param skyTrigram - 天盘卦
|
|
315
|
+
* @returns 宫位分析结果
|
|
316
|
+
*/
|
|
317
|
+
declare function analyzePalace(palace: Palace, skyTrigram: Trigram): PalaceAnalysis;
|
|
318
|
+
/**
|
|
319
|
+
* 获取八卦的中文名称
|
|
320
|
+
* Get Chinese name of trigram
|
|
321
|
+
* @param trigram - 八卦
|
|
322
|
+
* @returns 中文名称
|
|
323
|
+
*/
|
|
324
|
+
declare function getTrigramChineseName(trigram: Trigram): string;
|
|
325
|
+
/**
|
|
326
|
+
* 获取宫位的中文名称
|
|
327
|
+
* Get Chinese name of palace
|
|
328
|
+
* @param palace - 宫位
|
|
329
|
+
* @returns 中文名称
|
|
330
|
+
*/
|
|
331
|
+
declare function getPalaceChineseName(palace: Palace): string;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* 小成图排盘输入参数
|
|
335
|
+
*/
|
|
336
|
+
interface XiaoChengTuInput {
|
|
337
|
+
/** 本卦 */
|
|
338
|
+
baseHexagram: Hexagram;
|
|
339
|
+
/** 变卦 */
|
|
340
|
+
changedHexagram: Hexagram;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* 数字起卦输入参数
|
|
344
|
+
*/
|
|
345
|
+
interface NumberDivinationInput {
|
|
346
|
+
/** 本卦上卦数字 */
|
|
347
|
+
baseUpper: number;
|
|
348
|
+
/** 本卦下卦数字 */
|
|
349
|
+
baseLower: number;
|
|
350
|
+
/** 变卦上卦数字 */
|
|
351
|
+
changedUpper: number;
|
|
352
|
+
/** 变卦下卦数字 */
|
|
353
|
+
changedLower: number;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* 小成图排盘主类
|
|
357
|
+
* XiaoChengTu main class
|
|
358
|
+
*/
|
|
359
|
+
declare class XiaoChengTu {
|
|
360
|
+
private baseHexagram;
|
|
361
|
+
private changedHexagram;
|
|
362
|
+
private baseMutualHexagram;
|
|
363
|
+
private changedMutualHexagram;
|
|
364
|
+
private centerTrigram;
|
|
365
|
+
private result;
|
|
366
|
+
/**
|
|
367
|
+
* 使用卦象初始化
|
|
368
|
+
* @param input - 本卦和变卦
|
|
369
|
+
*/
|
|
370
|
+
constructor(input: XiaoChengTuInput);
|
|
371
|
+
/**
|
|
372
|
+
* 从数字创建小成图实例
|
|
373
|
+
* Create XiaoChengTu instance from numbers
|
|
374
|
+
* @param input - 数字起卦参数
|
|
375
|
+
* @returns XiaoChengTu 实例
|
|
376
|
+
*/
|
|
377
|
+
static fromNumbers(input: NumberDivinationInput): XiaoChengTu;
|
|
378
|
+
/**
|
|
379
|
+
* 随机起卦
|
|
380
|
+
* Generate random divination
|
|
381
|
+
* @returns XiaoChengTu 实例
|
|
382
|
+
*/
|
|
383
|
+
static random(): XiaoChengTu;
|
|
384
|
+
/**
|
|
385
|
+
* 时间起卦
|
|
386
|
+
* Generate divination from current time
|
|
387
|
+
* @param date - 可选,指定时间。默认使用当前时间
|
|
388
|
+
* @returns XiaoChengTu 实例
|
|
389
|
+
*/
|
|
390
|
+
static fromTime(date?: Date): XiaoChengTu;
|
|
391
|
+
/**
|
|
392
|
+
* 执行排盘
|
|
393
|
+
* Execute divination and generate result
|
|
394
|
+
* @returns 排盘结果
|
|
395
|
+
*/
|
|
396
|
+
divine(): XiaoChengTuResult;
|
|
397
|
+
/**
|
|
398
|
+
* 获取指定宫位的分析结果
|
|
399
|
+
* Get analysis result for specific palace
|
|
400
|
+
* @param palace - 宫位
|
|
401
|
+
* @returns 宫位分析结果
|
|
402
|
+
*/
|
|
403
|
+
getPalaceAnalysis(palace: Palace): PalaceAnalysis | undefined;
|
|
404
|
+
/**
|
|
405
|
+
* 输出盘面字符串(用于调试)
|
|
406
|
+
* Output board as string (for debugging)
|
|
407
|
+
* @returns 盘面字符串
|
|
408
|
+
*/
|
|
409
|
+
toString(): string;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export { BINARY_TO_TRIGRAM, DynamicProperty, FourImages, type Hexagram, MatchResult, NUMBER_TO_TRIGRAM, type NinePalaceBoard, type NumberDivinationInput, OPPOSITE_HEXAGRAMS, PALACE_TO_EARTH_TRIGRAM, Palace, type PalaceAnalysis, TRIGRAM_BINARY_CORRECT, TRIGRAM_PROPERTIES, Trigram, type TrigramProperties, WuXing, XiaoChengTu, type XiaoChengTuInput, type XiaoChengTuResult, YinYang, analyzePalace, buildSkyBoard, calculateCenterPalace, calculateFourImages, calculateMatchResult, generateFortuneDescription, generateMutualHexagram, getPalaceChineseName, getTrigramChineseName, guiCangAlgorithm, isOppositeHexagram, isPureHexagram, numberToTrigram };
|