sc2reader icon indicating copy to clipboard operation
sc2reader copied to clipboard

How can I get the values inside of PlayerStatsEvent?

Open bw-leran opened this issue 2 years ago • 4 comments

I'm able to get the normal events out of the replays, but when I print it using the following:

  replay = sc2reader.load_replay(
      'path_here',
      engine=sc2reader.engine.GameEngine(plugins=[ContextLoader(), APMTracker(), SelectionTracker()]))
  
  for r in replay.events:
      print(r)

I see the "Stats Update" every 10 seconds like expected, but I can't find a way to actually print out those stats? I'm interested in seeing the player's minerals, vespene gas, etc.

Hope someone can point me in the right direction, thanks!

bw-leran avatar May 24 '22 21:05 bw-leran

This should give you some help hopefully. This has all the various attributes for a PlayerStatsEvent.

https://github.com/ggtracker/sc2reader/blob/12634e133060ef8b8847b06974dcfc75e0e75b23/sc2reader/events/tracker.py#L57

Andrene avatar May 24 '22 23:05 Andrene

I guess you need to filter the events manually and extract interesting data yourself.

NumberPigeon avatar Sep 11 '23 06:09 NumberPigeon

Go to... https://github.com/ggtracker/sc2reader/blob/12634e133060ef8b8847b06974dcfc75e0e75b23/sc2reader/events/tracker.py#L277-L278 After that add...

    def __repr__(self) -> str:
        return f"{self.player}: minerals: {self.minerals_current}, vespene: {self.vespene_current}"

Then replace your print loop with...

print("\n".join(repr(event) for event in replay.events))

cclauss avatar Sep 11 '23 07:09 cclauss

Now you might want to have a look on sc2reader-plugins, and use PlayerStatsTracker, then all the interesting infos in PlayerStatsEvent will be attached to the player objects

NumberPigeon avatar Sep 11 '23 14:09 NumberPigeon