Exemplo n.º 1
0
 private static ObstacleType Convert(Models.ObstacleType obstacleType)
 {
     return(obstacleType switch
     {
         Models.ObstacleType.ForceField => ObstacleType.ForceField,
         Models.ObstacleType.Lock => ObstacleType.Lock,
         Models.ObstacleType.Stone => ObstacleType.Stone,
         Models.ObstacleType.Ghost => ObstacleType.Ghost,
         _ => throw new ArgumentOutOfRangeException(nameof(obstacleType), obstacleType, null)
     });
        public IEnumerable <ClearObstacle> GetAvailableObstaclesToClear(LocationId atLocationId, Models.ObstacleType obstacleType, Models.World world)
        {
            var connectedPathIds = world.Paths
                                   .Where(path => path.From == atLocationId)
                                   .Select(path => path.Id);

            return(world.Obstacles
                   .Where(obstacle => obstacle.Type == obstacleType && connectedPathIds.Any(pathId => obstacle.BlockedPathIds.Contains(pathId)))
                   .Select(obstacle => new ClearObstacle(obstacle.Id)));
        }