# README
Keep track of your basic game stats in Starcraft 2. Your win/loss record, win percentage, MMR gain/loss, and total win/loss for each gaming session.
This tool creates 7 text files in your current working directory:
- xvp.txt
- xvt.txt
- xvz.txt
- MMR-diff.txt
- winrate.txt
- totalWinLoss.txt
- scene.txt
useAPI
When a game finishes it saves your MMR to a .SC2Replay file (the start of game MMR). 1
There's a setting called useAPI
. It's optional, but it makes your MMR-diff
more accurate by 1 game (~ 20 MMR). If set to false, I get your MMR data from the replay. This isn't good because you must play 2 games before it starts showing a ± MMR. Also, on your last game I don't know your live MMR. 2
If set to true, then it's perfectly accurate. Your start MMR is set immediately, and as your last game finishes I also get your live MMR number.
Usage
# Lines starting with a hashtag (#) are ignored.
# The minimum configuration is 2 fields (name=, dir=) for useAPI = false.
# The minimum configuration is 3 fields (name=, dir=, mainToon=) for useAPI = true.
Place the .exe in any folder and run it. It will instantly close creating a template settings file (cfg.toml). Modify these 2 lines in cfg.toml
- name =
- dir =
and you're done. Rerun the program.
- Find your starcraft2.com profile URL.
- set race 3
- List all accounts you have for
name =
. 4 - Set
mainToon =
if using 2+ accounts. Use your profileID (last number in URL). - Set
dir =
. Where your replays are saved. For the path use a slash or backslash. - Set
useAPI =
to true if you want the most accurate MMR calculator.
You won't use this, but here is a minimum configuration cfg.toml file. Change 2 lines (name=, dir=).
[account]
name = [ [ 'https://starcraft2.com/en-us/profile/1/1/1331332', 'zerg' ] ]
[directory]
dir = '/home/erik/replays'
If you have two or more accounts you can do this:
[account]
name = [ [ 'https://starcraft2.com/en-us/profile/1/1/1331332', 'zerg' ],
[ 'https://starcraft2.com/en-us/profile/2/1/4545534', 'zerg' ] ]
# only needed when useAPI = true (so the ± MMR diff makes sense)
mainToon = 1331332
[directory]
dir = 'C:\Users\Erik\reps'
After you play SC2 or put a replay in your watch folder, the app will generate 7 .txt files you can use as overlays in something like OBS for streaming.
My OAuth2 credentials are used, but you could take 5 minutes to register your own Client ID 5 and insert those 2 values at the very bottom of the cfg.toml file.
How it works
The program only keeps track of 1v1 ranked ladder. Replays are ignored if they are computer A.I. or 1v1 custom. Unranked replays behave similar to ranked replays (updates your stats, but the MMR should not change).
- all files not ending with .SC2Replay are ignored
- subfolders are ignored
- computer A.I. replays are ignored
- custom 1v1 replays are ignored
- deleting 1+ files doesn't recalculate your stats
Say you play your first game and it ends. It shows you're +15 MMR now. You want to practice against the A.I. and delete the replay afterwards. Once the A.I. game is over, the program ignores the new replay and doesn't change your stats. Also, you can delete the A.I. replay and it doesn't recalculate any stats. It ignores deleting any type of file. If you delete all .SC2Replay files then it resets all stats to 0.
Build
I use https://github.com/mattn/go-sqlite3 for the database.
The database is making use of C code/libraries, which are not necessarily portable. To make a statically linked binary, you can cross-compile with either mingw or zig.
env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build
env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 \
CC="zig cc -target x86_64-windows-gnu" \
CXX="zig c++ -target x86_64-windows-gnu" go build
The code
Make a plantuml from source code
goplantuml -recursive -show-aggregations -show-compositions -aggregate-private-members -show-implementations -show-connection-labels $GOPATH/src/sc2-replay-go > file.puml
creates this UML diagram.
Here's an ERD diagram of the sqlite3 database.
Footnotes
-
When you click "Score screen" or "Rewind" data is sent back to blizzard. ↩
-
The start of game MMR, not the end result MMR. ↩
-
I need your race here because your account will have a distinct
ladderID
for each 1v1 race. ↩ -
If you only have one account URL, then use the first name= template. ↩
-
https://develop.battle.net/documentation/guides/getting-started If I die, or my web server loses power, then to continue using this app you need to get your own free clientID/clientSecret. ↩