-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunc_extract_yfs_explosions.py
More file actions
42 lines (34 loc) · 1.03 KB
/
func_extract_yfs_explosions.py
File metadata and controls
42 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
__version__ = "20181130"
__author__ = "Decaff_42"
__copyright__ = "2018 by Decaff_42"
__license__ = """Only non-comercial use with attribution is allowed without
prior written permission from Decaff_42."""
"""
VERSION HISTORY:
20181130 - Original release
20210129 - Re-formatting IAW PEPs.
"""
def extract_explosions(raw):
"""Extract the raw bullet record from the .yfs file."""
# Get the index of the explosion record
try:
start = raw.index("EXPRECOR")
except ValueError:
# No Explosion Records in this replay
return []
explosions = list()
raw = raw[start:]
record = False
num_lines = len(raw)
num_exp = 0
for ind, line in enumerate(raw):
if line.startswith("NUMRECO"):
num_exp = int(line.split(" ")[-1])
record = True
elif line.startswith("ENDRECO") or ind == num_lines:
record = False
break
elif record is True:
explosions.append(line)
return explosions