public IGameState ExecuteTurn(IGameState state) { IPlayer player = state.Player; ITile[,] tiles = state.Map.GetCurrentLayer().Tiles; ILayer layer = state.Map.GetCurrentLayer(); if (_validator.Validate(player.Position, player.NextMove, tiles)) { List <ICharacter> characters = _formatter.ToList(layer.Characters); Queue <ICharacter> characterTurns = _turnScheduler.Schedule(characters); _moveExecutioner.ExecuteMoves(characterTurns, layer); _interactionHandler.Interact(state); } return(state); }
public void TurnScheduler_ScheduleCalled_returnsQueue() { List <ICharacter> characters = new List <ICharacter>(); characters.Add(Substitute.For <ICharacter>()); characters[0].Stats.Speed.Returns(2); characters.Add(Substitute.For <ICharacter>()); characters[1].Stats.Speed.Returns(1); characters.Add(Substitute.For <ICharacter>()); characters[2].Stats.Speed.Returns(5); Queue <ICharacter> characterQueue = _uut.Schedule(characters); Assert.AreEqual(5, characterQueue.Dequeue().Stats.Speed); Assert.AreEqual(2, characterQueue.Dequeue().Stats.Speed); Assert.AreEqual(1, characterQueue.Dequeue().Stats.Speed); }