Skip to content

Commit

Permalink
Merge pull request #93 from SylarLong/feat-92
Browse files Browse the repository at this point in the history
🪄 add empty palace verification #92
  • Loading branch information
SylarLong committed Nov 10, 2023
2 parents b884c4b + 259fb5e commit 9155144
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 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.0.6

- 🪄 功能(feature)

🇨🇳

- 新增空宫判断 #92

🇺🇸

- add empty palace verification #92

## v2.0.5

- ✨ 改进(enhancement)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
- 判断指定运限宫位内是否存在四化
- 判断指定运限三方四正内是否存在某些星耀
- 判断指定运限三方四正内是否存在四化
- 判断指定宫位是否是空宫

- 其他

Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iztro",
"version": "2.0.5",
"version": "2.0.6",
"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 All @@ -14,11 +14,10 @@
"lint": "eslint . --ext .ts",
"test": "jest --config jestconfig.json --coverage",
"prepare": "yarn build",
"prepublishOnly": "npm test && yarn lint",
"prepublishOnly": "npm test && yarn lint && yarn build:umd",
"preversion": "yarn lint",
"version": "yarn format && git add -A src",
"postversion": "git push && git push --tags",
"pub": "yarn build:umd && yarn publish"
"postversion": "git push && git push --tags"
},
"files": [
"lib/**/*",
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/astro/astro.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ describe('Astrolabe', () => {
expect(result).toHaveProperty('body', '文昌');
expect(result).toHaveProperty('fiveElementsClass', '木三局');

expect(result.palace('父母')?.isEmpty()).toBeTruthy();
expect(result.palace('父母')?.isEmpty(['陀罗'])).toBeFalsy();
expect(result.palace('命宫')?.isEmpty()).toBeFalsy();
expect(result.palace('父母')?.isEmpty(['文昌', '文曲'])).toBeTruthy();

const horoscope = result.horoscope('2023-8-19 3:12');

expect(horoscope).toHaveProperty('solarDate', '2023-8-19');
Expand Down
25 changes: 25 additions & 0 deletions src/astro/FunctionalPalace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ export interface IFunctionalPalace extends Palace {
* @returns true | false
*/
notHaveMutagen: (mutagen: Mutagen) => boolean;

/**
* 判断一个宫位是否为空宫(没有主星),
* 有些派别在宫位内有某些星耀的情况下,
* 是不会将该宫位判断为空宫的。
* 所以加入一个参数来传入星耀。
*
* @version v2.0.6
*
* @param excludeStars 星耀名称数组
*
* @returns {boolean} true | false
*/
isEmpty: (excludeStars?: StarName[]) => boolean;
}

/**
Expand Down Expand Up @@ -104,4 +118,15 @@ export default class FunctionalPalace implements IFunctionalPalace {
hasOneOf = (stars: StarName[]): boolean => hasOneOfStars(this, stars);
hasMutagen = (mutagen: Mutagen): boolean => hasMutagenInPlace(this, mutagen);
notHaveMutagen = (mutagen: Mutagen): boolean => notHaveMutagenInPalce(this, mutagen);
isEmpty = (excludeStars?: StarName[]) => {
if (this.majorStars?.filter((star) => star.type === 'major').length) {
return false;
}

if (excludeStars?.length && this.hasOneOf(excludeStars)) {
return false;
}

return true;
};
}

0 comments on commit 9155144

Please sign in to comment.