Commit 8204abe0 authored by Constantin's avatar Constantin
Browse files

fixed many bugs

parent 6d1a22af
...@@ -38,7 +38,7 @@ class Labyrinth: ...@@ -38,7 +38,7 @@ class Labyrinth:
if len(self.things) == 0: if len(self.things) == 0:
return "there is nothing" return "there is nothing"
elif len(self.things) == 1: elif len(self.things) == 1:
return "there is "+self.things[0].toString() return "there is "+str(self.things[0])
else: else:
return "there are "+(", ".join([x.toString() for x in self.things[:-1]]))+" and "+self.things[-1].toString() return "there are "+(", ".join([x.toString() for x in self.things[:-1]]))+" and "+self.things[-1].toString()
...@@ -99,11 +99,14 @@ class Labyrinth: ...@@ -99,11 +99,14 @@ class Labyrinth:
assert thing.field.labyrinth == self assert thing.field.labyrinth == self
assert newField.labyrinth == self assert newField.labyrinth == self
thing.field._removeThing(thing) thing.field._removeThing(thing)
oldField = thing.field
thing.field = newField thing.field = newField
newField._addThing(thing) newField._addThing(thing)
thing.afterMove(oldField)
return True return True
def createThing (self, thing, field): def createThing (self, thing, field):
thing.field = field thing.field = field
field._addThing(thing) field._addThing(thing)
thing.onMove(field) thing.onMove(field)
\ No newline at end of file thing.afterMove(field)
\ No newline at end of file
...@@ -68,7 +68,6 @@ class Player(Thing): ...@@ -68,7 +68,6 @@ class Player(Thing):
thing.send("You hear someone saying: "+msg) thing.send("You hear someone saying: "+msg)
self.send("You say: "+msg) self.send("You say: "+msg)
def onMove(self, newField): def afterMove(self, oldField):
desc = self.game.labyrinth.getDescription(newField) desc = self.game.labyrinth.getDescription(self.field)
self.send(desc) self.send(desc)
return True
...@@ -3,4 +3,7 @@ class Thing(): ...@@ -3,4 +3,7 @@ class Thing():
self.field = None self.field = None
def onMove(self, newField): def onMove(self, newField):
return True return True
\ No newline at end of file
def afterMove(self, oldField):
pass
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment