Ejemplo n.º 1
0
            public bool Consommer(GenrePiece gp, int Joueur, int nb)
            {
                int          nbConso = 0;
                List <Piece> newList = new List <Piece>();

                foreach (Piece pc in prises[Joueur])
                {
                    if (pc.getGenre() != gp)
                    {
                        newList.Add(pc);
                    }
                    else
                    {
                        if (nbConso < nb)
                        {
                            nbConso++;
                        }
                        else
                        {
                            newList.Add(pc);
                        }
                    }
                }
                if (nbConso == nb)
                {
                    prises[Joueur] = newList;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
Ejemplo n.º 2
0
 public bool Placer(Point p1, int Joueur, GenrePiece genre)
 {
     if (Pieces[p1.X, p1.Y].PieceVide)
     {
         bool ok = ((genre == GenrePiece.Lapin || genre == GenrePiece.Herbe) && Consommer(GenrePiece.Herbe, Joueur, 1)) ||
                   (genre == GenrePiece.Loup && Consommer(GenrePiece.Lapin, Joueur, 1));
         if (ok)
         {
             Pieces[p1.X, p1.Y] = new Piece(genre, Joueur);
         }
         return(ok);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 3
0
            public bool DeplacementLegal(Point p1, Point p2)
            {
                GenrePiece gp = getPiece(p1.X, p1.Y).getGenre();

                if (gp == GenrePiece.Herbe || gp == GenrePiece.Vide)
                {
                    return(false);
                }
                else if (gp == GenrePiece.Lapin)
                {
                    return(Math.Max(Math.Abs(p1.X - p2.X), Math.Abs(p1.Y - p2.Y)) <= 1);
                }
                else if (gp == GenrePiece.Loup)
                {
                    int dist = 3;
                    if (!EntourageFavorable(p1.X, p1.Y, false))
                    {
                        dist = 1;
                    }
                    return((Math.Abs(p1.X - p2.X) <= dist) && (Math.Abs(p1.Y - p2.Y) == 0) || (Math.Abs(p1.Y - p2.Y) <= dist) && (Math.Abs(p1.X - p2.X) == 0) ||
                           (Math.Abs(p1.X - p2.X) <= dist) && (Math.Abs(p1.Y - p2.Y) == Math.Abs(p1.X - p2.X)));
                }
                return(false);
            }
Ejemplo n.º 4
0
 public Piece(GenrePiece genre, int joueur)
 {
     PieceVide  = false;
     this.genre = genre;
     Joueur     = joueur;
 }
Ejemplo n.º 5
0
 public Piece()
 {
     PieceVide = true;
     Joueur    = -1;
     genre     = GenrePiece.Vide;
 }