} //End private void reset() /***************EVENTS***************/ private void btnPlace_Click(object sender, EventArgs e) { //Declare variables Point playerChoice = new Point(this.cmbRow.SelectedIndex, this.cmbColumn.SelectedIndex); BoardVals playerVal = BoardVals.NULL; if (this.Difficulty == Difficulty.Beginner) { playerVal = this.Beginner.OpponentsVal; } //End if (this.Difficulty == Difficulty.Beginner) else if (this.Difficulty == Difficulty.Advanced) { playerVal = this.Advanced.OpponentsVal; } //End else if (this.Difficulty == Difficulty.Advanced) else if (this.Difficulty == Difficulty.Master) { playerVal = this.Master.OpponentsVal; } //End else if (this.Difficulty == Difficulty.Master) this.Board.setState(playerChoice, playerVal); this.Beginner.Board.setState(playerChoice, this.Advanced.OpponentsVal); this.Advanced.Board.setState(playerChoice, this.Advanced.OpponentsVal); this.Master.Board.setState(playerChoice, this.Master.OpponentsVal); displayData(this.Board.displayBoard()); } //End private void btnPlace_Click(object sender, EventArgs e)
} //End public bool isNotVal(Point tileToConsider, BoardVals valToAvoid) /// <summary> /// Places the given value in a tile if it's empty /// </summary> /// <param name="tileToConsider"></param> /// <param name="valToBePlaced"></param> /// <returns></returns> public bool setState(Point tileToConsider, BoardVals valToBePlaced) { //Declare variables bool returnVal = false; if (isValidSpace(tileToConsider, BoardVals.NULL)) { this.Board[tileToConsider.X, tileToConsider.Y] = valToBePlaced; returnVal = true; } //End if (isValidSpace(tileToConsider, BoardVals.NULL)) return(returnVal); } //End public bool setState(Point tileToConsider, BoardVals valToBePlaced)
public bool isNotVal(Point tileToConsider, BoardVals valToAvoid) { //Declare variables bool returnVal = false; if ((tileToConsider.X >= 0 && tileToConsider.X < 5) && (tileToConsider.Y >= 0 && tileToConsider.Y < 6)) { if (this.Board[tileToConsider.X, tileToConsider.Y] != valToAvoid) { returnVal = true; } //End if (this.Board[tileToConsider.X, tileToConsider.Y] == valToConsider) } //End if ((tileToConsider.X >= 0 && tileToConsider.X < 5) && (tileToConsider.Y >= 0 && tileToConsider.Y < 6)) else { ///Seems stupid to always return true, however, a tile outside the game board ///is indeed not the value that was passed, so technically is true. ///This helps handle the case where there are n in a row, with one end against ///the edge of the board. returnVal = true; } //End else return(returnVal); } //End public bool isNotVal(Point tileToConsider, BoardVals valToAvoid)
} //End private BoardVals OpponentsVal /***************CONSTRUCTOR***************/ public Beginner(BoardVals _PlayersVal) { this.PlayersVal = _PlayersVal; this.Board = new GameBoard(); } //End