コード例 #1
0
        public FuDeGong GetResult(PaiPan pan)
        {
            FuDeGong result = base.GetResult <FuDeGong>(pan, GongIndex.福德宫, 0);

            //主星
            foreach (var xing in result.ZhuXing)
            {
                if (pan.IsMale)
                {
                    xing.Content = dal.s12.Find(x => x.id == xing.Id.ToString()).jiexinan;
                }
                else
                {
                    xing.Content = dal.s12.Find(x => x.id == xing.Id.ToString()).jiexinu;
                }
            }

            //吉星
            foreach (var xing in result.JiXing)
            {
                xing.Content = dal.s12.Find(x => x.id == xing.Id.ToString()).jiexinan;
            }

            //凶星
            foreach (var xing in result.XiongXing)
            {
                xing.Content = dal.s12.Find(x => x.id == xing.Id.ToString()).jiexinan;
            }

            if (result.ZhuXing.Count == 2)
            {
                var shuang = dal.s12.Find(x => x.id == string.Format("{0}#{1}", result.ZhuXing[0].Id, result.ZhuXing[1].Id));
                result.ShuangZhuXing = pan.IsMale ? shuang.jiexinan : shuang.jiexinu;
            }

            base.GetJiXiong <FuDeGong>(result);

            result.DaShi = DaShisWords.GetDaShi(result, dal);

            return(result);
        }
コード例 #2
0
ファイル: GongAnalyzer.cs プロジェクト: snamper/ZW
        public T GetResult <T>(PaiPan pan, GongIndex gong_idx, int index_of_s2) where T : BasicGong, new()
        {
            T model = new T();

            #region 宫位信息初始化

            //三方四正
            model.SelfGong = pan.Gongs.First(g => g.Name == gong_idx.ToString());

            int dui = (model.SelfGong.Zhi + 6) % 12;
            if (dui == 0)
            {
                dui = 12;
            }
            else if (dui < 0)
            {
                dui += 12;
            }

            int hui1 = (model.SelfGong.Zhi + 4) % 12;
            if (hui1 == 0)
            {
                hui1 = 12;
            }
            else if (hui1 < 0)
            {
                hui1 += 12;
            }


            int hui2 = (model.SelfGong.Zhi - 4) % 12;
            if (hui2 == 0)
            {
                hui2 = 12;
            }
            else if (hui2 < 0)
            {
                hui2 += 12;
            }

            model.DuiZhaoGong = pan.Gongs[dui - 1];
            model.HuiGongs.Add(pan.Gongs[hui1 - 1]);
            model.HuiGongs.Add(pan.Gongs[hui2 - 1]);


            //主星
            var zhuxing = model.SelfGong.Stars.Where(s => dal.Dic_ZhuXing.ContainsKey(s.Name)).ToList();
            if (zhuxing.Count == 0)
            {
                model.isJieXing = true;
                zhuxing         = model.DuiZhaoGong.Stars.Where(s => dal.Dic_ZhuXing.ContainsKey(s.Name)).ToList(); //借星
            }

            foreach (var item in zhuxing)
            {
                model.ZhuXing.Add(new Xing(item, dal.Dic_ZhuXing[item.Name].id, Position.坐宫));
            }


            //吉星
            foreach (var item in model.SelfGong.Stars.Where(s => dal.Dic_JiXing.ContainsKey(s.Name)).ToList())
            {
                model.JiXing.Add(new Xing(item, dal.Dic_JiXing[item.Name].id, Position.坐宫));
            }

            foreach (var item in model.DuiZhaoGong.Stars.Where(s => dal.Dic_JiXing.ContainsKey(s.Name)).ToList())
            {
                model.JiXing.Add(new Xing(item, dal.Dic_JiXing[item.Name].id, Position.对照));
            }

            foreach (var gong in model.HuiGongs)
            {
                foreach (var item in gong.Stars.Where(s => dal.Dic_JiXing.ContainsKey(s.Name)).ToList())
                {
                    model.JiXing.Add(new Xing(item, dal.Dic_JiXing[item.Name].id, Position.加会));
                }
            }


            //凶星
            foreach (var item in model.SelfGong.Stars.Where(s => dal.Dic_XiongXing.ContainsKey(s.Name)).ToList())
            {
                model.XiongXing.Add(new Xing(item, dal.Dic_XiongXing[item.Name].id, Position.坐宫));
            }

            foreach (var item in model.DuiZhaoGong.Stars.Where(s => dal.Dic_XiongXing.ContainsKey(s.Name)).ToList())
            {
                model.XiongXing.Add(new Xing(item, dal.Dic_XiongXing[item.Name].id, Position.对照));
            }

            foreach (var gong in model.HuiGongs)
            {
                foreach (var item in gong.Stars.Where(s => dal.Dic_XiongXing.ContainsKey(s.Name)).ToList())
                {
                    model.XiongXing.Add(new Xing(item, dal.Dic_XiongXing[item.Name].id, Position.加会));
                }
            }

            #endregion

            //宫位
            model.GongWei = string.Format("【{0}在{1}】", gong_idx.ToString(), model.SelfGong.ZhiString) + dal.s11[model.SelfGong.Zhi - 1].items[gong_idx.GetHashCode()];


            //主星四化
            foreach (var item in model.ZhuXing.Where(x => !string.IsNullOrEmpty(x.Star.Hua)))
            {
                switch (item.Star.Hua)
                {
                case "禄":
                    item.HuaContent = dal.s4.Find(x => x.id == item.Id).items[gong_idx.GetHashCode()];
                    break;

                case "权":
                    item.HuaContent = dal.s5.Find(x => x.id == item.Id).items[gong_idx.GetHashCode()];
                    break;

                case "科":
                    item.HuaContent = dal.s6.Find(x => x.id == item.Id).items[gong_idx.GetHashCode()];
                    break;

                case "忌":
                    item.HuaContent = dal.s7.Find(x => x.id == item.Id).items[gong_idx.GetHashCode()];
                    break;
                }
            }

            foreach (var item in model.JiXing.Where(x => !string.IsNullOrEmpty(x.Star.Hua)))
            {
                switch (item.Star.Hua)
                {
                case "禄":
                    item.HuaContent = dal.s4.Find(x => x.id == item.Id).items[gong_idx.GetHashCode()];
                    break;

                case "权":
                    item.HuaContent = dal.s5.Find(x => x.id == item.Id).items[gong_idx.GetHashCode()];
                    break;

                case "科":
                    item.HuaContent = dal.s6.Find(x => x.id == item.Id).items[gong_idx.GetHashCode()];
                    break;

                case "忌":
                    item.HuaContent = dal.s7.Find(x => x.id == item.Id).items[gong_idx.GetHashCode()];
                    break;
                }
            }


            //四化(不只主星)
            foreach (var item in model.DuiZhaoGong.Stars.Where(x => !string.IsNullOrEmpty(x.Hua)))
            {
                model.Hua.Add(new Hua(item.Name, (HuaType)Enum.Parse(typeof(HuaType), item.Hua, false), Position.对照));
            }

            foreach (var item in model.SelfGong.Stars.Where(x => !string.IsNullOrEmpty(x.Hua)))
            {
                model.Hua.Add(new Hua(item.Name, (HuaType)Enum.Parse(typeof(HuaType), item.Hua, false), Position.坐宫));
            }

            foreach (var item in model.HuiGongs[0].Stars.Where(x => !string.IsNullOrEmpty(x.Hua)))
            {
                model.Hua.Add(new Hua(item.Name, (HuaType)Enum.Parse(typeof(HuaType), item.Hua, false), Position.加会));
            }

            foreach (var item in model.HuiGongs[1].Stars.Where(x => !string.IsNullOrEmpty(x.Hua)))
            {
                model.Hua.Add(new Hua(item.Name, (HuaType)Enum.Parse(typeof(HuaType), item.Hua, false), Position.加会));
            }


            //福德则直接返回
            if (gong_idx == GongIndex.福德宫)
            {
                return(model);
            }


            //主星
            foreach (var xing in model.ZhuXing)
            {
                xing.Content = dal.s2[xing.Id].items[index_of_s2];
            }

            //吉星
            foreach (var xing in model.JiXing)
            {
                xing.Content = dal.s2[xing.Id].items[index_of_s2];
            }

            //凶星
            foreach (var xing in model.XiongXing)
            {
                xing.Content = dal.s2[xing.Id].items[index_of_s2];
            }


            GetJiXiong <T>(model);

            model.DaShi = DaShisWords.GetDaShi(model, dal);

            return(model);
        }