liuyao 0.1.1 → 0.2.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/dist/index.d.ts CHANGED
@@ -226,7 +226,7 @@ declare class Yao {
226
226
  }
227
227
 
228
228
  type LiuYao = [Yao, Yao, Yao, Yao, Yao, Yao];
229
- declare const HexagramYaoIndex: readonly ["初爻", "二爻", "三爻", "四爻", "五爻", "上爻"];
229
+ declare const HexagramYaoOrder: readonly ["初爻", "二爻", "三爻", "四爻", "五爻", "上爻"];
230
230
  /**
231
231
  * Hexagram class represents a hexagram, which consists of 6 Yao.
232
232
  * - Each Yao can be either yin or yang, and can be changing or not.
@@ -292,11 +292,32 @@ declare class Hexagram {
292
292
  * - e.g.:“本卦乾为天,变卦坤为地,动爻:初爻、三爻”
293
293
  */
294
294
  toDescription(): string;
295
- toDescriptionEn(): string;
295
+ /**
296
+ * This output is meant for AI skills.
297
+ */
298
+ toAIReadable(): {
299
+ 本卦: HexagramAIReadable<'本卦'>;
300
+ 变卦: HexagramAIReadable<'变卦'> | null;
301
+ };
296
302
  clone(): Hexagram;
297
303
  toString(): string;
298
- [Symbol.toPrimitive](hint: string): string;
304
+ [Symbol.toPrimitive](): string;
305
+ }
306
+ interface YaoInfo {
307
+ 爻象: string;
308
+ 类型: '世' | '应' | null;
309
+ 六亲五行: string;
310
+ }
311
+ interface HexagramAIReadable<T extends '本卦' | '变卦'> {
312
+ 初爻: YaoInfo;
313
+ 二爻: YaoInfo;
314
+ 三爻: YaoInfo;
315
+ 四爻: YaoInfo;
316
+ 五爻: YaoInfo;
317
+ 上爻: YaoInfo;
318
+ 卦名: string;
319
+ 变爻?: string[];
299
320
  }
300
321
 
301
- export { Hexagram, HexagramInfoTable, HexagramYaoIndex, PalaceIndexTable, SixGodTable, TrigramInfoTable, Yao };
322
+ export { Hexagram, HexagramInfoTable, HexagramYaoOrder, PalaceIndexTable, SixGodTable, TrigramInfoTable, Yao };
302
323
  export type { HexagramInfo, SetupGramInfo, SixGod, SixGodInfo, TrigramInfo };
package/dist/index.mjs CHANGED
@@ -1708,14 +1708,88 @@ class l {
1708
1708
  return new l(this.yaos.map(n => n.toChanged()));
1709
1709
  }
1710
1710
  toDescription() {
1711
- const n = [ `本卦${this.info.id}` ], i = this.toChanged();
1712
- return i ? (n.push(`变卦${i.info.id}`), n.push(`动爻:${this.yaos.map((n, i) => n.isDynamic ? `${r[i]}` : null).filter(n => null !== n).join("、")}`)) : n.push("无动爻"),
1713
- n.join(",");
1711
+ const n = this.info.setupInfo.findIndex(n => "世" === n.hostGuest), i = this.info.setupInfo.findIndex(n => "应" === n.hostGuest), e = [ `本卦${this.info.id}`, `世爻为${r[n]}`, `应爻为${r[i]}` ], s = this.toChanged();
1712
+ if (s) {
1713
+ e.push(`${this.yaos.map((n, i) => n.isDynamic ? `${r[i]}` : null).filter(n => null !== n).join("、")}是动爻`),
1714
+ e.push(`变卦为${s.info.id}`);
1715
+ const n = s.info.setupInfo.findIndex(n => "世" === n.hostGuest);
1716
+ this.yaos[n].isDynamic ? e.push(`变卦世爻为${r[n]}`) : e.push("未变出新的世爻");
1717
+ const i = s.info.setupInfo.findIndex(n => "应" === n.hostGuest);
1718
+ this.yaos[i].isDynamic ? e.push(`变卦应爻为${r[i]}`) : e.push("未变出新的应爻");
1719
+ } else e.push("无动爻");
1720
+ return e.join(",");
1714
1721
  }
1715
- toDescriptionEn() {
1716
- const n = [ `Original Hexagram ${this.info.id}` ], i = this.toChanged();
1717
- return i ? (n.push(`Changed Hexagram ${i.info.id}`), n.push(`Dynamic Yaos: ${this.yaos.map((n, i) => n.isDynamic ? `${r[i]}` : null).filter(n => null !== n).join(", ")}`)) : n.push("No dynamic Yao"),
1718
- n.join(", ");
1722
+ toAIReadable() {
1723
+ const n = this.info.setupInfo, i = this.toChanged(), e = i?.info.setupInfo;
1724
+ return {
1725
+ "本卦": {
1726
+ "初爻": {
1727
+ "爻象": this.yaos[0].name,
1728
+ "类型": n[0].hostGuest || null,
1729
+ "六亲五行": n[0].kin
1730
+ },
1731
+ "二爻": {
1732
+ "爻象": this.yaos[1].name,
1733
+ "类型": n[1].hostGuest || null,
1734
+ "六亲五行": n[1].kin
1735
+ },
1736
+ "三爻": {
1737
+ "爻象": this.yaos[2].name,
1738
+ "类型": n[2].hostGuest || null,
1739
+ "六亲五行": n[2].kin
1740
+ },
1741
+ "四爻": {
1742
+ "爻象": this.yaos[3].name,
1743
+ "类型": n[3].hostGuest || null,
1744
+ "六亲五行": n[3].kin
1745
+ },
1746
+ "五爻": {
1747
+ "爻象": this.yaos[4].name,
1748
+ "类型": n[4].hostGuest || null,
1749
+ "六亲五行": n[4].kin
1750
+ },
1751
+ "上爻": {
1752
+ "爻象": this.yaos[5].name,
1753
+ "类型": n[5].hostGuest || null,
1754
+ "六亲五行": n[5].kin
1755
+ },
1756
+ "卦名": this.info.id,
1757
+ "变爻": this.isDynamic ? this.yaos.map((n, i) => n.isDynamic ? r[i] : null).filter(n => null !== n) : void 0
1758
+ },
1759
+ "变卦": e ? {
1760
+ "初爻": {
1761
+ "爻象": i.yaos[0].name,
1762
+ "类型": e[0].hostGuest || null,
1763
+ "六亲五行": e[0].kin
1764
+ },
1765
+ "二爻": {
1766
+ "爻象": i.yaos[1].name,
1767
+ "类型": e[1].hostGuest || null,
1768
+ "六亲五行": e[1].kin
1769
+ },
1770
+ "三爻": {
1771
+ "爻象": i.yaos[2].name,
1772
+ "类型": e[2].hostGuest || null,
1773
+ "六亲五行": e[2].kin
1774
+ },
1775
+ "四爻": {
1776
+ "爻象": i.yaos[3].name,
1777
+ "类型": e[3].hostGuest || null,
1778
+ "六亲五行": e[3].kin
1779
+ },
1780
+ "五爻": {
1781
+ "爻象": i.yaos[4].name,
1782
+ "类型": e[4].hostGuest || null,
1783
+ "六亲五行": e[4].kin
1784
+ },
1785
+ "上爻": {
1786
+ "爻象": i.yaos[5].name,
1787
+ "类型": e[5].hostGuest || null,
1788
+ "六亲五行": e[5].kin
1789
+ },
1790
+ "卦名": i.info.id
1791
+ } : null
1792
+ };
1719
1793
  }
1720
1794
  clone() {
1721
1795
  return new l(this.yaos);
@@ -1723,9 +1797,9 @@ class l {
1723
1797
  toString() {
1724
1798
  return this.info.id;
1725
1799
  }
1726
- [Symbol.toPrimitive](n) {
1800
+ [Symbol.toPrimitive]() {
1727
1801
  return this.info.id;
1728
1802
  }
1729
1803
  }
1730
1804
 
1731
- export { l as Hexagram, i as HexagramInfoTable, r as HexagramYaoIndex, n as PalaceIndexTable, s as SixGodTable, e as TrigramInfoTable, h as Yao };
1805
+ export { l as Hexagram, i as HexagramInfoTable, r as HexagramYaoOrder, n as PalaceIndexTable, s as SixGodTable, e as TrigramInfoTable, h as Yao };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "liuyao",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "author": {
5
5
  "name": "Kasukabe Tsumugi",
6
6
  "email": "futami16237@gmail.com"
@@ -38,4 +38,4 @@
38
38
  "url": "https://github.com/baendlorel/kt-packages/issues"
39
39
  },
40
40
  "homepage": "https://github.com/baendlorel/kt-packages/tree/main/packages/liuyao#readme"
41
- }
41
+ }