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("忌");