星耀
概述
星耀是紫微鬥數裏的重要組成部分,人的個性主要收到星耀的影響。不同的星耀組合形成了不同的個性,如果妳對星耀部分感興趣,我們強烈建議妳點擊 傳送門 進行相關知識學習。本篇主要關註的是開發層面。
提示
在 iztro 裏,主星、輔星、雜耀 都被統歸到星耀係統裏,但是 48神煞 沒有被歸類到星耀,如果妳還不知道 48神煞 是什麽,歡迎點擊 傳送門 進行學習。
功能類定義
與 FunctionalAstrolabe 和 FunctionalPalace 壹樣,我們並不建議妳手動去創建壹個 FunctionalStar 對象,而是使用其他對象返回的實例。
FunctionalStar ^1.2.0
implements
IFunctionalStar extends Star接口定義
tsinterface IFunctionalStar extends Star { palace: () => IFunctionalPalace | undefined; setPalace: (p: IFunctionalPalace) => void; setAstrolabe: (a: IFunctionalAstrolabe) => void; surroundedPalaces: () => IFunctionalSurpalaces | undefined; oppositePalace: () => IFunctionalPalace | undefined; withBrightness: (brightness: Brightness | Brightness[]) => boolean; withMutagen: (mutagen: Mutagen | Mutagen[]) => boolean; }interface IFunctionalStar extends Star { palace: () => IFunctionalPalace | undefined; setPalace: (p: IFunctionalPalace) => void; setAstrolabe: (a: IFunctionalAstrolabe) => void; surroundedPalaces: () => IFunctionalSurpalaces | undefined; oppositePalace: () => IFunctionalPalace | undefined; withBrightness: (brightness: Brightness | Brightness[]) => boolean; withMutagen: (mutagen: Mutagen | Mutagen[]) => boolean; }屬性
參考 Star
方法
❗️註意
為了使
FunctionalStar類使用起來更順暢,所以引入了setPalace()和setAstrolabe()兩個方法,但實際使用過程中請不要手動去調用這兩個方法,以免造成數據錯誤。palace()
用途
獲取星耀所在宮位
定義
tstype palace = () => IFunctionalPalace | undefined;type palace = () => IFunctionalPalace | undefined;參數
none返回值
FunctionalPalace|undefined示例
獲取
紫微星所在的宮位tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const palace = astrolabe.star("紫微星").palece();import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const palace = astrolabe.star("紫微星").palece();
surroundedPalaces()
用途
獲取當前星耀的三方四正宮位
定義
tstype surroundedPalaces = () => IFunctionalSurpalaces | undefined;type surroundedPalaces = () => IFunctionalSurpalaces | undefined;參數
none返回值
FunctionalSurpalaces|undefined示例
獲取
紫微星的三方四正宮位tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const palaces = astrolabe.star("紫微星").surroundedPalaces();import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const palaces = astrolabe.star("紫微星").surroundedPalaces();
oppositePalace()
用途
獲取當前星耀的對宮
定義
tstype oppositePalace = () => IFunctionalPalace | undefined;type oppositePalace = () => IFunctionalPalace | undefined;參數
none返回值
FunctionalPalace|undefined示例
獲取
紫微星的對宮tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const palace = astrolabe.star("紫微星").oppositePalace();import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const palace = astrolabe.star("紫微星").oppositePalace();
withBrightness()
用途
判斷星耀是否是傳入的亮度,也可以傳入多個亮度,隻要匹配到壹個亮度就會返回
true定義
tstype withBrightness = (brightness: Brightness | Brightness[]) => boolean;type withBrightness = (brightness: Brightness | Brightness[]) => boolean;參數
參數 類型 是否必填 默認值 說明 brightness Brightness|Brightness[]true- 需要判斷的星耀亮度 返回值
boolean示例
判斷
紫微星是否處於廟或者旺的狀態tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const result = astrolabe.star("紫微星").withBrightness(["廟", "旺"]);import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const result = astrolabe.star("紫微星").withBrightness(["廟", "旺"]);
withMutagen()
用途
判斷星耀是否產生了四化,也可以傳入多個四化進行判斷,隻要匹配到壹個亮度就會返回
true定義
tstype withMutagen = (mutagen: Mutagen | Mutagen[]) => boolean;type withMutagen = (mutagen: Mutagen | Mutagen[]) => boolean;參數
參數 類型 是否必填 默認值 說明 mutagen Mutagen|Mutagen[]true- 四化【祿|權|科|忌】 返回值
boolean示例
判斷
紫微星是否處於化權或者華科的狀態tsimport { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const result = astrolabe.star("紫微星").withMutagen(["權", "科"]);import { astro } from "iztro"; const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN"); const result = astrolabe.star("紫微星").withMutagen(["權", "科"]);