Commit 66e4ec86 authored by Ralf's avatar Ralf

treasure handling

parent 0e9065c0
from util import * from util import *
from thing import Thing from thing import Thing
import treasure
from labyrinth import directions as directionOffsets from labyrinth import directions as directionOffsets
from labyrinth import directions_inv as directions_t from labyrinth import directions_inv as directions_t
import random
goVerbs = ['go', 'walk', 'run', 'stroll'] goVerbs = ['go', 'walk', 'run', 'stroll']
sayVerbs = ['say', 'talk', 'scream', 'whisper'] sayVerbs = ['say', 'talk', 'scream', 'whisper']
...@@ -120,7 +122,7 @@ class Player(Thing): ...@@ -120,7 +122,7 @@ class Player(Thing):
if self.obstinacy < len(obstinacyTable): if self.obstinacy < len(obstinacyTable):
self.send(obstinacyTable[self.obstinacy]) self.send(obstinacyTable[self.obstinacy])
self.obstinacy += 1 self.obstinacy += 1
if self.obstinacy == len(obstinacyTable): # final message, do it else: # final message, do it
while target is not None and not target.isWalkable(): while target is not None and not target.isWalkable():
target = target.neighbor(dy=dy,dx=dx) target = target.neighbor(dy=dy,dx=dx)
if target is None: if target is None:
...@@ -130,6 +132,8 @@ class Player(Thing): ...@@ -130,6 +132,8 @@ class Player(Thing):
else: else:
pass pass
# not return # not return
# move around
self.obstinacy = 0
playerToPush = None playerToPush = None
for thing in target.things: for thing in target.things:
if thing != self and isinstance(thing, Player): if thing != self and isinstance(thing, Player):
...@@ -159,6 +163,22 @@ class Player(Thing): ...@@ -159,6 +163,22 @@ class Player(Thing):
desc = self.game.labyrinth.getDescription(self) desc = self.game.labyrinth.getDescription(self)
self.send(desc, end="") self.send(desc, end="")
elif verb in grabVerbs:
# FIXME we ignore the object...
objs = filter(lambda thing: thing != self, self.field.things)
if not len(objs):
self.send("There's nothing here, sorry!")
return
if isinstance(objs[0], treasure.Treasure):
self.send("Finally - after a long journey - you are close enough to the treasure to reach for it. What a moment! But what's that? The treasure fades to transparent. You try to grab it, but it's too late. Quantum effects seem to be really weird in this place. All you are left with is a note, saying \"I found the treasure in the Haxogreen maze, and didn't even get a lousy T-Shirt\".")
for player in self.game.players:
if player == self: continue
player.send("Someone *else* found the trasure. Why have you been so slow? But do not despair, by the law of preservation of treasures, there has to be a new treasure somewhere.")
newField = random.choice(self.game.labyrinth.getFreeTiles())
self.game.labyrinth.moveThing(objs[0], newField)
else:
self.send("Congratulations! This cannot happen.")
elif verb == self.game.adminPW: elif verb == self.game.adminPW:
self.send("Welcome to the vault, my son") self.send("Welcome to the vault, my son")
self.game.makeAdmin(self) self.game.makeAdmin(self)
......
...@@ -2,4 +2,7 @@ import thing ...@@ -2,4 +2,7 @@ import thing
class Treasure(Thing): class Treasure(Thing):
def __str__(self): def __str__(self):
return "the treasure" return "the treasure"
\ No newline at end of file
def __repr__(self):
return "T"
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