星耀
概述
星耀是紫微斗数里的重要组成部分,人的个性主要收到星耀的影响。不同的星耀组合形成了不同的个性,如果你对星耀部分感兴趣,我们强烈建议你点击 传送门 进行相关知识学习。本篇主要关注的是开发层面。
提示
在 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(["权", "科"]);