Пример #1
0
 public void actualizar(chess a)
 {
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             tab[i][j] = a.tab[i][j];
         }
     }
     juega    = a.juega;
     pmov     = a.pmov;
     inicio   = a.inicio;
     fin      = a.fin;
     ini_     = a.ini_;
     fin_     = a.fin_;
     bkcheck  = a.bkcheck;
     wkcheck  = a.wkcheck;
     bkmov    = a.bkmov;
     wkmov    = a.wkmov;
     bt1mov   = a.bt1mov;
     jugada   = a.jugada;
     wt1mov   = a.wt1mov;
     bt2mov   = a.bt2mov;
     wt2mov   = a.wt2mov;
     leng_alg = a.leng_alg;
 }
Пример #2
0
        public chess(chess a)
        {
            tab = new string[8][];
            for (int i = 0; i < 8; i++)
            {
                tab[i] = new string[8];
            }

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    tab[i][j] = a.tab[i][j];
                }
            }

            juega    = a.juega;
            pmov     = a.pmov;
            inicio   = a.inicio;
            fin      = a.fin;
            ini_     = a.ini_;
            fin_     = a.fin_;
            bkcheck  = a.bkcheck;
            wkcheck  = a.wkcheck;
            bkmov    = a.bkmov;
            wkmov    = a.wkmov;
            jugada   = 0;
            bt1mov   = a.bt1mov;
            wt1mov   = a.wt1mov;
            bt2mov   = a.bt2mov;
            wt2mov   = a.wt2mov;
            leng_alg = a.leng_alg;
        }
Пример #3
0
 public void Mover(Par mv, Par p)
 {
     if (Qtab[p.X][p.Y][1] == 'p' && p.Y != mv.Y && Qtab[mv.X][mv.Y] == "null")
     {
         Qtab[p.X][mv.Y] = "null";
     }
     Qtab[mv.X][mv.Y] = Qtab[p.X][p.Y];
     Qtab[p.X][p.Y]   = "null";
 }
Пример #4
0
        public bool jaque(string a)
        {
            Par        p = get_pos(a);
            List <Par> l;
            string     c;

            if (a[0] == 'w')
            {
                c = "b";
            }
            else
            {
                c = "w";
            }

            l = Qmov_caballo(p.X, p.Y);
            foreach (Par p1 in l)
            {
                if (Qtab[p1.X][p1.Y] == c + "n")
                {
                    return(true);
                }
            }
            l = Qmov_alfil(p.X, p.Y);
            foreach (Par p1 in l)
            {
                if (Qtab[p1.X][p1.Y] == c + "b" || Qtab[p1.X][p1.Y] == c + "q")
                {
                    return(true);
                }
            }
            l = Qmov_torre(p.X, p.Y);
            foreach (Par p1 in l)
            {
                if (Qtab[p1.X][p1.Y] == c + "r" || Qtab[p1.X][p1.Y] == c + "q")
                {
                    return(true);
                }
            }
            l = Qmov_peon_p(p.X, p.Y);
            foreach (Par p1 in l)
            {
                if (Qtab[p1.X][p1.Y] == c + "p")
                {
                    return(true);
                }
            }
            l = Qmov_rey_p(p.X, p.Y);
            foreach (Par p1 in l)
            {
                if (Qtab[p1.X][p1.Y] == c + "k")
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #5
0
 bool contain(List <Par> L, Par a)
 {
     foreach (Par p1 in L)
     {
         if (p1 == a)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #6
0
        public void tablero_inv()
        {
            Tinv = !Tinv;
            if (Tinv)
            {
                Point tmp = groupBoxb.Location;
                groupBoxb.Location = groupBoxw.Location;
                groupBoxw.Location = tmp;
                ntl.LoadAsync("image\\board\\ntl1.png");
                ntn.LoadAsync("image\\board\\ntn1.png");

                int i1, j1;
                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        i1 = 7 - i;
                        j1 = 7 - j;
                        A[i1][j1].Location = new Point((int)(sizeb + sizet * j), (int)(sizeb + sizet * i));
                    }
                }
            }
            else
            {
                Point tmp = groupBoxb.Location;
                groupBoxb.Location = groupBoxw.Location;
                groupBoxw.Location = tmp;
                ntl.LoadAsync("image\\board\\ntl.png");
                ntn.LoadAsync("image\\board\\ntn.png");

                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        A[i][j].Location = new Point((int)(sizeb + sizet * j + 0.5f), (int)(sizeb + sizet * i + 0.5f));
                    }
                }
            }

            if (PX.X != -1)
            {
                PX = new Par(7 - PX.X, 7 - PX.Y);
                PY = new Par(7 - PY.X, 7 - PY.Y);
            }

            //for (int i = 0; i < 8; i++)
            //    for (int j = 0; j < 8; j++)
            //        paint(i, j, "null");

            Ult_Mov.Clear();
            mx = my = -1;
            actualizar();
        }
Пример #7
0
        int contain(List <Par> L, Par p)
        {
            int s = L.Count();

            for (int i = 0; i < s; i++)
            {
                if (L[i] == p)
                {
                    return(i);
                }
            }
            return(-1);
        }
Пример #8
0
        public chess()
        {
            tab  = new string[8][];
            Qtab = new string[8][];
            for (int i = 0; i < 8; i++)
            {
                tab[i]  = new string[8];
                Qtab[i] = new string[8];
            }

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    tab[i][j] = "null";
                }
            }

            for (int j = 0; j < 8; j++)
            {
                tab[1][j] = "bp";
                tab[6][j] = "wp";
            }

            tab[0][0] = tab[0][7] = "br";
            tab[0][1] = tab[0][6] = "bn";
            tab[0][2] = tab[0][5] = "bb";
            tab[0][3] = "bq";
            tab[0][4] = "bk";

            tab[7][0] = tab[7][7] = "wr";
            tab[7][1] = tab[7][6] = "wn";
            tab[7][2] = tab[7][5] = "wb";
            tab[7][3] = "wq";
            tab[7][4] = "wk";

            juega    = false;
            jugada   = 0;
            inicio   = fin = new Par(-1, -1);
            ini_     = fin_ = new Par(-1, -1);
            bkcheck  = wkcheck = false;
            bkmov    = wkmov = false;
            bt1mov   = wt1mov = false;
            bt2mov   = wt2mov = false;
            leng_alg = "";
        }
Пример #9
0
        public void reset()
        {
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    tab[i][j] = "null";
                }
            }

            for (int j = 0; j < 8; j++)
            {
                tab[1][j] = "bp";
                tab[6][j] = "wp";
            }

            tab[0][0] = tab[0][7] = "br";
            tab[0][1] = tab[0][6] = "bn";
            tab[0][2] = tab[0][5] = "bb";
            tab[0][3] = "bq";
            tab[0][4] = "bk";

            tab[7][0] = tab[7][7] = "wr";
            tab[7][1] = tab[7][6] = "wn";
            tab[7][2] = tab[7][5] = "wb";
            tab[7][3] = "wq";
            tab[7][4] = "wk";

            juega    = false;
            inicio   = fin = new Par(-1, -1);
            jugada   = 0;
            bkcheck  = wkcheck = false;
            bkmov    = wkmov = false;
            bt1mov   = wt1mov = false;
            bt2mov   = wt2mov = false;
            leng_alg = "";
        }
Пример #10
0
        void cmd_Argg(object sender, CMD.argumento e)
        {
            string line = e.arg1;

            Text = line;
            if (line.Contains("O-O"))
            {
                Par enrr, enrr1;
                if (aj.juega)
                {
                    enrr = new Par(aj.get_pos("bk"));
                }
                else
                {
                    enrr = new Par(aj.get_pos("wk"));
                }

                bandera = 2;
                pictureBox2_MouseDown(A[enrr.X][enrr.Y], new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, 0, 0, 0));

                if (line.Count() > 3)
                {
                    enrr1 = new Par(enrr.X, enrr.Y - 2);
                }
                else
                {
                    enrr1 = new Par(enrr.X, enrr.Y + 2);
                }

                pictureBox2_MouseDown(A[enrr1.X][enrr1.Y], new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, 0, 0, 0));
                bandera = 0;
            }
            else
            {
                string nextmove = line.ToString();

                string next = "";
                int    i, j;
                for (i = 0; i < nextmove.Count(); i++)
                {
                    next += nextmove[i];
                }

                int t = 0;
                if (next[0].ToString() == next[0].ToString().ToUpper())
                {
                    next = next.Remove(0, 1);
                    t++;
                }

                j    = nextmove[t] - 'a';
                next = next.Remove(0, 1);
                t++;
                i    = 56 - nextmove[t];
                next = next.Remove(0, 1);
                t++;
                bandera = 2;
                pictureBox2_MouseDown(A[i][j], new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, 0, 0, 0));
                if (next[0] == 'x')
                {
                    next = next.Remove(0, 1);
                    t++;
                }
                j    = nextmove[t] - 'a';
                next = next.Remove(0, 1);
                t++;
                i    = 56 - nextmove[t];
                next = next.Remove(0, 1);
                t++;
                pictureBox2_MouseDown(A[i][j], new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, 0, 0, 0));
                bandera = 0;
            }
        }
Пример #11
0
        public void actualizar()
        {
            if (aj.juega)
            {
                pictureBox7.LoadAsync("image\\turn2.png");
                label_10.ForeColor = Color.Navy;
                label9.ForeColor   = Color.Silver;
                pictureBox6.LoadAsync("image\\turn.png");
            }
            else
            {
                pictureBox6.LoadAsync("image\\turn2.png");
                label9.ForeColor   = Color.Navy;
                label_10.ForeColor = Color.Silver;
                pictureBox7.LoadAsync("image\\turn.png");
            }

            if (PX.X != -1)
            {
                paint(PX.X, PX.Y, "null");
                paint(PY.X, PY.Y, "null");
            }

            if (aj.inicio.X != -1)
            {
                paint(aj.inicio.X, aj.inicio.Y, "u");
                paint(aj.fin.X, aj.fin.Y, "u");
            }

            if (aj.inicio != new Par(-1, -1))
            {
                paint(aj.inicio.X, aj.inicio.Y, "u");
                paint(aj.fin.X, aj.fin.Y, "u");
                PX = aj.inicio;
                PY = aj.fin;
            }

            aj.igual();
            if (!aj.juega)
            {
                if (aj.jaque("wk"))
                {
                    checkw.BringToFront();
                    checkb.SendToBack();
                    aj.wkcheck = true;
                    aj.bkcheck = false;
                    Algebra   += "+";
                }
                else
                {
                    checkw.SendToBack();
                    checkb.SendToBack();
                    aj.wkcheck = false;
                    aj.bkcheck = false;
                }
            }
            else
            {
                if (aj.jaque("bk"))
                {
                    checkb.BringToFront();
                    checkw.SendToBack();
                    aj.bkcheck = true;
                    aj.wkcheck = false;
                    Algebra   += "+";
                }
                else
                {
                    checkb.SendToBack();
                    checkw.SendToBack();
                    aj.bkcheck = false;
                    aj.wkcheck = false;
                }
            }

            bool hay_mov = aj.hay_mov();

            if (!hay_mov && (aj.bkcheck || aj.wkcheck))
            {
                label_10.ForeColor = Color.Navy;
                label9.ForeColor   = Color.Navy;
                //QMessageBox* jaquem = new QMessageBox(this);
                //jaquem->setIconPixmap(QPixmap(":/other/image/checkmate.png"));
                if (aj.bkcheck)
                {
                    //jaquem->setWindowTitle("THE WHITE PIECES WON");
                    pictureBox4.LoadAsync("image\\lose.png");
                    pictureBox4.BringToFront();
                    pictureBox5.LoadAsync("image\\win.png");
                    pictureBox5.BringToFront();
                }
                else
                {
                    //jaquem->setWindowTitle("THE BLACK PIECES WON");
                    pictureBox4.LoadAsync("image\\win.png");
                    pictureBox4.BringToFront();
                    pictureBox5.LoadAsync("image\\lose.png");
                    pictureBox5.BringToFront();
                }
                checkw.SendToBack();
                checkb.SendToBack();
                Algebra = Algebra.Replace('+', '#');
                //jaquem->exec();
            }
            else if (!hay_mov && !(aj.bkcheck && aj.wkcheck))
            {
                label_10.ForeColor = Color.Navy;
                label9.ForeColor   = Color.Navy;
                //QMessageBox* jaquem = new QMessageBox(this);
                //jaquem->setIconPixmap(QPixmap(":/other/image/stalemate.png"));
                //jaquem->setWindowTitle("THE GAME IS DRAW");
                pictureBox4.LoadAsync("image\\draw.png");
                pictureBox4.BringToFront();
                pictureBox5.LoadAsync("image\\draw.png");
                pictureBox5.BringToFront();
                checkw.SendToBack();
                checkb.SendToBack();
                //jaquem->exec();
            }
            else
            {
                pictureBox4.LoadAsync("image\\null.png");
                pictureBox5.LoadAsync("image\\null.png");
            }
        }
Пример #12
0
        public void act_lista_jaque(ref List <Par> l, Par p)
        {
            int t = 0, size = l.Count();

            if (size > 0)
            {
                for (int i = 0; i < size; i++)
                {
                    igual();
                    Mover(l[i], p);
                    if (!juega)
                    {
                        if (jaque("wk"))
                        {
                            l.RemoveAt(i);
                            i--;
                            size--;
                        }
                        else
                        {
                            t++;
                        }
                    }
                    else
                    {
                        if (jaque("bk"))
                        {
                            l.RemoveAt(i);
                            i--;
                            size--;
                        }
                        else
                        {
                            t++;
                        }
                    }
                }
            }
            if (size > 0)
            {
                if (!juega)
                {
                    if (!wkmov)
                    {
                        int tt = contain(l, new Par(p.X, p.Y - 1));
                        if (tt == -1)
                        {
                            tt = contain(l, new Par(p.X, p.Y - 2));
                            if (tt != -1)
                            {
                                l.RemoveAt(tt);
                                size--;
                            }
                        }
                        tt = contain(l, new Par(p.X, p.Y + 1));
                        if (tt == -1 && size > 0)
                        {
                            tt = contain(l, new Par(p.X, p.Y + 2));
                            if (tt != -1)
                            {
                                l.RemoveAt(tt);
                                size--;
                            }
                        }
                    }
                }
                else
                {
                    if (!bkmov)
                    {
                        int tt = contain(l, new Par(p.X, p.Y - 1));
                        if (tt == -1)
                        {
                            tt = contain(l, new Par(p.X, p.Y - 2));
                            if (tt != -1)
                            {
                                l.RemoveAt(tt);
                                size--;
                            }
                        }
                        tt = contain(l, new Par(p.X, p.Y + 1));
                        if (tt == -1 && size > 0)
                        {
                            tt = contain(l, new Par(p.X, p.Y + 2));
                            if (tt != -1)
                            {
                                l.RemoveAt(tt);
                                size--;
                            }
                        }
                    }
                }
            }
        }
Пример #13
0
 public Par(Par a)
 {
     X = a.X;
     Y = a.Y;
 }