-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfind_unimplemented_attacks.py
executable file
·44 lines (35 loc) · 1.14 KB
/
find_unimplemented_attacks.py
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
43
44
#!/usr/bin/env python3
"""
This script is meant to help discover attack types/damages that have not been
added to Pinobot unixmain.patch.
Example:
./find_unimplemented_attacks.py nethack/include/monattk.h pinobot/patch/unixmain.patch
"""
import re
import sys
AT_RE = re.compile('.*(AT|AD)_([0-9A-Za-z]+).*')
if __name__ == '__main__':
seen_ats1 = set()
seen_ats2 = set()
with open(sys.argv[1], 'rt') as f:
for line in f:
m = AT_RE.match(line)
if not m:
continue
seen_ats1.add(f'{m.group(1)}_{m.group(2)}')
with open(sys.argv[2], 'rt') as f:
for line in f:
m = AT_RE.match(line)
if not m:
continue
seen_ats2.add(f'{m.group(1)}_{m.group(2)}')
# What attacks/damages are missing?
missing = seen_ats1 - seen_ats2
# Go through the first file again, but if it contains a missing entry then
# print the entire line.
with open(sys.argv[1], 'rt') as f:
for line in f:
for m in missing:
if m in line:
print(line.rstrip('\n'))
break