spawningtool 2.12.0__tar.gz → 3.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. {spawningtool-2.12.0 → spawningtool-3.0.0}/CHANGELOG.md +7 -0
  2. {spawningtool-2.12.0/spawningtool.egg-info → spawningtool-3.0.0}/PKG-INFO +9 -2
  3. {spawningtool-2.12.0 → spawningtool-3.0.0}/README.md +1 -1
  4. {spawningtool-2.12.0 → spawningtool-3.0.0}/setup.py +1 -1
  5. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool/lotv_constants.py +296 -37
  6. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool/parser.py +29 -6
  7. {spawningtool-2.12.0 → spawningtool-3.0.0/spawningtool.egg-info}/PKG-INFO +9 -2
  8. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool.egg-info/SOURCES.txt +10 -0
  9. spawningtool-3.0.0/tests/__main__.py +310 -0
  10. spawningtool-3.0.0/tests/__pycache__/__main__.cpython-312.pyc +0 -0
  11. {spawningtool-2.12.0 → spawningtool-3.0.0}/tests/patch_380_protoss.json +17 -17
  12. spawningtool-3.0.0/tests/patch_380_terran.json +1415 -0
  13. spawningtool-3.0.0/tests/patch_380_zerg.json +1589 -0
  14. spawningtool-3.0.0/tests/patch_4_6_0_pvt.json +10258 -0
  15. spawningtool-3.0.0/tests/patch_4_9_2_zvt.json +18246 -0
  16. spawningtool-3.0.0/tests/patch_5_0_10_pvz.json +14339 -0
  17. spawningtool-3.0.0/tests/patch_5_0_13_tvp.json +7742 -0
  18. spawningtool-3.0.0/tests/patch_5_0_14_tvp.json +6820 -0
  19. {spawningtool-2.12.0 → spawningtool-3.0.0}/tests/patch_5_0_16.json +147 -147
  20. spawningtool-3.0.0/tests/patch_5_0_16_hotfix.json +7451 -0
  21. spawningtool-3.0.0/tests/patch_5_0_16b.json +22355 -0
  22. spawningtool-3.0.0/tests/patch_5_0_4_pvt.json +5347 -0
  23. spawningtool-2.12.0/tests/__main__.py +0 -112
  24. spawningtool-2.12.0/tests/__pycache__/__main__.cpython-312.pyc +0 -0
  25. {spawningtool-2.12.0 → spawningtool-3.0.0}/LICENSE.md +0 -0
  26. {spawningtool-2.12.0 → spawningtool-3.0.0}/MANIFEST.in +0 -0
  27. {spawningtool-2.12.0 → spawningtool-3.0.0}/setup.cfg +0 -0
  28. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool/__init__.py +0 -0
  29. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool/__main__.py +0 -0
  30. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool/analyzer.py +0 -0
  31. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool/coop_constants.py +0 -0
  32. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool/exception.py +0 -0
  33. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool/hots_constants.py +0 -0
  34. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool.egg-info/dependency_links.txt +0 -0
  35. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool.egg-info/entry_points.txt +0 -0
  36. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool.egg-info/requires.txt +0 -0
  37. {spawningtool-2.12.0 → spawningtool-3.0.0}/spawningtool.egg-info/top_level.txt +0 -0
  38. {spawningtool-2.12.0 → spawningtool-3.0.0}/tests/__init__.py +0 -0
  39. {spawningtool-2.12.0 → spawningtool-3.0.0}/tests/__pycache__/__init__.cpython-312.pyc +0 -0
  40. {spawningtool-2.12.0 → spawningtool-3.0.0}/tests/gameheart.json +0 -0
  41. {spawningtool-2.12.0 → spawningtool-3.0.0}/tests/kerrigan.json +0 -0
  42. {spawningtool-2.12.0 → spawningtool-3.0.0}/tests/patch_400.json +0 -0
  43. {spawningtool-2.12.0 → spawningtool-3.0.0}/tests/patch_5_0_11.json +0 -0
  44. {spawningtool-2.12.0 → spawningtool-3.0.0}/tests/tlo_v_thorzain.json +0 -0
  45. {spawningtool-2.12.0 → spawningtool-3.0.0}/tests/update_expected_results.py +0 -0
@@ -1,6 +1,13 @@
1
1
  Changes
2
2
  =======
3
3
 
4
+ * v3.0.0, July 29, 2026 -- build times are now selected by the date a replay was played, so replays are scored with the values that were live at the time rather than today's. Build order timings for older replays change as a result, hence the major version:
5
+ * `BUILD_TIME_CHANGES` in `lotv_constants.py` records every LotV build time change back to 3.8.0 (2016-11-22), sourced from the Blizzard patch notes. `BUILD_DATA_HISTORY` is derived from it, and each unit's recorded changes are verified at import to chain into its current value
6
+ * that check surfaced five errors: High/Dark Templar were raised 39->43 in 5.0.16 before the hotfix cut them to 40; the Void Ray was reduced 43->37 in 5.0.2 and restored to 43 in 5.0.9, which had been applied here in reverse; Hyperflight Rotors was left at 121s through both the 5.0.11 cut to 100s and the 5.0.15 cut to 79s; the Stalker's 5.0.14 cut from 30s to 27s was missing; and the March 25, 2019 balance update raised the Cybernetics Core air upgrades alongside the Forge ones to 129/154/179, which 5.0.11 then reduced for the Forge only, so air and ground now differ
7
+ * adds ladder data for 5.0.14 and 5.0.15, which had never been tracked, including the 5.0.14 revert to the 5.0.11 Cyclone (Mag-Field Accelerator back, Hurricane Engines gone)
8
+ * adds the 5.0.16 hotfix (Reaper 32->34, Adept 30->33, High/Dark Templar 43->40) and 5.0.16b (Warpgate Research Gateway reduction 40%->50%, effective 2026-07-16)
9
+ * adds eight test replays spanning 3.8.0, 4.6.0, 4.9.2, 5.0.4, 5.0.10, 5.0.13 and 5.0.14, all of which fail if the date-based lookup is bypassed
10
+ * the 5.0.14 Nanomuscular Swell upgrade and Energy Recharge ability still need their internal names before they can be added (#70)
4
11
  * v2.12.0, June 24, 2026 -- adjust Gateway unit build times for Warpgate Research in patch 5.0.16
5
12
  * v2.11.0, April 29, 2024 -- update ladder data for balance patch 5.0.12 and 5.0.13
6
13
  * v2.10.0, February 13, 2023 -- update ladder data for balance patch 5.0.11
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spawningtool
3
- Version: 2.12.0
3
+ Version: 3.0.0
4
4
  Summary: Build order parser for StarCraft 2 replays
5
5
  Home-page: https://github.com/StoicLoofah/spawningtool
6
6
  Author: Kevin Leung
@@ -83,7 +83,7 @@ python tests/update_expected_results.py REPLAY_NAME # e.g. patch_400
83
83
 
84
84
  Support
85
85
  ============
86
- Please submit any issues you encounter to the [GitHub project](https://github.com/StoicLoofah/spawningtool/issues). You're also welcome to email Kevin directly at kevin@kevinleung.com.
86
+ Please submit any issues you encounter to the [GitHub project](https://github.com/StoicLoofah/spawningtool/issues). You're also welcome to email Kevin directly at github@kevin.kevinleung.com.
87
87
 
88
88
  Thanks To
89
89
  ============
@@ -95,6 +95,13 @@ Thanks To
95
95
  Changes
96
96
  =======
97
97
 
98
+ * v3.0.0, July 29, 2026 -- build times are now selected by the date a replay was played, so replays are scored with the values that were live at the time rather than today's. Build order timings for older replays change as a result, hence the major version:
99
+ * `BUILD_TIME_CHANGES` in `lotv_constants.py` records every LotV build time change back to 3.8.0 (2016-11-22), sourced from the Blizzard patch notes. `BUILD_DATA_HISTORY` is derived from it, and each unit's recorded changes are verified at import to chain into its current value
100
+ * that check surfaced five errors: High/Dark Templar were raised 39->43 in 5.0.16 before the hotfix cut them to 40; the Void Ray was reduced 43->37 in 5.0.2 and restored to 43 in 5.0.9, which had been applied here in reverse; Hyperflight Rotors was left at 121s through both the 5.0.11 cut to 100s and the 5.0.15 cut to 79s; the Stalker's 5.0.14 cut from 30s to 27s was missing; and the March 25, 2019 balance update raised the Cybernetics Core air upgrades alongside the Forge ones to 129/154/179, which 5.0.11 then reduced for the Forge only, so air and ground now differ
101
+ * adds ladder data for 5.0.14 and 5.0.15, which had never been tracked, including the 5.0.14 revert to the 5.0.11 Cyclone (Mag-Field Accelerator back, Hurricane Engines gone)
102
+ * adds the 5.0.16 hotfix (Reaper 32->34, Adept 30->33, High/Dark Templar 43->40) and 5.0.16b (Warpgate Research Gateway reduction 40%->50%, effective 2026-07-16)
103
+ * adds eight test replays spanning 3.8.0, 4.6.0, 4.9.2, 5.0.4, 5.0.10, 5.0.13 and 5.0.14, all of which fail if the date-based lookup is bypassed
104
+ * the 5.0.14 Nanomuscular Swell upgrade and Energy Recharge ability still need their internal names before they can be added (#70)
98
105
  * v2.12.0, June 24, 2026 -- adjust Gateway unit build times for Warpgate Research in patch 5.0.16
99
106
  * v2.11.0, April 29, 2024 -- update ladder data for balance patch 5.0.12 and 5.0.13
100
107
  * v2.10.0, February 13, 2023 -- update ladder data for balance patch 5.0.11
@@ -49,7 +49,7 @@ python tests/update_expected_results.py REPLAY_NAME # e.g. patch_400
49
49
 
50
50
  Support
51
51
  ============
52
- Please submit any issues you encounter to the [GitHub project](https://github.com/StoicLoofah/spawningtool/issues). You're also welcome to email Kevin directly at kevin@kevinleung.com.
52
+ Please submit any issues you encounter to the [GitHub project](https://github.com/StoicLoofah/spawningtool/issues). You're also welcome to email Kevin directly at github@kevin.kevinleung.com.
53
53
 
54
54
  Thanks To
55
55
  ============
@@ -1,6 +1,6 @@
1
1
  from setuptools import find_packages, setup
2
2
 
3
- __version__ = "2.12.0"
3
+ __version__ = "3.0.0"
4
4
 
5
5
  setup(
6
6
  name="spawningtool",
@@ -3,6 +3,8 @@ spawningtool.constants
3
3
  ~~~~~~~~~~~~~~~~~~~~~~
4
4
  """
5
5
 
6
+ from datetime import datetime, timezone
7
+
6
8
  FRAMES_PER_SECOND = 22.4
7
9
 
8
10
  BO_EXCLUDED = set([
@@ -98,7 +100,7 @@ BUILD_DATA = {
98
100
  'is_morph': False
99
101
  },
100
102
  "Reaper": {
101
- "build_time": 32,
103
+ "build_time": 34,
102
104
  "built_from": [ "Barracks" ],
103
105
  "display_name": "Reaper",
104
106
  'race': RACE_TERRAN,
@@ -210,7 +212,7 @@ BUILD_DATA = {
210
212
  'is_morph': False
211
213
  },
212
214
  "Raven": {
213
- "build_time": 34, # 42.9 -> 34.3 in 5.0.11
215
+ "build_time": 34,
214
216
  "built_from": [ "Starport" ],
215
217
  "display_name": "Raven",
216
218
  'race': RACE_TERRAN,
@@ -259,7 +261,7 @@ BUILD_DATA = {
259
261
  'is_morph': False
260
262
  },
261
263
  "Stalker": {
262
- "build_time": 30,
264
+ "build_time": 27,
263
265
  "built_from": [ "Gateway", "WarpGate" ],
264
266
  "display_name": "Stalker",
265
267
  'race': RACE_PROTOSS,
@@ -267,7 +269,7 @@ BUILD_DATA = {
267
269
  'is_morph': False
268
270
  },
269
271
  "Sentry": {
270
- "build_time": 23, # 26.4 -> 22.9 in 5.0.11
272
+ "build_time": 23,
271
273
  "built_from": [ "Gateway", "WarpGate" ],
272
274
  "display_name": "Sentry",
273
275
  'race': RACE_PROTOSS,
@@ -275,7 +277,7 @@ BUILD_DATA = {
275
277
  'is_morph': False
276
278
  },
277
279
  "Adept": {
278
- "build_time": 30, # 27 -> 30 in 4.8.2
280
+ "build_time": 33,
279
281
  "built_from": [ "Gateway", "WarpGate" ],
280
282
  "display_name": "Adept",
281
283
  'race': RACE_PROTOSS,
@@ -291,7 +293,7 @@ BUILD_DATA = {
291
293
  'is_morph': False
292
294
  },
293
295
  "Mothership": {
294
- "build_time": 79, # 114 -> 79 in 5.0.12
296
+ "build_time": 79,
295
297
  "built_from": [ "Nexus" ],
296
298
  "display_name": "Mothership",
297
299
  'race': RACE_PROTOSS,
@@ -299,7 +301,7 @@ BUILD_DATA = {
299
301
  'is_morph': False
300
302
  },
301
303
  "HighTemplar": {
302
- "build_time": 39,
304
+ "build_time": 40,
303
305
  "built_from": [ "Gateway", "WarpGate" ],
304
306
  "display_name": "High Templar",
305
307
  'race': RACE_PROTOSS,
@@ -307,7 +309,7 @@ BUILD_DATA = {
307
309
  'is_morph': False
308
310
  },
309
311
  "DarkTemplar": {
310
- "build_time": 39,
312
+ "build_time": 40,
311
313
  "built_from": [ "Gateway", "WarpGate" ],
312
314
  "display_name": "Dark Templar",
313
315
  'race': RACE_PROTOSS,
@@ -347,7 +349,7 @@ BUILD_DATA = {
347
349
  'is_morph': False
348
350
  },
349
351
  "Observer": {
350
- "build_time": 18, # 21 -> 18 in 5.0.13
352
+ "build_time": 18,
351
353
  "built_from": [ "RoboticsFacility" ],
352
354
  "display_name": "Observer",
353
355
  'race': RACE_PROTOSS,
@@ -371,7 +373,7 @@ BUILD_DATA = {
371
373
  'is_morph': False
372
374
  },
373
375
  "VoidRay": {
374
- "build_time": 37, # decreased 43 -> 37 in 5.0.9 Mar 15 2022
376
+ "build_time": 43,
375
377
  "built_from": [ "Stargate" ],
376
378
  "display_name": "Void Ray",
377
379
  'race': RACE_PROTOSS,
@@ -395,7 +397,7 @@ BUILD_DATA = {
395
397
  'is_morph': False
396
398
  },
397
399
  "Carrier": {
398
- "build_time": 64, # decreased 86 -> 64 in 4.7.1
400
+ "build_time": 64,
399
401
  "built_from": [ "Stargate" ],
400
402
  "display_name": "Carrier",
401
403
  'race': RACE_PROTOSS,
@@ -697,7 +699,7 @@ BUILD_DATA = {
697
699
  },
698
700
  # Baneling Nest Upgrades
699
701
  "CentrificalHooks": {
700
- "build_time": 71, # 79 -> 71 in 5.0.12
702
+ "build_time": 71,
701
703
  "built_from": [ "BanelingNest" ],
702
704
  "display_name": "Centrifugal Hooks",
703
705
  'race': RACE_ZERG,
@@ -739,7 +741,7 @@ BUILD_DATA = {
739
741
  'is_morph': False
740
742
  },
741
743
  "EvolveGroovedSpines": { # added 3.8
742
- "build_time": 50, # 71 -> 50 in 5.0.12
744
+ "build_time": 50,
743
745
  "built_from": [ "HydraliskDen" ],
744
746
  "display_name": "Grooved Spines",
745
747
  'race': RACE_ZERG,
@@ -747,7 +749,7 @@ BUILD_DATA = {
747
749
  'is_morph': False
748
750
  },
749
751
  "EvolveMuscularAugments": { # added 3.8
750
- "build_time": 64, # 71 -> 64 in 5.0.12
752
+ "build_time": 64,
751
753
  "built_from": [ "HydraliskDen" ],
752
754
  "display_name": "Muscular Augments",
753
755
  'race': RACE_ZERG,
@@ -804,6 +806,7 @@ BUILD_DATA = {
804
806
  'type': TYPE_UPGRADE,
805
807
  'is_morph': False
806
808
  },
809
+ # dropped its research requirement after 4.11.0; an upgrade again in 5.0.15
807
810
  "MicrobialShroud": {
808
811
  "build_time": 79,
809
812
  "built_from": [ "InfestationPit" ],
@@ -1043,7 +1046,7 @@ BUILD_DATA = {
1043
1046
 
1044
1047
  # barracks tech lab
1045
1048
  "Stimpack": {
1046
- "build_time": 100, # reduced from 121s to 100s 8/21/19
1049
+ "build_time": 100,
1047
1050
  "built_from": [ "TechLab" ],
1048
1051
  "display_name": "Stimpack",
1049
1052
  'race': RACE_TERRAN,
@@ -1149,8 +1152,10 @@ BUILD_DATA = {
1149
1152
  'type': TYPE_UPGRADE,
1150
1153
  'is_morph': False
1151
1154
  },
1152
- "CycloneLockOnDamageUpgrade": { # re-introduced in 4.7.1, Deprecated in 5.0.12
1153
- "build_time": 100, # 79s -> 100s in 4.8.2
1155
+ # re-introduced in 4.7.1, deprecated in 5.0.12, back in 5.0.14 when the
1156
+ # Cyclone was reverted to its 5.0.11 version
1157
+ "CycloneLockOnDamageUpgrade": {
1158
+ "build_time": 100,
1154
1159
  "built_from": [ "TechLab" ],
1155
1160
  "display_name": "Mag-Field Accelerator",
1156
1161
  "race": RACE_TERRAN,
@@ -1173,7 +1178,8 @@ BUILD_DATA = {
1173
1178
  'type': TYPE_UPGRADE,
1174
1179
  'is_morph': False
1175
1180
  },
1176
- "HurricaneThrusters": { # Added 5.0.12
1181
+ # added 5.0.12, removed in 5.0.14 with the revert to the 5.0.11 Cyclone
1182
+ "HurricaneThrusters": {
1177
1183
  "build_time": 100,
1178
1184
  "built_from": [ "TechLab" ],
1179
1185
  "display_name": "Hurricane Engines",
@@ -1231,7 +1237,7 @@ BUILD_DATA = {
1231
1237
  'is_morph': False
1232
1238
  },
1233
1239
  "BansheeSpeed": {
1234
- "build_time": 121, # 93 -> 121 in 3.8.0, 121.4 -> 100 in 5.0.11
1240
+ "build_time": 79,
1235
1241
  "built_from": [ "TechLab" ],
1236
1242
  "display_name": "Hyperflight Rotors",
1237
1243
  'race': RACE_TERRAN,
@@ -1264,7 +1270,7 @@ BUILD_DATA = {
1264
1270
  'is_morph': False
1265
1271
  },
1266
1272
  "BattlecruiserEnableSpecializations": {
1267
- "build_time": 100, # 43 -> 100 in 4.8.2
1273
+ "build_time": 100,
1268
1274
  "built_from": [ "FusionCore" ],
1269
1275
  "display_name": "Weapon Refit",
1270
1276
  'race': RACE_TERRAN,
@@ -1297,7 +1303,7 @@ BUILD_DATA = {
1297
1303
  },
1298
1304
  # protoss upgrades
1299
1305
  "ProtossGroundWeaponsLevel1": {
1300
- "build_time": 122, # 128.6 -> 121.6 in 5.0.11
1306
+ "build_time": 122,
1301
1307
  "built_from": [ "Forge" ],
1302
1308
  "display_name": "Protoss Ground Weapons Level 1",
1303
1309
  'race': RACE_PROTOSS,
@@ -1305,7 +1311,7 @@ BUILD_DATA = {
1305
1311
  'is_morph': False
1306
1312
  },
1307
1313
  "ProtossGroundWeaponsLevel2": {
1308
- "build_time": 145, # 153.6 -> 144.6 in 5.0.11
1314
+ "build_time": 145,
1309
1315
  "built_from": [ "Forge" ],
1310
1316
  "display_name": "Protoss Ground Weapons Level 2",
1311
1317
  'race': RACE_PROTOSS,
@@ -1313,7 +1319,7 @@ BUILD_DATA = {
1313
1319
  'is_morph': False
1314
1320
  },
1315
1321
  "ProtossGroundWeaponsLevel3": {
1316
- "build_time": 168, # 178.6 -> 167.9 in 5.0.11
1322
+ "build_time": 168,
1317
1323
  "built_from": [ "Forge" ],
1318
1324
  "display_name": "Protoss Ground Weapons Level 3",
1319
1325
  'race': RACE_PROTOSS,
@@ -1321,7 +1327,7 @@ BUILD_DATA = {
1321
1327
  'is_morph': False
1322
1328
  },
1323
1329
  "ProtossGroundArmorsLevel1": {
1324
- "build_time": 122, # 128.6 -> 121.6 in 5.0.11
1330
+ "build_time": 122,
1325
1331
  "built_from": [ "Forge" ],
1326
1332
  "display_name": "Protoss Ground Armor Level 1",
1327
1333
  'race': RACE_PROTOSS,
@@ -1329,7 +1335,7 @@ BUILD_DATA = {
1329
1335
  'is_morph': False
1330
1336
  },
1331
1337
  "ProtossGroundArmorsLevel2": {
1332
- "build_time": 145, # 153.6 -> 144.6 in 5.0.11
1338
+ "build_time": 145,
1333
1339
  "built_from": [ "Forge" ],
1334
1340
  "display_name": "Protoss Ground Armor Level 2",
1335
1341
  'race': RACE_PROTOSS,
@@ -1337,7 +1343,7 @@ BUILD_DATA = {
1337
1343
  'is_morph': False
1338
1344
  },
1339
1345
  "ProtossGroundArmorsLevel3": {
1340
- "build_time": 168, # 178.6 -> 167.9 in 5.0.11
1346
+ "build_time": 168,
1341
1347
  "built_from": [ "Forge" ],
1342
1348
  "display_name": "Protoss Ground Armor Level 3",
1343
1349
  'race': RACE_PROTOSS,
@@ -1345,7 +1351,7 @@ BUILD_DATA = {
1345
1351
  'is_morph': False
1346
1352
  },
1347
1353
  "ProtossShieldsLevel1": {
1348
- "build_time": 122, # 128.6 -> 121.6 in 5.0.11
1354
+ "build_time": 122,
1349
1355
  "built_from": [ "Forge" ],
1350
1356
  "display_name": "Protoss Shields Level 1",
1351
1357
  'race': RACE_PROTOSS,
@@ -1353,7 +1359,7 @@ BUILD_DATA = {
1353
1359
  'is_morph': False
1354
1360
  },
1355
1361
  "ProtossShieldsLevel2": {
1356
- "build_time": 145, # 153.6 -> 144.6 in 5.0.11
1362
+ "build_time": 145,
1357
1363
  "built_from": [ "Forge" ],
1358
1364
  "display_name": "Protoss Shields Level 2",
1359
1365
  'race': RACE_PROTOSS,
@@ -1361,7 +1367,7 @@ BUILD_DATA = {
1361
1367
  'is_morph': False
1362
1368
  },
1363
1369
  "ProtossShieldsLevel3": {
1364
- "build_time": 168, # 178.6 -> 167.9 in 5.0.11
1370
+ "build_time": 168,
1365
1371
  "built_from": [ "Forge" ],
1366
1372
  "display_name": "Protoss Shields Level 3",
1367
1373
  'race': RACE_PROTOSS,
@@ -1369,7 +1375,7 @@ BUILD_DATA = {
1369
1375
  'is_morph': False
1370
1376
  },
1371
1377
  "ProtossAirWeaponsLevel1": {
1372
- "build_time": 114,
1378
+ "build_time": 129,
1373
1379
  "built_from": [ "CyberneticsCore" ],
1374
1380
  "display_name": "Protoss Air Weapons Level 1",
1375
1381
  'race': RACE_PROTOSS,
@@ -1377,7 +1383,7 @@ BUILD_DATA = {
1377
1383
  'is_morph': False
1378
1384
  },
1379
1385
  "ProtossAirWeaponsLevel2": {
1380
- "build_time": 136,
1386
+ "build_time": 154,
1381
1387
  "built_from": [ "CyberneticsCore" ],
1382
1388
  "display_name": "Protoss Air Weapons Level 2",
1383
1389
  'race': RACE_PROTOSS,
@@ -1385,7 +1391,7 @@ BUILD_DATA = {
1385
1391
  'is_morph': False
1386
1392
  },
1387
1393
  "ProtossAirWeaponsLevel3": {
1388
- "build_time": 157,
1394
+ "build_time": 179,
1389
1395
  "built_from": [ "CyberneticsCore" ],
1390
1396
  "display_name": "Protoss Air Weapons Level 3",
1391
1397
  'race': RACE_PROTOSS,
@@ -1393,7 +1399,7 @@ BUILD_DATA = {
1393
1399
  'is_morph': False
1394
1400
  },
1395
1401
  "ProtossAirArmorsLevel1": {
1396
- "build_time": 114,
1402
+ "build_time": 129,
1397
1403
  "built_from": [ "CyberneticsCore" ],
1398
1404
  "display_name": "Protoss Air Armor Level 1",
1399
1405
  'race': RACE_PROTOSS,
@@ -1401,7 +1407,7 @@ BUILD_DATA = {
1401
1407
  'is_morph': False
1402
1408
  },
1403
1409
  "ProtossAirArmorsLevel2": {
1404
- "build_time": 136,
1410
+ "build_time": 154,
1405
1411
  "built_from": [ "CyberneticsCore" ],
1406
1412
  "display_name": "Protoss Air Armor Level 2",
1407
1413
  'race': RACE_PROTOSS,
@@ -1409,7 +1415,7 @@ BUILD_DATA = {
1409
1415
  'is_morph': False
1410
1416
  },
1411
1417
  "ProtossAirArmorsLevel3": {
1412
- "build_time": 157,
1418
+ "build_time": 179,
1413
1419
  "built_from": [ "CyberneticsCore" ],
1414
1420
  "display_name": "Protoss Air Armor Level 3",
1415
1421
  'race': RACE_PROTOSS,
@@ -1417,7 +1423,7 @@ BUILD_DATA = {
1417
1423
  'is_morph': False
1418
1424
  },
1419
1425
  "WarpGateResearch": {
1420
- "build_time": 100, # 114s -> 100s in 4.8.2
1426
+ "build_time": 100,
1421
1427
  "built_from": [ "CyberneticsCore" ],
1422
1428
  "display_name": "Warp Gate",
1423
1429
  'race': RACE_PROTOSS,
@@ -1515,7 +1521,7 @@ BUILD_DATA = {
1515
1521
  },
1516
1522
  # Dark Shrine Upgrades
1517
1523
  "DarkTemplarBlinkUpgrade": {
1518
- "build_time": 100, # decreased 121 -> 100 in 4.7.1
1524
+ "build_time": 100,
1519
1525
  "built_from": [ "DarkShrine" ],
1520
1526
  "display_name": "Shadow Stride",
1521
1527
  'race': RACE_PROTOSS,
@@ -1604,9 +1610,262 @@ BUILD_DATA = {
1604
1610
  }
1605
1611
  }
1606
1612
 
1613
+
1614
+ # Balance patch history
1615
+ # =====================
1616
+ #
1617
+ # BUILD_DATA holds the current build times; this records when they changed, so a
1618
+ # replay is scored with the value that was live the day it was played. Balance
1619
+ # hotfixes don't always bump the replay build number, so the date decides.
1620
+ #
1621
+ # Entries are (patch_label, effective_date, {unit: (old_seconds, new_seconds)}),
1622
+ # chronological. Each unit's `old` must match the `new` of the previous entry that
1623
+ # touched it, and its last `new` must match BUILD_DATA; _build_history checks that
1624
+ # chain at import, so a patch recorded without its predecessor fails fast instead
1625
+ # of silently mis-scoring one window.
1626
+ #
1627
+ # Sourced from the patch notes off https://news.blizzard.com/en-us/feed/starcraft-2
1628
+ # (PTR notes are proposals, not shipped changes, so they are not used). Blizzard
1629
+ # quotes build times in this file's units; they are rounded to whole seconds to
1630
+ # match BUILD_DATA, with the exact figure noted inline where it differs. Dates are
1631
+ # the NA release at 00:00 UTC, so a replay played within a day of a patch may get
1632
+ # the adjacent value.
1633
+ #
1634
+ # Coverage starts at 3.8.0 (2016-11-22); earlier replays get the oldest value
1635
+ # here, which is not necessarily what was live then. (HotS and WoL use
1636
+ # hots_constants, which has no date handling at all.) Swept for build time
1637
+ # changes: 3.8.0, the 2017-12-18/2019-03-25/2019-08-21 balance updates, 4.7.1,
1638
+ # 4.8.2, 4.11.0, 5.0.2, 5.0.9, and 5.0.11 through 5.0.16. Not swept: 4.0-4.6,
1639
+ # 4.8.0/1/3/4, 4.9.x, the rest of 4.10.x, 5.0.0/1, 5.0.3-5.0.8, 5.0.10, and the
1640
+ # 5.0.11 hotfixes -- a gap there is no guarantee nothing changed, since 5.0.14 and
1641
+ # 5.0.15 both held changes that went unnoticed for years.
1642
+ #
1643
+ # Not recorded: past fixes to wrong data in this file, whose old values were never
1644
+ # live in the game -- the 2015-16 rounding cleanups (116 -> 114, 80 -> 79, ...),
1645
+ # the Liberator 60 -> 43 fix, and the Carrier and Disruptor corrections made
1646
+ # against the LotV release build.
1647
+ BUILD_TIME_CHANGES = [
1648
+ ('3.8.0', '2016-11-22', {
1649
+ 'BansheeSpeed': (93, 121), # Hyperflight Rotors
1650
+ }),
1651
+ ('Balance Update', '2017-12-18', {
1652
+ 'Oracle': (43, 37),
1653
+ 'WidowMine': (29, 21), # 28.6 -> 21.4
1654
+ }),
1655
+ ('4.7.1', '2018-11-20', {
1656
+ 'Carrier': (86, 64),
1657
+ 'DarkTemplarBlinkUpgrade': (121, 100), # Shadow Stride
1658
+ }),
1659
+ ('4.8.2', '2019-01-22', {
1660
+ 'Adept': (27, 30),
1661
+ 'BattlecruiserEnableSpecializations': (43, 100), # Weapon Refit
1662
+ 'CycloneLockOnDamageUpgrade': (79, 100), # Mag-Field Accelerator
1663
+ 'WarpGateResearch': (114, 100),
1664
+ }),
1665
+ # "Forge/Cybernetics Core: Level 1/2/3 upgrade times increased by 15/18/22
1666
+ # seconds" -- both structures, so the air upgrades moved too.
1667
+ ('Balance Update', '2019-03-25', {
1668
+ 'ProtossGroundWeaponsLevel1': (114, 129),
1669
+ 'ProtossGroundWeaponsLevel2': (136, 154),
1670
+ 'ProtossGroundWeaponsLevel3': (157, 179),
1671
+ 'ProtossGroundArmorsLevel1': (114, 129),
1672
+ 'ProtossGroundArmorsLevel2': (136, 154),
1673
+ 'ProtossGroundArmorsLevel3': (157, 179),
1674
+ 'ProtossShieldsLevel1': (114, 129),
1675
+ 'ProtossShieldsLevel2': (136, 154),
1676
+ 'ProtossShieldsLevel3': (157, 179),
1677
+ 'ProtossAirWeaponsLevel1': (114, 129),
1678
+ 'ProtossAirWeaponsLevel2': (136, 154),
1679
+ 'ProtossAirWeaponsLevel3': (157, 179),
1680
+ 'ProtossAirArmorsLevel1': (114, 129),
1681
+ 'ProtossAirArmorsLevel2': (136, 154),
1682
+ 'ProtossAirArmorsLevel3': (157, 179),
1683
+ }),
1684
+ ('Balance Update', '2019-08-21', {
1685
+ 'Stimpack': (121, 100),
1686
+ }),
1687
+ ('4.11.0', '2019-11-26', {
1688
+ 'DiggingClaws': (54, 57), # Adaptive Talons
1689
+ 'LurkerDenMP': (86, 57),
1690
+ }),
1691
+ # 5.0.9 got no live notes (community balance patch), so this pair is instead
1692
+ # confirmed by the test replays: patch_5_0_10_pvz produces Void Rays in
1693
+ # exactly 43.0s, patch_5_0_4_pvt in 25.1s, under a 43s unit's 28.7s floor.
1694
+ ('5.0.2', '2020-08-06', {
1695
+ 'VoidRay': (43, 37),
1696
+ }),
1697
+ ('5.0.9', '2022-03-15', {
1698
+ 'VoidRay': (37, 43), # reverted the 5.0.2 reduction
1699
+ }),
1700
+ ('5.0.11', '2023-01-23', {
1701
+ 'BansheeSpeed': (121, 100), # 121.4 -> 100, Hyperflight Rotors
1702
+ 'Raven': (43, 34), # 42.9 -> 34.3
1703
+ 'Sentry': (26, 23), # 26.4 -> 22.9
1704
+ 'ProtossGroundWeaponsLevel1': (129, 122), # 128.6 -> 121.6
1705
+ 'ProtossGroundWeaponsLevel2': (154, 145), # 153.6 -> 144.6
1706
+ 'ProtossGroundWeaponsLevel3': (179, 168), # 178.6 -> 167.9
1707
+ 'ProtossGroundArmorsLevel1': (129, 122),
1708
+ 'ProtossGroundArmorsLevel2': (154, 145),
1709
+ 'ProtossGroundArmorsLevel3': (179, 168),
1710
+ 'ProtossShieldsLevel1': (129, 122),
1711
+ 'ProtossShieldsLevel2': (154, 145),
1712
+ 'ProtossShieldsLevel3': (179, 168),
1713
+ }),
1714
+ ('5.0.12', '2023-09-29', {
1715
+ 'CentrificalHooks': (79, 71),
1716
+ 'EvolveGroovedSpines': (71, 50),
1717
+ 'EvolveMuscularAugments': (71, 64),
1718
+ 'Mothership': (114, 79),
1719
+ }),
1720
+ ('5.0.13', '2024-03-26', {
1721
+ 'Observer': (21, 18), # 21.4 -> 17.9
1722
+ }),
1723
+ ('5.0.14', '2024-11-25', {
1724
+ 'Stalker': (30, 27), # train time from Gateway
1725
+ }),
1726
+ ('5.0.15', '2025-09-30', {
1727
+ 'BansheeSpeed': (100, 79), # Hyperflight Rotors
1728
+ }),
1729
+ # 5.0.16 made Warp Gate Research a flat percentage off (see
1730
+ # WARPGATE_MODIFIERS) instead of separate warp-in timings. The High/Dark
1731
+ # Templar increase isn't stated outright, but the hotfix reduced them "from
1732
+ # 43" and 5.0.16's post-Warpgate 26s matches 43 * 0.6.
1733
+ ('5.0.16', '2026-06-22', {
1734
+ 'HighTemplar': (39, 43),
1735
+ 'DarkTemplar': (39, 43),
1736
+ }),
1737
+ ('5.0.16 hotfix', '2026-06-30', {
1738
+ 'Adept': (30, 33),
1739
+ 'DarkTemplar': (43, 40),
1740
+ 'HighTemplar': (43, 40),
1741
+ 'Reaper': (32, 34),
1742
+ }),
1743
+ ]
1744
+
1745
+
1746
+ def _patch_timestamp(date):
1747
+ """
1748
+ Unix timestamp (UTC) for a 'YYYY-MM-DD' patch date.
1749
+ """
1750
+ return int(datetime.strptime(date, '%Y-%m-%d').replace(tzinfo=timezone.utc).timestamp())
1751
+
1752
+
1753
+ def _build_history(changes):
1754
+ """
1755
+ Turn BUILD_TIME_CHANGES into {unit: [(superseded_timestamp, build_time)]},
1756
+ where build_time is the value that was live until that timestamp, oldest
1757
+ first. Raises ValueError if the recorded chain doesn't line up with
1758
+ BUILD_DATA, which means a patch is missing or has the wrong before/after
1759
+ value.
1760
+ """
1761
+ history = {}
1762
+ latest = {}
1763
+ previous_timestamp = None
1764
+
1765
+ for label, date, units in changes:
1766
+ timestamp = _patch_timestamp(date)
1767
+ if previous_timestamp is not None and timestamp < previous_timestamp:
1768
+ raise ValueError('BUILD_TIME_CHANGES is not in chronological order at {}'.format(label))
1769
+ previous_timestamp = timestamp
1770
+
1771
+ for unit_name, (old, new) in units.items():
1772
+ if unit_name not in BUILD_DATA:
1773
+ raise ValueError('{} ({}) is not in BUILD_DATA'.format(unit_name, label))
1774
+ expected = latest.get(unit_name)
1775
+ if expected is not None and expected != old:
1776
+ raise ValueError(
1777
+ '{} enters {} at {}s but the previous change left it at {}s'.format(
1778
+ unit_name, label, old, expected))
1779
+ history.setdefault(unit_name, []).append((timestamp, old))
1780
+ latest[unit_name] = new
1781
+
1782
+ for unit_name, new in latest.items():
1783
+ if BUILD_DATA[unit_name]['build_time'] != new:
1784
+ raise ValueError(
1785
+ '{} ends its patch history at {}s but BUILD_DATA says {}s'.format(
1786
+ unit_name, new, BUILD_DATA[unit_name]['build_time']))
1787
+
1788
+ return history
1789
+
1790
+
1791
+ # Previous build times per unit, oldest first, as
1792
+ # (timestamp_at_which_the_value_was_superseded, build_time). Built from
1793
+ # BUILD_TIME_CHANGES while BUILD_DATA is still in seconds, then converted to
1794
+ # frames alongside it.
1795
+ BUILD_DATA_HISTORY = _build_history(BUILD_TIME_CHANGES)
1796
+
1607
1797
  for value in BUILD_DATA.values():
1608
1798
  value['build_time'] *= FRAMES_PER_SECOND
1609
1799
 
1800
+ for unit_name in BUILD_DATA_HISTORY:
1801
+ BUILD_DATA_HISTORY[unit_name] = [
1802
+ (timestamp, build_time * FRAMES_PER_SECOND)
1803
+ for timestamp, build_time in BUILD_DATA_HISTORY[unit_name]
1804
+ ]
1805
+
1806
+
1807
+ def build_data_for_timestamp(timestamp):
1808
+ """
1809
+ Return BUILD_DATA adjusted for the balance patches that were live when the
1810
+ replay was played (timestamp is unix seconds, UTC). Units in
1811
+ BUILD_DATA_HISTORY are rolled back to their historical build time for
1812
+ replays played before a change took effect; everything else keeps the
1813
+ current value. The shared dict is returned as-is when nothing needs rolling
1814
+ back. Otherwise only the units being rolled back are copied, over a shallow
1815
+ copy of BUILD_DATA -- so the returned dict is safe to hand out, but the
1816
+ entries in it are the shared ones and must not be mutated, same as BUILD_DATA
1817
+ itself. A missing timestamp falls back to the current values.
1818
+ """
1819
+ adjusted = None
1820
+ for unit_name, history in BUILD_DATA_HISTORY.items():
1821
+ for superseded, build_time in history:
1822
+ if timestamp and timestamp < superseded:
1823
+ if adjusted is None:
1824
+ adjusted = dict(BUILD_DATA)
1825
+ adjusted[unit_name] = dict(BUILD_DATA[unit_name])
1826
+ adjusted[unit_name]['build_time'] = build_time
1827
+ break
1828
+ return adjusted if adjusted is not None else BUILD_DATA
1829
+
1830
+
1831
+ # Warp Gate Research speeds up Gateway unit production once complete, as a
1832
+ # fraction of the normal build time. Introduced in 5.0.16 at 40% off (0.6x);
1833
+ # 5.0.16b increased it to 50% off (0.5x). Oldest first, same shape as
1834
+ # BUILD_TIME_CHANGES: (patch_label, effective_date, modifier).
1835
+ WARPGATE_MODIFIERS = [
1836
+ ('5.0.16', '2026-06-22', 0.6),
1837
+ ('5.0.16b', '2026-07-16', 0.5),
1838
+ ]
1839
+
1840
+ # The percentage speedup itself only exists from the 5.0.16 build on.
1841
+ # WARPGATE_MODIFIERS says as much for a dated replay; this keeps an undated one,
1842
+ # which falls back to the current modifier, from getting a speedup that didn't
1843
+ # exist yet.
1844
+ WARPGATE_PERCENTAGE_BUILD = 97364
1845
+
1846
+ _WARPGATE_MODIFIERS = [
1847
+ (_patch_timestamp(date), modifier) for _, date, modifier in WARPGATE_MODIFIERS
1848
+ ]
1849
+
1850
+
1851
+ def warpgate_build_time_modifier(timestamp):
1852
+ """
1853
+ Fraction of the normal build time a Gateway unit takes once Warp Gate
1854
+ Research finishes, based on when the replay was played (unix seconds, UTC).
1855
+ None for a replay played before the percentage modifier existed, which is
1856
+ also how the parser spells "doesn't apply" for HotS and co-op. A missing
1857
+ timestamp falls back to the current value, matching build_data_for_timestamp.
1858
+ """
1859
+ if not timestamp:
1860
+ return _WARPGATE_MODIFIERS[-1][1]
1861
+
1862
+ modifier = None
1863
+ for effective, current in _WARPGATE_MODIFIERS:
1864
+ if timestamp < effective:
1865
+ break
1866
+ modifier = current
1867
+ return modifier
1868
+
1610
1869
 
1611
1870
  TRACKED_ABILITIES = set([
1612
1871
  '250mmStrikeCannons',