public void MoveValidator_ValidMoveUp_ReturnsTrue() { IPosition position = new Position(0, 1); Direction direction = Direction.Up; bool result = _uut.Validate(position, direction, _tiles); Assert.AreEqual(true, result); }
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 ArrayList GetCoordinatesAndDirection(out bool isValid, string input) { ArrayList result = new ArrayList(); result.Add("bad command"); isValid = false; string[] userInput = input.Split(' '); if (userInput.Length != 2) { return(result); } string[] data = userInput[1].Split(','); if (data.Length != 3) { return(result); } int x = 0, y = 0; if (!int.TryParse(data[0], out x) || !int.TryParse(data[1], out y)) { return(result); } Facing direction; if (!Enum.TryParse(data[2], out direction)) { return(result); } if (!validator.Validate(x, y)) { return(result); } result[0] = userInput[0]; result.Add(x); result.Add(y); result.Add(direction); isValid = true; return(result); }