UNPKG

@thanhtungka91/iztro

Version:

轻量级紫微斗数星盘生成库。可以通过出生年月日获取到紫微斗数星盘信息、生肖、星座等信息。This is a lightweight kit for generating astrolabes for Zi Wei Dou Shu (The Purple Star Astrology), an ancient Chinese astrology. It allows you to obtain your horoscope and personality analysis.

226 lines (225 loc) 12.6 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAdjectiveStar = exports.getQuocAnIndex = void 0; var lunar_lite_1 = require("lunar-lite"); var _1 = require("."); var i18n_1 = require("../i18n"); var FunctionalStar_1 = __importDefault(require("./FunctionalStar")); var location_1 = require("./location"); var astro_1 = require("../astro"); var utils_1 = require("../utils"); var getQuocAnIndex = function (heavenlyStem) { var earthlyBranchIndexMap = { 甲: 9, 乙: 10, 丙: 1, 丁: 2, 戊: 1, 己: 2, 庚: 4, 辛: 5, 壬: 7, 癸: 8, // Quý -> Thân }; var tyAbsoluteIndex = (0, utils_1.fixEarthlyBranchIndex)('zi'); // Tý has code 'zi' var currentIndex = earthlyBranchIndexMap[heavenlyStem] || 0; var relativePosition = (currentIndex + tyAbsoluteIndex) % 12; return (0, utils_1.fixIndex)(relativePosition); }; exports.getQuocAnIndex = getQuocAnIndex; /** * 安杂耀 * * @param {AstrolabeParam} param - 通用排盘参数参数 * @returns 38杂耀 */ var getAdjectiveStar = function (param) { var solarDate = param.solarDate, timeIndex = param.timeIndex, fixLeap = param.fixLeap; var algorithm = (0, astro_1.getConfig)().algorithm; var stars = (0, _1.initStars)(); var yearly = (0, lunar_lite_1.getHeavenlyStemAndEarthlyBranchBySolarDate)(solarDate, timeIndex, { year: (0, astro_1.getConfig)().yearDivide, }).yearly; var yearlyIndex = (0, location_1.getYearlyStarIndex)(param); var monthlyIndex = (0, location_1.getMonthlyStarIndex)(solarDate, timeIndex, fixLeap); var dailyIndex = (0, location_1.getDailyStarIndex)(solarDate, timeIndex, fixLeap); var timelyIndex = (0, location_1.getTimelyStarIndex)(timeIndex); var _a = (0, location_1.getLuanXiIndex)(yearly[1]), hongluanIndex = _a.hongluanIndex, tianxiIndex = _a.tianxiIndex; var suiqian12 = (0, _1.getYearly12)(solarDate).suiqian12; stars[hongluanIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('hongluan'), type: 'flower', scope: 'origin' })); stars[tianxiIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianxi'), type: 'flower', scope: 'origin' })); stars[monthlyIndex.tianyaoIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianyao'), type: 'flower', scope: 'origin' })); stars[yearlyIndex.xianchiIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('xianchi'), type: 'flower', scope: 'origin' })); stars[monthlyIndex.yuejieIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('jieshen'), type: 'helper', scope: 'origin' })); stars[dailyIndex.santaiIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('santai'), type: 'adjective', scope: 'origin' })); stars[dailyIndex.bazuoIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('bazuo'), type: 'adjective', scope: 'origin' })); stars[dailyIndex.enguangIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('engguang'), type: 'adjective', scope: 'origin' })); stars[dailyIndex.tianguiIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tiangui'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.longchiIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('longchi'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.fenggeIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('fengge'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tiancaiIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tiancai'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tianshouIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianshou'), type: 'adjective', scope: 'origin' })); stars[timelyIndex.taifuIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('taifu'), type: 'adjective', scope: 'origin' })); stars[timelyIndex.fenggaoIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('fenggao'), type: 'adjective', scope: 'origin' })); stars[monthlyIndex.tianwuIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianwu'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.huagaiIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('huagai'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tianguanIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianguan'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tianfuIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianfu'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tianchuIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianchu'), type: 'adjective', scope: 'origin' })); stars[monthlyIndex.tianyueIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianyue'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tiandeIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tiande'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.yuedeIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('yuede'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tiankongIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tiankong'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.xunkongIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('xunkong'), type: 'adjective', scope: 'origin' })); if (algorithm !== 'zhongzhou') { // 中州派没有的星耀 stars[yearlyIndex.jieluIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('jielu'), type: 'adjective', scope: 'origin' })); // stars[yearlyIndex.kongwangIndex].push( // new FunctionalStar({ name: t('kongwang'), type: 'adjective', scope: 'origin' }), // ); } else { // 中州派特有的星耀 stars[suiqian12.indexOf((0, i18n_1.t)((0, i18n_1.kot)('longde')))].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('longde'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.jiekongIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('jiekong'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.jieshaAdjIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('jieshaAdj'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.dahaoAdjIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('dahao'), type: 'adjective', scope: 'origin' })); } stars[yearlyIndex.guchenIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('guchen'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.guasuIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('guasu'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.feilianIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('feilian'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.posuiIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('posui'), type: 'adjective', scope: 'origin' })); stars[monthlyIndex.tianxingIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianxing'), type: 'adjective', scope: 'origin' })); stars[monthlyIndex.yinshaIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('yinsha'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tiankuIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianku'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tianxuIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianxu'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tianshiIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianshi'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tianshangIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tianshang'), type: 'adjective', scope: 'origin' })); // 生年年解 stars[yearlyIndex.nianjieIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('nianjie'), type: 'helper', scope: 'origin' })); stars[yearlyIndex.thaitueIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('thaitue'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.thieuduongIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('thieuduong'), type: 'adjective', scope: 'origin' })); // Add the remaining 10 stars in the Thái Tuế series stars[yearlyIndex.tangmonIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tangmon'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.thieuamIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('thieuam'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.quanphuIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('quanphu'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tuphuIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tuphu'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.tuephaIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('tuepha'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.longducIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('longduc'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.bachhoIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('bachho'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.phucducIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('phucduc'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.dieukhachIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('dieukhach'), type: 'adjective', scope: 'origin' })); stars[yearlyIndex.trucphuIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('trucphu'), type: 'adjective', scope: 'origin' })); stars[monthlyIndex.thiengiaiIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('thiengiai'), type: 'adjective', scope: 'origin' })); stars[monthlyIndex.diagiaiIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('diagiai'), type: 'adjective', scope: 'origin' })); var quocAnIndex = (0, exports.getQuocAnIndex)(yearly[0]); stars[quocAnIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('quocan'), type: 'adjective', scope: 'origin' })); // Thêm sao Đẩu Quân stars[yearlyIndex.dauQuanIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('dauquan'), type: 'adjective', scope: 'origin' })); var daoHoaIndex = (0, location_1.getDaoHoaIndex)(yearly[1]); // Add Đào Hoa star stars[daoHoaIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('daohoa'), type: 'adjective', scope: 'origin' })); var luuHaIndex = (0, _1.getLuuHaIndex)(yearly[0]); stars[luuHaIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('luuha'), type: 'adjective', scope: 'origin' })); var duongPhuIndex = (0, _1.getDuongPhuIndex)(yearly[0]); stars[duongPhuIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('duongphu'), type: 'adjective', scope: 'origin' })); var vantinhIndex = (0, location_1.getVanTinhIndex)(yearly[0]); stars[vantinhIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('vantinh'), type: 'adjective', scope: 'origin' })); var phuongCacIndex = (0, _1.getPhuongCatIndex)(yearly[1]); stars[phuongCacIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('phuongcac'), type: 'adjective', scope: 'origin' })); var dauQuanIndex = (0, _1.getDauQuanIndex)(param); stars[dauQuanIndex].push(new FunctionalStar_1.default({ name: (0, i18n_1.t)('dauquan'), type: 'adjective', scope: 'origin' })); return stars; }; exports.getAdjectiveStar = getAdjectiveStar;