From 51b9d3129ea5bade0abe0ec57236c7127cb15570 Mon Sep 17 00:00:00 2001 From: Sylar Date: Tue, 19 Dec 2023 23:19:14 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=84=20add=2012=20palaces=20for=20age?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ package.json | 2 +- src/astro/FunctionalAstrolabe.ts | 12 +++++++++++- src/data/types/astro.ts | 7 +------ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f7d5006..77088ab7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,10 +14,12 @@ 🇨🇳 - 新增童限指示 #154 + - 新增小限12宫 #157 🇺🇸 - add childhood scope indicator #154 + - add 12 palaces for age #157 ## v2.1.0 diff --git a/package.json b/package.json index 3f4216be..621ad549 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iztro", - "version": "2.1.0", + "version": "2.2.0", "description": "轻量级紫微斗数星盘生成库。可以通过出生年月日获取到紫微斗数星盘信息、生肖、星座等信息。A lightweight kit to astrolabe generator of The Purple Star Astrology (Zi Wei Dou Shu). The Purple Star Astrology(Zi Wei Dou Shu) is a Chinese ancient astrology. You're able to get your horoscope and personality from the astrolabe", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/astro/FunctionalAstrolabe.ts b/src/astro/FunctionalAstrolabe.ts index 2b75007f..32baefb0 100644 --- a/src/astro/FunctionalAstrolabe.ts +++ b/src/astro/FunctionalAstrolabe.ts @@ -68,6 +68,10 @@ const _getHoroscopeBySolarDate = ( let dailyIndex = -1; // 流时索引 let hourlyIndex = -1; + // 小限天干 + let heavenlyStemOfAge: HeavenlyStemName = 'jia'; + // 小限地支 + let earthlyBranchOfAge: EarthlyBranchName = 'zi'; // 查询大限索引 $.palaces.some(({ decadal }, index) => { @@ -98,9 +102,11 @@ const _getHoroscopeBySolarDate = ( } // 查询小限索引 - $.palaces.some(({ ages }, index) => { + $.palaces.some(({ ages, heavenlyStem, earthlyBranch }, index) => { if (ages.includes(nominalAge)) { ageIndex = index; + heavenlyStemOfAge = heavenlyStem; + earthlyBranchOfAge = earthlyBranch; return true; } @@ -136,6 +142,10 @@ const _getHoroscopeBySolarDate = ( index: ageIndex, nominalAge, name: t('turn'), + heavenlyStem: heavenlyStemOfAge, + earthlyBranch: earthlyBranchOfAge, + palaceNames: getPalaceNames(ageIndex), + mutagen: getMutagensByHeavenlyStem(heavenlyStemOfAge), }, yearly: { index: yearlyIndex, diff --git a/src/data/types/astro.ts b/src/data/types/astro.ts index 5874f837..6e862e2d 100644 --- a/src/data/types/astro.ts +++ b/src/data/types/astro.ts @@ -70,16 +70,11 @@ export type Horoscope = { * 小限 * * @property - * - index 小限所在宫位索引 * - nominalAge 虚岁 */ - age: { - /** 小限所在宫位索引 */ - index: number; + age: HoroscopeItem & { /** 虚岁 */ nominalAge: number; - /** 名称 */ - name: string; }; /** 流年 */ yearly: HoroscopeItem & { yearlyDecStar: { jiangqian12: StarName[]; suiqian12: StarName[] } };