Beispiel #1
0
        /// <summary>
        /// Determines whether the given change is a valid one.
        /// </summary>
        /// <param name="change">The change to be.</param>
        /// <returns>
        ///   <c>true</c> if it is a valid change otherwise, <c>false</c>.
        /// </returns>
        public bool IsChangeValid(Change change)
        {
            if (Board.GetHeight(change.X, change.Y) > 1 && change.AddedLetter.Equals(Board.Letters[change.X, change.Y][Board.Letters[change.X, change.Y].Count - 2])) {
                if (MessageChanged != null) {
                    MessageChanged(this, new MessageEventArgs("Invalid move. Adding a letter on it's equal is not allowed."));
                }

                return false;
            }
            if (change.X >= Board.Size || change.Y >= Board.Size) {
                if (MessageChanged != null) {
                    MessageChanged(this, new MessageEventArgs("Invalid move. Letter added in overflowing coordinates"));
                }

                return false;
            }
            if (Board.GetHeight(change.X, change.Y) > 5) {
                if (MessageChanged != null) {
                    MessageChanged(this, new MessageEventArgs("Invalid move. Can't add more than 5 letters to a cell."));
                }

                return false;
            }

            return true;
        }
Beispiel #2
0
 /// <summary>
 /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
 /// </summary>
 /// <param name="other">The <see cref="System.Object"/> to compare with this instance.</param>
 /// <returns>
 /// 	<c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
 /// </returns>
 public bool Equals(Change other)
 {
     return (other.X == this.X) && (other.Y==this.Y) && (other.AddedLetter==this.AddedLetter);
 }
Beispiel #3
0
 /// <summary>
 /// Applies the given change to the board.
 /// </summary>
 /// <param name="change">The change to be applied.</param>
 /// <returns>True if the change is applied succesfully, false otherwise.</returns>
 public bool ApplyChange(Change change)
 {
     Changes.Add(change);
     Players[0].UseLetter(change.AddedLetter);
     return Board.AddLetter(change.X, change.Y, change.AddedLetter);
 }