iching-shifa 1.0.0 → 1.0.1

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.cjs CHANGED
@@ -145,9 +145,9 @@ function timeQiGua(year, month, day, hour, lunarMonth, lunarDay, yearZhi, hourZh
145
145
  const hzCode = diZhiArr.indexOf(hourZhi) + 1;
146
146
  const cm = lunarMonth;
147
147
  const cd = lunarDay;
148
- let upperNum = (yzCode + cm + cd) % 8;
148
+ let upperNum = (yzCode + cm + cd + hzCode) % 8;
149
149
  if (upperNum === 0) upperNum = 8;
150
- let lowerNum = (yzCode + cm + cd + hzCode) % 8;
150
+ let lowerNum = (yzCode + cm + cd) % 8;
151
151
  if (lowerNum === 0) lowerNum = 8;
152
152
  let dongYao = (yzCode + cm + cd + hzCode) % 6;
153
153
  if (dongYao === 0) dongYao = 6;
@@ -208,16 +208,6 @@ function getMovingYaoPositions(yaoString) {
208
208
  }
209
209
  return positions;
210
210
  }
211
- const TRIGRAM_TO_BAGUA = {
212
- "797999997779797979979777979779977777977777777799799799997999997997979799999779799979779997997977977777797777997977797999779779977797997799779797779979999799977999777799999979777999797979977797": "乾",
213
- "776796976778778978976978798976976998998796776976776998996998998796778978798798978776998996796778776978996996798776976798996778796978798796798778978776996996998776798998996778976778978976796796": "兑",
214
- "967987769989987767787767967767969789967967969789789969987789767787987969989787967769767769989769767787989767787969787787987769767969987967989967789787967769987989789769989789969987769789989969": "离",
215
- "766966788788786786786966966766988986788986986988768986966786766988968986968788968786768988988786966768788786986988968986988788768968768786968966766766966766766968766788988968966768788768986768": "震",
216
- "877877699697699879697899699677879679879897679877879877677677877699879897679699899897897899677877897677699697877897899677897899897677679679679679697899699879879697697877679697677699899697899879": "巽",
217
- "878696678696876678876878696896876896676676698898698878876898878898878878676676696678696878698698876898676698678676896878698876696696898678898698678678896678898876896696876676896698676898896896": "坎",
218
- "867689687667867689669867867867667687869689889689689869669667669869887867689687887669687669889669889869687867889669869887887667667667889889687889887869669687887667869887689889869887687867667689": "艮",
219
- "886688666686688666866668668888886868686886688868666686688888668686886866666668888686666868668886888666866866688868686868868868668666886866688686866866866668668886888888686886666688888868888688": "坤"
220
- };
221
211
  const BAGUA_XIANG = {
222
212
  "1": "天",
223
213
  "2": "澤",
@@ -228,6 +218,16 @@ const BAGUA_XIANG = {
228
218
  "7": "山",
229
219
  "8": "地"
230
220
  };
221
+ const CODE_TO_BAGUA = {
222
+ "777": "乾",
223
+ "778": "兑",
224
+ "787": "离",
225
+ "788": "震",
226
+ "877": "巽",
227
+ "878": "坎",
228
+ "887": "艮",
229
+ "888": "坤"
230
+ };
231
231
  const GUA64_ORDER = [
232
232
  "乾",
233
233
  "姤",
@@ -5417,12 +5417,12 @@ function ganZhiToWuXing(ganOrZhi) {
5417
5417
  }
5418
5418
  return wx;
5419
5419
  }
5420
- function getWuXingRelation(a, b) {
5421
- if (a === b) return "比和";
5422
- if (SHENG[b] === a) return "生我";
5423
- if (SHENG[a] === b) return "我生";
5424
- if (KE[b] === a) return "尅我";
5425
- if (KE[a] === b) return "我尅";
5420
+ function getWuXingRelation(yaoWx, gongWx) {
5421
+ if (yaoWx === gongWx) return "比和";
5422
+ if (SHENG[yaoWx] === gongWx) return "生我";
5423
+ if (SHENG[gongWx] === yaoWx) return "我生";
5424
+ if (KE[yaoWx] === gongWx) return "尅我";
5425
+ if (KE[gongWx] === yaoWx) return "我尅";
5426
5426
  return "比和";
5427
5427
  }
5428
5428
  function wuXingToLiuQin(yaoWuXing, gongWuXing) {
@@ -5548,8 +5548,8 @@ function getGuaName(yaoString) {
5548
5548
  }
5549
5549
  const lower = staticYao.slice(0, 3);
5550
5550
  const upper = staticYao.slice(3, 6);
5551
- const lowerGua = TRIGRAM_TO_BAGUA[lower];
5552
- const upperGua = TRIGRAM_TO_BAGUA[upper];
5551
+ const lowerGua = CODE_TO_BAGUA[lower];
5552
+ const upperGua = CODE_TO_BAGUA[upper];
5553
5553
  if (lowerGua && upperGua) {
5554
5554
  return findGuaByTrigrams(lowerGua, upperGua) || `${lowerGua}${upperGua}`;
5555
5555
  }
@@ -5588,8 +5588,8 @@ function decodeGua(yaoString, dayGanZhi, isZhiGua = false) {
5588
5588
  const palaceLevel = GUA_PALACE_LEVEL[guaName] || "本宮";
5589
5589
  const palaceWuXing = PALACE_WUXING[palace] || "金";
5590
5590
  const staticYao = yaoString.replace(/9/g, "7").replace(/6/g, "8");
5591
- const lowerTrigram = TRIGRAM_TO_BAGUA[staticYao.slice(0, 3)] || "乾";
5592
- const upperTrigram = TRIGRAM_TO_BAGUA[staticYao.slice(3, 6)] || "乾";
5591
+ const lowerTrigram = CODE_TO_BAGUA[staticYao.slice(0, 3)] || "乾";
5592
+ const upperTrigram = CODE_TO_BAGUA[staticYao.slice(3, 6)] || "乾";
5593
5593
  const lowerNajiaRaw = NAJIA_LOWER[lowerTrigram] || [];
5594
5594
  const upperNajiaRaw = NAJIA_UPPER[upperTrigram] || [];
5595
5595
  const parseNajia = (item) => {
@@ -5675,8 +5675,8 @@ function findFuShen(yaoList, palace, palaceWuXing) {
5675
5675
  return void 0;
5676
5676
  }
5677
5677
  const pureCode = PALACE_PURE_CODE[palace] || "777777";
5678
- const pureLowerTrigram = TRIGRAM_TO_BAGUA[pureCode.slice(0, 3)] || "乾";
5679
- const pureUpperTrigram = TRIGRAM_TO_BAGUA[pureCode.slice(3, 6)] || "乾";
5678
+ const pureLowerTrigram = CODE_TO_BAGUA[pureCode.slice(0, 3)] || "乾";
5679
+ const pureUpperTrigram = CODE_TO_BAGUA[pureCode.slice(3, 6)] || "乾";
5680
5680
  const pureLowerNajiaRaw = NAJIA_LOWER[pureLowerTrigram] || [];
5681
5681
  const pureUpperNajiaRaw = NAJIA_UPPER[pureUpperTrigram] || [];
5682
5682
  const parseNajia = (item) => {