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
fixing tests from graylinkim/ggtracker merge
  • Loading branch information
StoicLoofah committed Nov 18, 2016
commit e6ca55b28c960771287dac39503655dab1428f61
38 changes: 21 additions & 17 deletions sc2reader/engine/plugins/creeptracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
from sets import Set
except ImportError:
Set = set
from PIL.Image import open as PIL_open
from PIL.Image import ANTIALIAS
try:
# required for CreepTracker, but CreepTracker is optional
from PIL.Image import open as PIL_open
from PIL.Image import ANTIALIAS
except ImportError:
pass
try:
from StringIO import StringIO
except ImportError:
Expand Down Expand Up @@ -43,7 +47,7 @@ def handleUnitDiedEvent(self, event, replay):
except Exception as e:
print("Whoa! {}".format(e))
pass


def handleUnitInitEvent(self,event,replay):
try:
Expand All @@ -53,7 +57,7 @@ def handleUnitInitEvent(self,event,replay):
except Exception as e:
print("Whoa! {}".format(e))
pass

def handleUnitBornEvent(self,event,replay):
try:
if event.unit_type_name== "Hatchery":
Expand Down Expand Up @@ -81,14 +85,14 @@ def handleEndGame(self, event, replay):
pass


## The class used to used to calculate the creep spread
## The class used to used to calculate the creep spread
class creep_tracker():
def __init__(self,replay):
#if the debug option is selected, minimaps will be printed to a file
##and a stringIO containing the minimap image will be saved for
##every minite in the game and the minimap with creep highlighted
##and a stringIO containing the minimap image will be saved for
##every minite in the game and the minimap with creep highlighted
## will be printed out.
self.debug = replay.opt.debug
self.debug = replay.opt['debug']
##This list contains creep spread area for each player
self.creep_spread_by_minute = dict()
## this list contains a minimap highlighted with creep spread for each player
Expand Down Expand Up @@ -125,7 +129,7 @@ def __init__(self,replay):
# resize height to MAPHEIGHT, and compute new width that
# would preserve aspect ratio
self.map_width = int(cropsize[0] * (float(self.map_height) / cropsize[1]))
self.mapSize =self.map_height * self.map_width
self.mapSize =self.map_height * self.map_width

## the following parameters are only needed if minimaps have to be printed
# minimapSize = ( self.map_width,int(self.map_height) )
Expand All @@ -138,10 +142,10 @@ def __init__(self,replay):
imageCenter = [(self.map_width/2), self.map_height/2]
# this is the scaling factor to go from the SC2 coordinate
# system to pixel coordinates
self.image_scale = float(self.map_height) / cropsize[1]
self.image_scale = float(self.map_height) / cropsize[1]
self.transX =imageCenter[0] + self.image_scale * (mapCenter[0])
self.transY = imageCenter[1] + self.image_scale * (mapCenter[1])

def radius_to_map_positions(self,radius):
## this function converts all radius into map coordinates
## centred around the origin that the creep can exist
Expand Down Expand Up @@ -180,7 +184,7 @@ def add_to_list(self,player_id,unit_id,unit_location,unit_type,event_time):
def remove_from_list(self,unit_id,time_frame):
## This function searches is given a unit ID for every unit who died
## the unit id will be searched in cgu_gen_units for matches
## if there are any, that unit will be removed from active CGUs
## if there are any, that unit will be removed from active CGUs
## and appended as a new time frame
for player_id in self.creep_gen_units:
length_cgu_list = len(self.creep_gen_units[player_id])
Expand All @@ -194,7 +198,7 @@ def remove_from_list(self,unit_id,time_frame):
self.creep_gen_units_times[player_id].append(time_frame)

def cgu_gen_times_to_chunks(self,cgu_time_list):
## this function returns the index and value of every cgu time
## this function returns the index and value of every cgu time
maximum_cgu_time = max(cgu_time_list)
for i in range(0, maximum_cgu_time):
a = list(filter(lambda x_y: x_y[1]//60==i , enumerate(cgu_time_list)))
Expand All @@ -211,7 +215,7 @@ def cgu_in_min_to_cgu_units(self,player_id,cgu_in_minutes):
cgu_units.append(self.creep_gen_units[player_id][index])
cgu_max_in_minute = max(cgu_units,key = len)
yield cgu_max_in_minute

def reduce_cgu_per_minute(self,player_id):
#the creep_gen_units_lists contains every single time frame
#where a CGU is added,
Expand All @@ -224,7 +228,7 @@ def reduce_cgu_per_minute(self,player_id):
self.creep_gen_units_times[player_id] = list(minutes)

def get_creep_spread_area(self,player_id):
## iterates through all cgus and and calculate the area
## iterates through all cgus and and calculate the area
for index,cgu_per_player in enumerate(self.creep_gen_units[player_id]):
# convert cgu list into centre of circles and radius
cgu_radius = map(lambda x: (x[1], self.unit_name_to_radius[x[2]]),\
Expand All @@ -234,7 +238,7 @@ def get_creep_spread_area(self,player_id):
creep_area_positions = self.cgu_radius_to_map_positions(cgu_radius,self.radius_to_coordinates)
cgu_event_time = self.creep_gen_units_times[player_id][index]
cgu_event_time_str=str(int(cgu_event_time//60))+":"+str(cgu_event_time%60)
if self.debug:
if self.debug:
self.print_image(creep_area_positions,player_id,cgu_event_time_str)
creep_area = len(creep_area_positions)
self.creep_spread_by_minute[player_id][cgu_event_time]=\
Expand All @@ -251,7 +255,7 @@ def cgu_radius_to_map_positions(self,cgu_radius,radius_to_coordinates):
point = cgu[0]
radius = cgu[1]
## subtract all radius_to_coordinates with centre of
## cgu radius to change centre of circle
## cgu radius to change centre of circle
cgu_map_position = map( lambda x:(x[0]+point[0],x[1]+point[1])\
,self.radius_to_coordinates[radius])
total_points_on_map= total_points_on_map | Set(cgu_map_position)
Expand Down
7 changes: 5 additions & 2 deletions test_replays/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import unittest

import sc2reader
from sc2reader.exceptions import CorruptTrackerFileError

sc2reader.log_utils.log_to_console("INFO")

Expand Down Expand Up @@ -395,8 +396,10 @@ def test_creepTracker(self):
assert replay.player[2].creep_spread_by_minute[780] == 22.42

def test_bad_unit_ids(self):
replay = sc2reader.load_replay("test_replays/2.0.11.26825/bad_unit_ids_1.SC2Replay", load_level=4)
replay = sc2reader.load_replay("test_replays/2.0.9.26147/bad_unit_ids_2.SC2Replay", load_level=4)
with self.assertRaises(CorruptTrackerFileError):
replay = sc2reader.load_replay("test_replays/2.0.11.26825/bad_unit_ids_1.SC2Replay", load_level=4)
with self.assertRaises(CorruptTrackerFileError):
replay = sc2reader.load_replay("test_replays/2.0.9.26147/bad_unit_ids_2.SC2Replay", load_level=4)

def test_daedalus_point(self):
replay = sc2reader.load_replay("test_replays/2.0.11.26825/DaedalusPoint.SC2Replay")
Expand Down