Пример #1
0
 public bool Wincheck(int a)
 {
     for (int i = 0; i < 3; i++)
     {
         if (_MangOco[0, i].Sohuu == a && _MangOco[1, i].Sohuu == a && _MangOco[2, i].Sohuu == a)
         {
             if (a == 1)
             {
                 _ketthuc = Ketthuc.Player;
             }
             else if (a == 2)
             {
                 _ketthuc = Ketthuc.Com;
             }
             return(true);
         }
         if (_MangOco[i, 0].Sohuu == a && _MangOco[i, 1].Sohuu == a && _MangOco[i, 2].Sohuu == a)
         {
             if (a == 1)
             {
                 _ketthuc = Ketthuc.Player;
             }
             else if (a == 2)
             {
                 _ketthuc = Ketthuc.Com;
             }
             return(true);
         }
     }
     if (_MangOco[0, 0].Sohuu == a && _MangOco[1, 1].Sohuu == a && _MangOco[2, 2].Sohuu == a)
     {
         if (a == 1)
         {
             _ketthuc = Ketthuc.Player;
         }
         else if (a == 2)
         {
             _ketthuc = Ketthuc.Com;
         }
         return(true);
     }
     if (_MangOco[0, 2].Sohuu == a && _MangOco[1, 1].Sohuu == a && _MangOco[2, 0].Sohuu == a)
     {
         if (a == 1)
         {
             _ketthuc = Ketthuc.Player;
         }
         else if (a == 2)
         {
             _ketthuc = Ketthuc.Com;
         }
         return(true);
     }
     return(false);
 }
Пример #2
0
        public int KiemtraChienThang(Oco[,] _Mangoco)
        {
            if (Stack_CacNuocDaDi.Count == _BanCo.SoCot * _BanCo.SoDong)
            {
                _ketthuc = Ketthuc.Hoaco;
                return 0;
            }
            foreach (Oco item in Stack_CacNuocDaDi)
            {
                if (DuyetDoc(item.Dong, item.Cot, item.SoHuu) == 5)
                {
                    if (item.SoHuu == 1)
                        _ketthuc = Ketthuc.Man1;
                    if (item.SoHuu == 2)
                        _ketthuc = Ketthuc.Man2;
                    if (item.SoHuu == 3)
                        _ketthuc = Ketthuc.Com;
                    return true;
                }
                if (DuyetNgang(item.Dong, item.Cot, item.SoHuu) == 5)
                {
                    if (item.SoHuu == 1)
                        _ketthuc = Ketthuc.Man1;
                    if (item.SoHuu == 2)
                        _ketthuc = Ketthuc.Man2;
                    if (item.SoHuu == 3)
                        _ketthuc = Ketthuc.Com;

                    return true;
                }
                if (DuyetCheoXuoi(item.Dong, item.Cot, item.SoHuu) == 5)
                {
                    if (item.SoHuu == 1)
                        _ketthuc = Ketthuc.Man1;
                    if (item.SoHuu == 2)
                        _ketthuc = Ketthuc.Man2;
                    if (item.SoHuu == 3)
                        _ketthuc = Ketthuc.Com;

                    return true;
                }
                if (DuyetCheoNguoc(item.Dong, item.Cot, item.SoHuu) == 5)
                {
                    if (item.SoHuu == 1)
                        _ketthuc = Ketthuc.Man1;
                    if (item.SoHuu == 2)
                        _ketthuc = Ketthuc.Man2;
                    if (item.SoHuu == 3)
                        _ketthuc = Ketthuc.Com;

                    return true;
                }
            }
            return false;
        }
Пример #3
0
        public bool kiemtra_thangthua()
        {
            if (stackCacnuocdadi.Count == Banco.Socot * Banco.Sodong)
            {
                ketthuc = Ketthuc.Hoa;

                return(true);
            }
            foreach (oCo oco in stackCacnuocdadi)
            {
                if (duyetdoc(oco.Dong, oco.Cot, oco.Sohuu) || duyetngang(oco.Dong, oco.Cot, oco.Sohuu) || duyetcheoxuoi(oco.Dong, oco.Cot, oco.Sohuu) || duyetcheonguoc(oco.Dong, oco.Cot, oco.Sohuu))
                {
                    ketthuc = oco.Sohuu == 1 ? Ketthuc.Ps1 : Ketthuc.Ps2;
                    return(true);
                }
            }
            return(false);
        }
Пример #4
0
 public bool Hoa()
 {
     if (Wincheck(0) || Wincheck(1))
     {
         return(false);
     }
     for (int i = 0; i < 3; i++)
     {
         for (int j = 0; j < 3; j++)
         {
             if (_MangOco[i, j].Sohuu == 0)
             {
                 return(false);
             }
         }
     }
     _ketthuc = Ketthuc.Hoa;
     return(true);
 }