cs2df 3.1.1__tar.gz → 4.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.
- {cs2df-3.1.1 → cs2df-4.0.0}/PKG-INFO +6 -6
- {cs2df-3.1.1 → cs2df-4.0.0}/pyproject.toml +11 -8
- {cs2df-3.1.1 → cs2df-4.0.0}/src/cs2df/__init__.py +1 -1
- {cs2df-3.1.1 → cs2df-4.0.0}/src/cs2df/cli.py +137 -60
- {cs2df-3.1.1 → cs2df-4.0.0}/src/cs2df/enums.py +100 -27
- {cs2df-3.1.1 → cs2df-4.0.0}/src/cs2df/events.py +342 -166
- {cs2df-3.1.1 → cs2df-4.0.0}/src/cs2df/merge.py +65 -20
- {cs2df-3.1.1 → cs2df-4.0.0}/src/cs2df/package.py +156 -57
- {cs2df-3.1.1 → cs2df-4.0.0}/src/cs2df/parse.py +225 -91
- {cs2df-3.1.1 → cs2df-4.0.0}/src/cs2df/rounds.py +25 -6
- {cs2df-3.1.1 → cs2df-4.0.0}/src/cs2df/streams.py +135 -68
- {cs2df-3.1.1 → cs2df-4.0.0}/src/cs2df/validate.py +241 -67
- {cs2df-3.1.1 → cs2df-4.0.0}/tests/test_cli_batch.py +12 -6
- cs2df-4.0.0/tests/test_json_schema_fixtures.py +20 -0
- {cs2df-3.1.1 → cs2df-4.0.0}/tests/test_merge.py +34 -19
- {cs2df-3.1.1 → cs2df-4.0.0}/tests/test_replay_boundaries.py +26 -11
- {cs2df-3.1.1 → cs2df-4.0.0}/tests/test_round_windows.py +29 -17
- cs2df-4.0.0/tests/test_trades.py +100 -0
- cs2df-4.0.0/uv.lock +483 -0
- cs2df-3.1.1/uv.lock +0 -662
- {cs2df-3.1.1 → cs2df-4.0.0}/.gitignore +0 -0
- {cs2df-3.1.1 → cs2df-4.0.0}/README.md +0 -0
- {cs2df-3.1.1 → cs2df-4.0.0}/tests/test_version_consistency.py +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cs2df
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: Reference exporter & validator CLI for cs2-demo-format v3 (CS2 demo → ZIP data package)
|
|
5
5
|
Project-URL: Homepage, https://github.com/Starfie1d1272/cs2-demo-format
|
|
6
6
|
Project-URL: Repository, https://github.com/Starfie1d1272/cs2-demo-format
|
|
7
7
|
Project-URL: Issues, https://github.com/Starfie1d1272/cs2-demo-format/issues
|
|
8
8
|
License: MIT
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.14
|
|
10
10
|
Requires-Dist: demoparser2>=0.42.2
|
|
11
|
-
Requires-Dist: jsonschema>=4.
|
|
12
|
-
Requires-Dist: numpy>=
|
|
13
|
-
Requires-Dist: orjson>=3.
|
|
14
|
-
Requires-Dist: pandas>=
|
|
11
|
+
Requires-Dist: jsonschema>=4.26.0
|
|
12
|
+
Requires-Dist: numpy>=2.5.5
|
|
13
|
+
Requires-Dist: orjson>=3.13.0
|
|
14
|
+
Requires-Dist: pandas>=3.1.1
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
|
|
17
17
|
# cs2df
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "cs2df"
|
|
3
|
-
version = "
|
|
3
|
+
version = "4.0.0"
|
|
4
4
|
description = "Reference exporter & validator CLI for cs2-demo-format v3 (CS2 demo → ZIP data package)"
|
|
5
5
|
readme = "README.md"
|
|
6
|
-
requires-python = ">=3.
|
|
6
|
+
requires-python = ">=3.14"
|
|
7
7
|
license = { text = "MIT" }
|
|
8
8
|
dependencies = [
|
|
9
9
|
"demoparser2>=0.42.2",
|
|
10
|
-
"pandas>=
|
|
11
|
-
"numpy>=
|
|
12
|
-
"orjson>=3.
|
|
13
|
-
"jsonschema>=4.
|
|
10
|
+
"pandas>=3.1.1",
|
|
11
|
+
"numpy>=2.5.5",
|
|
12
|
+
"orjson>=3.13.0",
|
|
13
|
+
"jsonschema>=4.26.0",
|
|
14
14
|
]
|
|
15
15
|
|
|
16
16
|
[project.urls]
|
|
@@ -22,11 +22,14 @@ Issues = "https://github.com/Starfie1d1272/cs2-demo-format/issues"
|
|
|
22
22
|
cs2df = "cs2df.cli:main"
|
|
23
23
|
|
|
24
24
|
[build-system]
|
|
25
|
-
requires = ["hatchling"]
|
|
25
|
+
requires = ["hatchling>=1.33.0"]
|
|
26
26
|
build-backend = "hatchling.build"
|
|
27
27
|
|
|
28
28
|
[tool.hatch.build.targets.wheel]
|
|
29
29
|
packages = ["src/cs2df"]
|
|
30
30
|
|
|
31
31
|
[dependency-groups]
|
|
32
|
-
dev = [
|
|
32
|
+
dev = [
|
|
33
|
+
"pytest>=9.2.0",
|
|
34
|
+
"ruff==0.17.6",
|
|
35
|
+
]
|
|
@@ -23,46 +23,102 @@ DEFAULT_COMPRESS_LEVEL = 3
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def main(argv: list[str] | None = None) -> int:
|
|
26
|
-
parser = argparse.ArgumentParser(
|
|
27
|
-
|
|
26
|
+
parser = argparse.ArgumentParser(
|
|
27
|
+
prog="cs2df", description="cs2-demo-format v3 reference exporter & validator"
|
|
28
|
+
)
|
|
28
29
|
sub = parser.add_subparsers(dest="command", required=True)
|
|
29
30
|
|
|
30
31
|
p_exp = sub.add_parser("export", help="export a CS2 .dem to a v3 ZIP package")
|
|
31
|
-
p_exp.add_argument(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
32
|
+
p_exp.add_argument(
|
|
33
|
+
"demo",
|
|
34
|
+
nargs="+",
|
|
35
|
+
help="path to the .dem file; pass multiple split parts "
|
|
36
|
+
"(…-p1.dem …-p2.dem) of ONE match to merge them",
|
|
37
|
+
)
|
|
38
|
+
p_exp.add_argument(
|
|
39
|
+
"-o",
|
|
40
|
+
"--output",
|
|
41
|
+
default=None,
|
|
42
|
+
help="output zip path (default: <demo>.zip next to the input)",
|
|
43
|
+
)
|
|
44
|
+
p_exp.add_argument(
|
|
45
|
+
"--research",
|
|
46
|
+
action="store_true",
|
|
47
|
+
help="also emit duels.json (full-tick combat windows)",
|
|
48
|
+
)
|
|
49
|
+
p_exp.add_argument(
|
|
50
|
+
"--sample-rate",
|
|
51
|
+
type=int,
|
|
52
|
+
default=8,
|
|
53
|
+
help="replay stream sample rate in Hz (default 8)",
|
|
54
|
+
)
|
|
55
|
+
p_exp.add_argument(
|
|
56
|
+
"--window-before",
|
|
57
|
+
type=int,
|
|
58
|
+
default=2000,
|
|
59
|
+
help="duel window extent before each anchor, ms (default 2000)",
|
|
60
|
+
)
|
|
61
|
+
p_exp.add_argument(
|
|
62
|
+
"--window-after",
|
|
63
|
+
type=int,
|
|
64
|
+
default=1000,
|
|
65
|
+
help="duel window extent after each anchor, ms (default 1000)",
|
|
66
|
+
)
|
|
67
|
+
p_exp.add_argument(
|
|
68
|
+
"--compress-level",
|
|
69
|
+
type=int,
|
|
70
|
+
default=DEFAULT_COMPRESS_LEVEL,
|
|
71
|
+
help="ZIP DEFLATE compression level 0-9 (default 3)",
|
|
72
|
+
)
|
|
73
|
+
p_exp.add_argument(
|
|
74
|
+
"-q", "--quiet", action="store_true", help="suppress progress output"
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
p_batch = sub.add_parser(
|
|
78
|
+
"export-batch", help="batch-export all .dem files in a directory"
|
|
79
|
+
)
|
|
80
|
+
p_batch.add_argument(
|
|
81
|
+
"directory", help="directory to scan for .dem files (non-recursive)"
|
|
82
|
+
)
|
|
83
|
+
p_batch.add_argument("--research", action="store_true", help="also emit duels.json")
|
|
84
|
+
p_batch.add_argument(
|
|
85
|
+
"--sample-rate",
|
|
86
|
+
type=int,
|
|
87
|
+
default=8,
|
|
88
|
+
help="replay stream sample rate in Hz (default 8)",
|
|
89
|
+
)
|
|
90
|
+
p_batch.add_argument(
|
|
91
|
+
"--window-before",
|
|
92
|
+
type=int,
|
|
93
|
+
default=2000,
|
|
94
|
+
help="duel window extent before each anchor, ms (default 2000)",
|
|
95
|
+
)
|
|
96
|
+
p_batch.add_argument(
|
|
97
|
+
"--window-after",
|
|
98
|
+
type=int,
|
|
99
|
+
default=1000,
|
|
100
|
+
help="duel window extent after each anchor, ms (default 1000)",
|
|
101
|
+
)
|
|
102
|
+
p_batch.add_argument(
|
|
103
|
+
"--compress-level",
|
|
104
|
+
type=int,
|
|
105
|
+
default=DEFAULT_COMPRESS_LEVEL,
|
|
106
|
+
help="ZIP DEFLATE compression level 0-9 (default 3)",
|
|
107
|
+
)
|
|
108
|
+
p_batch.add_argument(
|
|
109
|
+
"--workers",
|
|
110
|
+
type=int,
|
|
111
|
+
default=None,
|
|
112
|
+
help="parallel worker count (default: logical CPU count)",
|
|
113
|
+
)
|
|
114
|
+
p_batch.add_argument(
|
|
115
|
+
"--fail-fast", action="store_true", help="stop on first failure"
|
|
116
|
+
)
|
|
117
|
+
p_batch.add_argument(
|
|
118
|
+
"--descriptive",
|
|
119
|
+
action="store_true",
|
|
120
|
+
help="use descriptive filenames (date_map_teams_score.zip)",
|
|
121
|
+
)
|
|
66
122
|
|
|
67
123
|
p_val = sub.add_parser("validate", help="validate a v3 ZIP package")
|
|
68
124
|
p_val.add_argument("zip", help="path to the .zip file to validate")
|
|
@@ -99,17 +155,21 @@ def _cmd_export(args) -> int:
|
|
|
99
155
|
t0 = time.perf_counter()
|
|
100
156
|
progress = None
|
|
101
157
|
if not args.quiet:
|
|
158
|
+
|
|
102
159
|
def progress(stage: str, frac: float) -> None:
|
|
103
160
|
print(f" [{frac * 100:5.1f}%] {stage}")
|
|
104
161
|
|
|
105
162
|
if len(dems) > 1:
|
|
106
163
|
print(f"合并 {len(dems)} 段 → {out.name}")
|
|
107
|
-
data, _match_meta = export_demo_merged(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
164
|
+
data, _match_meta = export_demo_merged(
|
|
165
|
+
[str(d) for d in dems],
|
|
166
|
+
research=args.research,
|
|
167
|
+
sample_rate=args.sample_rate,
|
|
168
|
+
window_before_ms=args.window_before,
|
|
169
|
+
window_after_ms=args.window_after,
|
|
170
|
+
compress_level=args.compress_level,
|
|
171
|
+
progress=progress,
|
|
172
|
+
)
|
|
113
173
|
out.write_bytes(data)
|
|
114
174
|
dt = time.perf_counter() - t0
|
|
115
175
|
print(f"wrote {out} ({len(data) / 1e6:.2f} MB) in {dt:.1f}s")
|
|
@@ -150,8 +210,13 @@ def _cmd_export_batch(args) -> int:
|
|
|
150
210
|
futures = {}
|
|
151
211
|
for dem in demos:
|
|
152
212
|
submitted = time.perf_counter()
|
|
153
|
-
future = pool.submit(
|
|
154
|
-
|
|
213
|
+
future = pool.submit(
|
|
214
|
+
_export_one_report,
|
|
215
|
+
str(dem),
|
|
216
|
+
str(directory),
|
|
217
|
+
export_kwargs,
|
|
218
|
+
args.descriptive,
|
|
219
|
+
)
|
|
155
220
|
futures[future] = (dem, submitted)
|
|
156
221
|
for future in as_completed(futures):
|
|
157
222
|
dem, submitted = futures[future]
|
|
@@ -161,10 +226,14 @@ def _cmd_export_batch(args) -> int:
|
|
|
161
226
|
row = _failed_batch_row(dem, submitted, _format_exception(exc))
|
|
162
227
|
report.append(row)
|
|
163
228
|
if row["ok"]:
|
|
164
|
-
print(
|
|
165
|
-
|
|
229
|
+
print(
|
|
230
|
+
f" ok {dem.name} -> {Path(row['zip']).name} "
|
|
231
|
+
f"{row['zipBytes'] / 1e6:.1f}MB {row['durationSeconds']:.1f}s"
|
|
232
|
+
)
|
|
166
233
|
else:
|
|
167
|
-
print(
|
|
234
|
+
print(
|
|
235
|
+
f" FAIL {dem.name}: {row['error']} ({row['durationSeconds']:.1f}s)"
|
|
236
|
+
)
|
|
168
237
|
if args.fail_fast:
|
|
169
238
|
pool.shutdown(wait=False, cancel_futures=True)
|
|
170
239
|
dt = time.perf_counter() - t0
|
|
@@ -209,8 +278,10 @@ def _resolve_spec_dir(arg: str | None) -> Path | None:
|
|
|
209
278
|
|
|
210
279
|
# ── batch helpers (module-level for picklability with ProcessPoolExecutor) ──────
|
|
211
280
|
|
|
212
|
-
|
|
213
|
-
|
|
281
|
+
|
|
282
|
+
def _export_one_report(
|
|
283
|
+
dem_path: str, out_dir: str, export_kwargs: dict, descriptive: bool
|
|
284
|
+
) -> dict:
|
|
214
285
|
"""Parse → build → package one demo; return a structured result row."""
|
|
215
286
|
from .package import export_demo
|
|
216
287
|
|
|
@@ -275,13 +346,15 @@ def _build_descriptive_from_meta(match_meta: dict, stem: str, date_str: str) ->
|
|
|
275
346
|
def _sanitize(s: str) -> str:
|
|
276
347
|
"""Sanitize a string for safe filename use."""
|
|
277
348
|
for ch in r' <>:"/\|?*':
|
|
278
|
-
s = s.replace(ch,
|
|
279
|
-
while
|
|
280
|
-
s = s.replace(
|
|
281
|
-
return s.strip(
|
|
349
|
+
s = s.replace(ch, "_")
|
|
350
|
+
while "__" in s:
|
|
351
|
+
s = s.replace("__", "_")
|
|
352
|
+
return s.strip("_")
|
|
282
353
|
|
|
283
354
|
|
|
284
|
-
def _write_unique_zip(
|
|
355
|
+
def _write_unique_zip(
|
|
356
|
+
out_dir: Path, preferred_name: str, stem: str, data: bytes
|
|
357
|
+
) -> Path:
|
|
285
358
|
"""Write bytes without overwriting an existing batch output."""
|
|
286
359
|
preferred = Path(preferred_name)
|
|
287
360
|
suffix = preferred.suffix or ".zip"
|
|
@@ -335,20 +408,24 @@ def _compress_level_ok(value: int) -> bool:
|
|
|
335
408
|
|
|
336
409
|
|
|
337
410
|
def _aggregate_timings(report: list[dict]) -> dict:
|
|
338
|
-
rows = [
|
|
411
|
+
rows = [
|
|
412
|
+
r.get("timingsSeconds")
|
|
413
|
+
for r in report
|
|
414
|
+
if r.get("ok") and r.get("timingsSeconds")
|
|
415
|
+
]
|
|
339
416
|
if not rows:
|
|
340
417
|
return {"count": 0, "total": {}, "average": {}}
|
|
341
418
|
keys = sorted({key for row in rows for key in row})
|
|
342
419
|
totals = {
|
|
343
|
-
key: round(sum(float(row.get(key) or 0.0) for row in rows), 3)
|
|
344
|
-
for key in keys
|
|
420
|
+
key: round(sum(float(row.get(key) or 0.0) for row in rows), 3) for key in keys
|
|
345
421
|
}
|
|
346
422
|
averages = {key: round(value / len(rows), 3) for key, value in totals.items()}
|
|
347
423
|
return {"count": len(rows), "total": totals, "average": averages}
|
|
348
424
|
|
|
349
425
|
|
|
350
|
-
def _write_batch_report(
|
|
351
|
-
|
|
426
|
+
def _write_batch_report(
|
|
427
|
+
out_dir: Path, report: list[dict], duration_seconds: float
|
|
428
|
+
) -> None:
|
|
352
429
|
"""Write report.json with aggregate stats next to the exported ZIPs."""
|
|
353
430
|
demo_bytes = sum(r["demoBytes"] for r in report)
|
|
354
431
|
zip_bytes = sum(r["zipBytes"] for r in report)
|
|
@@ -13,16 +13,38 @@ from typing import Any
|
|
|
13
13
|
|
|
14
14
|
# ── hit groups ────────────────────────────────────────────────────────────────
|
|
15
15
|
|
|
16
|
-
_HITGROUP_ENUM = {
|
|
17
|
-
|
|
16
|
+
_HITGROUP_ENUM = {
|
|
17
|
+
"generic",
|
|
18
|
+
"head",
|
|
19
|
+
"chest",
|
|
20
|
+
"stomach",
|
|
21
|
+
"left_arm",
|
|
22
|
+
"right_arm",
|
|
23
|
+
"left_leg",
|
|
24
|
+
"right_leg",
|
|
25
|
+
"gear",
|
|
26
|
+
"neck",
|
|
27
|
+
}
|
|
18
28
|
|
|
19
29
|
_HITGROUP_MAP = {
|
|
20
|
-
"head": "head",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
30
|
+
"head": "head",
|
|
31
|
+
"chest": "chest",
|
|
32
|
+
"stomach": "stomach",
|
|
33
|
+
"leftarm": "left_arm",
|
|
34
|
+
"left arm": "left_arm",
|
|
35
|
+
"left_arm": "left_arm",
|
|
36
|
+
"rightarm": "right_arm",
|
|
37
|
+
"right arm": "right_arm",
|
|
38
|
+
"right_arm": "right_arm",
|
|
39
|
+
"leftleg": "left_leg",
|
|
40
|
+
"left leg": "left_leg",
|
|
41
|
+
"left_leg": "left_leg",
|
|
42
|
+
"rightleg": "right_leg",
|
|
43
|
+
"right leg": "right_leg",
|
|
44
|
+
"right_leg": "right_leg",
|
|
45
|
+
"gear": "gear",
|
|
46
|
+
"neck": "neck",
|
|
47
|
+
"generic": "generic",
|
|
26
48
|
}
|
|
27
49
|
|
|
28
50
|
|
|
@@ -84,11 +106,21 @@ def normalize_round_end_reason(raw: Any) -> str:
|
|
|
84
106
|
|
|
85
107
|
# ── grenades ───────────────────────────────────────────────────────────────────
|
|
86
108
|
|
|
87
|
-
_GRENADE_TYPE_ENUM = {
|
|
109
|
+
_GRENADE_TYPE_ENUM = {
|
|
110
|
+
"flashbang",
|
|
111
|
+
"smoke",
|
|
112
|
+
"molotov",
|
|
113
|
+
"incendiary",
|
|
114
|
+
"hegrenade",
|
|
115
|
+
"decoy",
|
|
116
|
+
}
|
|
88
117
|
_GRENADE_WEAPON_TO_TYPE = {
|
|
89
|
-
"smokegrenade": "smoke",
|
|
90
|
-
"
|
|
91
|
-
"
|
|
118
|
+
"smokegrenade": "smoke",
|
|
119
|
+
"flashbang": "flashbang",
|
|
120
|
+
"hegrenade": "hegrenade",
|
|
121
|
+
"molotov": "molotov",
|
|
122
|
+
"incgrenade": "incendiary",
|
|
123
|
+
"decoy": "decoy",
|
|
92
124
|
}
|
|
93
125
|
|
|
94
126
|
|
|
@@ -121,8 +153,12 @@ def grenade_projectile_to_type(class_name: str) -> str | None:
|
|
|
121
153
|
# grenade sets and ignore everything else (knives, C4, Zeus, unknown).
|
|
122
154
|
|
|
123
155
|
_GRENADE_ITEMS = {
|
|
124
|
-
"Smoke Grenade",
|
|
125
|
-
"
|
|
156
|
+
"Smoke Grenade",
|
|
157
|
+
"Flashbang",
|
|
158
|
+
"High Explosive Grenade",
|
|
159
|
+
"Incendiary Grenade",
|
|
160
|
+
"Molotov",
|
|
161
|
+
"Decoy Grenade",
|
|
126
162
|
}
|
|
127
163
|
_GRENADE_ITEM_TO_TYPE = {
|
|
128
164
|
"Smoke Grenade": "smoke",
|
|
@@ -133,19 +169,46 @@ _GRENADE_ITEM_TO_TYPE = {
|
|
|
133
169
|
"Decoy Grenade": "decoy",
|
|
134
170
|
}
|
|
135
171
|
_PISTOL_ITEMS = {
|
|
136
|
-
"Glock-18",
|
|
137
|
-
"
|
|
172
|
+
"Glock-18",
|
|
173
|
+
"USP-S",
|
|
174
|
+
"P2000",
|
|
175
|
+
"Dual Berettas",
|
|
176
|
+
"P250",
|
|
177
|
+
"Five-SeveN",
|
|
178
|
+
"Tec-9",
|
|
179
|
+
"CZ75-Auto",
|
|
180
|
+
"Desert Eagle",
|
|
181
|
+
"R8 Revolver",
|
|
138
182
|
}
|
|
139
183
|
_PRIMARY_ITEMS = {
|
|
140
184
|
# SMG
|
|
141
|
-
"MAC-10",
|
|
185
|
+
"MAC-10",
|
|
186
|
+
"MP9",
|
|
187
|
+
"MP7",
|
|
188
|
+
"MP5-SD",
|
|
189
|
+
"UMP-45",
|
|
190
|
+
"P90",
|
|
191
|
+
"PP-Bizon",
|
|
142
192
|
# Rifle / sniper
|
|
143
|
-
"Galil AR",
|
|
144
|
-
"
|
|
193
|
+
"Galil AR",
|
|
194
|
+
"FAMAS",
|
|
195
|
+
"AK-47",
|
|
196
|
+
"M4A4",
|
|
197
|
+
"M4A1-S",
|
|
198
|
+
"SSG 08",
|
|
199
|
+
"SG 553",
|
|
200
|
+
"AUG",
|
|
201
|
+
"AWP",
|
|
202
|
+
"G3SG1",
|
|
203
|
+
"SCAR-20",
|
|
145
204
|
# Shotgun
|
|
146
|
-
"Nova",
|
|
205
|
+
"Nova",
|
|
206
|
+
"XM1014",
|
|
207
|
+
"Sawed-Off",
|
|
208
|
+
"MAG-7",
|
|
147
209
|
# LMG
|
|
148
|
-
"M249",
|
|
210
|
+
"M249",
|
|
211
|
+
"Negev",
|
|
149
212
|
}
|
|
150
213
|
|
|
151
214
|
|
|
@@ -246,7 +309,11 @@ def normalize_weapon_name(raw: Any) -> str | None:
|
|
|
246
309
|
if lower in _WEAPON_DISPLAY_TO_CANONICAL:
|
|
247
310
|
return _WEAPON_DISPLAY_TO_CANONICAL[lower]
|
|
248
311
|
ident = lower.replace("-", "_").replace(" ", "_")
|
|
249
|
-
return
|
|
312
|
+
return (
|
|
313
|
+
ident
|
|
314
|
+
if ident and ident[0].isalpha() and all(c.isalnum() or c == "_" for c in ident)
|
|
315
|
+
else None
|
|
316
|
+
)
|
|
250
317
|
|
|
251
318
|
|
|
252
319
|
# ── bombs ──────────────────────────────────────────────────────────────────────
|
|
@@ -258,6 +325,7 @@ def normalize_weapon_name(raw: Any) -> str | None:
|
|
|
258
325
|
# in `last_place_name`, which is "BombsiteA" / "BombsiteB" when on a site. This
|
|
259
326
|
# is authoritative, map-agnostic, and needs no per-map calibration.
|
|
260
327
|
|
|
328
|
+
|
|
261
329
|
def bomb_site_from_place(place: Any) -> str | None:
|
|
262
330
|
"""Map a CS2 place name to "a"/"b"; None if it is not a bombsite area."""
|
|
263
331
|
p = str(place or "").strip().lower()
|
|
@@ -269,10 +337,15 @@ def bomb_site_from_place(place: Any) -> str | None:
|
|
|
269
337
|
|
|
270
338
|
|
|
271
339
|
_BOMB_TYPE_MAP = {
|
|
272
|
-
"plant": "plant_begin",
|
|
340
|
+
"plant": "plant_begin",
|
|
341
|
+
"plant_begin": "plant_begin",
|
|
273
342
|
"planted": "planted",
|
|
274
|
-
"defuse": "defuse_begin",
|
|
275
|
-
"
|
|
276
|
-
"
|
|
277
|
-
"
|
|
343
|
+
"defuse": "defuse_begin",
|
|
344
|
+
"defuse_begin": "defuse_begin",
|
|
345
|
+
"defused": "defused",
|
|
346
|
+
"defuse_complete": "defused",
|
|
347
|
+
"explode": "exploded",
|
|
348
|
+
"exploded": "exploded",
|
|
349
|
+
"dropped": "dropped",
|
|
350
|
+
"picked_up": "picked_up",
|
|
278
351
|
}
|