Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
dda41fb
Fix up event names and hierarchy.
GraylinKim Sep 22, 2013
24c0acf
Flesh out the ping class.
GraylinKim Sep 22, 2013
bb8f9d2
Misc. documentation improvements.
GraylinKim Sep 22, 2013
1d03283
First pass at replay resume support. refs #91
GraylinKim Sep 22, 2013
e672168
Remove unused player_names. closes #158.
GraylinKim Nov 17, 2013
a3153db
Remove map specific attributes from the listing.
GraylinKim Dec 2, 2013
6fb12e8
Raise an informative error on corrupt tracker file
GraylinKim Dec 2, 2013
caeb6ca
Fix python3 bug in plugin error handling routine.
GraylinKim Dec 2, 2013
2b35c07
Fixes #160 with non back compatible changes.
GraylinKim Dec 2, 2013
72da6ae
Remove some old % style string formatting.
GraylinKim Dec 2, 2013
6d13524
And this is why you run tests before pushing.
GraylinKim Dec 2, 2013
665cc12
Make note of the additional changes in the log.
GraylinKim Dec 2, 2013
1d9c141
adding a missing change from the list
StoicLoofah Dec 6, 2013
52e5be9
Merge pull request #163 from StoicLoofah/update-0.7-changelog
GraylinKim Dec 7, 2013
fe86668
Remove a couple more defunct replay attributes.
GraylinKim Dec 11, 2013
9283c33
Use generic UnitType and Ability classes for data.
GraylinKim Dec 11, 2013
4d068bf
datapacks is a better word than builds here.
GraylinKim Dec 11, 2013
0e6286f
Replace all references to gateway with region.
GraylinKim Dec 11, 2013
d9df519
Fix typo.
GraylinKim Dec 11, 2013
bd2a8cf
Use a regular dict for raw data results.
GraylinKim Dec 11, 2013
f58daf7
Remove stray reference.
GraylinKim Dec 11, 2013
b968b57
Misc import and documentation improvements.
GraylinKim Dec 11, 2013
81809e5
Don't forget the tests.
GraylinKim Dec 11, 2013
03bbdae
Our readers and lambdas can't be pickled.
GraylinKim Dec 11, 2013
b421a7c
Initial pass at PTR 2.1 support.
GraylinKim Dec 11, 2013
38dfa77
Fix small bugs in PTR support.
GraylinKim Dec 12, 2013
ba404a5
Clarify the highest leauge user attribute.
GraylinKim Dec 12, 2013
94263a5
The clan logo is a DepotFile location, not a string.
GraylinKim Dec 13, 2013
f012566
Fixes #165, properly parse mouse click events.
GraylinKim Dec 13, 2013
4b45b62
Fix initdata parsing for base_build 23260 replays.
GraylinKim Dec 13, 2013
53e5678
Add killer logic to ContextLoader, refine the API.
GraylinKim Dec 19, 2013
e5001a3
added a replay thats failing for GGTracker, but surprisingly it turns…
dsjoerg Jan 5, 2014
00411e3
Bump mpyq version.
GraylinKim Jan 8, 2014
18ca54c
fix name of 'ControlGroupEvent' in comments
eqy Jan 30, 2014
a303fd7
Merge pull request #167 from eqy/patch-1
GraylinKim Jan 30, 2014
9277ec4
No more lints.
Apr 13, 2014
d275182
Merge pull request #168 from MakozFriends/master
GraylinKim Apr 15, 2014
214cd7c
Fixes SelectionTracker plugin with new handler names.
Apr 23, 2014
1a6220b
Merge pull request #169 from MakozFriends/hotfix/selectiontracker
GraylinKim May 5, 2014
b35d88c
new failing test for replays that started by loading a saved game
dsjoerg Jun 30, 2014
c860d8e
fix for replays that started with a load from a saved game
dsjoerg Jun 30, 2014
89f4eee
amended author info
dsjoerg Sep 26, 2014
6f30900
fix for 2.1.4
dsjoerg Sep 26, 2014
6580ebb
Fix various issues related to issue #180.
GraylinKim Dec 29, 2014
0dbe561
Fix gameheart plugin handling of teams and observers. Closes #174.
GraylinKim Dec 29, 2014
83d3809
Add option to print observers to sc2printer.
GraylinKim Dec 29, 2014
26c569e
Harden up the code for processing s2ma files.
GraylinKim Dec 29, 2014
6c48e8a
This is a polish translation.
GraylinKim Dec 29, 2014
a194b67
Remove PersonDict and AttributeDict implementations.
GraylinKim Dec 31, 2014
3e1cea3
Remove dead code.
GraylinKim Jan 5, 2015
722ae4f
Bump version to a pre-release (for clarity).
GraylinKim Jan 5, 2015
c5d22d6
decoding this so that it reads as a string not bytes in python 3
StoicLoofah Feb 11, 2015
4b3bd9b
Merge pull request #183 from StoicLoofah/decode_upgrade_type_name
GraylinKim Mar 3, 2015
20156ec
Fix ancient typo in struct decoder. refs #184
GraylinKim Mar 15, 2015
2139abc
remove debugging print statement
dsjoerg Oct 7, 2015
d69feb4
add failing test for 3.0
dsjoerg Oct 7, 2015
d5eb61a
Merge remote-tracking branch 'upstream/master' into ggtracker/upstream
StoicLoofah Nov 18, 2016
e6ca55b
fixing tests from graylinkim/ggtracker merge
StoicLoofah Nov 18, 2016
c86eb5a
fixing more references from the CHANGELOG
StoicLoofah Nov 28, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes #160 with non back compatible changes.
Renames all ability events as following:

* AbilityEvent -> CommandEvent
* AbilityEvent -> BasicCommandEvent
* TargetAbilityEvent -> TargetUnitCommandEvent
* LocationAbilityEvent -> TargetPointCommandEvent

As such, all references to these classes, statements that check the event name,
and engine plugin event handlers need to be renamed. Its not ideal but it is
much better than being wrong.
  • Loading branch information
GraylinKim committed Dec 2, 2013
commit 2b35c07e09eceafa47a0d1c9470bf3e5ffe18725
2 changes: 1 addition & 1 deletion sc2reader/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, unit_id):
self.killed_by = None

#: The unique in-game id for this unit. The id can sometimes be zero because
#: TargetAbilityEvents will create a new unit with id zero when a unit
#: TargetUnitCommandEvents will create a new unit with id zero when a unit
#: behind the fog of war is targetted.
self.id = unit_id

Expand Down
18 changes: 9 additions & 9 deletions sc2reader/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class GameEngine(object):
Example Usage::

class Plugin1():
def handleAbilityEvent(self, event, replay):
def handleCommandEvent(self, event, replay):
pass

class Plugin2():
def handleEvent(self, event, replay):
pass

def handleTargetAbilityEvent(self, event, replay):
def handleTargetUnitCommandEvent(self, event, replay):
pass

...
Expand All @@ -35,11 +35,11 @@ def handleTargetAbilityEvent(self, event, replay):
engine.reigster_plugin(Plugin(5))
engine.run(replay)

Calls functions in the following order for a ``TargetAbilityEvent``::
Calls functions in the following order for a ``TargetUnitCommandEvent``::

Plugin1.handleAbilityEvent(event, replay)
Plugin1.handleCommandEvent(event, replay)
Plugin2.handleEvent(event, replay)
Plugin2.handleTargetAbilityEvent(event, replay)
Plugin2.handleTargetUnitCommandEvent(event, replay)


Plugin Specification
Expand All @@ -57,7 +57,7 @@ def handleEventName(self, event, replay)
* handleMessageEvent - called for events in replay.message.events
* handleGameEvent - called for events in replay.game.events
* handleTrackerEvent - called for events in replay.tracker.events
* handleAbilityEvent - called for all types of ability events
* handleCommandEvent - called for all types of command events
* handleControlGroupEvent - called for all player control group events

Plugins may also handle optional ``InitGame`` and ``EndGame`` events generated
Expand Down Expand Up @@ -90,7 +90,7 @@ def handleEvent(self, event, replay):
return
...

def handleAbilityEvent(self, event, replay):
def handleCommandEvent(self, event, replay):
try:
possibly_throwing_error()
catch Error as e:
Expand Down Expand Up @@ -204,8 +204,8 @@ def _get_plugin_event_handlers(self, plugin, event):
handlers.append(getattr(plugin, 'handleGameEvent', None))
if isinstance(event, TrackerEvent) and hasattr(plugin, 'handleTrackerEvent'):
handlers.append(getattr(plugin, 'handleTrackerEvent', None))
if isinstance(event, AbilityEvent) and hasattr(plugin, 'handleAbilityEvent'):
handlers.append(getattr(plugin, 'handleAbilityEvent', None))
if isinstance(event, CommandEvent) and hasattr(plugin, 'handleCommandEvent'):
handlers.append(getattr(plugin, 'handleCommandEvent', None))
if isinstance(event, ControlGroupEvent) and hasattr(plugin, 'handleControlGroupEvent'):
handlers.append(getattr(plugin, 'handleControlGroupEvent', None))
if hasattr(plugin, 'handle'+event.name):
Expand Down
4 changes: 2 additions & 2 deletions sc2reader/engine/plugins/apm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class APMTracker(object):
"""
Builds ``player.aps`` and ``player.apm`` dictionaries where an action is
any Selection, ControlGroup, or Ability event.
any Selection, ControlGroup, or Command event.

Also provides ``player.avg_apm`` which is defined as the sum of all the
above actions divided by the number of seconds played by the player (not
Expand All @@ -31,7 +31,7 @@ def handleSelectionEvent(self, event, replay):
event.player.aps[event.second] += 1
event.player.apm[int(event.second/60)] += 1

def handleAbilityEvent(self, event, replay):
def handleCommandEvent(self, event, replay):
event.player.aps[event.second] += 1
event.player.apm[int(event.second/60)] += 1

Expand Down
4 changes: 2 additions & 2 deletions sc2reader/engine/plugins/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def handleGameEvent(self, event, replay):
def handleMessageEvent(self, event, replay):
self.load_message_game_player(event, replay)

def handleAbilityEvent(self, event, replay):
def handleCommandEvent(self, event, replay):
if not replay.datapack:
return

Expand All @@ -43,7 +43,7 @@ def handleAbilityEvent(self, event, replay):
elif event.other_unit_id is not None:
self.logger.error("Other unit {0} not found".format(event.other_unit_id))

def handleTargetAbilityEvent(self, event, replay):
def handleTargetUnitCommandEvent(self, event, replay):
if not replay.datapack:
return

Expand Down
67 changes: 41 additions & 26 deletions sc2reader/events/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,31 +105,31 @@ def __init__(self, frame, pid, data):
def create_command_event(frame, pid, data):
ability_type = data['data'][0]
if ability_type == 'None':
return AbilityEvent(frame, pid, data)
return BasicCommandEvent(frame, pid, data)

elif ability_type == 'TargetUnit':
return TargetAbilityEvent(frame, pid, data)
return TargetUnitCommandEvent(frame, pid, data)

elif ability_type == 'TargetPoint':
return LocationAbilityEvent(frame, pid, data)
return TargetPointCommandEvent(frame, pid, data)

elif ability_type == 'Data':
return SelfAbilityEvent(frame, pid, data)
return DataCommandEvent(frame, pid, data)


@loggable
class AbilityEvent(GameEvent):
class CommandEvent(GameEvent):
"""
Ability events are generated when ever a player in the game issues a command
to a unit or group of units. They are split into three subclasses of ability,
each with their own set of associated data. The attributes listed below are
shared across all ability event types.

See :class:`LocationAbilityEvent`, :class:`TargetAbilityEvent`, and :class:`SelfAbilityEvent`
for individual details.
See :class:`TargetPointCommandEvent`, :class:`TargetUnitCommandEvent`, and
:class:`DataCommandEvent` for individual details.
"""
def __init__(self, frame, pid, data):
super(AbilityEvent, self).__init__(frame, pid)
super(CommandEvent, self).__init__(frame, pid)

#: Flags on the command???
self.flags = data['flags']
Expand Down Expand Up @@ -235,25 +235,38 @@ def __str__(self):
return string


class LocationAbilityEvent(AbilityEvent):
class BasicCommandEvent(CommandEvent):
"""
Extends :class:`AbilityEvent`
Extends :class:`CommandEvent`

This event is recorded for events that have no extra information recorded.

Note that like all CommandEvents, the event will be recorded regardless
of whether or not the command was successful.
"""
def __init__(self, frame, pid, data):
super(TargetPointCommandEvent, self).__init__(frame, pid, data)


class TargetPointCommandEvent(CommandEvent):
"""
Extends :class:`CommandEvent`

This event is recorded when ever a player issues a command that targets a location
and NOT a unit. Commands like Psistorm, Attack Move, Fungal Growth, and EMP fall
under this category.

Note that like all AbilityEvents, the event will be recorded regardless
Note that like all CommandEvents, the event will be recorded regardless
of whether or not the command was successful.
"""
def __init__(self, frame, pid, data):
super(LocationAbilityEvent, self).__init__(frame, pid, data)
super(TargetPointCommandEvent, self).__init__(frame, pid, data)

#: The x coordinate of the target. Available for TargetPoint and TargetUnit type events.
self.x = self.ability_type_data['point'].get('x', 0)/4096.0
self.x = self.ability_type_data['point'].get('x', 0) / 4096.0

#: The y coordinate of the target. Available for TargetPoint and TargetUnit type events.
self.y = self.ability_type_data['point'].get('y', 0)/4096.0
self.y = self.ability_type_data['point'].get('y', 0) / 4096.0

#: The z coordinate of the target. Available for TargetPoint and TargetUnit type events.
self.z = self.ability_type_data['point'].get('z', 0)
Expand All @@ -262,18 +275,19 @@ def __init__(self, frame, pid, data):
self.location = (self.x, self.y, self.z)


class TargetAbilityEvent(AbilityEvent):
class TargetUnitCommandEvent(CommandEvent):
"""
Extends :class:`AbilityEvent`
Extends :class:`CommandEvent`

TargetAbilityEvents are recorded when ever a player issues a command that targets a unit.
This event is recorded when ever a player issues a command that targets a unit.
The location of the target unit at the time of the command is also recorded. Commands like
Chronoboost, Transfuse, and Snipe fall under this category.

Note that all AbilityEvents are recorded regardless of whether or not the command was successful.
Note that like all CommandEvents, the event will be recorded regardless
of whether or not the command was successful.
"""
def __init__(self, frame, pid, data):
super(TargetAbilityEvent, self).__init__(frame, pid, data)
super(TargetUnitCommandEvent, self).__init__(frame, pid, data)

#: Flags set on the target unit. Available for TargetUnit type events
self.target_flags = self.ability_type_data.get('flags', None)
Expand Down Expand Up @@ -301,10 +315,10 @@ def __init__(self, frame, pid, data):
self.upkeep_player_id = self.ability_type_data.get('upkeep_player_id', None)

#: The x coordinate of the target. Available for TargetPoint and TargetUnit type events.
self.x = self.ability_type_data['point'].get('x', 0)/4096.0
self.x = self.ability_type_data['point'].get('x', 0) / 4096.0

#: The y coordinate of the target. Available for TargetPoint and TargetUnit type events.
self.y = self.ability_type_data['point'].get('y', 0)/4096.0
self.y = self.ability_type_data['point'].get('y', 0) / 4096.0

#: The z coordinate of the target. Available for TargetPoint and TargetUnit type events.
self.z = self.ability_type_data['point'].get('z', 0)
Expand All @@ -313,17 +327,18 @@ def __init__(self, frame, pid, data):
self.location = (self.x, self.y, self.z)


class SelfAbilityEvent(AbilityEvent):
class DataCommandEvent(CommandEvent):
"""
Extends :class:`AbilityEvent`
Extends :class:`CommandEvent`

SelfAbilityEvents are recorded when ever a player issues a command that has no target. Commands
DataCommandEvent are recorded when ever a player issues a command that has no target. Commands
like Burrow, SeigeMode, Train XYZ, and Stop fall under this category.

Note that all AbilityEvents are recorded regardless of whether or not the command was successful.
Note that like all CommandEvents, the event will be recorded regardless
of whether or not the command was successful.
"""
def __init__(self, frame, pid, data):
super(SelfAbilityEvent, self).__init__(frame, pid, data)
super(DataCommandEvent, self).__init__(frame, pid, data)

#: Other target data. Available for Data type events.
self.target_data = self.ability_type_data.get('data', None)
Expand Down
2 changes: 1 addition & 1 deletion sc2reader/events/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class UnitBornEvent(TrackerEvent):

Unfortunately, units that are born do not have events marking their beginnings like
:class:`UnitInitEvent` and :class:`UnitDoneEvent` do. The closest thing to it are the
:class:`~sc2reader.event.game.AbilityEvent` game events where the ability is a train unit
:class:`~sc2reader.event.game.CommandEvent` game events where the command is a train unit
command.
"""
def __init__(self, frames, data, build):
Expand Down
4 changes: 2 additions & 2 deletions sc2reader/factories/plugins/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def toDict(replay):
def APMTracker(replay):
"""
Builds ``player.aps`` and ``player.apm`` dictionaries where an action is
any Selection, Hotkey, or Ability event.
any Selection, Hotkey, or Command event.

Also provides ``player.avg_apm`` which is defined as the sum of all the
above actions divided by the number of seconds played by the player (not
Expand All @@ -106,7 +106,7 @@ def APMTracker(replay):
player.seconds_played = replay.length.seconds

for event in player.events:
if event.name == 'SelectionEvent' or 'AbilityEvent' in event.name or 'ControlGroup' in event.name:
if event.name == 'SelectionEvent' or 'CommandEvent' in event.name or 'ControlGroup' in event.name:
player.aps[event.second] += 1
player.apm[int(event.second/60)] += 1

Expand Down
2 changes: 1 addition & 1 deletion sc2reader/scripts/sc2parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def main():
human.pids = set([human.pid for human in replay.humans])
event_pids = set([event.player.pid for event in replay.events if getattr(event, 'player', None)])
player_pids = set([player.pid for player in replay.players if player.is_human])
ability_pids = set([event.player.pid for event in replay.events if 'AbilityEvent' in event.name])
ability_pids = set([event.player.pid for event in replay.events if 'CommandEvent' in event.name])
if human.pids != event_pids:
print('Event Pid problem! pids={pids} but event pids={event_pids}'.format(pids=human.pids, event_pids=event_pids))
print(' with {path}: {build} - {real_type} on {map_name} - Played {start_time}'.format(path=path, **replay.__dict__))
Expand Down
4 changes: 2 additions & 2 deletions sc2reader/scripts/sc2replayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def getch():
def main():
parser = argparse.ArgumentParser(
description="""Step by step replay of game events; shows only the
Initialization, Ability, and Selection events by default. Press any
Initialization, Command, and Selection events by default. Press any
key to advance through the events in sequential order."""
)

Expand Down Expand Up @@ -77,7 +77,7 @@ def main():
# Loop through the events
for event in events:

if isinstance(event, AbilityEvent) or \
if isinstance(event, CommandEvent) or \
isinstance(event, SelectionEvent) or \
isinstance(event, PlayerLeaveEvent) or \
isinstance(event, GameStartEvent) or \
Expand Down