private void IsMoveAttemptValid(object s, NewMoveAttemptEventArgs e)
        {
            string currentValueInCell = e.theBoard[e.Coordinates[0], e.Coordinates[1]];

            if (String.IsNullOrWhiteSpace(currentValueInCell))
            {
                e.MoveAllowed = true;
            }
            else
            {
                e.MoveAllowed = false;
                Console.WriteLine("Cell already played in. Please try again");
            }
        }
Esempio n. 2
0
        //Triggered from Player
        public bool OnNewMoveAttempt(Object sender, int[] newMoveCoordinates, string playerSymbol)
        {
            var NewMoveAttemptedDelegate = NewMoveAttempted as EventHandler <NewMoveAttemptEventArgs>;

            if (NewMoveAttemptedDelegate != null)
            {
                NewMoveAttemptEventArgs thisMoveAttemptEventArgs =
                    new NewMoveAttemptEventArgs {
                    Coordinates = newMoveCoordinates, theBoard = BoardHandler.GetBoard()
                };
                NewMoveAttemptedDelegate(sender, thisMoveAttemptEventArgs);
                return(thisMoveAttemptEventArgs.MoveAllowed);
            }
            Console.WriteLine("Error when raising OnNewMoveAttemptEvent");
            return(false);
        }