Esempio n. 1
0
        public void shah(int x, int y, PictureBox[] pics, int[,] mat, int playernum)
        {
            king         k   = new king(new Point(x, y), mat, picbox, playernum, kings, rooks);
            List <Point> lst = k.helping(playernum * -1, mat, x, y, picbox, kings, rooks);
            Node <Point> pos = lst.GetFirst();

            for (int i = 0; i < 64; i++)
            {
                if (picbox[i].BackColor == Color.Green)
                {
                    picbox[i].Enabled = true;
                }
                else
                {
                    picbox[i].Enabled = false;
                }
            }
            while (pos != null)
            {
                picbox[pos.GetInfo().X * 10 + pos.GetInfo().Y - 2 * pos.GetInfo().X].Enabled = true;
                pos = pos.GetNext();
            }

            picbox[x * 10 + y - 2 * x].Enabled = true;

            MessageBox.Show("shaaaaaaaaaaaaaaaaaaaa7");
        }
Esempio n. 2
0
        void gooo(int x, int y)
        {
            game_main.loss = 0;
            if (playernum == 1)
            {
                timer1.Start();
            }
            else
            {
                timer2.Start();
            }

            if (flage == true)
            {
                canx  = x;
                cany  = y;
                flage = false;
            }
            if (steps == 40)
            {
                for (int i = 0; i < 64; i++)
                {
                    picbox[i].Enabled = false;
                }
                MessageBox.Show("equality ");
                result = "drow";
                winer  = 3;
            }

            game_main      pppp = new game_main();
            computerplayer comp = new computerplayer();

            if (picbox[x * 10 + y - 2 * x].BackColor == Color.Green || picbox[x * 10 + y - 2 * x].BackColor == Color.Yellow)
            {
                pppp.IFgreenmovelastItem(lastclick, picbox, mat, x, y, pppp.chessimage(mat[lastclick.X, lastclick.Y]), kings, rooks, kingsplace);
                setlosser();
                if (game_main.loss > 0)
                {
                    lossb += game_main.loss + ",";
                }
                else if (game_main.loss != 0)
                {
                    lossw += game_main.loss + ",";
                }

                history(x, y, canx, cany);
                flage = true;

                pppp.refreshcolors(picbox, playernum, mat);
                if (Form2.justkings(mat) == true)
                {
                    steps++;
                }

                playernum = playernum * -1;

                pppp.playerrole(playernum, picbox, mat);
            }
            else
            {
                pppp.refreshcolors(picbox, playernum, mat);

                Wathitem(x, y);
            }
            if (playernum == 1)
            {
                timer1.Stop();
                timer2.Start();
            }
            else
            {
                timer2.Stop();
                timer1.Start();
            }


            int   x1 = kingsplace[0].X;
            int   y1 = kingsplace[0].Y;
            int   x2 = kingsplace[1].X;
            int   y2 = kingsplace[1].Y;
            Point kp = new Point(-1, -1);
            king  k1 = new king(new Point(x1, y1), mat, picbox, playernum, kings, rooks);
            king  k2 = new king(new Point(x2, y2), mat, picbox, playernum, kings, rooks);

            if (k1.toking(x1, y1, mat, picbox, 1) != new Point(-1, -1))
            {
                k1.redtoging(new Point(x1, y1), picbox, -1);
            }
            if (k2.toking(x2, y2, mat, picbox, -1) != new Point(-1, -1))
            {
                k2.redtoging(new Point(x2, y2), picbox, 1);
            }
            if (k1.toking(x1, y1, mat, picbox, 1) != new Point(-1, -1) && playernum == -1)
            {
                k1.shah(x1, y1, picbox, mat, -1);
            }
            if (k2.toking(x2, y2, mat, picbox, -1) != new Point(-1, -1) && playernum == 1)
            {
                k2.shah(x2, y2, picbox, mat, 1);
            }

            if (k1.deathofking(x1, y1, mat, picbox, kings, rooks, 1) == true)
            {
                if (k1.helping(1, mat, x1, y1, picbox, kings, rooks).IsEmpty() == true)
                {
                    timer1.Stop();
                    timer2.Stop();
                    k1.shahmeet("wihte lose!");
                    result = "1";
                    winer  = 1;
                }
            }



            if (k2.deathofking(x2, y2, mat, picbox, kings, rooks, -1) == true)
            {
                if (k2.helping(-1, mat, x2, y2, picbox, kings, rooks).IsEmpty() == true)
                {
                    timer1.Stop();
                    timer2.Stop();
                    k2.shahmeet("blcak lose!");
                    result = "-1";
                    winer  = -1;
                }
            }


            lastclick = new Point(x, y);
        }