-wwww
-wffw
-wffw
-wwww
\ No newline at end of file
+wwwwwwwwwwwwwwwwwwwwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wsfffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wffffffffffffffffffwwwwwwwwww
+wwwwwwwwwwwwwwwwwwwwwwwwwwwww
\ No newline at end of file
+import os
+import json
+
+ATTRIBUTE_MAP = {
+ ' ': {'floor': {'base': 'floor',
+ 'behaviour': ['walk', 'fly'],
+ },
+ },
+ 'w': {'floor': {'base': 'floor',
+ 'behaviour': [],
+ },
+ },
+ 'o': {'tunnels': {'base': 'underground',
+ 'behaviour': [],
+ }
+ },
+ 't': {'tunnels': {'base': 'underground',
+ 'behaviour': [],
+ }
+ },
+ '-': {'tunnels': {'base': 'tunnel',
+ 'behaviour': ['walk', ],
+ },
+ },
+ 'f': {'floor': {'base': 'floor',
+ 'behaviour': ['walk', 'fly'],
+ },
+ },
+ 'd': {'floor': {'base': 'floor',
+ 'behaviour': ['walk', 'fly'],
+ },
+ },
+ 'g': {'floor': {'base': 'floor',
+ 'behaviour': ['walk', 'fly'],
+ },
+ },
+ 'k': {'floor': {'base': 'floor',
+ 'behaviour': ['walk', 'fly'],
+ },
+ },
+ 's': {'floor': {'base': 'floor',
+ 'behaviour': ['walk', 'fly'],
+ },
+ },
+}
+
+
+class level_generator:
+
+ def __init__(self):
+
+ pass
+
+ def convert(self, passage_file, tunnel_file):
+ print('Make level')
+ with open(passage_file) as passages:
+ with open(tunnel_file) as tunnels:
+ p = []
+ for a in passages:
+ r = []
+ for aa in a:
+ r.append(aa)
+ p.append(r)
+ t = []
+ for a in tunnels:
+ r = []
+ for aa in a:
+ r.append(aa)
+ t.append(r)
+ level = {}
+ level['tileset'] = 'bunker'
+ level['tiles'] = []
+ level['starting pos'] = []
+ level['door_info'] = []
+
+
+
+ for l, lu in zip(p, t):
+ row = []
+ for t1, t2 in zip(l, lu):
+ if t1 != '\n' and t2 != '\n':
+ print(t1, t2)
+ tile = ATTRIBUTE_MAP[t1].copy()
+ tile.update(ATTRIBUTE_MAP[t2])
+ row.append(tile)
+ if t1 == 's':
+ level['starting pos'] = [len(level) - 1, len(row) - 1]
+ # if t2 == 'd'
+ level['tiles'].append(row)
+ # Crude hack so the level is written into the levels folder
+ name = os.path.join(os.path.dirname(__file__), '..', 'levels', 'map.json')
+ f = open(name, 'w')
+ json.dump(level, f, indent=3)
+ f.close()
+
+
+if __name__ == '__main__':
+ l = level_generator()
+ l.convert('l2', 't2')