Skip to content

Commit b71c25d

Browse files
committed
Update the documentation for the release
1 parent 6aaec97 commit b71c25d

File tree

12 files changed

+250
-183
lines changed

12 files changed

+250
-183
lines changed

docs/source/index.rst

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,27 @@ Thanks for choosing sc2reader for your Starcraft analysis needs.
66
There is a pressing need in the SC2 community for better statistics, better
77
analytics, better tools for organizing and searching replays. Better websites
88
for sharing replays and hosting tournaments. These tools can't be created with
9-
out first being able to open up replay files and analyse the content within. That's why SC2Reader was built, to provide a solid foundation on which the next
9+
out first being able to open up replay files and analyse the content within.
10+
That's why SC2Reader was built, to provide a solid foundation on which the next
1011
generation of tools and websites can be built and benefit the community.
1112

1213
So lets get you started right away! Through the linked tutorials and reference
1314
pages below we'll get you started building your own tools and systems in no
14-
time. Any questions, suggestions, or concerns should be posted to the sc2reader `mailing list`_. You can also pop on to our #sc2reader, our `IRC channel`_ on Freenode if you want to chat or need some live support.
15+
time. Any questions, suggestions, or concerns should be posted to the sc2reader
16+
`mailing list`_. You can also pop on to our #sc2reader, our `IRC channel`_ on
17+
Freenode if you want to chat or need some live support.
1518

1619
.. _mailing list: http://groups.google.com/group/sc2reader
1720
.. _IRC Channel: http://webchat.freenode.net/?channels=#sc2reader
1821

22+
1923
Tutorials
2024
---------------
2125

2226
The best way to learn how to pick sc2Reader up and get started is probably by example. With that in mind, we've written up a series of tutorials on getting various simple tasks done with sc2reader; hopefully they can serve as a quick on ramp for you.
2327

2428
* :doc:`tutorials/prettyprinter` (10-15 minutes)
25-
* :doc:`tutorials/actionlistener` (10-15 minutes)
29+
2630

2731
Reference Pages
2832
-----------------------
@@ -32,10 +36,10 @@ SC2 replays hold a ton of information. The following reference pages were put to
3236
.. toctree::
3337

3438
sc2reader
35-
mainstructures
36-
supportstructures
37-
listeners
38-
processors
39+
primaryresources
40+
supportobjects
41+
utilityclasses
42+
plugins
3943

4044

4145
.. toctree::
@@ -44,8 +48,8 @@ SC2 replays hold a ton of information. The following reference pages were put to
4448
:glob:
4549

4650
sc2reader
47-
mainstructures
48-
supportstructures
49-
listeners
50-
processors
51-
tutorials/*
51+
primaryresources
52+
supportobjects
53+
utilityclasses
54+
plugins
55+
tutorials/*

docs/source/mainstructures.rst

Lines changed: 0 additions & 90 deletions
This file was deleted.

docs/source/plugins.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Plugins
2+
=============
3+
4+
A plugin is pretty much just a callable function or object that accepts a replay
5+
file as a single argument. sc2reader supports assignment of plugins to different
6+
resource types via the :meth:`SC2Factory.register_plugin` factory method.
7+
8+
::
9+
10+
import sc2reader
11+
from sc2reader.plugins.replay import APMTracker, SelectionTracker
12+
sc2reader.register_plugin('Replay',APMTracker())
13+
sc2reader.register_plugin('Replay',SelectionTracker())
14+
15+
The order you register plugins is the order they are executed in so be careful to
16+
put register in the right order if you have dependencies between plugins.
17+
18+
19+
APMTracker
20+
----------------
21+
22+
The APMTracker adds three simple fields based on a straight tally of non-camera
23+
player action events such as selections, abilities, and hotkeys.
24+
25+
* ``player.aps`` = a dictionary of second => total actions in that second
26+
* ``player.apm`` = a dictionary of minute => total actions in that minute
27+
* ``player.avg_apm`` = Average APM as a float
28+
29+
30+
SelectionTracker
31+
--------------------
32+
33+
The :class:`SelectionTracker` plugin simulates every person's selection at every
34+
frame in both the hotkey and active selection buffers. This selection information
35+
is stored in ``person.selection`` as a two dimensional array of lists.
36+
37+
::
38+
39+
unit_list = replay.player[1].selection[frame][buffer]
40+
41+
Where buffer is a hotkey 0-9 or 10 which represents the active selection.
42+
43+
There are a number of known flaws with the current tracking algorithm and/or the
44+
source information on which it works:
45+
46+
* Deaths are not recorded. A selected unit that dies will be deselected though.
47+
* Transformations are not recorded. A hotkey'd egg that hatches into 2 zerglings
48+
will not register and the egg will stay hotkeyed until the hotkey is over
49+
written. If the transformed unit is part of active selection the
50+
selection/deslection is handled properly.
51+
52+
To help expose these short comings a ``person.selection_errors`` tally is kept. An
53+
error is recorded every time a selection event instructs us to do something that
54+
would not be possible with what we believe to be the current selection. Such an
55+
event would mean that our tracker went wrong previously.
56+
57+
Players that consistently use ``shift+ctrl+hotkey`` to add to hotkeys instead of
58+
resetting hotkeys with ``ctrl+hotkey`` create tons of issues for this tracker
59+
because selection changes in hotkeys are not recorded in the replay file.

docs/source/primaryresources.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.. currentmodule:: sc2reader.resources
2+
3+
Main Structures
4+
======================
5+
6+
The outline of the key structures in the replay object.
7+
8+
9+
Replay
10+
--------------
11+
12+
.. autoclass:: Replay
13+
:members:
14+
15+
Map
16+
------------
17+
18+
.. autoclass:: Map
19+
:members:
20+
21+
Game Summary
22+
---------------
23+
24+
.. autoclass:: GameSummary
25+
:members:
26+
27+
MapInfo
28+
---------------
29+
30+
.. autoclass:: MapInfo
31+
:members:
32+
33+
MapHeader
34+
---------------
35+
36+
.. autoclass:: MapHeader
37+
:members:

docs/source/sc2reader.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
.. currentmodule:: sc2reader
1+
.. currentmodule:: sc2reader.factories
22

33
SC2Reader
44
======================
55

66
The replay factory
77

8-
.. autoclass:: SC2Reader
9-
:members: load_replay, load_replays, register_listener, configure, register_datapack, register_reader, reset
8+
.. autoclass:: SC2Factory
9+
:members:

docs/source/supportobjects.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.. currentmodule:: sc2reader.objects
2+
3+
Support Structures
4+
=========================
5+
6+
These dumb data structures help to give meaningful organization and structure to the information in their respective parent resources.
7+
8+
9+
Team
10+
----------------
11+
12+
.. autoclass:: Team
13+
14+
15+
Person
16+
-------------
17+
18+
.. autoclass:: Person
19+
:members:
20+
21+
22+
Observer
23+
---------------
24+
25+
.. autoclass:: Observer
26+
:members:
27+
28+
29+
Player
30+
------------------
31+
32+
.. autoclass:: Player
33+
:members:
34+
35+
36+
PlayerSummary
37+
-----------------
38+
39+
.. autoclass:: PlayerSummary
40+
:members:
41+
42+
Graph
43+
-----------
44+
45+
.. autoclass:: Graph
46+
:members:
47+

docs/source/supportstructures.rst

Lines changed: 0 additions & 29 deletions
This file was deleted.

docs/source/tutorials/prettyprinter.rst

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ The replay object itself is a dumb data structure; there are no access methods o
8282
>>> replay.teams
8383
[<sc2reader.objects.Team object at 0x2b5e410>, <sc2reader.objects.Team object at 0x2b5e4d0>]
8484

85-
Many of the replay attributes are nested data structures which are generally all pretty dumb as well. The idea being that you should be able to access almost anything with a mixture of indexes and dot notation. Clean and simple accessibility is one of the primary design goals for sc2reader.
85+
Many of the replay attributes are nested data structures which are generally all pretty dumb as well. The idea being that you should be able to access almost anything with a mixture of indexes and dot notation. Clean and simple accessibility is one of the primary design goals for sc2reader.
8686

8787
::
8888

@@ -125,7 +125,7 @@ Similar formatting written in a more verbose and less pythonic way:
125125
return output
126126

127127
Next we need to format the teams for display. The :class:`Team` and :class:`Player` data structures are pretty straightforward as well so we can apply a bit of string formatting and produce this:
128-
128+
129129
::
130130

131131
def formatTeams(replay):
@@ -230,4 +230,19 @@ Recognizing that most users will only ever need one active configuration at a ti
230230
followlinks=True
231231
)
232232

233-
An ideal prettyPrinter script would let the user configure these options as arguments using the argparse library. Such an expansion is beyond the scope of sc2reader though, so we'll leave it as an exercise to the reader.
233+
Many of your replay files might be custom games for which events cannot be parsed. Since the pretty printer doesn't use game event information in its output we can limit the parse level of the replay to stop after loading the basic details. This will make the pretty printer work for custom games as well.
234+
235+
::
236+
237+
import sc2reader
238+
239+
sc2reader.load_replay(path, load_level=1)
240+
241+
There are 4 available load levels:
242+
243+
* 0: Parses the replay header for version, build, and length information
244+
* 1: Also parses the replay.details file for player, team, winner, map, and time information
245+
* 2: Also parses the replay.message.events file for chat messages and player pings.
246+
* 3: Also parses the replay.events file for game event information.
247+
248+
So that's it! An ideal prettyPrinter script might let the user configure these options as arguments using the argparse library. Such an expansion is beyond the scope of sc2reader though, so we'll leave it that one to you.

0 commit comments

Comments
 (0)