95 lines
2.6 KiB
Python
95 lines
2.6 KiB
Python
"""
|
|
Room
|
|
|
|
Rooms are simple containers that has no location of their own.
|
|
|
|
"""
|
|
|
|
from evennia.objects.objects import DefaultRoom
|
|
from evennia.contrib.grid.extended_room import ExtendedRoom
|
|
from evennia.prototypes.spawner import spawn
|
|
|
|
# from .objects import LightSource
|
|
from .drinkables import TEACUP_DESCS
|
|
from .pets import Hunger
|
|
from commands.drinkables import CmdSetTrolley
|
|
from utils.word_list import routput, Token
|
|
|
|
import random
|
|
|
|
# the system error-handling module is defined in the settings. We load the
|
|
# given setting here using utils.object_from_module. This way we can use
|
|
# it regardless of if we change settings later.
|
|
from django.conf import settings
|
|
|
|
from evennia import (
|
|
TICKER_HANDLER,
|
|
CmdSet,
|
|
Command,
|
|
DefaultExit,
|
|
DefaultRoom,
|
|
create_object,
|
|
default_cmds,
|
|
search_object,
|
|
syscmdkeys,
|
|
utils,
|
|
)
|
|
|
|
|
|
_SEARCH_AT_RESULT = utils.object_from_module(settings.SEARCH_AT_RESULT)
|
|
from .objects import ObjectParent
|
|
|
|
|
|
class Room(ObjectParent, ExtendedRoom):
|
|
"""
|
|
Rooms are like any Object, except their location is None
|
|
(which is default). They also use basetype_setup() to
|
|
add locks so they cannot be puppeted or picked up.
|
|
(to change that, use at_object_creation instead)
|
|
|
|
See mygame/typeclasses/objects.py for a list of
|
|
properties and methods available on all Objects.
|
|
"""
|
|
is_dark = False
|
|
has_weather = False
|
|
|
|
|
|
class DabblersRoom(Room):
|
|
teacup_prototype = {
|
|
"typeclass": "typeclasses.drinkables.TeaCup",
|
|
"key": "teacup",
|
|
"desc": "A nice teacup.",
|
|
}
|
|
|
|
def at_object_creation(self):
|
|
"""
|
|
called at creation
|
|
"""
|
|
self.cmdset.add_default(CmdSetTrolley, persistent=True)
|
|
|
|
def produce_teacup(self, caller):
|
|
if caller.has("teacup"):
|
|
caller.msg("You already have a teacup.")
|
|
else:
|
|
cuptype = self.teacup_prototype
|
|
cuptype['desc'] = routput(random.choice(TEACUP_DESCS))
|
|
|
|
cup = spawn(cuptype)[0]
|
|
cup.location = caller
|
|
caller.msg("You pick up a teacup.")
|
|
|
|
def get_display_desc(self, looker):
|
|
fire = self.search("fire")
|
|
full_desc = self.db.initial_desc
|
|
if fire.hunger() == Hunger.RAVENOUS:
|
|
full_desc += " " + self.db.fire_out
|
|
elif fire.hunger() == Hunger.HUNGRY:
|
|
full_desc += " " + self.db.fire_dim
|
|
elif fire.hunger() == Hunger.FULL:
|
|
full_desc += " " + self.db.fire_full
|
|
else:
|
|
full_desc += " " + self.db.fire_on
|
|
full_desc += " " + self.db.final_desc
|
|
|
|
return full_desc
|