Пример #1
0
        public void showGreenplaces(int i, int j, PictureBox[] pics)
        {
            Node <Point> np   = null;
            Point        pos  = new Point(i, j);
            List <Point> lst2 = new List <Point>();
            Point        pt   = new Point();
            knight       r1   = new knight(pos, mat, pics, playernum, kingplaces, kings, rooks);

            if (playernum == -1)
            {
                pt = kingplaces[0];
            }
            else
            {
                pt = kingplaces[1];
            }
            king k = new king(pt, mat, picbox, playernum, kings, rooks);
            bool t = k.deathofking(pt.X, pt.Y, mat, picbox, kings, rooks, playernum * -1);

            try
            {
                lst2 = r1.placestomove();
                Point pp = lst2.GetFirst().GetInfo();
                np = lst2.GetFirst();
            }
            catch (Exception)
            {
            }

            int[,] help = new int[8, 8];
            for (int ii = 0; ii < 8; ii++)
            {
                for (int jj = 0; jj < 8; jj++)
                {
                    help[ii, jj] = mat[ii, jj];
                }
            }

            while (np != null)
            {
                int x = np.GetInfo().X;
                int y = np.GetInfo().Y;
                int n = x * 10 + y - 2 * x;
                int v = help[x, y];
                help[x, y] = playernum;
                if (k.toking(pt.X, pt.Y, help, picbox, playernum * -1) == new Point(-1, -1))
                {
                    pics[n].BackColor = Color.Green;
                    pics[n].Enabled   = true;
                    pics[n].Visible   = true;
                }
                else
                {
                    pics[n].BackColor = Color.Red;
                    pics[n].Enabled   = false;
                    pics[n].Visible   = true;
                }
                help[x, y] = v;
                np         = np.GetNext();
            }
        }
Пример #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);
        }