public IEnumerator MakeMove_executesValidMove() { Setup(); Player nonHumanPlayer = game.players [2]; game.currentPlayer = nonHumanPlayer; //Set current player to the NonHumanPlayer game.currentPlayer.SetActive(true); //Activate player foreach (Player player in game.players) { if (player != nonHumanPlayer) { for (int i = 0; i < player.units.Count; i++) //remove units from other players. { player.units[i].DestroySelf(); } } } int expectedNumberOfSectorsOwned = nonHumanPlayer.ownedSectors.Count + 2; //expected that the NonHumanPlayer will make a move into an unowned sector. Sector unitsOriginSector = nonHumanPlayer.units[0].GetSector(); NonHumanPlayer computerPlayer = (NonHumanPlayer)nonHumanPlayer; computerPlayer.makeMove(game.GetTurnState()); Assert.AreEqual(expectedNumberOfSectorsOwned, nonHumanPlayer.ownedSectors.Count); Assert.AreNotSame(unitsOriginSector, nonHumanPlayer.units [0].GetSector()); yield return(null); }
/** * nonHumanPlayerTurn(): * ADDITION: 01/02/18 * Checks to see if the current player is a non-human player, and if so, calls its makeMove method. * This has been added to allow for the AI functionality. */ public void nonHumanPlayerTurn() { if (this.currentPlayer != null) { if (this.currentPlayer.GetType() == typeof(NonHumanPlayer)) { NonHumanPlayer compPlayer = (NonHumanPlayer)this.currentPlayer; compPlayer.makeMove(this.turnState); } } }