Giter VIP home page Giter VIP logo

fortel-ziweidoushu's Introduction

fortel-ziweidoushu

紫微斗數排盤 (中州派) Javascript library


What is it?

This is a Javascript library for Zi Wei Dou Shu creating destiny broad (紫微斗數排盤).

Which branch(門派) of 紫微斗數 it is?

This library is based on 中州派 .

What feature is supported?

  • Create destiny board with friendly input options. (排盤)
  • Check board criteria. (檢查宮位是否存在/會見各星)
  • Present board as JSON object.
  • Print board as string.

install

npm i fortel-ziweidoushu


Hello world

Create board with Lunar date (以農曆參數排盤)

You can use DestinyConfigBuilder.withlunar to specify the parameters. And then use new DestinyBoard(config) to build the board.

import fortel, { DestinyBoard } from 'fortel-ziweidoushu'
const { DestinyConfigBuilder, DayTimeGround, ConfigType, Gender } = fortel.config

// 農曆1952年三月十五日寅時女士
const destinyBoard = new DestinyBoard(
    DestinyConfigBuilder.withlunar({
        year: 1952, // 年
        month: 3, //月
        day: 15, //日
        isLeapMonth: false, // 非潤月
        bornTimeGround: DayTimeGround.getByName('寅時'), // 出生時辰
        configType: ConfigType.SKY, // 天盤, if missing this option, default is 天盤
        gender: Gender.F, // 女士
    }),
)

console.log(destinyBoard.toString())

output

DestinyBoard {
    config: {"year":1952,"month":3,"day":15,"isLeapMonth":false,"yearSky":"壬","yearGround":"辰","monthSky":"甲","monthGround":"辰","daySky":"乙","dayGround":"酉","bornTimeGround":"寅時","configType":"天盤","gender":"女
"},
    element: 金四局,
    destinyMaster: 廉貞,
    bodyMaster: 文昌,
    startControl: 子,
    cells: [
        Cell {壬子, temples=[夫妻], majorStars=[武曲 1,天府 2], minorStars=[鈴星,擎羊], miniStars=[], miscStars=[官府,白虎,將星], ageRange=[24-33], lifeStage=[衰]},
        Cell {癸丑, temples=[兄弟], majorStars=[太陽 -1,太陰 2], minorStars=[地劫], miniStars=[寡宿,破碎], miscStars=[伏兵,天德,攀鞍], ageRange=[14-23], lifeStage=[帝旺]},
        Cell {壬寅, temples=[命宮], majorStars=[貪狼 0], minorStars=[天馬], miniStars=[天哭,截空,天巫], miscStars=[大耗,弔客,歲驛], ageRange=[4-13], lifeStage=[臨官]},
        Cell {癸卯, temples=[父母], majorStars=[天機 1,巨門 2], minorStars=[天魁], miniStars=[截空,天姚], miscStars=[病符,病符,息神], ageRange=[114-123], lifeStage=[冠帶]},
        Cell {甲辰, temples=[福德], majorStars=[紫微 -1,天相 1], minorStars=[火星], miniStars=[封誥,天月], miscStars=[喜神,太歲,華蓋], ageRange=[104-113], lifeStage=[沐浴]},
        Cell {乙巳, temples=[田宅], majorStars=[天梁 -1], minorStars=[天鉞], miniStars=[天喜,孤辰,劫煞,天空], miscStars=[蜚廉,晦氣,劫煞], ageRange=[94-103], lifeStage=[長生]},
        Cell {丙午, temples=[身宮,事業], majorStars=[七殺 1], minorStars=[文曲,左輔], miniStars=[天福,鳳閣,解神,天才,旬空,蜚廉,八座], miscStars=[奏書,喪門,災煞], ageRange=[84-93], lifeStage=[養]},
        Cell {丁未, temples=[交友], majorStars=[], minorStars=[], miniStars=[旬空,天貴,天使], miscStars=[將軍,貫索,天煞], ageRange=[74-83], lifeStage=[胎]},
        Cell {戊申, temples=[遷移], majorStars=[廉貞 2], minorStars=[文昌,右弼], miniStars=[龍池,台輔,三台], miscStars=[小耗,官符,指背], ageRange=[64-73], lifeStage=[絕]},
        Cell {己酉, temples=[疾厄], majorStars=[], minorStars=[地空], miniStars=[天廚,咸池,月德,恩光,天傷], miscStars=[青龍,小耗,咸池], ageRange=[54-63], lifeStage=[墓]},
        Cell {庚戌, temples=[財帛], majorStars=[破軍 1], minorStars=[陀羅], miniStars=[天官,天虛,天壽,陰煞,解神], miscStars=[力士,歲破,月煞], ageRange=[44-53], lifeStage=[死]},
        Cell {辛亥, temples=[子女], majorStars=[天同 2], minorStars=[祿存], miniStars=[紅鸞,大耗,天刑], miscStars=[博士,龍德,亡神], ageRange=[34-43], lifeStage=[病]}
    ],
    #bornStarDerivativeMap: {"祿":"天梁","權":"紫微","科":"天府","忌":"武曲"}
}

Create board with Solar date (以西曆參數排盤)

use DestinyConfigBuilder.withSolar instead of DestinyConfigBuilder.withlunar for Solar Calendar date input parameters.

// 公曆1952年4月9日寅時女士
const destinyBoard = new DestinyBoard(
    DestinyConfigBuilder.withSolar({
        year: 1952,
        month: 4,
        day: 9,
        bornTimeGround: DayTimeGround.getByName('寅時'),
        configType: ConfigType.SKY,
        gender: Gender.F,
    }),
)

Create board with human text (以文字描述排盤)

The library can parse your reasonable human description text and turn it into the board.

Basically we need such information from text:

  • Calendar type (農曆/公曆)
  • year
  • month (and whether it is leap month)
  • day
  • Born time hour
  • Gender
import fortel, { DestinyBoard } from 'fortel-ziweidoushu'
const { DestinyConfigBuilder, DayTimeGround, ConfigType, Gender } = fortel.config

// 農曆1952年三月十五日寅時女士
const destinyBoard = new DestinyBoard(DestinyConfigBuilder.withText('農曆1952年三月十五日寅時女士'))

Criteria

You can use BoardCriteria to check broad criteria condition.

Example - Check Temple having stars

  • 判斷兄弟宮是否有太陽, 地劫, 寡宿全部星。
  • 判斷夫妻宮是否有武曲, 貪狼, 任意一顆星。
import fortel, { DestinyBoard, Temple, BoardCriteria, starByName } from 'fortel-ziweidoushu'
const { DestinyConfigBuilder, DayTimeGround, ConfigType, Gender } = fortel.config

// 公曆1952年4月9日寅時出生女士
const destinyBoard = new DestinyBoard(DestinyConfigBuilder.withText('公曆1952年4月9日寅時出生女士'))

console.log(destinyBoard.toString())

console.log(
    new BoardCriteria(destinyBoard).ofTemple(Temple.TEMPLE_BROTHER).hasAllStars([starByName('太陽'), starByName('地劫'), starByName('寡宿')])
)

console.log(
    new BoardCriteria(destinyBoard).ofTemple(Temple.TEMPLE_MARRIAGE).hasAnyStars([starByName('武曲'), starByName('貪狼')])
)

output

DestinyBoard {
    config: {"year":1952,"month":3,"day":15,"isLeapMonth":false,"yearSky":"壬","yearGround":"辰","monthSky":"甲","monthGround":"辰","daySky":"乙","dayGround":"酉","bornTimeGround":"寅時","configType":"天盤","gender":"女
"},
    element: 金四局,
    destinyMaster: 廉貞,
    bodyMaster: 文昌,
    startControl: 子,
    cells: [
        Cell {壬子, temples=[夫妻], majorStars=[武曲 1,天府 2], minorStars=[鈴星,擎羊], miniStars=[], miscStars=[官府,白虎,將星], ageRange=[24-33], lifeStage=[衰]},
        Cell {癸丑, temples=[兄弟], majorStars=[太陽 -1,太陰 2], minorStars=[地劫], miniStars=[寡宿,破碎], miscStars=[伏兵,天德,攀鞍], ageRange=[14-23], lifeStage=[帝旺]},
        ......
    ],
    #bornStarDerivativeMap: {"祿":"天梁","權":"紫微","科":"天府","忌":"武曲"}
}
true
true

Explain

new BoardCriteria(destinyBoard).ofTemple(Temple.TEMPLE_BROTHER)

This means building a checking criteria of the broad for target temple TEMPLE_BROTHER (兄弟宮).

.hasAllStars([starByName('太陽'), starByName('地劫'), starByName('寡宿')])

This means we check for the temple having ALL stars 太陽, 地劫, 寡宿.

.hasAnyStars([starByName('武曲'), starByName('貪狼')])

This means we check for the temple having ANY ONE OF stars 武曲, 貪狼.


Author

Airic Yu

Special Credit

Jea杨 - Thanks for his lunar/solar calendar conversion library ( https://github.com/jjonline/calendar.js )

fortel-ziweidoushu's People

Contributors

airicyu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.