Commit 325c3f7d authored by Constantin's avatar Constantin
Browse files

functional horror code to fix stuff somehow

parent 6550d3d5
...@@ -52,9 +52,8 @@ class Player(Thing): ...@@ -52,9 +52,8 @@ class Player(Thing):
def __str__(self): def __str__(self):
return "another player" return "another player"
def isMovedBy(self,pusher): def pushAway(self,pusher,direction):
dx = self.field.column - pusher.field.column dy,dx = directionOffsets[direction]
dy = self.field.row - pusher.field.row
pushTarget = self.field.neighbor(dx=dx,dy=dy) pushTarget = self.field.neighbor(dx=dx,dy=dy)
travelDistance = 1 travelDistance = 1
while pushTarget is not None and not pushTarget.isWalkable(): while pushTarget is not None and not pushTarget.isWalkable():
...@@ -74,9 +73,9 @@ class Player(Thing): ...@@ -74,9 +73,9 @@ class Player(Thing):
playerToPush = None playerToPush = None
for thing in pushTarget.things: for thing in pushTarget.things:
if thing != self and isinstance(thing, Player): if thing != self and isinstance(thing, Player):
playerToPush = thing # yes, this may have higher speeds than one *grin* playerToPush = thing
self.send("After coming out of the wall with incredible speed, you hit another player, who is in turn pushed away by your momentum. Poor bastard...") self.send("After coming out of the wall with incredible speed, you hit another player, who is in turn pushed away by your momentum. Poor bastard...")
self.game.labyrinth.moveThing(self,pushTarget,(lambda:playerToPush.isMovedBy(self) if playerToPush else None)) self.game.labyrinth.moveThing(self,pushTarget,(lambda:playerToPush.pushAway(self) if playerToPush else None))
# high(er)-level functions # high(er)-level functions
def readCmd(self, cmd): def readCmd(self, cmd):
...@@ -103,9 +102,9 @@ class Player(Thing): ...@@ -103,9 +102,9 @@ class Player(Thing):
for thing in target.things: for thing in target.things:
if thing != self and isinstance(thing, Player): if thing != self and isinstance(thing, Player):
playerToPush = thing playerToPush = thing
self.send("By moving to the "+direction[0]+" you pushed another player away.")) self.send("By moving to the "+direction[0]+" you pushed another player away.")
self.game.labyrinth.moveThing(self, target, (lambda:playerToPush.isMovedBy(self) if playerToPush else None)) self.game.labyrinth.moveThing(self, target, (lambda:playerToPush.pushAway(self,direction[0]) if playerToPush else None))
elif verb in sayVerbs: elif verb in sayVerbs:
msg = " ".join(words[1:]) msg = " ".join(words[1:])
......
Supports Markdown
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