Exemplo n.º 1
0
        void getlossers(int[] a)
        {
            int       c1 = 0, c2 = 0;
            game_main pppp = new game_main();

            PictureBox[] picbox1 = { pp1, pp2, pp3, pp4, pp5, pp6, pp7, pp8, pp9, pp10, pp11, pp12, pp13, pp14, pp15, pp16 };
            PictureBox[] picbox2 = { pw1, pw2, pw3, pw4, pw5, pw6, pw7, pw8, pw9, pw10, pw11, pw12, pw13, pw14, pw15, pw16 };
            for (int ii = 0; ii < 32; ii++)
            {
                if (a[ii] > 0)
                {
                    if (picbox1[c1].Image == null)
                    {
                        picbox1[c1].ImageLocation = pppp.chessimage(a[ii]);
                        picbox1[c1].SizeMode      = PictureBoxSizeMode.CenterImage;
                        c1++;
                    }
                }
                else if (a[ii] < 0)
                {
                    if (picbox2[c2].Image == null)
                    {
                        picbox2[c2].ImageLocation = pppp.chessimage(a[ii]);
                        picbox2[c2].SizeMode      = PictureBoxSizeMode.CenterImage;

                        c2++;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void setlosser()
        {
            PictureBox[] picbox3 = { pp1, pp2, pp3, pp4, pp5, pp6, pp7, pp8, pp9, pp10, pp11, pp12, pp13, pp14, pp15, pp16 };
            PictureBox[] picbox4 = { pw1, pw2, pw3, pw4, pw5, pw6, pw7, pw8, pw9, pw10, pw11, pw12, pw13, pw14, pw15, pw16 };

            game_main pppp = new game_main();

            for (int i = 0; i < 16; i++)
            {
                if (game_main.loss > 0)
                {
                    if (picbox3[i].Image == null)
                    {
                        picbox3[i].ImageLocation = pppp.chessimage(game_main.loss);
                        picbox3[i].SizeMode      = PictureBoxSizeMode.CenterImage;

                        break;
                    }
                }
                else if (game_main.loss < 0)
                {
                    if (picbox4[i].Image == null)
                    {
                        picbox4[i].ImageLocation = pppp.chessimage(game_main.loss);
                        picbox4[i].SizeMode      = PictureBoxSizeMode.CenterImage;
                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
        //רוזמרין   اقليل الجبل

        public void Filllist(int n, Point[] pt, List <Point>[] lpt)
        {
            if (n >= 0)
            {
                List <Point> lst = new List <Point>();
                Node <Point> np1 = lst.GetFirst();
                Point        pp  = pt[n - 1];
                int          x   = pp.X;
                int          y   = pp.Y;
                if (mat[x, y] * playernum > 0)//>
                {
                    switch (mat[x, y])
                    {
                    case 1:
                    case -1: Pawn p2 = new Pawn(new Point(x, y), mat, picbox, playernum, kingsplace, kings, rooks);
                        p2.showGreenplaces(x, y, picbox); break;

                    case 2:
                    case -2: rook r2 = new rook(new Point(x, y), mat, picbox, playernum, kingsplace, kings, rooks);
                        r2.showGreenplaces(x, y, picbox); break;

                    case 3:
                    case -3: knight kn2 = new knight(new Point(x, y), mat, picbox, playernum, kingsplace, kings, rooks);
                        kn2.showGreenplaces(x, y, picbox); break;

                    case 4:
                    case -4: fou f2 = new fou(new Point(x, y), mat, picbox, playernum, kingsplace, kings, rooks);
                        f2.showGreenplaces(x, y, picbox); break;

                    case 5:
                    case -5: queen q2 = new queen(new Point(x, y), mat, picbox, playernum, kingsplace, kings, rooks);
                        q2.showGreenplaces(x, y, picbox); break;

                    case -6: king k2 = new king(new Point(x, y), mat, picbox, playernum, kings, rooks);
                        k2.showGreenplaces(x, y, picbox); break;

                    default: break;
                    }

                    for (int i = 0; i < 8; i++)
                    {
                        for (int j = 0; j < 8; j++)
                        {
                            if (picbox[i * 10 + j - 2 * i].BackColor == Color.Green)
                            {
                                np1 = lst.Insert(np1, new Point(i, j));
                            }
                        }
                    }
                    game_main gm = new game_main();
                    gm.refreshcolors(picbox, playernum, mat);
                }
                lpt[n - 1] = lst;
                if (n > 1)
                {
                    Filllist(n - 1, pt, lpt);
                }
            }
        }
Exemplo n.º 4
0
        private void p00_Click(object sender, EventArgs e)
        {
            game_main pppp = new game_main();


            int x = 0, y = 0;

            gooo(x, y);
        }
Exemplo n.º 5
0
        //داله تعيد عدد الاماكن الخضراء
        public int count_greenplace() //good
        {
            int count = 0;

            int[,] help = new int[8, 8];
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    help[i, j] = mat[i, j];
                }
            }
            help[after.X, after.Y] = help[befor.X, befor.Y];
            help[befor.X, befor.Y] = 0;
            game_main aaa = new game_main();

            aaa.refreshcolors(picbox, playernum, mat);
            switch (help[after.X, after.Y])
            {
            case 1:
            case -1: Pawn p2 = new Pawn(after, help, picbox, playernum, kingsplace, kings, rooks);
                p2.showGreenplaces(after.X, after.Y, picbox);  break;

            case 2:
            case -2: rook r2 = new rook(after, help, picbox, playernum, kingsplace, kings, rooks);
                r2.showGreenplaces(after.X, after.Y, picbox);  break;

            case 3:
            case -3: knight kn2 = new knight(after, help, picbox, playernum, kingsplace, kings, rooks);
                kn2.showGreenplaces(after.X, after.Y, picbox); break;

            case 4:
            case -4: fou f2 = new fou(after, help, picbox, playernum, kingsplace, kings, rooks);
                f2.showGreenplaces(after.X, after.Y, picbox); break;

            case 5:
            case -5: queen q2 = new queen(after, help, picbox, playernum, kingsplace, kings, rooks);
                q2.showGreenplaces(after.X, after.Y, picbox); break;

            case -6: king k2 = new king(after, help, picbox, playernum, kings, rooks);
                k2.showGreenplaces(after.X, after.Y, picbox); break;

            default: break;
            }

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (picbox[i * 10 + j - 2 * i].BackColor == Color.Green)
                    {
                        count++;
                    }
                }
            }
            return(count);
        }
Exemplo n.º 6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string stimw = "", stimb = "";

            c       = 0;
            replace = 1;
            game_main pppp = new game_main();

            if (passing_value.bdika == 1)
            {
                mat       = passing_value.newmat;
                playernum = passing_value.playernum;
            }
            if (putmat.check == 1)
            {
                mat         = putmat.pushmat;
                label7.Text = Form14.timw;
                stimw       = label7.Text;

                puttime(stimw, -1);
                label9.Text = Form14.timb;

                stimb = label9.Text;
                puttime(stimb, 1);
                label5.Text = Form14.step2p;

                getlossers(putmat.pushpace);
            }

            // wp.URL = pppp.imageurl("sound\\sound.mp3");
            // wp.controls.play();
            PictureBox[] picbox2 = { p00, p01, p02, p03, p04, p05, p06, p07, p10, p11, p12, p13, p14, p15, p16, p17, p20, p21, p22, p23, p24, p25, p26, p27, p30, p31, p32, p33, p34, p35, p36, p37, p40, p41, p42, p43, p44, p45, p46, p47, p50, p51, p52, p53, p54, p55, p56, p57, p60, p61, p62, p63, p64, p65, p66, p67, p70, p71, p72, p73, p74, p75, p76, p77 };
            picbox = picbox2;
            int p = 0;


            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (mat[i, j] != 0)
                    {
                        picbox2[p].ImageLocation = pppp.chessimage(mat[i, j]);
                        picbox2[p].SizeMode      = PictureBoxSizeMode.CenterImage;
                    }
                    else
                    {
                        picbox[p].Image = null;
                    }
                    picbox2[p].Visible = true;
                    p++;
                }
            }

            pppp.playerrole(playernum, picbox, mat);
        }
Exemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            game_main pppp = new game_main();
            int       yes = 0, playerblack = 0, playerwith = 0;

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    switch (msf[i, j])
                    {
                    case 1: playerblack++; break;

                    case -1: playerwith++; break;

                    case 2: playerblack++; break;

                    case -2: playerwith++; break;

                    case 3: playerblack++; break;

                    case -3: playerwith++; break;

                    case 4: playerblack++; break;

                    case -4: playerwith++; break;

                    case 5: playerblack++; break;

                    case -5: playerwith++; break;

                    case 6: playerblack++; yes++; break;

                    case -6: playerwith++; yes++; break;
                    }
                }
            }

            if (yes == 2 && playerwith > 0 && playerblack > 0)
            {
                finsh = 1;
                passing_value.newmat    = msf;
                passing_value.bdika     = 1;
                passing_value.playernum = playernum;
            }
            else
            {
                MessageBox.Show("you must to put king and put paice for every players");
            }
        }
Exemplo n.º 8
0
        public void setpaciec(int x, int y)
        {
            int p = 0;

            PictureBox[] picbox2 = { p00, p01, p02, p03, p04, p05, p06, p07, p10, p11, p12, p13, p14, p15, p16, p17, p20, p21, p22, p23, p24, p25, p26, p27, p30, p31, p32, p33, p34, p35, p36, p37, p40, p41, p42, p43, p44, p45, p46, p47, p50, p51, p52, p53, p54, p55, p56, p57, p60, p61, p62, p63, p64, p65, p66, p67, p70, p71, p72, p73, p74, p75, p76, p77 };
            game_main    pppp    = new game_main();

            picbox = picbox2;
            if (ch != 0)
            {
                if (ch == 6)
                {
                    kbx = x;
                    kby = y;
                }
                else if (ch == -6)
                {
                    kwx = x;
                    kwy = y;
                }
                msf[x, y] = ch;
                ch        = 0;
                picbox2[x * 10 + y - 2 * x].ImageLocation = pppp.chessimage(msf[x, y]);
                picbox2[x * 10 + y - 2 * x].SizeMode      = PictureBoxSizeMode.CenterImage;
                c++;
            }

            else
            {
                picbox[p].Image    = null;
                picbox2[p].Visible = true;
                p++;

                if (finsh != 1)
                {
                    MessageBox.Show("get another pacise");
                }
            }
        }
Exemplo n.º 9
0
        public void clever(int playernum, int[] kings, int[] rooks, Point[] kingsplace, PictureBox[] picbox, int[,] mat)
        {
            int k = 0; // number of items in the game for the playernumber

            TimeSpan    interval = new TimeSpan(0, 0, 2);
            tootalscoor tc       = new tootalscoor(picbox, kings, playernum, rooks, mat, kingsplace);

            for (int i = 0; i < mat.GetLength(0); i++)
            {
                for (int j = 0; j < mat.GetLength(1); j++)
                {
                    if (mat[i, j] * playernum > 0)
                    {
                        k++;
                    }
                }
            }
            Point[] pt = new Point[k];
            int     p  = 0;

            for (int i = 0; i < mat.GetLength(0); i++)
            {
                for (int j = 0; j < mat.GetLength(1); j++)
                {
                    if (mat[i, j] * playernum > 0)
                    {
                        pt[p] = new Point(i, j);
                        p++;
                    }
                }
            }
            List <Point>[] lpt = new List <Point> [k];
            tc.Filllist(k, pt, lpt);

            List <chess_power> cplst = new List <chess_power>();

            tc.filllistinchess_power(k, pt, lpt, cplst);

            //  int t = 1; // this is just to stop the debug
            int max = tc.getmaxtotalscore(cplst);
            List <chess_power> thebest = new List <chess_power>();

            thebest = tc.whatthebestpaice(cplst);
            chess_power final = tc.whatthemorbestpaice(thebest);

            if (mat[final.after.X, final.after.Y] != 0)
            {
                smartply.loser = mat[final.after.X, final.after.Y];
            }
            ///////////////////////////////////////
            int old = mat[final.befor.X, final.befor.Y];

            lastx = new Point(final.befor.X, final.befor.Y);
            mat[final.befor.X, final.befor.Y] = 0;
            mat[final.after.X, final.after.Y] = old;
            ////////////////////////////////////////////////


            game_main pppp = new game_main();

            picbox[final.befor.X * 10 + final.befor.Y - 2 * final.befor.X].ImageLocation = null;
            Application.DoEvents();

            picbox[final.after.X * 10 + final.after.Y - 2 * final.after.X].ImageLocation = pppp.chessimage(old);
            newx = new Point(final.after.X, final.after.Y);
            picbox[final.after.X * 10 + final.after.Y - 2 * final.after.X].SizeMode = PictureBoxSizeMode.CenterImage;

            pppp.refreshcolors(picbox, playernum, mat);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        //عند انتقال القطعه للمكان الجديد نفحص عدد القطع التي تستطيع القطعه تهديدها ونعيدها واذا ولا قطعه نعيد 0
        public int count_piesethreated() //good
        {
            game_main aaa = new game_main();

            int[,] help = new int[8, 8];
            int k = 0, c = 0;

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    help[i, j] = mat[i, j];
                }
            }
            help[after.X, after.Y] = help[befor.X, befor.Y];
            help[befor.X, befor.Y] = 0;
            aaa.refreshcolors(picbox, playernum, help);
            switch (help[after.X, after.Y])
            {
            case 1:
            case -1: Pawn p2 = new Pawn(after, help, picbox, playernum, kingsplace, kings, rooks);
                p2.showGreenplaces(after.X, after.Y, picbox); break;

            case 2:
            case -2: rook r2 = new rook(after, help, picbox, playernum, kingsplace, kings, rooks);
                r2.showGreenplaces(after.X, after.Y, picbox); break;

            case 3:
            case -3: knight kn2 = new knight(after, help, picbox, playernum, kingsplace, kings, rooks);
                kn2.showGreenplaces(after.X, after.Y, picbox); break;

            case 4:
            case -4: fou f2 = new fou(after, help, picbox, playernum, kingsplace, kings, rooks);
                f2.showGreenplaces(after.X, after.Y, picbox); break;

            case 5:
            case -5: queen q2 = new queen(after, help, picbox, playernum, kingsplace, kings, rooks);
                q2.showGreenplaces(after.X, after.Y, picbox); break;

            case 6:
            case -6: king k2 = new king(after, help, picbox, playernum, kings, rooks);
                k2.showGreenplaces(after.X, after.Y, picbox); break;

            default: break;
            }
            for (int d = 0; d < 8; d++)
            {
                for (int e = 0; e < 8; e++)
                {
                    if (picbox[k].BackColor == Color.Green)
                    {
                        if (help[d, e] != 0)
                        {
                            c++;
                        }
                    }
                    k++;
                }
            }
            aaa.refreshcolors(picbox, playernum, help);
            return(c * 10);
        }
Exemplo n.º 12
0
        //اذا كانت القطعه او عند انتقالها للمكان الجديد تستطيع قتل قطع من قطع العو تعيد حسب اهميته جندي 60 وغير ذلك 0
        public int killer()  // good
        {
            game_main aaa = new game_main();

            aaa.refreshcolors(picbox, playernum, mat); // no color
            switch (mat[befor.X, befor.Y])             // show color green before move the item
            {
            case -1:
            case 1: Pawn p2 = new Pawn(befor, mat, picbox, playernum, kingsplace, kings, rooks);
                p2.showGreenplaces(befor.X, befor.Y, picbox); break;

            case -2:
            case 2: rook r2 = new rook(befor, mat, picbox, playernum, kingsplace, kings, rooks);
                r2.showGreenplaces(befor.X, befor.Y, picbox); break;

            case -3:
            case 3: knight kn2 = new knight(befor, mat, picbox, playernum, kingsplace, kings, rooks);
                kn2.showGreenplaces(befor.X, befor.Y, picbox); break;

            case -4:
            case 4: fou f2 = new fou(befor, mat, picbox, playernum, kingsplace, kings, rooks);
                f2.showGreenplaces(befor.X, befor.Y, picbox); break;

            case -5:
            case 5: queen q2 = new queen(befor, mat, picbox, playernum, kingsplace, kings, rooks);
                q2.showGreenplaces(befor.X, befor.Y, picbox); break;

            case -6:
            case 6: king k2 = new king(befor, mat, picbox, playernum, kings, rooks);
                k2.showGreenplaces(befor.X, befor.Y, picbox); break;

            default: break;
            }
            if (picbox[after.X * 10 + after.Y - 2 * after.X].BackColor == Color.Green) // new point is green?
            {
                if (mat[after.X, after.Y] != 0)                                        // new pos in mat(orginal) not 0
                {
                    switch (Math.Abs(mat[after.X, after.Y]))
                    {
                    case -1:
                    case 1: aaa.refreshcolors(picbox, playernum, mat); return(60);

                    case -2:
                    case 2: aaa.refreshcolors(picbox, playernum, mat); return(62);

                    case -3:
                    case 3: aaa.refreshcolors(picbox, playernum, mat); return(64);

                    case -4:
                    case 4: aaa.refreshcolors(picbox, playernum, mat); return(66);

                    case -5:
                    case 5: aaa.refreshcolors(picbox, playernum, mat); return(68);

                    default: break;
                    }
                }
            }

            return(0);
        }
Exemplo n.º 13
0
        public void computerplayer1(int playernum, int[] kings, int[] rooks, Point[] kingsplace, PictureBox[] picbox, int[,] mat)
        {
            Point        last = new Point();
            Random       rd = new Random();
            game_main    pppp = new game_main();
            int          i, j, newx, newy, found = 0, c = 0, a, m = 0, p, timer;
            List <Point> lst = new List <Point>();

            List <Point> lst2 = new List <Point>();
            Node <Point> np   = lst2.GetFirst();
            Node <Point> np2;

            timer = rd.Next(3) + 1;
            TimeSpan interval = new TimeSpan(0, 0, timer);


            for (i = 0; i < 8 && found == 0; i++)
            {
                c     = 0;
                found = 0;
                for (j = 0; j < 8 && found == 0; j++)
                {
                    if (mat[i, j] * playernum > 0)
                    {
                        last = new Point(i, j);

                        switch (mat[i, j])
                        {
                        case -1:
                        case 1: Pawn p2 = new Pawn(new Point(i, j), mat, picbox, playernum, kingsplace, kings, rooks);
                            p2.showGreenplaces(i, j, picbox); lst = p2.placestomove(); break;

                        case -2:
                        case 2: rook r2 = new rook(new Point(i, j), mat, picbox, playernum, kingsplace, kings, rooks);
                            r2.showGreenplaces(i, j, picbox); lst = r2.placestomove(); break;

                        case -3:
                        case 3: knight kn2 = new knight(new Point(i, j), mat, picbox, playernum, kingsplace, kings, rooks);
                            kn2.showGreenplaces(i, j, picbox); lst = kn2.placestomove(); break;

                        case -4:
                        case 4: fou f2 = new fou(new Point(i, j), mat, picbox, playernum, kingsplace, kings, rooks);
                            f2.showGreenplaces(i, j, picbox); lst = f2.placestomove(); break;

                        case -5:
                        case 5: queen q2 = new queen(new Point(i, j), mat, picbox, playernum, kingsplace, kings, rooks);
                            q2.showGreenplaces(i, j, picbox); lst = q2.placestomove(); break;

                        case -6:
                        case 6: king k2 = new king(new Point(i, j), mat, picbox, playernum, kings, rooks);
                            k2.showGreenplaces(i, j, picbox); lst = k2.placestomove(); break;

                        default: break;
                        }
                    }
                    if (lst.IsEmpty() == false)
                    {
                        for (int k = 0; k < 8; k++)
                        {
                            for (int t = 0; t < 8; t++)
                            {
                                if (picbox[k * 10 + t - 2 * k].BackColor == Color.Green)
                                {
                                    np = lst2.Insert(np, new Point(k, t));
                                    c++;
                                }
                            }
                        }
                        if (lst2.IsEmpty() == false)
                        {
                            found = 1;
                        }
                    }
                }
            }


            a   = rd.Next(c + 1);
            m   = 0;
            np2 = lst2.GetFirst();
            while (a != m)
            {
                np2 = np2.GetNext();
                m++;
            }


            int b1 = last.X;
            int b2 = last.Y;

            lx = new Point(b1, b2);
            computerplayer.oldstep = new Point(b1, b2);
            newx = np.GetInfo().X;
            newy = np.GetInfo().Y;
            computerplayer.newstep = new Point(newx, newy);
            nx = new Point(newx, newy);
            if (mat[newx, newy] != 0)
            {
                computerplayer.loscomp = mat[newx, newy];
            }
            if (newx == 7 * playernum && mat[b1, b2] == 1 * playernum)
            {
                mat[b1, b2] = 0;

                mat[newx, newy] = 5;

                picbox[b1 * 10 + b2 - 2 * b1].ImageLocation = null;
                Thread.Sleep(interval);
                Application.DoEvents();
                picbox[newx * 10 + newy - 2 * newx].ImageLocation = pppp.chessimage(5);

                picbox[newx * 10 + newy - 2 * newx].SizeMode = PictureBoxSizeMode.CenterImage;
                pppp.refreshcolors(picbox, playernum, mat);
            }


            else if (newx == 0 && mat[b1, b2] * playernum == -1 * playernum)
            {
                mat[b1, b2] = 0;

                mat[newx, newy] = -5;

                picbox[b1 * 10 + b2 - 2 * b1].ImageLocation = null;
                Thread.Sleep(interval);
                Application.DoEvents();
                picbox[newx * 10 + newy - 2 * newx].ImageLocation = pppp.chessimage(-5);

                picbox[newx * 10 + newy - 2 * newx].SizeMode = PictureBoxSizeMode.CenterImage;
                pppp.refreshcolors(picbox, playernum, mat);
            }
            else
            {
                p           = mat[b1, b2];
                mat[b1, b2] = 0;

                mat[newx, newy] = p;

                picbox[b1 * 10 + b2 - 2 * b1].ImageLocation = null;
                Thread.Sleep(interval);
                Application.DoEvents();

                picbox[newx * 10 + newy - 2 * newx].ImageLocation = pppp.chessimage(p);

                picbox[newx * 10 + newy - 2 * newx].SizeMode = PictureBoxSizeMode.CenterImage;

                pppp.refreshcolors(picbox, playernum, mat);
            }
        }
Exemplo n.º 14
0
        public void IFgreenmovelastItem(Point lastpt, PictureBox[] pics, int[,] mat, int newx, int newy, string image, int [] kings, int[] rooks, Point [] kingsplaces)
        {
            game_main pppp = new game_main();
            int       x    = lastpt.X;
            int       y    = lastpt.Y;


            if (pics[newx * 10 + newy - 2 * newx].BackColor == Color.Green)
            {
                int p = mat[x, y];
                mat[x, y] = 0;
                pics[x * 10 + y - 2 * x].ImageLocation = "";
                pics[x * 10 + y - 2 * x].SizeMode      = PictureBoxSizeMode.CenterImage;

                if (mat[newx, newy] != 0)
                {
                    game_main.loss = mat[newx, newy];
                }

                if (newx == 7 && p == 1)
                {
                    mat[newx, newy] = 5;
                    pics[newx * 10 + newy - 2 * newx].ImageLocation = pppp.chessimage(5);
                    pics[newx * 10 + newy - 2 * newx].SizeMode      = PictureBoxSizeMode.CenterImage;
                }
                if (newx == 0 && p == -1)
                {
                    mat[newx, newy] = -5;
                    pics[newx * 10 + newy - 2 * newx].ImageLocation = pppp.chessimage(-5);
                    pics[newx * 10 + newy - 2 * newx].SizeMode      = PictureBoxSizeMode.CenterImage;
                }

                if (!(newx == 7 && p == 1) && !(newx == 0 && p == -1))
                {
                    mat[newx, newy] = p;
                    pics[newx * 10 + newy - 2 * newx].ImageLocation = image;
                    pics[newx * 10 + newy - 2 * newx].SizeMode      = PictureBoxSizeMode.CenterImage;
                }
                if (p == -6)
                {
                    kings[0]++; kingsplaces[0] = new Point(newx, newy);
                }
                if (p == 6)
                {
                    kings[1]++; kingsplaces[1] = new Point(newx, newy);
                }

                if (p == -2 && y == 7)
                {
                    rooks[0] = rooks[0] + 1;                   //rook - wit
                }
                if (p == 2 && y == 7)
                {
                    rooks[1] = rooks[1] + 1;                  //rook + blk
                }
            }
            if (pics[newx * 10 + newy - 2 * newx].BackColor == Color.Yellow)
            {
                int p = mat[x, y];
                int t = mat[newx, newy];
                mat[x, y] = 0; mat[newx, newy] = 0;
                int m = 0, r = 0;
                pics[x * 10 + y - 2 * x].ImageLocation          = "";
                pics[newx * 10 + newy - newx * 2].ImageLocation = "";

                mat[x, y + 2]       = p;
                mat[newx, newy - 2] = t;
                m = x * 10 + (y + 2) - 2 * x;
                r = newx * 10 + (newy - 2) - 2 * newx;



                pics[m].ImageLocation = "";
                pics[r].ImageLocation = "";

                pics[m].ImageLocation = chessimage(p);
                pics[r].ImageLocation = chessimage(t);
                pics[m].SizeMode      = PictureBoxSizeMode.CenterImage;
                pics[r].SizeMode      = PictureBoxSizeMode.CenterImage;
            }
        }