getChangSheng12 function

List<StarName> getChangSheng12(
  1. AstrolabeParams params
)

长生12神。

阳男阴女顺行,阴男阳女逆行,安长生、沐浴、冠带、临官、帝旺、衰、病、死、墓、绝 、胎、养。

@returns 长生12神从寅宫开始的顺序

Implementation

List<StarName> getChangSheng12(AstrolabeParams params) {
  List<StarName> changSheng12 = List.filled(12, StarName.tai);
  final yearly =
      getHeavenlyStemAndEarthlyBranchSolarDate(
        params.solarDate,
        0,
        getConfig().yearDivide,
      ).yearly;
  final earhtlyBranchOfYear = getMyEarthlyBranchNameFrom(yearly[1]);
  // 获取命宫干支,需要通过命宫干支计算五行局
  final soulAndBody = getSoulAndBody(params);
  // 获取五行局,通过五行局获取起运年龄
  final fiveElementClass = getFiveElementClass(
    soulAndBody.heavenlyStenName,
    soulAndBody.earthlyBranchName,
  );

  const stars = [
    changSheng,
    muYu,
    guanDai,
    linGuan,
    diWang,
    shuai,
    bing,
    si,
    mu,
    jue,
    tai,
    yang,
  ];
  int startIndex = getChangSheng12StartIndex(fiveElementClass);
  for (int i = 0; i < stars.length; i++) {
    int index = 0;
    if (genderMap[params.gender?.key] ==
        earthlyBranchesMap[earhtlyBranchOfYear.key]?["yinYang"]) {
      index = fixIndex(i + startIndex);
    } else {
      index = fixIndex(startIndex - i);
    }
    changSheng12[index] = getStarNameFrom(stars[i]);
  }

  return changSheng12;
}