moss-n-puddles/typeclasses/rooms.py
2025-04-24 11:34:48 -07:00

63 lines
1.8 KiB
Python

"""
Room
Rooms are simple containers that has no location of their own.
"""
from datetime import datetime
from evennia import utils
from evennia.utils import gametime
from evennia.contrib.grid.extended_room import ExtendedRoom
from evennia.contrib.rpg.rpsystem import ContribRPRoom
from django.conf import settings
# from .objects import LightSource
from .pets import Hunger
from .objects import ObjectParent
_SEARCH_AT_RESULT = utils.object_from_module(settings.SEARCH_AT_RESULT)
class Room(ObjectParent, ExtendedRoom, ContribRPRoom):
"""
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
def get_time(self):
"""
Return tuple of current time of this location.
(Minute, Hour, Time of Day, Season)
"""
timestamp = gametime.gametime(absolute=True)
datestamp = datetime.fromtimestamp(timestamp)
return (datestamp.minute, datestamp.hour,
self.get_time_of_day(), self.get_season())
class DabblersRoom(Room):
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