-
Notifications
You must be signed in to change notification settings - Fork 1
/
gridmapper_ref.py
151 lines (139 loc) · 11.9 KB
/
gridmapper_ref.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import re, html
# Remove well-formed tags, fixing mistakes by legitimate users
legend_gridmapper = {}
legend_gridmapper['B'] = "pVVVV"
legend_gridmapper['O'] = "Outside Entrance"
legend_gridmapper['C'] = "Corridor/Passage"
legend_gridmapper['R'] = "Chamber/Room"
legend_gridmapper['D'] = "Dead End"
legend_gridmapper['CH'] = "Chasm"
legend_gridmapper['ri'] = "river"
legend_gridmapper['br'] = "bridge"
legend_gridmapper['bo'] = "boat - opposide side"
legend_gridmapper['bn'] = "boat - near side"
legend_gridmapper['L'] = "Lake"
legend_gridmapper['P'] = "Pool"
legend_gridmapper['W'] = "Well"
legend_gridmapper['S'] = "Shaft"
legend_gridmapper['d'] = "door"
legend_gridmapper[':'] = "direction of Door"
legend_gridmapper['wm'] = "Wandering Monster"
legend_gridmapper['sd'] = "Secret Door"
legend_gridmapper['st'] = "Stairs"
legend_gridmapper['sn'] = "Stairs dead end"
legend_gridmapper['ch'] = "Chute"
legend_gridmapper['cm'] = "Chimney"
legend_gridmapper['td'] = "Trapdoor"
legend_gridmapper['pi'] = "Pit Trap"
legend_gridmapper['pt'] = "Pit Trap: Secret Door"
legend_gridmapper['ps'] = "Pit Trap: Spikes"
legend_gridmapper['pc'] = "Pit Trap: Crushing Walls"
legend_gridmapper['el'] = "Elevator Trap"
legend_gridmapper['ar'] = "Arrow Trap"
legend_gridmapper['sp'] = "Spear Trap"
legend_gridmapper['df'] = "Door Falls Trap"
legend_gridmapper['sf'] = "Stone Falls Trap"
legend_gridmapper['gs'] = "Gas Trap"
legend_gridmapper['bw'] = "Blocked Wall Trap"
legend_gridmapper['ol'] = "Oil Trap"
legend_gridmapper['m'] = "Monster"
legend_gridmapper['t'] = "Treasure"
legend_gridmapper['c'] = "Treasure: Copper"
legend_gridmapper['s'] = "Treasure: Silver"
legend_gridmapper['e'] = "Treasure: Electrum"
legend_gridmapper['g'] = "Treasure: Gold"
legend_gridmapper['p'] = "Treasure: Platinum"
legend_gridmapper['G'] = "Treasure: Gems"
legend_gridmapper['j'] = "Treasure: Jewellery"
legend_gridmapper['M'] = "Treasure: Magic"
background_dict = {}
background_dict['black'] = 'nothing'
background_dict['green'] = 'outside entrance'
background_dict['blue'] = 'water'
background_dict['red'] = 'bad_things'
background_dict['white'] = 'corridor/passage'
background_dict['brown'] = 'dead end'
legend_gridmapper = {}
for key in legend_gridmapper:
legend_gridmapper[key] = ''
legend_gridmapper['B'] = "pvvvv"
legend_gridmapper['O'] = "fF"
legend_gridmapper['C'] = "f"
legend_gridmapper['R'] = "fQ"
legend_gridmapper['RA'] = "cQ"
legend_gridmapper['D'] = "gS"
legend_gridmapper['CH'] = "n"
legend_gridmapper['ri'] = "fVVB"
legend_gridmapper['br'] = "bridge"
legend_gridmapper['bo'] = "boat - opposide side"
legend_gridmapper['bn'] = "boat - near side"
legend_gridmapper['L'] = "fvvD"
legend_gridmapper['P'] = "fvvB"
legend_gridmapper['W'] = "bvB"
legend_gridmapper['S'] = "bvv"
legend_gridmapper['d'] = "d"
legend_gridmapper[':'] = "direction of Door"
legend_gridmapper['wm'] = "fE"
legend_gridmapper['sd'] = "dv"
legend_gridmapper['st'] = "oE"
legend_gridmapper['sn'] = "ovE"
legend_gridmapper['ch'] = "Chute"
legend_gridmapper['cm'] = "Chimney"
legend_gridmapper['td'] = "tvvvE"
legend_gridmapper['pi'] = "tvE"
legend_gridmapper['pt'] = "tvE"
legend_gridmapper['ps'] = "tvE"
legend_gridmapper['pc'] = "tvE"
legend_gridmapper['el'] = "svE"
legend_gridmapper['ar'] = "tvvvvvvE"
legend_gridmapper['sp'] = "tvvvvvvE"
legend_gridmapper['df'] = "dvvvvvE"
legend_gridmapper['sf'] = "tvvvvvvE"
legend_gridmapper['gs'] = "tvvvvvvE"
legend_gridmapper['bw'] = "wE"
legend_gridmapper['ol'] = "tvvvvvvE"
legend_gridmapper['m'] = "fE"
legend_gridmapper['t'] = "cA"
legend_gridmapper['c'] = "cA"
legend_gridmapper['s'] = "cA"
legend_gridmapper['e'] = "cA"
legend_gridmapper['g'] = "cA"
legend_gridmapper['p'] = "cA"
legend_gridmapper['G'] = "cA"
legend_gridmapper['j'] = "cA"
legend_gridmapper['M'] = "cA"
testt = '''<table><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td>C</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td>C</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td>C</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="green_background">O</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td>C</td><td>C</td><td>C</td><td class="red_background">pt</td><td>C</td><td>C</td><td>C</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td>C</td><td class="black_background">B</td><td class="black_background">B</td><td class="red_background">wm</td><td class="gray_background">R2</td><td class="gray_background">R2</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td>C</td><td class="black_background">B</td><td class="black_background">B</td><td class="red_background">td</td><td class="gray_background" style="color:#FFD700">R2g</td><td class="gray_background">R2</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td>C</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td>C</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td>C</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td>C</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR><TR><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td><td class="black_background">B</td></TR></table>'''
testt = testt.replace('<TR>','')
testt = testt.replace('<table>','')
testt = testt.replace(r'</table>','')
testlist = testt.split(r'</TR>')
print(testlist)
striplist = []
tag_re = re.compile(r'(<!--.*?-->|<[^>]*>)')
if 1 == 1:
#tag_re = re.compile(r'<[^>]+')
print(tag_re)
#result = pattern.sub('',text)
for t in testlist:
no_tags = tag_re.sub(' ', t)
tag_list = no_tags.split()
new_list = []
for tl in tag_list:
if 'R' in tl:
usetl = tl
if len(usetl) > 1:
tl = 'R'
if 'g' in usetl or 'p' in usetl or 'g' in usetl or 's' in usetl or 'c' in usetl:
tl = 'RA'
newtl = legend_gridmapper[tl]
new_list.append(newtl)
striplist.append(new_list)
print(striplist)
with open('testgrid.txt','w') as f:
for s in striplist:
for sl in s:
if sl != 'f':
f.write(str(sl) + " ")
else:
f.write(str(sl) + "")
f.write("\n")