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
if (lobj.cmdset.current and
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:
#This is necessary for object sets, or we won't be able to
# 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:
# faster to do tuple on list than to build tuple directly
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:
# cached merge exist; use that
cmdset = _CMDSET_MERGE_CACHE[mergehash]

View file

@ -384,16 +384,16 @@ north
# Some details to look at
#
@detail shutters;storm =
The shutters are closed.
The shutters are closed.
#
@detail evennia =
You think you might have heard of this name before,
but at the moment you can recall where from.
@detail inn;sign =
You think you might have heard of this name before,
but at the moment you can recall where from.
#
@detail snake;letters =
The snake is cartoonish with big googly eyes. It looks somewhat
like one of those big snakes from the distant jungles - the kind
squeezes their victims.
@detail snake;letters;writing =
The snake is cartoonish with big googly eyes. It looks somewhat
like one of those big snakes from the distant jungles - the kind
squeezes their victims.
#------------------------------------------------------------
#
@ -421,6 +421,10 @@ north
(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 =
The landlord is a cheerful fellow, always ready to supply you with
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
# 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 =
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": {
"typeclass": "tutorial_world.objects.Weapon",
"typeclass": "evennia.contrib.tutorial_world.objects.Weapon",
"key": "Weapon",
"hit": 0.2,
"parry": 0.2,
@ -892,7 +892,7 @@ WEAPON_PROTOTYPES = {
"key": "Kitchen knife",
"desc":"A rusty kitchen knife. Better than nothing.",
"damage": 3},
"rusty dagger": {
"dagger": {
"prototype": "knife",
"key": "Rusty dagger",
"aliases": ["knife", "dagger"],
@ -1029,9 +1029,9 @@ class WeaponRack(TutorialObject):
self.db.rack_id = "weaponrack_1"
# these are prototype names from the prototype
# dictionary above.
self.db.get_weapon_msg = "You pull %s from the rack."
self.db.no_more_weapons_msg = "%s has no more to offer you." % self.key
self.db.available_weapons = ["knife", "rusty_dagger",
self.db.get_weapon_msg = "You find {c%s{n."
self.db.no_more_weapons_msg = "you find nothing else of use."
self.db.available_weapons = ["knife", "dagger",
"sword", "club"]
def produce_weapon(self, caller):
@ -1044,12 +1044,12 @@ class WeaponRack(TutorialObject):
"""
rack_id = self.db.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:
prototype = random.choice(self.db.available_weapons)
# use the spawner to create a new Weapon from the
# 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)
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
args = self.args
print "tutorial look"
if args:
# we use quiet=True to turn off automatic error reporting.
# 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)
# look for a detail that may match
detail = self.obj.return_detail(args)
print "look detail:", detail, self.obj, self.obj.db.details
if detail:
self.caller.msg(detail)
return
@ -232,7 +230,7 @@ class TutorialRoom(DefaultRoom):
"""
if new_arrival.has_player and not new_arrival.is_superuser:
# 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"):
obj.at_new_arrival(new_arrival)
@ -242,12 +240,13 @@ class TutorialRoom(DefaultRoom):
returns the value of it.
Args:
detailkey (str): The detail being looked at
detailkey (str): The detail being looked at. This is
case-insensitive.
"""
details = self.db.details
if details:
return details.get(detailkey, None)
return details.get(detailkey.lower(), None)
def set_detail(self, detailkey, description):
"""
@ -256,15 +255,15 @@ class TutorialRoom(DefaultRoom):
Args:
detailkey (str): The detail identifier to add (for
aliases you need to add multiple keys to the
same description).
same description). Case-insensitive.
description (str): The text to return when looking
at the given detailkey.
"""
if self.db.details:
self.db.details[detailkey] = description
self.db.details[detailkey.lower()] = description
else:
self.db.details = {detailkey: description}
self.db.details = {detailkey.lower(): description}
def reset(self):
"Can be called by the tutorial runner."
@ -759,7 +758,7 @@ class CmdLookBridge(Command):
BRIDGE_POS_MESSAGES[bridge_position],
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:
# we create the You see: message manually here
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):
"""
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
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):
"""

View file

@ -93,6 +93,7 @@ class Ticker(object):
"""
Set up the ticker
"""
print "Ticker __init__", interval
self.interval = interval
self.subscriptions = {}
# set up a twisted asynchronous repeat call
@ -112,7 +113,7 @@ class Ticker(object):
if not subs:
self.task.stop()
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)
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
#sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
#os.environ['DJANGO_SETTINGS_MODULE'] = 'game.settings'
@ -149,6 +149,7 @@ def _batch_create_object(*objparams):
"nattributes": objparam[5]}
# this triggers all hooks
obj.save()
objs.append(obj)
return objs