Fixed errors in bridge room. Some issues with tickerhandler starting with an invalid interval.

This commit is contained in:
Griatch 2015-02-22 09:01:15 +01:00
parent 6f4cbbc1be
commit 5af3617d4e
7 changed files with 35 additions and 32 deletions

View file

@ -146,7 +146,6 @@ def get_and_merge_cmdsets(caller, session, player, obj,
yield [lobj.cmdset.current for lobj in local_objlist yield [lobj.cmdset.current for lobj in local_objlist
if (lobj.cmdset.current and if (lobj.cmdset.current and
lobj.locks.check(caller, 'call', no_superuser_bypass=True))] lobj.locks.check(caller, 'call', no_superuser_bypass=True))]
print "local_obj_cmdsets:", [c.key for c in local_obj_cmdsets]
for cset in local_obj_cmdsets: for cset in local_obj_cmdsets:
#This is necessary for object sets, or we won't be able to #This is necessary for object sets, or we won't be able to
# separate the command sets from each other in a busy room. # separate the command sets from each other in a busy room.
@ -210,7 +209,6 @@ def get_and_merge_cmdsets(caller, session, player, obj,
if cmdsets: if cmdsets:
# faster to do tuple on list than to build tuple directly # faster to do tuple on list than to build tuple directly
mergehash = tuple([id(cmdset) for cmdset in cmdsets]) mergehash = tuple([id(cmdset) for cmdset in cmdsets])
print "mergehash:", mergehash, mergehash in _CMDSET_MERGE_CACHE, [(c.key, c.priority) for c in cmdsets]
if mergehash in _CMDSET_MERGE_CACHE: if mergehash in _CMDSET_MERGE_CACHE:
# cached merge exist; use that # cached merge exist; use that
cmdset = _CMDSET_MERGE_CACHE[mergehash] cmdset = _CMDSET_MERGE_CACHE[mergehash]

View file

@ -384,16 +384,16 @@ north
# Some details to look at # Some details to look at
# #
@detail shutters;storm = @detail shutters;storm =
The shutters are closed. The shutters are closed.
# #
@detail evennia = @detail inn;sign =
You think you might have heard of this name before, You think you might have heard of this name before,
but at the moment you can recall where from. but at the moment you can recall where from.
# #
@detail snake;letters = @detail snake;letters;writing =
The snake is cartoonish with big googly eyes. It looks somewhat The snake is cartoonish with big googly eyes. It looks somewhat
like one of those big snakes from the distant jungles - the kind like one of those big snakes from the distant jungles - the kind
squeezes their victims. squeezes their victims.
#------------------------------------------------------------ #------------------------------------------------------------
# #
@ -421,6 +421,10 @@ north
(to get a weapon from the barrel, use {wget weapon{n) (to get a weapon from the barrel, use {wget weapon{n)
# #
@desc barrel =
This barrel has the air of leftovers - it contains an assorted
mess of random weaponry in various states and qualities.
#
@detail barkeep;man;landlord = @detail barkeep;man;landlord =
The landlord is a cheerful fellow, always ready to supply you with The landlord is a cheerful fellow, always ready to supply you with
more beer. He mentions doing some sort of arcane magic known as more beer. He mentions doing some sort of arcane magic known as
@ -446,7 +450,7 @@ north
# defined in tutorial_world.objects.WEAPON_PROTOTYPES. We also set a # defined in tutorial_world.objects.WEAPON_PROTOTYPES. We also set a
# message to use when trying to grab a second weapon. # message to use when trying to grab a second weapon.
# #
@set barrel/available_weapons = ["knife", "rusty_dagger", "sword", "club", "ornate_longsword"] @set barrel/available_weapons = ["knife", "dagger", "sword", "club"]
# #
@set barrel/no_more_weapons_msg = @set barrel/no_more_weapons_msg =
The barkeep shakes his head. He says: 'Sorry pal. We get a lot of needy The barkeep shakes his head. He says: 'Sorry pal. We get a lot of needy

View file

@ -879,7 +879,7 @@ class Weapon(TutorialObject):
WEAPON_PROTOTYPES = { WEAPON_PROTOTYPES = {
"weapon": { "weapon": {
"typeclass": "tutorial_world.objects.Weapon", "typeclass": "evennia.contrib.tutorial_world.objects.Weapon",
"key": "Weapon", "key": "Weapon",
"hit": 0.2, "hit": 0.2,
"parry": 0.2, "parry": 0.2,
@ -892,7 +892,7 @@ WEAPON_PROTOTYPES = {
"key": "Kitchen knife", "key": "Kitchen knife",
"desc":"A rusty kitchen knife. Better than nothing.", "desc":"A rusty kitchen knife. Better than nothing.",
"damage": 3}, "damage": 3},
"rusty dagger": { "dagger": {
"prototype": "knife", "prototype": "knife",
"key": "Rusty dagger", "key": "Rusty dagger",
"aliases": ["knife", "dagger"], "aliases": ["knife", "dagger"],
@ -1029,9 +1029,9 @@ class WeaponRack(TutorialObject):
self.db.rack_id = "weaponrack_1" self.db.rack_id = "weaponrack_1"
# these are prototype names from the prototype # these are prototype names from the prototype
# dictionary above. # dictionary above.
self.db.get_weapon_msg = "You pull %s from the rack." self.db.get_weapon_msg = "You find {c%s{n."
self.db.no_more_weapons_msg = "%s has no more to offer you." % self.key self.db.no_more_weapons_msg = "you find nothing else of use."
self.db.available_weapons = ["knife", "rusty_dagger", self.db.available_weapons = ["knife", "dagger",
"sword", "club"] "sword", "club"]
def produce_weapon(self, caller): def produce_weapon(self, caller):
@ -1044,12 +1044,12 @@ class WeaponRack(TutorialObject):
""" """
rack_id = self.db.rack_id rack_id = self.db.rack_id
if caller.tags.get(rack_id): if caller.tags.get(rack_id):
caller.msg("%s has no more to offer you." % self.key) caller.msg(self.db.no_more_weapons_msg)
else: else:
prototype = random.choice(self.db.available_weapons) prototype = random.choice(self.db.available_weapons)
# use the spawner to create a new Weapon from the # use the spawner to create a new Weapon from the
# spawner dictionary, tag the caller # spawner dictionary, tag the caller
wpn = spawn(WEAPON_PROTOTYPES[prototype], prototype_parents=WEAPON_PROTOTYPES) wpn = spawn(WEAPON_PROTOTYPES[prototype], prototype_parents=WEAPON_PROTOTYPES)[0]
caller.tags.add(rack_id) caller.tags.add(rack_id)
wpn.location = caller wpn.location = caller
caller.msg(self.db.weapon_msg % wpn.key) caller.msg(self.db.get_weapon_msg % wpn.key)

View file

@ -147,7 +147,6 @@ class CmdTutorialLook(default_cmds.CmdLook):
""" """
caller = self.caller caller = self.caller
args = self.args args = self.args
print "tutorial look"
if args: if args:
# we use quiet=True to turn off automatic error reporting. # we use quiet=True to turn off automatic error reporting.
# This tells search that we want to handle error messages # This tells search that we want to handle error messages
@ -159,7 +158,6 @@ class CmdTutorialLook(default_cmds.CmdLook):
# no target found or more than one target found (multimatch) # no target found or more than one target found (multimatch)
# look for a detail that may match # look for a detail that may match
detail = self.obj.return_detail(args) detail = self.obj.return_detail(args)
print "look detail:", detail, self.obj, self.obj.db.details
if detail: if detail:
self.caller.msg(detail) self.caller.msg(detail)
return return
@ -232,7 +230,7 @@ class TutorialRoom(DefaultRoom):
""" """
if new_arrival.has_player and not new_arrival.is_superuser: if new_arrival.has_player and not new_arrival.is_superuser:
# this is a character # this is a character
for obj in self.content_get(exclude=new_arrival): for obj in self.contents_get(exclude=new_arrival):
if hasattr(obj, "at_new_arrival"): if hasattr(obj, "at_new_arrival"):
obj.at_new_arrival(new_arrival) obj.at_new_arrival(new_arrival)
@ -242,12 +240,13 @@ class TutorialRoom(DefaultRoom):
returns the value of it. returns the value of it.
Args: Args:
detailkey (str): The detail being looked at detailkey (str): The detail being looked at. This is
case-insensitive.
""" """
details = self.db.details details = self.db.details
if details: if details:
return details.get(detailkey, None) return details.get(detailkey.lower(), None)
def set_detail(self, detailkey, description): def set_detail(self, detailkey, description):
""" """
@ -256,15 +255,15 @@ class TutorialRoom(DefaultRoom):
Args: Args:
detailkey (str): The detail identifier to add (for detailkey (str): The detail identifier to add (for
aliases you need to add multiple keys to the aliases you need to add multiple keys to the
same description). same description). Case-insensitive.
description (str): The text to return when looking description (str): The text to return when looking
at the given detailkey. at the given detailkey.
""" """
if self.db.details: if self.db.details:
self.db.details[detailkey] = description self.db.details[detailkey.lower()] = description
else: else:
self.db.details = {detailkey: description} self.db.details = {detailkey.lower(): description}
def reset(self): def reset(self):
"Can be called by the tutorial runner." "Can be called by the tutorial runner."
@ -759,7 +758,7 @@ class CmdLookBridge(Command):
BRIDGE_POS_MESSAGES[bridge_position], BRIDGE_POS_MESSAGES[bridge_position],
random.choice(BRIDGE_MOODS)) random.choice(BRIDGE_MOODS))
chars = [obj for obj in self.obj.get_contents(exclude=caller) if obj.has_player] chars = [obj for obj in self.obj.contents_get(exclude=caller) if obj.has_player]
if chars: if chars:
# we create the You see: message manually here # we create the You see: message manually here
message += "\n You see: %s" % ", ".join("{c%s{n" % char.key for char in chars) message += "\n You see: %s" % ", ".join("{c%s{n" % char.key for char in chars)

View file

@ -519,12 +519,12 @@ def superuser(*args, **kwargs):
def has_player(accessing_obj, accessed_obj, *args, **kwargs): def has_player(accessing_obj, accessed_obj, *args, **kwargs):
""" """
Only returns true if accessing_obj has_player is true, that is, Only returns true if accessing_obj has_player is true, that is,
this is a player-controlled object. T this is a player-controlled object. It fails on actual players!
This is a useful lock for traverse-locking Exits to restrain NPC This is a useful lock for traverse-locking Exits to restrain NPC
mobiles from moving outside their areas. mobiles from moving outside their areas.
""" """
return hasattr(accessing_obj, "has_player") and accessing_obj.has_player() return hasattr(accessing_obj, "has_player") and accessing_obj.has_player
def serversetting(accessing_obj, accessed_obj, *args, **kwargs): def serversetting(accessing_obj, accessed_obj, *args, **kwargs):
""" """

View file

@ -93,6 +93,7 @@ class Ticker(object):
""" """
Set up the ticker Set up the ticker
""" """
print "Ticker __init__", interval
self.interval = interval self.interval = interval
self.subscriptions = {} self.subscriptions = {}
# set up a twisted asynchronous repeat call # set up a twisted asynchronous repeat call
@ -112,7 +113,7 @@ class Ticker(object):
if not subs: if not subs:
self.task.stop() self.task.stop()
elif subs: elif subs:
#print "starting with start_delay=", start_delay print "validating tickerhandler:", subs, start_delay, self.interval
self.task.start(self.interval, now=False, start_delay=start_delay) self.task.start(self.interval, now=False, start_delay=start_delay)
def add(self, store_key, obj, *args, **kwargs): def add(self, store_key, obj, *args, **kwargs):

View file

@ -69,7 +69,7 @@ many traits with a normal goblin.
""" """
import os, sys, copy import copy
#TODO #TODO
#sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) #sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
#os.environ['DJANGO_SETTINGS_MODULE'] = 'game.settings' #os.environ['DJANGO_SETTINGS_MODULE'] = 'game.settings'
@ -149,6 +149,7 @@ def _batch_create_object(*objparams):
"nattributes": objparam[5]} "nattributes": objparam[5]}
# this triggers all hooks # this triggers all hooks
obj.save() obj.save()
objs.append(obj)
return objs return objs