Start implementing tell networks, and messages for room activities.

main
Cas Rusnov 3 years ago
parent 4952c1e5ef
commit 5eb72c1d22
  1. 2
      pyoo/interpret.py
  2. 19
      pyoo/things.py
  3. 2
      setup.py

@ -62,6 +62,8 @@ class Interpreter(object):
def interpret(self, command, player):
# FIXME make this better to support mulitple word objstrs and prepstr
if not command:
return
cmd_comps = command.split()
verbstr = cmd_comps[0]

@ -12,6 +12,9 @@ class Thing(object):
self.location = None
self.interpreter = None
def tell(self, message):
print("<tell stub>", self, message)
def verbs(self):
"""Return a list of bound methods which denote themselves as verbs."""
verbs = list()
@ -104,6 +107,13 @@ class Container(Thing):
pass
self.update_caches()
def handle_tell(self, msg, who):
for obj in who:
obj.tell(msg)
def tell(self, msg):
self.handle_tell(msg, self.contents)
def __repr__(self):
return "<Container '%s' object at 0x%x>" % (self.name, self.__hash__())
@ -113,6 +123,9 @@ class Place(Container):
super().__init__(names, description)
self.ways = dict()
def tell_only(self, message, verb_callframe):
self.handle_tell(message, self.contents - {verb_callframe.player})
# this verb expects to be annotated from update_go. We never want it ot be at the top of a match list by its deault
# name either
@make_verb("#go", "none", "none", "none")
@ -125,8 +138,14 @@ class Place(Container):
def do_go(self, direction, verb_callframe):
if direction in self.ways:
self.tell_only("{} moves {}".format(verb_callframe.player, direction), verb_callframe)
verb_callframe.player.tell("You move {}".format(direction))
verb_callframe.environment.handle_move(self.ways[direction], verb_callframe.player)
def handle_enter(self, newobj):
super().handle_enter(newobj)
self.tell("{} arrives".format(newobj))
def update_go(self):
# note does no actually remove items from the go verb in case the descender is overloading.
# also note, the interpreter needs to have update() called after this is called.

@ -4,7 +4,7 @@ import os.path
from setuptools import setup, find_packages
PACKAGE_NAME = "pyoo"
VERSION = "0.0.2"
VERSION = "0.0.3"
srcpath = os.path.dirname(__file__)

Loading…
Cancel
Save