宫位
概述
紫微斗数中一共有 十二 个宫位,叫做 十二人事宫,囊括了与人有关的其他人和事物,这十二宫按顺序分别是 命宫、兄弟宫、夫妻宫、子女宫、财帛宫、疾厄宫、迁移宫、仆役宫、官禄宫、田宅宫、福德宫、父母宫。除了这展示在 星盘 里的十二宫以外,紫微斗数还有三个隐藏宫位,它们分别是 身宫、来因宫、暗合宫。每一个宫位有着它特殊的意义,但本页不详细展开来叙述。如果你对紫微斗数的宫位没有概念,或者想深入研究,可以点击 传送门 查看详细资料。与宫位地支顺时针排列相反,宫位名称是按逆时针排列的。如下面表格所示:
巳 田宅 | 午 官禄 | 未 仆役 | 申 迁移 |
辰 福德 | 中宫 | 酉 疾厄 | |
卯 父母 | 戌 财帛 | ||
寅 命宫 | 丑 兄弟 | 子 夫妻 | 亥 子女 |
以上表格只是一个例子,
命宫的位置会根据你的出生日期和出生时间的不同而不同,它可能出现在上述任何一个宫位,但这个顺序是不会变的。
宫位其实是 宫 和 位 两个概念组成的,通过 出生日期 和 出生时间 计算出来的,叫 宫,所以你星盘中的 财帛宫 位置在本命盘中是固定的,如果你不知道什么叫 本命盘,我们强烈建议你点击 传送门 学习。位 则是一个 相对 位置,比如 夫妻宫 的 财帛位 是 迁移宫。这听起来有些绕,好消息是,你不需要记忆这些烧脑的信息,只需要有这么一个概念就可以了。
功能类定义
开发建议
因为宫位是基于星盘而存在的,所以我们并不推荐你手动 new 一个宫位对象,而是使用星盘静态方法返回的对象使用。星盘的 palaces 属性包含了十二宫的数据,为了和地支的顺序保持一致,它是从 寅宫 开始按照地支顺序顺时针排列的。
import { astro } from "iztro";
const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN");import { astro } from "iztro";
const astrolabe = astro.astrolabeBySolarDate("2000-8-16", 2, "女", true, "zh-CN");你可以有几种方式从上述 astrolabe 变量里获取到目标宫位,请根据实际需求使用:
通过
palaces的下标获取ts// 获取卯宫宫位 const palace = astrolabe.palaces[1];// 获取卯宫宫位 const palace = astrolabe.palaces[1];通过
FunctionalAstrolabe类的palace()方法传入宫位索引获取ts// 获取卯宫宫位 const palace = astrolabe.palace(1);// 获取卯宫宫位 const palace = astrolabe.palace(1);通过
FunctionalAstrolabe类的palace()方法传入宫位名称获取ts// 获取命宫 const palace = astrolabe.palace("命宫");// 获取命宫 const palace = astrolabe.palace("命宫");
FunctionalPalace
implements
IFuncionalPalace extends Palace该类所有属性都是继承自 Palace,然后在接口内定义了一些方法用于对星耀进行分析。
接口定义
tsinterface IFunctionalPalace extends Palace { has: (stars: StarName[]) => boolean; notHave: (stars: StarName[]) => boolean; hasOneOf: (stars: StarName[]) => boolean; hasMutagen: (mutagen: Mutagen): boolean; notHaveMutagen: (mutagen: Mutagen): boolean; }interface IFunctionalPalace extends Palace { has: (stars: StarName[]) => boolean; notHave: (stars: StarName[]) => boolean; hasOneOf: (stars: StarName[]) => boolean; hasMutagen: (mutagen: Mutagen): boolean; notHaveMutagen: (mutagen: Mutagen): boolean; }属性
参考 Palace
方法
has() ^1.0.0
用途
判断某个宫位内是否有传入的
星耀,要所有星耀都在宫位内才会返回true定义
tstype has = (stars: StarName[]) => boolean;type has = (stars: StarName[]) => boolean;参数
参数 类型 是否必填 默认值 说明 stars StarName[]true- 星耀名称,可以包含主星、辅星、杂耀 返回值
boolean示例
如果你想查看
命宫是否有紫微星和右弼星tsconst palace = astrolabe.palace("命宫"); const result = palace.has(["紫微", "右弼"]);const palace = astrolabe.palace("命宫"); const result = palace.has(["紫微", "右弼"]);当然你也可以使用
链式调用来简化代码tsconst result = astrolabe.palace("命宫").has(["紫微", "右弼"]);const result = astrolabe.palace("命宫").has(["紫微", "右弼"]);
notHave() ^1.0.0
用途
判断某个宫位内是否没有传入的
星耀,要所有星耀都不在宫位内才会返回true定义
tstype notHave = (stars: StarName[]) => boolean;type notHave = (stars: StarName[]) => boolean;参数
参数 类型 是否必填 默认值 说明 stars StarName[]true- 星耀名称,可以包含主星、辅星、杂耀 返回值
boolean示例
如果你想查看
命宫是没有地空星和地劫星tsconst palace = astrolabe.palace("命宫"); const result = palace.notHave(["地空", "地劫"]);const palace = astrolabe.palace("命宫"); const result = palace.notHave(["地空", "地劫"]);当然你也可以使用
链式调用来简化代码tsconst result = astrolabe.palace("命宫").notHave(["地空", "地劫"]);const result = astrolabe.palace("命宫").notHave(["地空", "地劫"]);
hasOneOf() ^1.0.0
用途
判断某个宫位内是否有传入
星耀的其中一个,只要命中一个就会返回true定义
tstype hasOneOf = (stars: StarName[]) => boolean;type hasOneOf = (stars: StarName[]) => boolean;参数
参数 类型 是否必填 默认值 说明 stars StarName[]true- 星耀名称,可以包含主星、辅星、杂耀 返回值
boolean示例
如果你想查看
命宫是否有天魁星或天钺星tsconst palace = astrolabe.palace("命宫"); const result = palace.hasOneOf(["天魁", "天钺"]);const palace = astrolabe.palace("命宫"); const result = palace.hasOneOf(["天魁", "天钺"]);当然你也可以使用
链式调用来简化代码tsconst result = astrolabe.palace("命宫").hasOneOf(["天魁", "天钺"]);const result = astrolabe.palace("命宫").hasOneOf(["天魁", "天钺"]);
hasMutagen() ^1.2.0
用途
判断宫位内是否有生年四化
定义
tstype hasMutagen = (mutagen: Mutagen) => boolean;type hasMutagen = (mutagen: Mutagen) => boolean;参数
参数 类型 是否必填 默认值 说明 mutagen Mutagentrue- 四化名称【禄|权|科|忌】 返回值
boolean示例
如果你想查看
命宫是否有化禄tsconst palace = astrolabe.palace("命宫"); const result = palace.hasMutagen("禄");const palace = astrolabe.palace("命宫"); const result = palace.hasMutagen("禄");当然你也可以使用
链式调用来简化代码tsconst result = astrolabe.palace("命宫").hasMutagen("禄");const result = astrolabe.palace("命宫").hasMutagen("禄");
notHaveMutagen() ^1.2.0
用途
判断宫位内是否没有生年四化
定义
tstype notHaveMutagen = (mutagen: Mutagen) => boolean;type notHaveMutagen = (mutagen: Mutagen) => boolean;参数
参数 类型 是否必填 默认值 说明 mutagen Mutagentrue- 四化名称【禄|权|科|忌】 返回值
boolean示例
如果你想查看
命宫是不是没有化忌tsconst palace = astrolabe.palace("命宫"); const result = palace.notHaveMutagen("忌");const palace = astrolabe.palace("命宫"); const result = palace.notHaveMutagen("忌");当然你也可以使用
链式调用来简化代码tsconst result = astrolabe.palace("命宫").notHaveMutagen("忌");const result = astrolabe.palace("命宫").notHaveMutagen("忌");
FunctionalSurpalaces ^1.2.0
implements
IFunctionalSurpalaces extends SurroundedPalaces该类所有属性都是继承自 SurroundedPalaces,然后在接口内定义了一些方法用于对星耀进行分析。
接口定义
tsinterface FunctionalSurpalaces extends SurroundedPalaces { have: (stars: StarName[]) => boolean; notHave: (stars: StarName[]) => boolean; haveOneOf: (stars: StarName[]) => boolean; haveMutagen: (mutagen: Mutagen) => boolean; notHaveMutagen: (mutagen: Mutagen): boolean; }interface FunctionalSurpalaces extends SurroundedPalaces { have: (stars: StarName[]) => boolean; notHave: (stars: StarName[]) => boolean; haveOneOf: (stars: StarName[]) => boolean; haveMutagen: (mutagen: Mutagen) => boolean; notHaveMutagen: (mutagen: Mutagen): boolean; }属性
方法
have()
用途
判断某个宫三方四正内是否有传入的
星耀,要所有星耀都在三方四正内才会返回true定义
tstype have = (stars: StarName[]) => boolean;type have = (stars: StarName[]) => boolean;参数
参数 类型 是否必填 默认值 说明 stars StarName[]true- 星耀名称,可以包含主星、辅星、杂耀 返回值
boolean示例
如果你想查看
命宫三方四正是否有紫微星和右弼星tsconst palaces = astrolabe.surroundedPalaces("命宫"); const result = palaces.have(["紫微", "右弼"]);const palaces = astrolabe.surroundedPalaces("命宫"); const result = palaces.have(["紫微", "右弼"]);当然你也可以使用
链式调用来简化代码tsconst result = astrolabe.surroundedPalaces("命宫").have(["紫微", "右弼"]);const result = astrolabe.surroundedPalaces("命宫").have(["紫微", "右弼"]);
notHave()
用途
判断某个宫三方四正内是否没有传入的
星耀,要所有星耀都不在三方四正内才会返回true定义
tstype notHave = (stars: StarName[]) => boolean;type notHave = (stars: StarName[]) => boolean;参数
参数 类型 是否必填 默认值 说明 stars StarName[]true- 星耀名称,可以包含主星、辅星、杂耀 返回值
boolean示例
如果你想查看
命宫三方四正是否没有地空星和地劫星tsconst palaces = astrolabe.surroundedPalaces("命宫"); const result = palaces.notHave(["地空", "地劫"]);const palaces = astrolabe.surroundedPalaces("命宫"); const result = palaces.notHave(["地空", "地劫"]);当然你也可以使用
链式调用来简化代码tsconst result = astrolabe.surroundedPalaces("命宫").notHave(["地空", "地劫"]);const result = astrolabe.surroundedPalaces("命宫").notHave(["地空", "地劫"]);
haveOneOf()
用途
判断某个宫位的三方四正内是否有传入
星耀的其中一个,只要命中一个就会返回true定义
tstype haveOneOf = (stars: StarName[]) => boolean;type haveOneOf = (stars: StarName[]) => boolean;参数
参数 类型 是否必填 默认值 说明 stars StarName[]true- 星耀名称,可以包含主星、辅星、杂耀 返回值
boolean示例
如果你想查看
命宫三方四正是否有天魁星或天钺星tsconst palaces = astrolabe.surroundedPalaces("命宫"); const result = palaces.haveOneOf(["天魁", "天钺"]);const palaces = astrolabe.surroundedPalaces("命宫"); const result = palaces.haveOneOf(["天魁", "天钺"]);当然你也可以使用
链式调用来简化代码tsconst result = astrolabe.surroundedPalaces("命宫").haveOneOf(["天魁", "天钺"]);const result = astrolabe.surroundedPalaces("命宫").haveOneOf(["天魁", "天钺"]);
haveMutagen()
用途
判断宫位三方四正内是否有生年四化
定义
tstype haveMutagen = (mutagen: Mutagen) => boolean;type haveMutagen = (mutagen: Mutagen) => boolean;参数
参数 类型 是否必填 默认值 说明 mutagen Mutagentrue- 四化名称【禄|权|科|忌】 返回值
boolean示例
如果你想查看
命宫三方四正是否有化禄tsconst palaces = astrolabe.surroundedPalaces("命宫"); const result = palaces.haveMutagen("禄");const palaces = astrolabe.surroundedPalaces("命宫"); const result = palaces.haveMutagen("禄");当然你也可以使用
链式调用来简化代码tsconst result = astrolabe.surroundedPalaces("命宫").haveMutagen("禄");const result = astrolabe.surroundedPalaces("命宫").haveMutagen("禄");
notHaveMutagen()
用途
判断宫位三方四正内是否没有生年四化
定义
tstype notHaveMutagen = (mutagen: Mutagen) => boolean;type notHaveMutagen = (mutagen: Mutagen) => boolean;参数
参数 类型 是否必填 默认值 说明 mutagen Mutagentrue- 四化名称【禄|权|科|忌】 返回值
boolean示例
如果你想查看
命宫三方四正是不是没有化忌tsconst palace = astrolabe.surroundedPalaces("命宫"); const result = palace.notHaveMutagen("忌");const palace = astrolabe.surroundedPalaces("命宫"); const result = palace.notHaveMutagen("忌");当然你也可以使用
链式调用来简化代码tsconst result = astrolabe.surroundedPalaces("命宫").notHaveMutagen("忌");const result = astrolabe.surroundedPalaces("命宫").notHaveMutagen("忌");