Exemple #1
0
        /// <summary>
        /// transform un pion en une autre pièce reçu en paramètre
        /// </summary>
        /// <param name="type"></param>
        public void ChangePawn(Type type)
        {
            iPawnChange++;
            Piece  p         = lstPlayer[0].LastPiece;
            String strRemove = "";
            Piece  newPiece  = null;

            if (type == typeof(Queen))
            {
                newPiece = new Queen(p.Color);
            }
            if (type == typeof(Rook))
            {
                newPiece = new Rook(p.Color);
            }
            if (type == typeof(Bishop))
            {
                newPiece = new Bishop(p.Color);
            }
            if (type == typeof(Knights))
            {
                newPiece = new Knights(p.Color);
            }
            newPiece.PositionX = p.PositionX;
            newPiece.PositionY = p.PositionY;
            Display.SetPicture(newPiece);


            iPawnChange += 2;
            if (p.Color == strColor1)
            {
                foreach (string s in dicWhitePiece.Keys)
                {
                    if (p == dicWhitePiece[s])
                    {
                        strRemove = s;
                    }
                }
                dicWhitePiece.Remove(strRemove);

                dicWhitePiece.Add(type.Name + iPawnChange.ToString() + p.Color, newPiece);
            }
            else
            {
                foreach (string s in dicBlackPiece.Keys)
                {
                    if (p == dicBlackPiece[s])
                    {
                        strRemove = s;
                    }
                }
                dicBlackPiece.Remove(strRemove);
                dicBlackPiece.Add(type.Name + iPawnChange.ToString() + p.Color, newPiece);
            }
            iPawnChange -= 2;

            FillTablePiece();
        }
Exemple #2
0
        public Piece Clone()
        {
            Piece Clone;

            switch (this.ToString())
            {
            case "echec.Rook":
                Clone = new Rook(this.Color);
                break;

            case "echec.Queen":
                Clone = new Queen(this.Color);
                break;

            case "echec.Pawn":
                Clone = new Pawn(this.Color);
                break;

            case "echec.Knights":
                Clone = new Knights(this.Color);
                break;

            case "echec.King":
                Clone = new King(this.Color);
                break;

            case "echec.Bishop":
                Clone = new Bishop(this.Color);
                break;

            default:
                Clone = null;
                break;
            }
            Clone.lstMove       = this.lstMove;
            Clone.PositionX     = this.PositionX;
            Clone.PositionY     = this.PositionY;
            Clone.Picture       = this.Picture;
            Clone.IsAlreadyMove = this.IsAlreadyMove;
            return(Clone);
        }