Beispiel #1
0
        /// <summary>
        /// Determines whether the specified player can attack this square.
        /// </summary>
        /// <param name="player">
        /// The player being tested. (
        /// </param>
        /// <returns>
        /// True if player can move a piece to this square.
        /// </returns>
        public bool PlayerCanAttackSquare(Player player)
        {
            foreach (Piece.PieceNames pieceName in player.PieceTypes())
            {
                if (Piece.CanPlayerPieceNameAttackSquare(this, player, pieceName))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the cheapest piece defending this square.
        /// </summary>
        /// <param name="player">
        /// Defending player who pieces should be listed.
        /// </param>
        /// <returns>
        /// List of pieces.
        /// </returns>
        public Piece CheapestPieceDefendingThisSquare(Player player)
        {
            Piece piece;

            foreach (Piece.PieceNames pieceName in player.PieceTypes())
            {
                if (Piece.CanPlayerPieceNameAttackSquare(this, player, pieceName, out piece))
                {
                    return(piece);
                }
            }
            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// Calculates defense points for the player on this square. Returns the value of the cheapest piece defending the square.
        /// If no pieces are defending, then returns a high value (15,000).
        /// </summary>
        /// <param name="player">
        /// The defending player.
        /// </param>
        /// <returns>
        /// Defense points.
        /// </returns>
        public int DefencePointsForPlayer(Player player)
        {
            Piece piece;

            foreach (Piece.PieceNames pieceName in player.PieceTypes())
            {
                if (Piece.CanPlayerPieceNameAttackSquare(this, player, pieceName, out piece))
                {
                    return(piece.Value);
                }
            }
            return(15000);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the cheapest piece defending this square.
        /// </summary>
        /// <param name="player">
        /// Defending player who pieces should be listed.
        /// </param>
        /// <returns>
        /// List of pieces.
        /// </returns>
        public Piece CheapestPieceDefendingThisSquare(Player player)
        {
            Piece piece;

            foreach (Piece.PieceNames pieceName in player.PieceTypes())
            {
                if (Piece.CanPlayerPieceNameAttackSquare(this, player, pieceName, out piece))
                    return piece;
            }
            return null;
        }
Beispiel #5
0
        /// <summary>
        /// Calculates defense points for the player on this square. Returns the value of the cheapest piece defending the square.
        /// If no pieces are defending, then returns a high value (15,000).
        /// </summary>
        /// <param name="player">
        /// The defending player.
        /// </param>
        /// <returns>
        /// Defense points.
        /// </returns>
        public int DefencePointsForPlayer(Player player)
        {

            Piece piece;

            foreach (Piece.PieceNames pieceName in player.PieceTypes())
            {
                if (Piece.CanPlayerPieceNameAttackSquare(this, player, pieceName, out piece))
                    return piece.Value;
            }
            return 15000;
        }
Beispiel #6
0
        /// <summary>
        /// Determines whether the specified player can attack this square.
        /// </summary>
        /// <param name="player">
        /// The player being tested. (
        /// </param>
        /// <returns>
        /// True if player can move a piece to this square.
        /// </returns>
        public bool PlayerCanAttackSquare(Player player)
        {

            foreach (Piece.PieceNames pieceName in player.PieceTypes())
            {
                if (Piece.CanPlayerPieceNameAttackSquare(this, player, pieceName))
                    return true;
            }

            return false;
        }