Skip to content

Commit

Permalink
🪄 add horoscope stars for monthlydailyhourly. #210
Browse files Browse the repository at this point in the history
  • Loading branch information
SylarLong committed Nov 9, 2024
1 parent 56cd86d commit bf41a18
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 24 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
- 🛠️ 修复(fix)
- 🧹 琐事(Chore)

## v2.4.4

- 🪄 功能(feature)

🇨🇳

- 增加流月、流日、流时的流耀 #210

🇺🇸

- add horoscope stars for `monthly``daily``hourly`. #210

## v2.4.3

- 🛠️ 修复(fix)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iztro",
"version": "2.4.3",
"version": "2.4.4",
"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",
Expand Down
3 changes: 3 additions & 0 deletions src/astro/FunctionalAstrolabe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const _getHoroscopeBySolarDate = (
earthlyBranch: t(kot(monthly[1], 'Earthly')),
palaceNames: getPalaceNames(monthlyIndex),
mutagen: getMutagensByHeavenlyStem(monthly[0]),
stars: getHoroscopeStar(monthly[0], monthly[1], 'monthly'),
},
daily: {
index: dailyIndex,
Expand All @@ -178,6 +179,7 @@ const _getHoroscopeBySolarDate = (
earthlyBranch: t(kot(daily[1], 'Earthly')),
palaceNames: getPalaceNames(dailyIndex),
mutagen: getMutagensByHeavenlyStem(daily[0]),
stars: getHoroscopeStar(daily[0], daily[1], 'daily'),
},
hourly: {
index: hourlyIndex,
Expand All @@ -186,6 +188,7 @@ const _getHoroscopeBySolarDate = (
earthlyBranch: t(kot(hourly[1], 'Earthly')),
palaceNames: getPalaceNames(hourlyIndex),
mutagen: getMutagensByHeavenlyStem(hourly[0]),
stars: getHoroscopeStar(hourly[0], hourly[1], 'hourly'),
},
};

Expand Down
118 changes: 95 additions & 23 deletions src/star/horoscopeStar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { initStars } from '.';
import { t, HeavenlyStemName, EarthlyBranchName } from '../i18n';
import { Scope } from '../data/types';
import { t, HeavenlyStemName, EarthlyBranchName, StarName } from '../i18n';
import FunctionalStar from './FunctionalStar';
import {
getChangQuIndexByHeavenlyStem,
Expand All @@ -20,40 +21,111 @@ import {
export const getHoroscopeStar = (
heavenlyStem: HeavenlyStemName,
earthlyBranch: EarthlyBranchName,
scope: 'decadal' | 'yearly',
scope: Scope,
): FunctionalStar[][] => {
const { kuiIndex, yueIndex } = getKuiYueIndex(heavenlyStem);
const { changIndex, quIndex } = getChangQuIndexByHeavenlyStem(heavenlyStem);
const { luIndex, yangIndex, tuoIndex, maIndex } = getLuYangTuoMaIndex(heavenlyStem, earthlyBranch);
const { hongluanIndex, tianxiIndex } = getLuanXiIndex(earthlyBranch);
const stars = initStars();

const trans: Record<
Scope,
Record<
'tiankui' | 'tianyue' | 'wenchang' | 'wenqu' | 'lucun' | 'qingyang' | 'tuoluo' | 'tianma' | 'hongluan' | 'tianxi',
StarName
>
> = {
origin: {
tiankui: t('tiankuiMin'),
tianyue: t('tianyueMin'),
wenchang: t('wenchangMin'),
wenqu: t('wenquMin'),
lucun: t('lucunMin'),
qingyang: t('qingyangMin'),
tuoluo: t('tuoluoMin'),
tianma: t('tianmaMin'),
hongluan: t('hongluanMin'),
tianxi: t('tianxi'),
},
decadal: {
tiankui: t('yunkui'),
tianyue: t('yunyue'),
wenchang: t('yunchang'),
wenqu: t('yunqu'),
lucun: t('yunlu'),
qingyang: t('yunyang'),
tuoluo: t('yuntuo'),
tianma: t('yunma'),
hongluan: t('yunluan'),
tianxi: t('yunxi'),
},
yearly: {
tiankui: t('liukui'),
tianyue: t('liuyue'),
wenchang: t('liuchang'),
wenqu: t('liuqu'),
lucun: t('liulu'),
qingyang: t('liuyang'),
tuoluo: t('liutuo'),
tianma: t('liuma'),
hongluan: t('liuluan'),
tianxi: t('liuxi'),
},
monthly: {
tiankui: t('yuekui'),
tianyue: t('yueyue'),
wenchang: t('yuechang'),
wenqu: t('yuequ'),
lucun: t('yuelu'),
qingyang: t('yueyang'),
tuoluo: t('yuetuo'),
tianma: t('yuema'),
hongluan: t('yueluan'),
tianxi: t('yuexi'),
},
daily: {
tiankui: t('rikui'),
tianyue: t('riyue'),
wenchang: t('richang'),
wenqu: t('riqu'),
lucun: t('rilu'),
qingyang: t('riyang'),
tuoluo: t('rituo'),
tianma: t('rima'),
hongluan: t('riluan'),
tianxi: t('rixi'),
},
hourly: {
tiankui: t('shikui'),
tianyue: t('shiyue'),
wenchang: t('shichang'),
wenqu: t('shiqu'),
lucun: t('shilu'),
qingyang: t('shiyang'),
tuoluo: t('shituo'),
tianma: t('shima'),
hongluan: t('shiluan'),
tianxi: t('shixi'),
},
};

if (scope === 'yearly') {
const nianjieIndex = getNianjieIndex(earthlyBranch);

stars[nianjieIndex].push(new FunctionalStar({ name: t('nianjie'), type: 'helper', scope: 'yearly' }));
stars[kuiIndex].push(new FunctionalStar({ name: t('liukui'), type: 'soft', scope }));
stars[yueIndex].push(new FunctionalStar({ name: t('liuyue'), type: 'soft', scope }));
stars[changIndex].push(new FunctionalStar({ name: t('liuchang'), type: 'soft', scope }));
stars[quIndex].push(new FunctionalStar({ name: t('liuqu'), type: 'soft', scope }));
stars[luIndex].push(new FunctionalStar({ name: t('liulu'), type: 'lucun', scope }));
stars[yangIndex].push(new FunctionalStar({ name: t('liuyang'), type: 'tough', scope }));
stars[tuoIndex].push(new FunctionalStar({ name: t('liutuo'), type: 'tough', scope }));
stars[maIndex].push(new FunctionalStar({ name: t('liuma'), type: 'tianma', scope }));
stars[hongluanIndex].push(new FunctionalStar({ name: t('liuluan'), type: 'flower', scope }));
stars[tianxiIndex].push(new FunctionalStar({ name: t('liuxi'), type: 'flower', scope }));
} else {
stars[kuiIndex].push(new FunctionalStar({ name: t('yunkui'), type: 'soft', scope }));
stars[yueIndex].push(new FunctionalStar({ name: t('yunyue'), type: 'soft', scope }));
stars[changIndex].push(new FunctionalStar({ name: t('yunchang'), type: 'soft', scope }));
stars[quIndex].push(new FunctionalStar({ name: t('yunqu'), type: 'soft', scope }));
stars[luIndex].push(new FunctionalStar({ name: t('yunlu'), type: 'lucun', scope }));
stars[yangIndex].push(new FunctionalStar({ name: t('yunyang'), type: 'tough', scope }));
stars[tuoIndex].push(new FunctionalStar({ name: t('yuntuo'), type: 'tough', scope }));
stars[maIndex].push(new FunctionalStar({ name: t('yunma'), type: 'tianma', scope }));
stars[hongluanIndex].push(new FunctionalStar({ name: t('yunluan'), type: 'flower', scope }));
stars[tianxiIndex].push(new FunctionalStar({ name: t('yunxi'), type: 'flower', scope }));
}

stars[kuiIndex].push(new FunctionalStar({ name: trans[scope].tiankui, type: 'soft', scope }));
stars[yueIndex].push(new FunctionalStar({ name: trans[scope].tianyue, type: 'soft', scope }));
stars[changIndex].push(new FunctionalStar({ name: trans[scope].wenchang, type: 'soft', scope }));
stars[quIndex].push(new FunctionalStar({ name: trans[scope].wenqu, type: 'soft', scope }));
stars[luIndex].push(new FunctionalStar({ name: trans[scope].lucun, type: 'lucun', scope }));
stars[yangIndex].push(new FunctionalStar({ name: trans[scope].qingyang, type: 'tough', scope }));
stars[tuoIndex].push(new FunctionalStar({ name: trans[scope].tuoluo, type: 'tough', scope }));
stars[maIndex].push(new FunctionalStar({ name: trans[scope].tianma, type: 'tianma', scope }));
stars[hongluanIndex].push(new FunctionalStar({ name: trans[scope].hongluan, type: 'flower', scope }));
stars[tianxiIndex].push(new FunctionalStar({ name: trans[scope].tianxi, type: 'flower', scope }));

return stars;
};

0 comments on commit bf41a18

Please sign in to comment.