/// <summary> /// Construtor interno para um nova peça que pode ou não estar em jogo /// </summary> /// <param name="owner">Jogo ao qual a peça pertence</param> /// <param name="player">Qual jogador é dono da peça.</param> /// <param name="rank">Qual o tipo de peça.</param> /// <param name="location">Localização da peça no tabuleiro.</param> /// <param name="inPlay">A peça está em jogo?</param> internal CheckersPiece(CheckersGame owner, int player, CheckersRank rank, System.Drawing.Point location, bool inPlay) { // Se o index do jogador é diferente de 1 ou 2 if ((player < 1) || (player > 2)) { // Lança exceção throw new ArgumentOutOfRangeException(nameof(player), player, @"A variável 'player' deve ser um número com valor 1 ou 2."); } // Se a localização não está dentro dos limites do tabuleiro if ((location.X < 0) || (location.X >= CheckersGame.BoardSize.Width) || (location.Y < 0) || (location.Y >= CheckersGame.BoardSize.Height)) { // Lança exceção throw new ArgumentOutOfRangeException(nameof(location), location, @"A variável 'location' deve ser um valor válido no tabuleiro."); } this._Owner = owner; this._Player = player; this._Rank = rank; this._Location = location; this._InPlay = inPlay; }
internal CheckersPiece(CheckersGame owner, int player, CheckersRank rank, Point location, bool inPlay) { if((player < 1) || (player > 2)) throw new ArgumentOutOfRangeException("player", player, "Argument 'player' must be a valid player number (a number greater or equal to 1)."); if((location.X < 0) || (location.X >= CheckersGame.BoardSize.Width) || (location.Y < 0) || (location.Y >= CheckersGame.BoardSize.Height)) throw new ArgumentOutOfRangeException("location", player, "Argument 'location' must be a valid position on the board."); this.owner = owner; this.player = player; this.rank = rank; this.location = location; this.inPlay = inPlay; }
internal CheckersPiece(CheckersGame owner, int player, CheckersRank rank, Point location, bool inPlay) { if ((player < 1) || (player > 2)) { throw new ArgumentOutOfRangeException("player", player, "Argument 'player' must be a valid player number (a number greater or equal to 1)."); } if ((location.X < 0) || (location.X >= CheckersGame.BoardSize.Width) || (location.Y < 0) || (location.Y >= CheckersGame.BoardSize.Height)) { throw new ArgumentOutOfRangeException("location", player, "Argument 'location' must be a valid position on the board."); } this.owner = owner; this.player = player; this.rank = rank; this.location = location; this.inPlay = inPlay; }
/// <summary>Cria uma nova peça que está em jogo.</summary> /// <param name="player">Qual jogador é dono da peça.</param> /// <param name="rank">Qual o tipo de peça.</param> /// <param name="location">Localização da peça no tabuleiro.</param> public CheckersPiece(int player, CheckersRank rank, System.Drawing.Point location) : this(null, player, rank, location, true) { }
// Construtores #region Construtores /// <summary>Cria uma nova peça genérica que náo está em jogo.</summary> /// <param name="player">Qual jogador é dono da peça.</param> /// <param name="rank">Qual o tipo de peça.</param> public CheckersPiece(int player, CheckersRank rank) : this(null, player, rank, System.Drawing.Point.Empty, false) { }
/// <summary> /// Peça promovida a rei /// </summary> internal void Promoted() { this._Rank = CheckersRank.King; }
/// <summary>Creates a new generic CheckersPiece object that is in play.</summary> /// <param name="player">The player index of the piece.</param> /// <param name="rank">The piece's rank.</param> /// <param name="location">The piece's location on the board.</param> public CheckersPiece(int player, CheckersRank rank, Point location) : this(null, player, rank, location, true) { }
/// <summary>Creates a new generic CheckersPiece object that is not currently in play.</summary> /// <param name="player">The player index of the piece.</param> /// <param name="rank">The piece's rank.</param> public CheckersPiece(int player, CheckersRank rank) : this(null, player, rank, Point.Empty, false) { }
internal void Promoted() { rank = CheckersRank.King; }
/// <summary>Creates a new generic CheckersPiece object that is in play.</summary> /// <param name="player">The player index of the piece.</param> /// <param name="rank">The piece's rank.</param> /// <param name="location">The piece's location on the board.</param> public CheckersPiece(int player, CheckersRank rank, Point location) : this(null, player, rank, location, true) { }
/// <summary>Creates a new generic CheckersPiece object that is not currently in play.</summary> /// <param name="player">The player index of the piece.</param> /// <param name="rank">The piece's rank.</param> public CheckersPiece(int player, CheckersRank rank) : this(null, player, rank, Point.Empty, false) { }
internal void Promoted() { rank = CheckersRank.King; }