Commit 62f391ea authored by Constantin's avatar Constantin
Browse files

obstinacy

parent 9d20f69f
......@@ -3,10 +3,24 @@ from thing import Thing
from labyrinth import directions as directionOffsets
from labyrinth import directions_inv as directions_t
goVerbs = ['go', 'walk', 'run']
goVerbs = ['go', 'walk', 'run', 'stroll']
sayVerbs = ['say', 'talk', 'scream', 'whisper']
announceVerbs = ['announce']
leaveVerbs = ['leave', 'quit', 'exit', 'suicide']
grabVerbs = ['grab', 'get', 'investigate', 'examine', 'check']
obstinacyTable = [
"Sorry, you cannot go there",
"Sorry, you really cannot go there",
"You cannot go there",
"That's not possible",
"There, you ram your head against the obstacle and get a concussion. Are you happy now?",
"Sorry, you cannot go there",
"By repeatedly hammering against the wall with your full force, you break a hole in it. In that hole, you find the Triforce of Courage.\nlol jk, you ain't get shit.",
"YOU CAN'T GO THROUGH WALLS!",
"You run against the wall, faint and as you wake up, all your inventory is gone! Yes, all of it!",
"Okay, actually you can go through walls if you try really hard. I mean, it's just a game and it would be way too depressing for you, if you couldn't.",
]
playerUID = 0
......@@ -18,6 +32,7 @@ class Player(Thing):
self.game = game
self.conn = conn
self.uid = playerUID
self.obstinacy = 0
playerUID += 1
log_stdout("New player: {0}".format(self.uid))
......@@ -84,26 +99,41 @@ class Player(Thing):
if not words:
self.send("What did you mean?")
return
try:
words.remove("to")
except ValueError:
pass
try:
words.remove("the")
except ValueError:
pass
verb = words[0]
if verb in goVerbs:
if len(words) >= 3 and words[1:3] == ["to", "the"]:
direction = words[3:]
else:
direction = words[1:]
direction = words[1:]
if len(direction) != 1 or direction[0] not in directionOffsets:
self.send("Where do you want to go?")
return
dy, dx = directionOffsets.get(direction[0])
target = self.field.neighbor(dy=dy, dx=dx)
if target is None or not target.isWalkable():
self.send("Sorry, you cannot go there")
return
if self.obstinacy < len(obstinacyTable):
self.send(obstinacyTable[self.obstinacy])
self.obstinacy += 1
if self.obstinacy == len(obstinacyTable): # final message, do it
while target is not None and not target.isWalkable():
target = target.neighbor(dy=dy,dx=dx)
if target is None:
self.send("Unfortunately behind this wall, the game world ended. You see a sign. It says 'Here be dragons'. Shortly thereafter you are slain by some actual dragons.\nGood Bye.")
self.game.removePlayer(self)
return
else:
pass
# not return
playerToPush = None
for thing in target.things:
if thing != self and isinstance(thing, Player):
playerToPush = thing
self.send("By moving to the "+direction[0]+" you pushed another player away.")
self.game.labyrinth.moveThing(self, target, (lambda:playerToPush.pushAway(self,direction[0])) if playerToPush else None)
elif verb in sayVerbs:
......
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