Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I get the values inside of PlayerStatsEvent? #173

Open
bw-leran opened this issue May 24, 2022 · 4 comments
Open

How can I get the values inside of PlayerStatsEvent? #173

bw-leran opened this issue May 24, 2022 · 4 comments

Comments

@bw-leran
Copy link

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!

@Andrene
Copy link
Contributor

Andrene commented May 24, 2022

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

class PlayerStatsEvent(TrackerEvent):

@NumberPigeon
Copy link
Contributor

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

@cclauss
Copy link
Collaborator

cclauss commented Sep 11, 2023

Go to...

def __str__(self):
return self._str_prefix() + "{0: >15} - Stats Update".format(str(self.player))

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))

@NumberPigeon
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants