Beispiel #1
0
        /// <summary>
        /// 计算互溶关系
        /// </summary>
        /// <param name="stars"></param>
        /// <param name="isWang">是否包括旺相互溶</param>
        /// <returns></returns>
        public List<List<PublicValue.AstroStar>> GetHuRong(Star[] stars, bool isWang)
        {
            List<List<PublicValue.AstroStar>> ret = new List<List<PublicValue.AstroStar>>();
            List<PublicValue.AstroStar> checkedstar = new List<PublicValue.AstroStar>();
            foreach (Star tmpstar in stars)//遍历盘中所有星体
            {
                if ((int)tmpstar.StarName > 10)//只选取主星体
                {
                    continue;
                }
                if (checkedstar.Contains(tmpstar.StarName))//排除已排查过的星体
                {
                    continue;
                }

                checkedstar.Add(tmpstar.StarName);
                List<List<Star>> checkingstars = new List<List<Star>>();//创建当前主星体引申出的互溶链
                checkingstars.Add(new List<Star>() { tmpstar });

                while (checkingstars.Count > 0)//循环处理当前互溶链组
                {
                    List<Star> nowline = checkingstars[0];//拿出顶端链
                    List<PublicValue.AstroStar> shouhuxing = GetShouHu(checkingstars[0].Last().Constellation, isWang);//获取当前链最后星体所在星座的守护星

                    checkingstars.RemoveAt(0);
                    foreach (PublicValue.AstroStar sh in shouhuxing)//逐一处理守护星
                    {
                        checkedstar.Add(sh);//守护星加入已排查队列
                        if (sh == nowline.Last().StarName)//当前互溶链中最后一个星体入庙,排除该守护星
                        {
                            continue;
                        }
                        bool isexist = false;
                        foreach (Star tmps in nowline)//该守护星存在于互溶链中,拼出该链,加入返回列表中
                        {
                            if (tmps.StarName == sh)
                            {
                                List<PublicValue.AstroStar> tmpinput = new List<PublicValue.AstroStar>();
                                int index = nowline.IndexOf(tmps);
                                for (int i = index; i < nowline.Count; i++)
                                {
                                    tmpinput.Add(nowline[i].StarName);
                                }
                                ret.Add(tmpinput);
                                isexist = true;
                                break;
                            }
                        }
                        if (!isexist)
                        {
                            foreach (Star tmps in stars)//原互溶链中不存在该守护星,将该链完善重新加入待处理互溶链组中
                            {
                                if (tmps.StarName == sh)
                                {
                                    List<Star> tmplist = new List<Star>();
                                    foreach (Star ttmp in nowline)
                                    {
                                        tmplist.Add(ttmp);
                                    }
                                    tmplist.Add(tmps);
                                    checkingstars.Add(tmplist);
                                    break;
                                }
                            }
                        }
                    }
                }

            }

            for (int i = 0; i < ret.Count; i++)
            {
                for (int j = i + 1; j < ret.Count; j++)
                {
                    if (ret[i].Except(ret[j]).Count() == 0 && ret[j].Except(ret[i]).Count() == 0)
                    {
                        ret.RemoveAt(j);
                        j--;
                    }
                }
            }
            return ret;
        }
Beispiel #2
0
        /// <summary>
        /// 根据ID处理临时参数文件
        /// </summary>
        /// <param name="GraphicID"></param>
        public void SetParas(ref AstroMod mod, string tmpname)
        {
            if (mod.graphicID == "")
            {
                return;
            }

            string newName = tmpname;
            #region 分析文件
            if (!File.Exists(newName))
            {
                return;
            }
            StreamReader smRead = new StreamReader(newName, System.Text.Encoding.Default);
            string content = "";
            string line;
            while ((line = smRead.ReadLine()) != null)
            {
                content += line;
            }
            smRead.Dispose();
            File.Delete(newName);

            string[] regstr = new string[5];
            string p = @"YF (?<star>[\S]+?):[\s]+?(?<degree>[\S]+?)[\s]+?(?<const>[\S]+?)[\s]+?(?<cent>[\S]+?),[\s]+?[\S]+?[\s]+?[\S]+?,[\s]+?(?<progress>[\S]+?)[\s]+?";
            string varstr = "star|degree|const|cent|progress";
            string[] var = varstr.Split(new char[] { '|' });
            MatchCollection mMCollection = Regex.Matches(content, p, RegexOptions.IgnoreCase);
            if (mMCollection.Count > 1)
            {
                int i = 0;
                foreach (Match m in mMCollection)
                {
                    Astro.Star tmp_star = new Star((int)((PublicValue.AstroStar)Enum.Parse(typeof(PublicValue.AstroStar),
                        m.Groups["star"].Value.Replace("12t", "Twelveth").Replace("11t", "Eleventh").Replace("9","Nin")
                        .Replace("8","Eigh").Replace("6","Six").Replace("5","Fif").Replace("3","Thi").Replace("2","Seco"))));
                    tmp_star.Degree = int.Parse(m.Groups["degree"].Value);
                    tmp_star.Constellation = (PublicValue.Constellation)Enum.Parse(typeof(PublicValue.Constellation), m.Groups["const"].Value);
                    tmp_star.Cent = decimal.Parse(m.Groups["cent"].Value);
                    tmp_star.Progress = decimal.Parse(m.Groups["progress"].Value);
                    mod.Stars[(int)tmp_star.StarName-1] = tmp_star;
                    i++;
                }
            }

            for (int i = 0; i < mod.Stars.Length; i++)
            {
                if(mod.Stars[i]==null)
                {
                    continue;
                }
                if (mod.Stars[i].StarName == PublicValue.AstroStar.Asc)
                {
                    break;
                }
                decimal tmpdegree = Convert.ToDecimal(mod.Stars[i].Degree) + mod.Stars[i].Cent / (decimal)100 + Convert.ToDecimal(((int)mod.Stars[i].Constellation * 100));
                bool isgong = false;
                int asc = 20;
                for (int j = 0; j < mod.Stars.Length; j++)
                {
                    try
                    {
                        if (mod.Stars[j]!=null&&mod.Stars[j].StarName == PublicValue.AstroStar.Second)
                        {
                            isgong = true;
                            asc = j - 1;
                        }
                        if (isgong)
                        {

                            if ((tmpdegree <= Convert.ToDecimal(mod.Stars[j].Degree) + mod.Stars[j].Cent / (decimal)100 + Convert.ToDecimal(((int)mod.Stars[j].Constellation * 100))) &&
                                (tmpdegree >= Convert.ToDecimal(mod.Stars[j - 1].Degree) + mod.Stars[j - 1].Cent / (decimal)100 + Convert.ToDecimal(((int)mod.Stars[j - 1].Constellation * 100))))
                            {
                                mod.Stars[i].Gong = j - asc;
                                break;
                            }
                            else if (Convert.ToDecimal(mod.Stars[j].Degree) + mod.Stars[j].Cent / (decimal)100 + Convert.ToDecimal(((int)mod.Stars[j].Constellation * 100)) < Convert.ToDecimal(mod.Stars[j - 1].Degree) + mod.Stars[j - 1].Cent / (decimal)100 + Convert.ToDecimal(((int)mod.Stars[j - 1].Constellation * 100))
                                && tmpdegree <= Convert.ToDecimal(mod.Stars[j].Degree) + mod.Stars[j].Cent / (decimal)100 + Convert.ToDecimal(((int)mod.Stars[j].Constellation * 100)))
                            {
                                mod.Stars[i].Gong = j - asc;
                                break;
                            }
                            else if ((tmpdegree <= Convert.ToDecimal(mod.Stars[20].Degree) + mod.Stars[20].Cent / (decimal)100 + Convert.ToDecimal(((int)mod.Stars[20].Constellation * 100))) &&
                                (tmpdegree >= Convert.ToDecimal(mod.Stars[31].Degree) + mod.Stars[31].Cent / (decimal)100 + Convert.ToDecimal(((int)mod.Stars[31].Constellation * 100))))
                            {
                                mod.Stars[i].Gong = 12;
                                break;
                            }

                        }
                    }
                    catch
                    {
                        mod.Stars[i].Gong = 12;
                        break;
                    }
                }
            }

            #endregion
        }
Beispiel #3
0
        public int GetGongPower(Star[] stars, int gong)
        {
            int ret = 0;
            List<List<PublicValue.AstroStar>> m_hurong = GetHuRong(stars, true);
            List<PublicValue.AstroStar> m_gongzhu = GetGongMasters(stars, gong, true);//获取宫主星列表,包括第二宫主星

            Dictionary<PublicValue.AstroStar, Star> m_star = new Dictionary<PublicValue.AstroStar, Star>();
            foreach (Star nowstar in stars)
            {
                m_star.Add(nowstar.StarName, nowstar);
            }

            //金木是否落入宫内
            if (m_star[PublicValue.AstroStar.Ven].Gong == gong)
            {
                ret++;
            }
            if (m_star[PublicValue.AstroStar.Jup].Gong == gong)
            {
                ret++;
            }

            foreach (PublicValue.AstroStar tmpgongzhu in m_gongzhu)
            {
                //宫主星(非金木)与金木是否有相位
                if (tmpgongzhu != PublicValue.AstroStar.Jup && HasAnyMainPhase(m_star[PublicValue.AstroStar.Jup], m_star[tmpgongzhu]))
                {
                    ret++;
                }
                if (tmpgongzhu != PublicValue.AstroStar.Ven && HasAnyMainPhase(m_star[PublicValue.AstroStar.Ven], m_star[tmpgongzhu]))
                {
                    ret++;
                }

                //宫主星(非金木)与金木是否互溶
                foreach (List<PublicValue.AstroStar> hurong in m_hurong)
                {
                    if (tmpgongzhu != PublicValue.AstroStar.Jup)
                    {
                        if (hurong.Contains(PublicValue.AstroStar.Jup) && hurong.Contains(tmpgongzhu))
                        {
                            ret++;
                        }
                    }
                    if (tmpgongzhu != PublicValue.AstroStar.Ven)
                    {
                        if (hurong.Contains(PublicValue.AstroStar.Ven) && hurong.Contains(tmpgongzhu))
                        {
                            ret++;
                        }
                    }
                }

                //宫主星与宫内行星(非金木)是否有相位或互溶
                foreach (Star tmpstar in stars)
                {
                    if (tmpstar.Gong == gong && tmpstar.StarName != tmpgongzhu && tmpstar.StarName != PublicValue.AstroStar.Jup && tmpstar.StarName != PublicValue.AstroStar.Ven)
                    {
                        if (HasAnyMainPhase(tmpstar, m_star[tmpgongzhu]))
                        {
                            ret++;
                        }
                        foreach (List<PublicValue.AstroStar> hurong in m_hurong)
                        {
                            if (hurong.Contains(tmpstar.StarName) && hurong.Contains(tmpgongzhu))
                            {
                                ret++;
                            }
                        }
                    }
                }

                //宫主星落在本宫内
                if (m_star[tmpgongzhu].Gong == gong)
                {
                    ret++;
                }
            }
            return ret;
        }
Beispiel #4
0
 /// <summary>
 /// 获取宫主星
 /// </summary>
 /// <param name="stars"></param>
 /// <param name="gong"></param>
 /// <returns></returns>
 public List<PublicValue.AstroStar> GetGongMasters(Star[] stars,int gong,bool second)
 {
     List<PublicValue.AstroStar> ret = new List<PublicValue.AstroStar>();
     List<PublicValue.AstroStar> tmp = new List<PublicValue.AstroStar>();
     int gongafter = gong+1;
         if(gongafter==13)
         {
             gongafter=1;
         }
     int gongconst = 0;
     foreach (Star tmpstar in stars)
     {
         if ((int)tmpstar.StarName == gong + 20)
         {
             gongconst = (int)tmpstar.Constellation;
             tmp = GetShouHu(tmpstar.Constellation,false);
             foreach (PublicValue.AstroStar tmps in tmp)
             {
                 ret.Add(tmps);
             }
         }
     }
     foreach (Star tmpstar in stars)
     {
         //劫夺
         if ((int)tmpstar.StarName == gongafter + 20)
         {
             if ((int)tmpstar.Constellation - gongconst == 2 || (int)tmpstar.Constellation - gongconst == -10)
             {
                 int gongplus = gongconst + 1;
                 if (gongplus == 13)
                 {
                     gongplus = 1;
                 }
                 tmp = GetShouHu((PublicValue.Constellation)(gongplus), false);
                 foreach (PublicValue.AstroStar tmps in tmp)
                 {
                     ret.Add(tmps);
                 }
             }
         }
     }
     ret = ret.Distinct().ToList();
     return ret;
 }
Beispiel #5
0
        public bool HasPhase(Star a, Star b, PublicValue.Phase phase, decimal offset)
        {
            if (offset == AppConst.DecimalNull)
            {
                switch (phase)
                {
                    case PublicValue.Phase.he:
                        offset = 10;
                        break;
                    case PublicValue.Phase.xing:
                        offset = 8;
                        break;
                    case PublicValue.Phase.chong:
                        offset = 8;
                        break;
                    case PublicValue.Phase.gong:
                        offset = 8;
                        break;
                    case PublicValue.Phase.bangong:
                        offset = 5;
                        break;
                }
            }

            decimal degreeA = ((int)a.Constellation-1) * 30 + a.Degree + a.Cent / 60;
            decimal degreeB = ((int)b.Constellation-1) * 30 + b.Degree + b.Cent / 60;

            decimal angle = Math.Abs(degreeA - degreeB);
            if (angle > 180)
            {
                angle = 360 - angle;
            }

            if (angle <= offset + (int)phase && angle >= (int)phase - offset)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Beispiel #6
0
 public bool HasAnyMainPhase(Star a, Star b, decimal offset)
 {
     if (HasPhase(a, b, PublicValue.Phase.he, offset)
         || (HasPhase(a, b, PublicValue.Phase.chong, offset) && !((int)a.StarName > 20 && (int)a.StarName < 33) && !((int)b.StarName > 20 && (int)b.StarName < 33))
         || (HasPhase(a, b, PublicValue.Phase.xing, offset) && !((int)a.StarName > 20 && (int)a.StarName < 33) && !((int)b.StarName > 20 && (int)b.StarName < 33))
         || (HasPhase(a, b, PublicValue.Phase.gong, offset) && !((int)a.StarName > 20 && (int)a.StarName < 33) && !((int)b.StarName > 20 && (int)b.StarName < 33))
         || (HasPhase(a, b, PublicValue.Phase.bangong, offset) && !((int)a.StarName > 20 && (int)a.StarName < 33) && !((int)b.StarName > 20 && (int)b.StarName < 33)))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Beispiel #7
0
 /// <summary>
 /// 是否有任何主相位,0,60,90,120,180,四轴只判定合相
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public bool HasAnyMainPhase(Star a, Star b)
 {
     if (HasPhase(a, b, PublicValue.Phase.he, AppConst.DecimalNull)
         || (HasPhase(a, b, PublicValue.Phase.chong, AppConst.DecimalNull) && !((int)a.StarName > 20 && (int)a.StarName < 33) && !((int)b.StarName > 20 && (int)b.StarName < 33))
         || (HasPhase(a, b, PublicValue.Phase.xing, AppConst.DecimalNull) && !((int)a.StarName > 20 && (int)a.StarName < 33) && !((int)b.StarName > 20 && (int)b.StarName < 33))
         || (HasPhase(a, b, PublicValue.Phase.gong, AppConst.DecimalNull) && !((int)a.StarName > 20 && (int)a.StarName < 33) && !((int)b.StarName > 20 && (int)b.StarName < 33))
         || (HasPhase(a, b, PublicValue.Phase.bangong, AppConst.DecimalNull) && !((int)a.StarName > 20 && (int)a.StarName < 33) && !((int)b.StarName > 20 && (int)b.StarName < 33)))
     {
         return true;
     }
     else
     {
         return false;
     }
 }