private string ExecuteTurnAction(MoveAwayFrom moveAwayFrom) { if (moveAwayFrom.EnergyCost > EP) { return($"{Name} does not have enough energy to move."); } var nearestPlaces = GetNearestPlaces(); if (nearestPlaces.Any()) { var newPlace = nearestPlaces .OrderByDescending(p => p.DistanceTo(moveAwayFrom.Place)) .First(); var direction = GetDirectionTo(newPlace); if (direction != Direction.None) { DrainEnergy(moveAwayFrom.EnergyCost); PositionTo(newPlace.X, newPlace.Y); return($"{Name} moves {direction}."); } return($"{Name} stays at current position."); } return($"{Name} cannot move in any direction."); }
public void SetUp() { NewPlace = new Mock <IBattlefieldPlace>().Object; TurnAction = Player.TurnActions.TurnAction.Move.AwayFrom(NewPlace) as MoveAwayFrom; }