Repository: hsahovic/poke-env

Issue:
parsing error on showdown-format teams without items
Teambuilder class doesn't work with showdown-format teams when a Pokémon doesn't have items. Same team functioned properly when adding an item to each Pokémon.

Log:
```
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-21-ae950723727d> in <module>
     10         team=opponent_team,
     11         max_concurrent_battles=20,
---> 12         log_level=40,
     13      )

C:\ProgramData\Anaconda3\lib\site-packages\poke_env\player\player.py in __init__(self, player_configuration, avatar, battle_format, log_level, max_concurrent_battles, server_configuration, start_listening, team)
    111             self._team = team
    112         elif isinstance(team, str):
--> 113             self._team = ConstantTeambuilder(team)
    114         else:
    115             self._team = None

C:\ProgramData\Anaconda3\lib\site-packages\poke_env\teambuilder\constant_teambuilder.py in __init__(self, team)
     11             self.converted_team = team
     12         else:
---> 13             mons = self.parse_showdown_team(team)
     14             self.converted_team = self.join_team(mons)
     15 

C:\ProgramData\Anaconda3\lib\site-packages\poke_env\teambuilder\teambuilder.py in parse_showdown_team(team)
     89                     mon_info, item = line.split(" @ ")
     90                     current_mon.item = item.strip()
---> 91                 split_mon_info = mon_info.split(" ")
     92 
     93                 if split_mon_info[-1] == "(M)":

UnboundLocalError: local variable 'mon_info' referenced before assignment
```

Code that generated error:
```
opponent_team="""
Flareon  
Ability: Flash Fire  
EVs: 252 HP / 126 Def / 126 SpD / 4 Spe  
Hardy Nature  
- Flare Blitz  
- Superpower  
- Double-Edge  
- Iron Tail  

Ninetales  
Ability: Flash Fire  
EVs: 252 HP / 126 Def / 126 SpD / 4 Spe  
IVs: 0 Atk  
- Flamethrower  
- Extrasensory  
- Calm Mind  
- Dark Pulse  

Arcanine  
Ability: Flash Fire  
EVs: 252 HP / 126 Def / 126 SpD / 4 Spe  
- Flare Blitz  
- Wild Charge  
- Facade  
- Crunch  

Heatmor  
Ability: Flash Fire  
EVs: 252 HP / 126 Def / 126 SpD / 4 Spe  
- Flare Blitz  
- Body Slam  
- Night Slash  
- Stomping Tantrum  

Typhlosion  
Ability: Flash Fire  
EVs: 252 HP / 126 Def / 126 SpD / 4 Spe  
- Flamethrower  
- Extrasensory  
- Flare Blitz  
- Earthquake  

Rapidash  
Ability: Flash Fire  
EVs: 252 HP / 126 Def / 126 SpD / 4 Spe  
- Flare Blitz  
- Wild Charge  
- Drill Run  
- Poison Jab  
"""

p2 = SimpleHeuristicsPlayer(
        battle_format='gen8nationaldexag',
        team=opponent_team,
        max_concurrent_battles=20,
        log_level=40,
     )
```

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/hsahovic/poke-env/pull/68?src=pr&el=h1) Report
> Merging [#68](https://codecov.io/gh/hsahovic/poke-env/pull/68?src=pr&el=desc) into [master](https://codecov.io/gh/hsahovic/poke-env/commit/8c0fbbde4587fd8ff984bc64ac1baab9b102de51?el=desc) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.


```diff
@@           Coverage Diff           @@
##           master      #68   +/-   ##
=======================================
  Coverage   81.34%   81.35%           
=======================================
  Files          31       31           
  Lines        2455     2456    +1     
=======================================
+ Hits         1997     1998    +1     
  Misses        458      458           
```


Patch:
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 3349981..f40d161 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -37,7 +37,7 @@ jobs:
       # Download and cache dependencies
       - restore_cache:
           keys:
-            - requirements-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "python-version.txt" }}-v3
+            - requirements-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "python-version.txt" }}-v4
 
       - run:
           name: install dependencies
@@ -134,13 +134,13 @@ jobs:
       - run:
           name: Uninstall poke-env before caching
           command: |
-            pip uninstall poke-env
+            pip uninstall poke-env --yes
 
       - save_cache:
           paths:
             - ./venv
             - ./Pokemon-Showdown
-          key: requirements-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "python-version.txt" }}-v3
+          key: requirements-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}-{{ checksum "python-version.txt" }}-v4
 
       - run:
           name: Start showdown server in the background
diff --git a/src/poke_env/teambuilder/teambuilder.py b/src/poke_env/teambuilder/teambuilder.py
index f1b2264..b5f6f91 100644
--- a/src/poke_env/teambuilder/teambuilder.py
+++ b/src/poke_env/teambuilder/teambuilder.py
@@ -88,6 +88,8 @@ class Teambuilder(ABC):
                 if "@" in line:
                     mon_info, item = line.split(" @ ")
                     current_mon.item = item.strip()
+                else:
+                    mon_info = line
                 split_mon_info = mon_info.split(" ")
 
                 if split_mon_info[-1] == "(M)":


Test patch:
diff --git a/unit_tests/teambuilder/test_constant_teambuilder.py b/unit_tests/teambuilder/test_constant_teambuilder.py
index ccdb69a..c71e02c 100644
--- a/unit_tests/teambuilder/test_constant_teambuilder.py
+++ b/unit_tests/teambuilder/test_constant_teambuilder.py
@@ -20,3 +20,63 @@ def test_constant_teambuilder_yields_showdown(
             tb = ConstantTeambuilder(showdown_team)
             for _ in range(10):
                 assert tb.yield_team() == packed_team
+
+
+def test_showdown_team_parsing_works_without_items():
+    team = """
+Flareon
+Ability: Flash Fire
+EVs: 252 HP / 126 Def / 126 SpD / 4 Spe
+Hardy Nature
+- Flare Blitz
+- Superpower
+- Double-Edge
+- Iron Tail
+
+Ninetales
+Ability: Flash Fire
+EVs: 252 HP / 126 Def / 126 SpD / 4 Spe
+IVs: 0 Atk
+- Flamethrower
+- Extrasensory
+- Calm Mind
+- Dark Pulse
+
+Arcanine
+Ability: Flash Fire
+EVs: 252 HP / 126 Def / 126 SpD / 4 Spe
+- Flare Blitz
+- Wild Charge
+- Facade
+- Crunch
+
+Heatmor
+Ability: Flash Fire
+EVs: 252 HP / 126 Def / 126 SpD / 4 Spe
+- Flare Blitz
+- Body Slam
+- Night Slash
+- Stomping Tantrum
+
+Typhlosion
+Ability: Flash Fire
+EVs: 252 HP / 126 Def / 126 SpD / 4 Spe
+- Flamethrower
+- Extrasensory
+- Flare Blitz
+- Earthquake
+
+Rapidash
+Ability: Flash Fire
+EVs: 252 HP / 126 Def / 126 SpD / 4 Spe
+- Flare Blitz
+- Wild Charge
+- Drill Run
+- Poison Jab
+"""
+
+    packed_team = "Flareon|||flashfire|flareblitz,superpower,doubleedge,irontail|Hardy|252,,126,,126,4|||||]Ninetales|||flashfire|flamethrower,extrasensory,calmmind,darkpulse||252,,126,,126,4||,0,,,,|||]Arcanine|||flashfire|flareblitz,wildcharge,facade,crunch||252,,126,,126,4|||||]Heatmor|||flashfire|flareblitz,bodyslam,nightslash,stompingtantrum||252,,126,,126,4|||||]Typhlosion|||flashfire|flamethrower,extrasensory,flareblitz,earthquake||252,,126,,126,4|||||]Rapidash|||flashfire|flareblitz,wildcharge,drillrun,poisonjab||252,,126,,126,4|||||"  # noqa: E501
+
+    print(ConstantTeambuilder(team).yield_team())
+
+    assert ConstantTeambuilder(team).yield_team() == packed_team