Skip to content

Commit 82cc736

Browse files
committed
map as string
1 parent 53763a8 commit 82cc736

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎bomber/engine.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def first(iterator):
2929

3030
class MapObject:
3131

32+
char = "Q"
3233
hidden = False
3334
color = (100, 100, 100)
3435

@@ -46,6 +47,10 @@ def position_float(self):
4647
def update(self, dt):
4748
pass
4849

50+
def hide(self):
51+
self.hidden = True
52+
self.char = self.char.lower()
53+
4954

5055
class FireTrail(MapObject):
5156

@@ -173,6 +178,7 @@ def update(self, dt):
173178

174179
class GroundBlock(MapObject):
175180

181+
char = "g"
176182
color = (0, 200, 0)
177183

178184

@@ -182,12 +188,14 @@ class Wall(MapObject):
182188

183189
class DestructableWall(Wall):
184190

191+
char = "W"
185192
color = (200, 100, 100)
186193
destructable = True
187194

188195

189196
class IndestructableWall(Wall):
190197

198+
char = "M"
191199
color = (100, 100, 100)
192200
destructable = False
193201

@@ -273,7 +281,8 @@ def handle_msg(self, msg):
273281
elif msg["type"] == "whoami":
274282
self.client.inform("OK", self.whoami_data)
275283
elif msg["type"] == "map":
276-
self.client.inform("OK", self.map._map,)
284+
self.client.inform("OK", "\n".join(
285+
"".join(e.char for e in line) for line in self.map._map),)
277286
elif msg["type"] == "bomb":
278287
self.bomb()
279288

0 commit comments

Comments
 (0)