Skip to content

宫位

概述

紫微斗数中一共有 十二 个宫位,叫做 十二人事宫,囊括了与人有关的其他人和事物,这十二宫按顺序分别是 命宫兄弟宫夫妻宫子女宫财帛宫疾厄宫迁移宫仆役宫官禄宫田宅宫福德宫父母宫。除了这展示在 星盘 里的十二宫以外,紫微斗数还有三个隐藏宫位,它们分别是 身宫来因宫暗合宫。每一个宫位有着它特殊的意义,但本页不详细展开来叙述。如果你对紫微斗数的宫位没有概念,或者想深入研究,可以点击 传送门 查看详细资料。与宫位地支顺时针排列相反,宫位名称是按逆时针排列的。如下面表格所示:

田宅官禄仆役迁移
福德中宫疾厄
父母财帛
命宫兄弟夫妻子女

以上表格只是一个例子,命宫 的位置会根据你的 出生日期出生时间 的不同而不同,它可能出现在上述任何一个宫位,但这个顺序是不会变的。

宫位其实是 两个概念组成的,通过 出生日期出生时间 计算出来的,叫 ,所以你星盘中的 财帛宫 位置在本命盘中是固定的,如果你不知道什么叫 本命盘,我们强烈建议你点击 传送门 学习。 则是一个 相对 位置,比如 夫妻宫财帛位迁移宫。这听起来有些绕,好消息是,你不需要记忆这些烧脑的信息,只需要有这么一个概念就可以了。

功能类定义

开发建议

因为宫位是基于星盘而存在的,所以我们并不推荐你手动 new 一个宫位对象,而是使用星盘静态方法返回的对象使用。星盘的 palaces 属性包含了十二宫的数据,为了和地支的顺序保持一致,它是从 寅宫 开始按照地支顺序顺时针排列的。

ts
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 变量里获取到目标宫位,请根据实际需求使用:

  1. 通过 palaces 的下标获取

    ts
    // 获取卯宫宫位
    const palace = astrolabe.palaces[1];
    // 获取卯宫宫位
    const palace = astrolabe.palaces[1];
  2. 通过 FunctionalAstrolabe 类的 palace() 方法传入宫位 索引 获取

    ts
    // 获取卯宫宫位
    const palace = astrolabe.palace(1);
    // 获取卯宫宫位
    const palace = astrolabe.palace(1);
  3. 通过 FunctionalAstrolabe 类的 palace() 方法传入宫位 名称 获取

    ts
    // 获取命宫
    const palace = astrolabe.palace("命宫");
    // 获取命宫
    const palace = astrolabe.palace("命宫");

FunctionalPalace


implements IFuncionalPalace extends Palace

该类所有属性都是继承自 Palace,然后在接口内定义了一些方法用于对星耀进行分析。

  • 接口定义

    ts
    interface 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

    • 定义

      ts
      type has = (stars: StarName[]) => boolean;
      type has = (stars: StarName[]) => boolean;
    • 参数

      参数类型是否必填默认值说明
      starsStarName[]true-星耀名称,可以包含主星、辅星、杂耀
    • 返回值

      boolean

    • 示例

      如果你想查看 命宫 是否有 紫微星右弼星

      ts
      const palace = astrolabe.palace("命宫");
      const result = palace.has(["紫微", "右弼"]);
      const palace = astrolabe.palace("命宫");
      const result = palace.has(["紫微", "右弼"]);

      当然你也可以使用 链式调用 来简化代码

      ts
      const result = astrolabe.palace("命宫").has(["紫微", "右弼"]);
      const result = astrolabe.palace("命宫").has(["紫微", "右弼"]);

    notHave() ^1.0.0
    • 用途

      判断某个宫位内是否没有传入的 星耀,要所有星耀 都不在 宫位内才会返回 true

    • 定义

      ts
      type notHave = (stars: StarName[]) => boolean;
      type notHave = (stars: StarName[]) => boolean;
    • 参数

      参数类型是否必填默认值说明
      starsStarName[]true-星耀名称,可以包含主星、辅星、杂耀
    • 返回值

      boolean

    • 示例

      如果你想查看 命宫 是没有 地空星地劫星

      ts
      const palace = astrolabe.palace("命宫");
      const result = palace.notHave(["地空", "地劫"]);
      const palace = astrolabe.palace("命宫");
      const result = palace.notHave(["地空", "地劫"]);

      当然你也可以使用 链式调用 来简化代码

      ts
      const result = astrolabe.palace("命宫").notHave(["地空", "地劫"]);
      const result = astrolabe.palace("命宫").notHave(["地空", "地劫"]);

    hasOneOf() ^1.0.0
    • 用途

      判断某个宫位内是否有传入 星耀 的其中一个,只要 命中一个 就会返回 true

    • 定义

      ts
      type hasOneOf = (stars: StarName[]) => boolean;
      type hasOneOf = (stars: StarName[]) => boolean;
    • 参数

      参数类型是否必填默认值说明
      starsStarName[]true-星耀名称,可以包含主星、辅星、杂耀
    • 返回值

      boolean

    • 示例

      如果你想查看 命宫 是否有 天魁星天钺星

      ts
      const palace = astrolabe.palace("命宫");
      const result = palace.hasOneOf(["天魁", "天钺"]);
      const palace = astrolabe.palace("命宫");
      const result = palace.hasOneOf(["天魁", "天钺"]);

      当然你也可以使用 链式调用 来简化代码

      ts
      const result = astrolabe.palace("命宫").hasOneOf(["天魁", "天钺"]);
      const result = astrolabe.palace("命宫").hasOneOf(["天魁", "天钺"]);

    hasMutagen() ^1.2.0
    • 用途

      判断宫位内是否有生年四化

    • 定义

      ts
      type hasMutagen = (mutagen: Mutagen) => boolean;
      type hasMutagen = (mutagen: Mutagen) => boolean;
    • 参数

      参数类型是否必填默认值说明
      mutagenMutagentrue-四化名称【禄|权|科|忌】
    • 返回值

      boolean

    • 示例

      如果你想查看 命宫 是否有 化禄

      ts
      const palace = astrolabe.palace("命宫");
      const result = palace.hasMutagen("禄");
      const palace = astrolabe.palace("命宫");
      const result = palace.hasMutagen("禄");

      当然你也可以使用 链式调用 来简化代码

      ts
      const result = astrolabe.palace("命宫").hasMutagen("禄");
      const result = astrolabe.palace("命宫").hasMutagen("禄");

    notHaveMutagen() ^1.2.0
    • 用途

      判断宫位内是否没有生年四化

    • 定义

      ts
      type notHaveMutagen = (mutagen: Mutagen) => boolean;
      type notHaveMutagen = (mutagen: Mutagen) => boolean;
    • 参数

      参数类型是否必填默认值说明
      mutagenMutagentrue-四化名称【禄|权|科|忌】
    • 返回值

      boolean

    • 示例

      如果你想查看 命宫 是不是没有 化忌

      ts
      const palace = astrolabe.palace("命宫");
      const result = palace.notHaveMutagen("忌");
      const palace = astrolabe.palace("命宫");
      const result = palace.notHaveMutagen("忌");

      当然你也可以使用 链式调用 来简化代码

      ts
      const result = astrolabe.palace("命宫").notHaveMutagen("忌");
      const result = astrolabe.palace("命宫").notHaveMutagen("忌");

FunctionalSurpalaces ^1.2.0


implements IFunctionalSurpalaces extends SurroundedPalaces

该类所有属性都是继承自 SurroundedPalaces,然后在接口内定义了一些方法用于对星耀进行分析。

  • 接口定义

    ts
    interface 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;
    }
  • 属性

    参考 SurroundedPalaces

  • 方法

    have()
    • 用途

      判断某个宫三方四正内是否有传入的 星耀,要 所有 星耀 都在 三方四正内才会返回 true

    • 定义

      ts
      type have = (stars: StarName[]) => boolean;
      type have = (stars: StarName[]) => boolean;
    • 参数

      参数类型是否必填默认值说明
      starsStarName[]true-星耀名称,可以包含主星、辅星、杂耀
    • 返回值

      boolean

    • 示例

      如果你想查看 命宫 三方四正是否有 紫微星右弼星

      ts
      const palaces = astrolabe.surroundedPalaces("命宫");
      const result = palaces.have(["紫微", "右弼"]);
      const palaces = astrolabe.surroundedPalaces("命宫");
      const result = palaces.have(["紫微", "右弼"]);

      当然你也可以使用 链式调用 来简化代码

      ts
      const result = astrolabe.surroundedPalaces("命宫").have(["紫微", "右弼"]);
      const result = astrolabe.surroundedPalaces("命宫").have(["紫微", "右弼"]);

    notHave()
    • 用途

      判断某个宫三方四正内是否没有传入的 星耀,要所有星耀 都不在 三方四正内才会返回 true

    • 定义

      ts
      type notHave = (stars: StarName[]) => boolean;
      type notHave = (stars: StarName[]) => boolean;
    • 参数

      参数类型是否必填默认值说明
      starsStarName[]true-星耀名称,可以包含主星、辅星、杂耀
    • 返回值

      boolean

    • 示例

      如果你想查看 命宫 三方四正是否没有 地空星地劫星

      ts
      const palaces = astrolabe.surroundedPalaces("命宫");
      const result = palaces.notHave(["地空", "地劫"]);
      const palaces = astrolabe.surroundedPalaces("命宫");
      const result = palaces.notHave(["地空", "地劫"]);

      当然你也可以使用 链式调用 来简化代码

      ts
      const result = astrolabe.surroundedPalaces("命宫").notHave(["地空", "地劫"]);
      const result = astrolabe.surroundedPalaces("命宫").notHave(["地空", "地劫"]);

    haveOneOf()
    • 用途

      判断某个宫位的三方四正内是否有传入 星耀 的其中一个,只要 命中一个 就会返回 true

    • 定义

      ts
      type haveOneOf = (stars: StarName[]) => boolean;
      type haveOneOf = (stars: StarName[]) => boolean;
    • 参数

      参数类型是否必填默认值说明
      starsStarName[]true-星耀名称,可以包含主星、辅星、杂耀
    • 返回值

      boolean

    • 示例

      如果你想查看 命宫 三方四正是否有 天魁星天钺星

      ts
      const palaces = astrolabe.surroundedPalaces("命宫");
      const result = palaces.haveOneOf(["天魁", "天钺"]);
      const palaces = astrolabe.surroundedPalaces("命宫");
      const result = palaces.haveOneOf(["天魁", "天钺"]);

      当然你也可以使用 链式调用 来简化代码

      ts
      const result = astrolabe.surroundedPalaces("命宫").haveOneOf(["天魁", "天钺"]);
      const result = astrolabe.surroundedPalaces("命宫").haveOneOf(["天魁", "天钺"]);

    haveMutagen()
    • 用途

      判断宫位三方四正内是否有生年四化

    • 定义

      ts
      type haveMutagen = (mutagen: Mutagen) => boolean;
      type haveMutagen = (mutagen: Mutagen) => boolean;
    • 参数

      参数类型是否必填默认值说明
      mutagenMutagentrue-四化名称【禄|权|科|忌】
    • 返回值

      boolean

    • 示例

      如果你想查看 命宫 三方四正是否有 化禄

      ts
      const palaces = astrolabe.surroundedPalaces("命宫");
      const result = palaces.haveMutagen("禄");
      const palaces = astrolabe.surroundedPalaces("命宫");
      const result = palaces.haveMutagen("禄");

      当然你也可以使用 链式调用 来简化代码

      ts
      const result = astrolabe.surroundedPalaces("命宫").haveMutagen("禄");
      const result = astrolabe.surroundedPalaces("命宫").haveMutagen("禄");

    notHaveMutagen()
    • 用途

      判断宫位三方四正内是否没有生年四化

    • 定义

      ts
      type notHaveMutagen = (mutagen: Mutagen) => boolean;
      type notHaveMutagen = (mutagen: Mutagen) => boolean;
    • 参数

      参数类型是否必填默认值说明
      mutagenMutagentrue-四化名称【禄|权|科|忌】
    • 返回值

      boolean

    • 示例

      如果你想查看 命宫 三方四正是不是没有 化忌

      ts
      const palace = astrolabe.surroundedPalaces("命宫");
      const result = palace.notHaveMutagen("忌");
      const palace = astrolabe.surroundedPalaces("命宫");
      const result = palace.notHaveMutagen("忌");

      当然你也可以使用 链式调用 来简化代码

      ts
      const result = astrolabe.surroundedPalaces("命宫").notHaveMutagen("忌");
      const result = astrolabe.surroundedPalaces("命宫").notHaveMutagen("忌");