Exemple #1
0
        private GroupType CopyType(List <s_type> source)
        {
            GroupType ret = new GroupType();

            for (int i = 0; i < source.Count; i++)
            {
                ret.Add(source[i]);
            }

            return(ret);
        }
Exemple #2
0
        private void AddTypeExposed(PlayerData p, GroupType gtmp)
        {
            List <Group> tmp = p.GetExposed();

            for (int i = 0; i < tmp.Count; i++)
            {
                Group  grotmp = tmp[i].Clone();
                s_type st     = new s_type();

                grotmp.Remove(grotmp[0]);

                st.Group   = tmp[i];
                st.exposed = true;
                st.Type    = e_type.Single;
                if (IsChow(grotmp, tmp[i][0], 0).Count > 0)
                {
                    st.Type = e_type.Chow;
                }
                if (IsChow(grotmp, tmp[i][0], 1).Count > 0)
                {
                    st.Type = e_type.Chow;
                }
                if (IsChow(grotmp, tmp[i][0], 2).Count > 0)
                {
                    st.Type = e_type.Chow;
                }
                if (IsSimilar(grotmp, tmp[i][0], 3).Count > 0)
                {
                    st.Type = e_type.Kong;
                }
                if (st.Type == e_type.Single)
                {
                    if (IsSimilar(grotmp, tmp[i][0], 2).Count > 0)
                    {
                        st.Type = e_type.Pong;
                    }
                }
                if (st.Type != e_type.Single)
                {
                    gtmp.Add(st);
                }
            }
        }
Exemple #3
0
        private bool RecurMah(Group hand, GroupType types)
        {
            if (hand.Count == 0)
            {
                m_results.Add(types);
                return(true);
            }
            Group gtmp = hand.Clone();

            Tile tiletmp = gtmp[0];

            gtmp.Remove(tiletmp);

            #region Kong

            Group kong = IsSimilar(gtmp, tiletmp, 3);
            if (kong.Count > 0)
            {
                Group insgtmp = gtmp.Clone();
                insgtmp.Remove(kong[0]);
                insgtmp.Remove(kong[1]);
                insgtmp.Remove(kong[2]);
                GroupType ttmp = CopyType(types);
                s_type    tmp  = new s_type();
                tmp.exposed = false;
                tmp.Type    = e_type.Kong;
                tmp.Group   = kong;
                ttmp.Add(tmp);
                RecurMah(insgtmp, ttmp);
            }

            #endregion

            #region Pong

            Group pong = IsSimilar(gtmp, tiletmp, 2);
            if (pong.Count > 0)
            {
                Group insgtmp = gtmp.Clone();
                insgtmp.Remove(pong[0]);
                insgtmp.Remove(pong[1]);
                GroupType ttmp = CopyType(types);
                s_type    tmp  = new s_type();
                tmp.exposed = false;
                tmp.Type    = e_type.Pong;
                tmp.Group   = pong;
                ttmp.Add(tmp);
                RecurMah(insgtmp, ttmp);
            }

            #endregion

            #region Chow

            Group chow1 = IsChow(gtmp, tiletmp, 1);
            if (chow1.Count > 0)
            {
                Group insgtmp = gtmp.Clone();
                insgtmp.Remove(chow1[0]);
                insgtmp.Remove(chow1[1]);
                GroupType ttmp = CopyType(types);
                s_type    tmp  = new s_type();
                tmp.exposed = false;
                tmp.Type    = e_type.Chow;
                tmp.Group   = chow1;
                ttmp.Add(tmp);
                RecurMah(insgtmp, ttmp);
            }

            Group chow2 = IsChow(gtmp, tiletmp, 2);
            if (chow2.Count > 0)
            {
                Group insgtmp = gtmp.Clone();
                insgtmp.Remove(chow2[0]);
                insgtmp.Remove(chow2[1]);
                GroupType ttmp = CopyType(types);
                s_type    tmp  = new s_type();
                tmp.exposed = false;
                tmp.Type    = e_type.Chow;
                tmp.Group   = chow2;
                ttmp.Add(tmp);
                RecurMah(insgtmp, ttmp);
            }

            Group chow3 = IsChow(gtmp, tiletmp, 3);
            if (chow3.Count > 0)
            {
                Group insgtmp = gtmp.Clone();
                insgtmp.Remove(chow3[0]);
                insgtmp.Remove(chow3[1]);
                GroupType ttmp = CopyType(types);
                s_type    tmp  = new s_type();
                tmp.exposed = false;
                tmp.Type    = e_type.Chow;
                tmp.Group   = chow3;
                ttmp.Add(tmp);
                RecurMah(insgtmp, ttmp);
            }

            #endregion

            #region Pair

            Group doublee = IsSimilar(gtmp, tiletmp, 1);
            if (doublee.Count > 0)
            {
                Group insgtmp = gtmp.Clone();
                insgtmp.Remove(doublee[0]);
                GroupType ttmp = CopyType(types);
                s_type    tmp  = new s_type();
                tmp.exposed = false;
                tmp.Type    = e_type.Double;
                tmp.Group   = doublee;
                ttmp.Add(tmp);
                RecurMah(insgtmp, ttmp);
            }

            #endregion

            #region Single

            Group single = IsSingle(gtmp, tiletmp);
            if (single.Count > 0)
            {
                GroupType ttmp = CopyType(types);
                s_type    tmp  = new s_type();
                tmp.exposed = false;
                tmp.Type    = e_type.Single;
                tmp.Group   = single;
                ttmp.Add(tmp);
                RecurMah(gtmp, ttmp);
            }

            #endregion

            return(false);
        }