Skip to content

Commit 90f3697

Browse files
committed
🛠️ 修复地盘、人盘一些星耀的错误
1 parent 67ba955 commit 90f3697

File tree

5 files changed

+71
-7
lines changed

5 files changed

+71
-7
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
- 🛠️ 修复(fix)
88
- 🧹 琐事(Chore)
99

10+
## v2.5.7
11+
12+
- 🛠️ 修复(fix)
13+
14+
- v2.5.6版本修复天使星位置错误导致天使重复。
15+
- 地盘、人盘中十二长生没有传入性别导致顺序错误。
16+
1017
## v2.5.6
1118

1219
- 🛠️ 修复(fix)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iztro",
3-
"version": "2.5.6",
3+
"version": "2.5.7",
44
"description": "轻量级紫微斗数星盘生成库。可以通过出生年月日获取到紫微斗数星盘信息、生肖、星座等信息。This is a lightweight kit for generating astrolabes for Zi Wei Dou Shu (The Purple Star Astrology), an ancient Chinese astrology. It allows you to obtain your horoscope and personality analysis.",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/__tests__/astro/astro.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,36 @@ describe('Astrolabe', () => {
993993
expect(soulPalace?.decadal).toStrictEqual({ range: [6, 15], heavenlyStem: '丁', earthlyBranch: '卯' });
994994
});
995995

996+
test('withOptions() with earth type', () => {
997+
astro.config({ algorithm: 'zhongzhou' });
998+
999+
const result = withOptions({
1000+
dateStr: '1999-05-03',
1001+
type: 'solar',
1002+
timeIndex: 8,
1003+
gender: 'female',
1004+
astroType: 'earth',
1005+
});
1006+
1007+
expect(result.palaces[0].changsheng12).toEqual('病');
1008+
expect(result.palaces[1].changsheng12).toEqual('死');
1009+
});
1010+
1011+
test('withOptions() with earth type', () => {
1012+
astro.config({ algorithm: 'zhongzhou' });
1013+
1014+
const result = withOptions({
1015+
dateStr: '1999-05-03',
1016+
type: 'solar',
1017+
timeIndex: 8,
1018+
gender: 'male',
1019+
astroType: 'earth',
1020+
});
1021+
1022+
expect(result.palaces[0].changsheng12).toEqual('病');
1023+
expect(result.palaces[1].changsheng12).toEqual('衰');
1024+
});
1025+
9961026
test('withOptions() with human type', () => {
9971027
astro.config({ algorithm: 'zhongzhou' });
9981028

src/__tests__/star/star.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,32 @@ describe('star/index', () => {
242242
'胎',
243243
'养',
244244
]);
245+
expect(
246+
getchangsheng12({
247+
solarDate: '1999-5-3',
248+
timeIndex: 8,
249+
gender: '女',
250+
fixLeap: true,
251+
}),
252+
).toStrictEqual(['绝', '胎', '养', '长生', '沐浴', '冠带', '临官', '帝旺', '衰', '病', '死', '墓']);
253+
expect(
254+
getchangsheng12({
255+
solarDate: '1999-5-3',
256+
timeIndex: 8,
257+
gender: '男',
258+
fixLeap: true,
259+
from: { heavenlyStem: '丙', earthlyBranch: '子' },
260+
}),
261+
).toStrictEqual(['病', '衰', '帝旺', '临官', '冠带', '沐浴', '长生', '养', '胎', '绝', '墓', '死']);
262+
expect(
263+
getchangsheng12({
264+
solarDate: '1999-5-3',
265+
timeIndex: 8,
266+
gender: '女',
267+
fixLeap: true,
268+
from: { heavenlyStem: '丙', earthlyBranch: '子' },
269+
}),
270+
).toStrictEqual(['病', '死', '墓', '绝', '胎', '养', '长生', '沐浴', '冠带', '临官', '帝旺', '衰']);
245271
});
246272

247273
test('getchangsheng12() vi-VN', () => {

src/astro/astro.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,13 @@ export function rearrangeAstrolable<T extends FunctionalAstrolabe>({
355355
const fiveElementsClass = getFiveElementsClass(from.heavenlyStem, from.earthlyBranch);
356356
const palaceNames = getPalaceNames(soulIndex);
357357
const majorStars = getMajorStar({ solarDate: astrolable.solarDate, timeIndex, fixLeap, from });
358-
const changsheng12 = getchangsheng12({ solarDate: astrolable.solarDate, timeIndex, fixLeap, from });
358+
const changsheng12 = getchangsheng12({
359+
solarDate: astrolable.solarDate,
360+
gender: astrolable.gender as GenderName,
361+
timeIndex,
362+
fixLeap,
363+
from,
364+
});
359365
const { decadals, ages } = getHoroscope({
360366
solarDate: astrolable.solarDate,
361367
timeIndex,
@@ -414,11 +420,6 @@ export function rearrangeAstrolable<T extends FunctionalAstrolabe>({
414420
palace.adjectiveStars.push(new FunctionalStar({ name: t('tiancai'), type: 'adjective', scope: 'origin' }));
415421
}
416422

417-
if (_tianshiIdx === -1 && tianshiIndex === i) {
418-
// 当天使应该在该宫位却不在,加之
419-
palace.adjectiveStars.push(new FunctionalStar({ name: t('tianshi'), type: 'adjective', scope: 'origin' }));
420-
}
421-
422423
palace.name = palaceNames[i];
423424
palace.majorStars = majorStars[i];
424425
palace.changsheng12 = changsheng12[i];

0 commit comments

Comments
 (0)