/// <summary> /// 可以没有天干,但必须有地支。 /// </summary> /// <param name="gan"></param> /// <param name="zhi"></param> public GanZhi(string gan, string zhi) { this.Gan = Gan.Get(gan); this.Zhi = Zhi.Get(zhi); this.ValidCheck(); }
public GanZhi(int gan, int zhi) { this.Gan = Gan.Get(gan); this.Zhi = Zhi.Get(zhi); this.ValidCheck(); }
static Gan() { instances = new Gan[BaseDef.Gans.Length]; for (int idx = 0; idx < instances.Length; idx++) { instances[idx] = new Gan(idx, BaseDef.Gans[idx]); } }
public string 长生(Gan gan) { var index = gan.长生.Index; var direction = (gan.Index % 2 == 0) ? 1 : -1; for (var i = 0; i < 12; i++) { var izhi = (index + i * direction + 12) % 12; if (izhi == this.Index) { return(BaseDef.ChangSheng[i]); } } return("计算长生十二宫出错"); }
public GanZhi(string name) { string g = string.Empty; string z = string.Empty; if (string.IsNullOrEmpty(name) || name.Length > 2) { this.Gan = Gan.Zero; this.Zhi = Zhi.Zero; } else if (name.Length == 1) { this.Gan = Gan.Zero; this.Zhi = Zhi.Get(name); } else { this.Gan = Gan.Get(name.Substring(0, 1)); this.Zhi = Zhi.Get(name.Substring(1, 1)); } this.ValidCheck(); }
public static string Calc10(Gan me, IBase other, bool shortname = false) { bool indextest = true; if (other.GetType() == typeof(Gan)) { indextest = me.Index % 2 == other.Index % 2; } else if (other.GetType() == typeof(Zhi)) { indextest = me.Index % 2 != other.Index % 2; } if (me.五行.克 == other.五行) { if (me.Index % 2 == other.Index % 2) { return(!shortname ? "正财" : "财"); } else { return(!shortname ? "偏财" : "才"); } } else if (other.五行.克 == me.五行) { if (me.Index % 2 == other.Index % 2) { return(!shortname ? "七杀" : "杀"); } else { return(!shortname ? "正官" : "官"); } } else if (me.五行.生 == other.五行) { if (indextest) { return(!shortname ? "食神" : "食"); } else { return(!shortname ? "伤官" : "伤"); } } else if (other.五行.生 == me.五行) { if (indextest) { return(!shortname ? "枭神" : "枭"); } else { return(!shortname ? "正印" : "印"); } } else if (other.五行 == me.五行) { if (me.Index % 2 == other.Index % 2) { return(!shortname ? "比肩" : "比"); } else { return(!shortname ? "劫财" : "劫"); } } return(string.Empty); }