getSurroundedPalaces function

IFunctionlSurpalaces getSurroundedPalaces(
  1. IFunctionalAstrolabe astrolabe,
  2. dynamic indexOfPalace
)

Implementation

IFunctionlSurpalaces getSurroundedPalaces(
    IFunctionalAstrolabe astrolabe, dynamic indexOfPalace) {
  final IFunctionalPalace? palace = getPalace(astrolabe, indexOfPalace);
  if (palace == null) {
    throw UnimplementedError('index or name is inccoreect');
  }
  // 获取目标宫位索引
  final palaceIndex = fixEarthlyBranchIndex(palace.earthlyBranch);
  // 获取对宫
  var palace6 = getPalace(astrolabe, fixIndex(palaceIndex + 6));
  // 获取官禄位
  var palace4 = getPalace(astrolabe, fixIndex(palaceIndex + 4));
  // 获取财帛位
  var palace8 = getPalace(astrolabe, fixIndex(palaceIndex + 8));
  if (palace6 == null || palace8 == null || palace4 == null) {
    throw Exception("index or name is inccourrect");
  }
  var surroundPalace = SurroundedPalaces(
      target: palace, opposite: palace6, wealth: palace8, career: palace4);
  return FunctionalSurpalaces(surroundPalace);
}