ggtracker / sc2reader

Extracts gameplay information from Starcraft II replay files
http://pypi.python.org/pypi/sc2reader
MIT License
145 stars 144 forks source link

a TypeError when printing events. #63

Closed miguelgondu closed 5 years ago

miguelgondu commented 6 years ago

First of all, thanks for maintaining this code. It's a great tool, now that SC2 is becoming the testbed for RTS AI.

There seems to be a bug when printing UnitBornEvents. I loaded a replay (that I link to) and tried to print all the events with a for loop:

replay1 = sc2reader.load_replay('solar1.SC2Replay', load_map=True)
for event in replay1.events:
    print(event)

and the first two events (PlayerSetupEvents) print just fine, but once they come to the first UnitBornEvents (the ones that concern mineral fields, for example), I get the following TypeError:


TypeError Traceback (most recent call last)

in () 1 for event in replay1.events: ----> 2 print(event) ~/.virtualenvs/StarCraft2_venv/lib/python3.5/site-packages/sc2reader/events/tracker.py in __str__(self) 292 293 def __str__(self): --> 294 return self._str_prefix() + "{0: >15} - Unit born {1}".format(self.unit_upkeeper, self.unit) 295 296 TypeError: non-empty format string passed to object.__format__ --------------------------------------------------------------------------- Checking the variables that are to be formatted into the string, it seems that `self.unit_upkeeper` is `None` for these particular `UnitBornEvents`. It may be a bug. Thanks!
StoicLoofah commented 5 years ago

@miguelgondu does the latest version address your problem?

StoicLoofah commented 5 years ago

Closing this out as completed. @miguelgondu you can re-open if you still notice issues