Repository: PokemonGoF/PokemonGo-Bot

Issue:
[BUG] Calling an object not instatiated after #4333
### Config

```
      "type": "MoveToMapPokemon",
      "config": {
        "address": "http://localhost:5000",
        "max_distance": 500,
        "min_ball": 20,
        "prioritize_vips": true,
        "snipe": true,
        "snipe_high_prio_only": true,
        "snipe_high_prio_threshold": 400,
        "update_map": true,
        "mode": "priority",
        "map_path": "raw_data",
        "walker": "StepWalker",
        "max_extra_dist_fort": 10,
        …
```

Seems like #4333 made appear a bug.
Apparently `step_walker = self._move_to_pokemon_througt_fort(nearest_fort, pokemon)` doesn’t always return a StepWalker, causing the error when calling it later `if not step_walker.step():`
See line 297 of move_to_map_pokemon.py

```
step_walker = self._move_to_pokemon_througt_fort(nearest_fort, pokemon)
if not step_walker.step():
```
### Output when issue occurred

```
Traceback (most recent call last):
  File "pokecli.py", line 677, in <module>
    main()
  File "pokecli.py", line 118, in main
    bot.tick()
  File "/home/brice/Code/PokemonGo-Bot/pokemongo_bot/__init__.py", line 561, in tick
    if worker.work() == WorkerResult.RUNNING:
  File "/home/brice/Code/PokemonGo-Bot/pokemongo_bot/cell_workers/move_to_map_pokemon.py", line 297, in work
    if not step_walker.step():
AttributeError: 'NoneType' object has no attribute 'step'
l
```
### Steps to Reproduce

Use MoveToMapPokemon
### Other Information

OS: Archlinux
Branch: dev
Git Commit: c4d651c59cbf6a5ad9a629bc129002a7c798db24
Python Version: Python 2.7.12



Discussion:
I guess the `return` at line 440 should not be inside the `if`

#### EDIT

I guess when it reaches the fort (when it doesn't go inside that if) it should spin the fort and return a StepWalker to the pokemon or any location, since it will be recalculated. 


Resolving patch:
diff --git a/pokemongo_bot/cell_workers/move_to_map_pokemon.py b/pokemongo_bot/cell_workers/move_to_map_pokemon.py
--- a/pokemongo_bot/cell_workers/move_to_map_pokemon.py
+++ b/pokemongo_bot/cell_workers/move_to_map_pokemon.py
@@ -430,27 +430,23 @@ def _move_to_pokemon_througt_fort(self, fort, pokemon):
                 'poke_dist': (format_dist(pokemon['dist'], self.unit))
             }
 
-
             self.emit_event(
                 'moving_to_pokemon_throught_fort',
                 formatted="Moving towards {poke_name} - {poke_dist}  through pokestop  {fort_name} - {distance}",
                 data= pokemon_throught_fort_event_data
             )
+        else:
+            self.emit_event(
+                'arrived_at_fort',
+                formatted='Arrived at fort.'
+            )	
 
-            return walker_factory(self.walker,
-                self.bot,
-                lat,
-                lng
-                )
-
-
-        self.emit_event(
-            'arrived_at_fort',
-            formatted='Arrived at fort.'
+	return walker_factory(self.walker,
+            self.bot,
+            lat,
+            lng
         )
 
-
-
     def get_nearest_fort_on_the_way(self, pokemon):
         forts = self.bot.get_forts(order_by_distance=True)
 


Test patch: