Exemple #1
0
class WuYunLiuQi:
  def __init__(self, yy):
    self.year = int(yy)

    # 天干地支时间
    self.gz = GZTime(self.year)

    # 五运
    self.wy = WuYun(self.year)

    # 六气
    self.lq = LiuQi(self.year)

    # 司天气
    self.stq = self.lq.getSiTianZhiQi()

    # 在泉气
    self.zqq = self.lq.getZaiQuanZhiQi()

    # 中运气
    self.zyq = self.wy.getZhongYunZhiQi()

  # 是否天符
  def isTianFu(self):
    return self.zyq[0] == self.stq

  # 是否岁会
  def isSuiHui(self):
    return self.zyq[0] == self.gz.getYSuiqi()

  # 是否同天符: 太过的中运之气 == 在泉之气
  def isTongTianFu(self):
    if self.zyq[1] == "太":
      return self.zyq[0] == self.zqq
    return False

  # 同岁会: 不及的中运之气 == 在泉之气
  def isTongSuiHui(self):
    if self.zyq[1] == "少":
      return self.zyq[0] == self.zqq
    return False

  # 太乙天符
  def isTaiYiTianFu(self):
    return self.isTianFu() and self.isSuiHui()

  def toSimpleJson(self):
    ret = {}
    ret["year"] = self.year
    ret["ganzhi"] = self.wy.getYTD()
    ret["wuyun"] = self.wy.toSimpleJson()
    ret["liuqi"] = self.lq.toSimpleJson()
    ret["special"] = self.getYearSpecial()
    return ret

  def getYearSpecial(self):
    ret = ""
    if self.isTaiYiTianFu():
      ret += "太乙天符 "
    else:
      if self.isTianFu():
        ret += "天符 "
      if self.isSuiHui():
        ret += "岁会 "
    if self.isTongTianFu():
      ret += "同天符 "
    if self.isTongSuiHui():
      ret += "同岁会 "
    return ret.strip()

  def toString(self):
    ret = ""
    ret += str(self.year) + " " + self.wy.getYTD()
    ret += "\n"
    ret += "\n" + str(self.wy.getWuYunSanJi())
    ret += "\n"
    ret += "\n司天气: " + self.stq
    ret += "\n在泉气: " + self.zqq
    ret += "\n中运气: " + self.zyq[1] + self.zyq[0]
    ret += "\n岁支气: " + self.gz.getYSuiqi()

    ss = self.getYearSpecial()
    if len(ss) > 0:
      ret += "\n" + ss

    ret += "\n" + self.wy.toString()
    ret += "\n\n" + self.lq.toString()

    return ret