Create a Janitor to clean rooms if too much debris appears
This commit is contained in:
parent
d2fda42a32
commit
503dd0301a
7 changed files with 1813 additions and 133 deletions
|
|
@ -288,10 +288,7 @@ class CmdGM(MuxCommand):
|
||||||
msg = routput(self.args)
|
msg = routput(self.args)
|
||||||
for o in send_to:
|
for o in send_to:
|
||||||
if o.is_typeclass('typeclasses.rooms.Room'):
|
if o.is_typeclass('typeclasses.rooms.Room'):
|
||||||
# Send the message to all characters and any recording
|
o.msg_contents(msg)
|
||||||
# scribes in attendance:
|
|
||||||
chars = o.contents_get(None, 'character') + [o.has(Scribe)]
|
|
||||||
send_emote(me, chars, msg, 'say', None)
|
|
||||||
elif o.is_typeclass('typeclasses.characters.Character'):
|
elif o.is_typeclass('typeclasses.characters.Character'):
|
||||||
o.msg(msg)
|
o.msg(msg)
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
95
typeclasses/janitor.py
Executable file
95
typeclasses/janitor.py
Executable file
|
|
@ -0,0 +1,95 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
"""
|
||||||
|
Janitor
|
||||||
|
|
||||||
|
Create a service that goes through the world at an interval
|
||||||
|
moving things that don't belong into a hamper.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from evennia.utils import search
|
||||||
|
from evennia.utils import logger
|
||||||
|
|
||||||
|
from typeclasses.scripts import Script
|
||||||
|
from typeclasses.exits import Exit
|
||||||
|
from typeclasses.consumables import Producer
|
||||||
|
|
||||||
|
ROOMS_TO_CLEAN = [
|
||||||
|
"Grove of the Matriarchs",
|
||||||
|
"Boulder Top",
|
||||||
|
"Cozy House",
|
||||||
|
"Grotto",
|
||||||
|
"Frog Meadow",
|
||||||
|
"Lazy Dock",
|
||||||
|
"Lair",
|
||||||
|
"Mellow Marsh",
|
||||||
|
"Homey Hut",
|
||||||
|
"Wyldwood Bar",
|
||||||
|
"Cramped Kitchen",
|
||||||
|
"Secret Room",
|
||||||
|
"Bedroom",
|
||||||
|
"Prairie",
|
||||||
|
"Shore",
|
||||||
|
"Salty Shack", # mp16
|
||||||
|
"Glittering Glade", # mp19
|
||||||
|
"Dark Tunnel", # mp20
|
||||||
|
"Workshop", # mp21
|
||||||
|
"Damp Cave",
|
||||||
|
"Leaf Boat",
|
||||||
|
"Lonely Island",
|
||||||
|
"Antechamber",
|
||||||
|
"Escape Hallway",
|
||||||
|
]
|
||||||
|
|
||||||
|
ROOM_EXCEPTIONS = {
|
||||||
|
"Grove of the Matriarchs": [ "stick" ],
|
||||||
|
"Cozy House": [ "crystal ball" ],
|
||||||
|
"Lazy Dock": [ "fishing pole" ],
|
||||||
|
"Homey Hut": [ "horn" ],
|
||||||
|
"Bedroom": [ "pair slippers" ],
|
||||||
|
}
|
||||||
|
|
||||||
|
class Janitor(Script):
|
||||||
|
"""
|
||||||
|
Should this be an Object or inherit from Script?
|
||||||
|
"""
|
||||||
|
def at_script_creation(self):
|
||||||
|
self.key = "Janitor"
|
||||||
|
self.desc = "Move trash to a receptacle"
|
||||||
|
self.interval = 60 * 60 * 24
|
||||||
|
self.start_delay = False
|
||||||
|
self.persistent = True
|
||||||
|
|
||||||
|
def at_start(self, **kwargs):
|
||||||
|
self.at_repeat()
|
||||||
|
|
||||||
|
def at_repeat(self, **kwargs):
|
||||||
|
for name in ROOMS_TO_CLEAN:
|
||||||
|
for room in search.objects(name):
|
||||||
|
self.clean_room(room)
|
||||||
|
|
||||||
|
def clean_room(self, room):
|
||||||
|
"""
|
||||||
|
Sweep through the room's contents.
|
||||||
|
Anything that shouldn't be there is moved to 'mp00'.
|
||||||
|
|
||||||
|
Exceptions include objects that are locked to the room,
|
||||||
|
_exits_ and _producers_ (because producers are not locked),
|
||||||
|
and actual exceptions in ROOM_EXCEPTIONS.
|
||||||
|
"""
|
||||||
|
exceptions = ROOM_EXCEPTIONS.get(room.key, [])
|
||||||
|
trash = [i for i in room.contents
|
||||||
|
if not i.is_typeclass(Exit)
|
||||||
|
and not i.is_typeclass(Producer)
|
||||||
|
and i.locks.get("get") != "get:false()"
|
||||||
|
and i.name not in exceptions ]
|
||||||
|
|
||||||
|
for t in trash:
|
||||||
|
to_room = search.objects("mp00")[0]
|
||||||
|
for room,objs in ROOM_EXCEPTIONS.items():
|
||||||
|
if t.key in objs:
|
||||||
|
to_room = search.objects(room)[0]
|
||||||
|
|
||||||
|
# Quietly move it to where the object belongs:
|
||||||
|
logger.info(f"JANITOR: Move '{t.name}' to {to_room.name}")
|
||||||
|
t.location.msg_contents(f"A rat with beady eyes and a leather satchel appears, picks up the {t.name} and takes off with it.")
|
||||||
|
t.move_to(to_room, quiet=True)
|
||||||
|
|
@ -570,7 +570,12 @@ class WeeBeastie(Friendly, Familiar, Listener, AI):
|
||||||
|
|
||||||
|
|
||||||
class BHB(Friendly, Listener, AI):
|
class BHB(Friendly, Listener, AI):
|
||||||
|
"""
|
||||||
|
The Big Hairy Beast is a special pet that has a circadian
|
||||||
|
rhythm, and goes to bed each night and wakes each morning.
|
||||||
|
"""
|
||||||
def return_appearance(self, looker):
|
def return_appearance(self, looker):
|
||||||
|
"""The beast looks different when it is sleeping."""
|
||||||
if self.db.is_awake:
|
if self.db.is_awake:
|
||||||
return super().return_appearance(looker)
|
return super().return_appearance(looker)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,7 @@ class Wood(Litterable):
|
||||||
]))
|
]))
|
||||||
|
|
||||||
|
|
||||||
class Stick(Consumable):
|
class Stick(Object):
|
||||||
"An object to throw."
|
"An object to throw."
|
||||||
def at_object_creation(self):
|
def at_object_creation(self):
|
||||||
self.cmdset.add_default(CmdSetStick)
|
self.cmdset.add_default(CmdSetStick)
|
||||||
|
|
|
||||||
|
|
@ -1204,11 +1204,95 @@ expectit "Frog Meadow"
|
||||||
send "west\n"
|
send "west\n"
|
||||||
expectit "Grove of the Matriarchs"
|
expectit "Grove of the Matriarchs"
|
||||||
|
|
||||||
send "west\n"
|
send "south\n"
|
||||||
expectit "Grotto"
|
expectit "Lazy Dock"
|
||||||
|
|
||||||
|
set timeout 240
|
||||||
|
send "blow horn\n"
|
||||||
|
# expectit "You blow your horn"
|
||||||
|
expectit "The giant leaf slows as it arrives next to the dock."
|
||||||
|
|
||||||
|
send "boat\n"
|
||||||
|
expectit "The giant leaf gently bobs in the surf of this island, allowing you to disembark."
|
||||||
|
|
||||||
|
send "disembark\n"
|
||||||
|
expectit "Lonely Island"
|
||||||
|
|
||||||
|
send "get moonberry\n"
|
||||||
|
expectit "You collect a handful of moonberries"
|
||||||
|
|
||||||
|
dont_expect "You notice" "seagrass"
|
||||||
|
|
||||||
|
send "get seagrass\n"
|
||||||
|
expectit "You harvest a bunch of seagrass"
|
||||||
|
|
||||||
|
send "look statue\n"
|
||||||
|
expectit "A massive statue"
|
||||||
|
|
||||||
|
send "look trident\n"
|
||||||
|
expectit "Held loosely with one hand"
|
||||||
|
|
||||||
|
send "look ball\n"
|
||||||
|
expectit "sphere resting"
|
||||||
|
|
||||||
|
send "look shield\n"
|
||||||
|
expectit "An ornate shield"
|
||||||
|
|
||||||
|
send "look plaque\n"
|
||||||
|
expectit "Glory to the seamother"
|
||||||
|
|
||||||
|
send "say The answer is Thalome, right?\n"
|
||||||
|
expectit "revealing an open archway"
|
||||||
|
|
||||||
|
send "look opening\n"
|
||||||
|
expectit "shaped as a cresent moon"
|
||||||
|
|
||||||
|
send "arch\n"
|
||||||
|
expect {
|
||||||
|
"The room is completely dark" {
|
||||||
|
send "light torch\n"
|
||||||
|
expectit "The room is lit up"
|
||||||
|
|
||||||
|
send "look\n"
|
||||||
|
expectit "Antechamber"
|
||||||
|
}
|
||||||
|
"Antechamber" {
|
||||||
|
send_user "We still have our torch lit from the last time."
|
||||||
|
}
|
||||||
|
timeout {
|
||||||
|
puts "ERROR: Expected response for 'get stick' not received."
|
||||||
|
send "quit\n"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
send "look cavity\n"
|
||||||
|
expectit "this opening"
|
||||||
|
|
||||||
|
send "look blocks\n"
|
||||||
|
expectit "the stones are tightly placed"
|
||||||
|
|
||||||
|
send "look dome\n"
|
||||||
|
expectit "Perhaps 30 feet high"
|
||||||
|
|
||||||
|
send "look obelisk\n"
|
||||||
|
expectit "grazes the top of the dome"
|
||||||
|
|
||||||
|
send "get obelisk\n"
|
||||||
|
expectit "That is way too big"
|
||||||
|
|
||||||
|
send "say Is the magic word, Water?\n"
|
||||||
|
expectit "Upon uttering that phrase"
|
||||||
|
|
||||||
|
# Make sure we got a blue medal ... Or whatever reward we should get
|
||||||
|
send "inv\n"
|
||||||
|
expectit "blue medal"
|
||||||
|
|
||||||
|
send "look door\n"
|
||||||
|
expectit "A door you didn't notice before"
|
||||||
|
|
||||||
send "door\n"
|
send "door\n"
|
||||||
expectit "Cozy House"
|
expectit "Escape Hallway"
|
||||||
|
|
||||||
send "leave\n"
|
send "leave\n"
|
||||||
expectit "Grotto"
|
expectit "Grotto"
|
||||||
|
|
@ -1346,17 +1430,6 @@ expectit "Frog Meadow"
|
||||||
send "west\n"
|
send "west\n"
|
||||||
expectit "Grove"
|
expectit "Grove"
|
||||||
|
|
||||||
send "south\n"
|
|
||||||
expectit "Lazy Dock"
|
|
||||||
|
|
||||||
set timeout 240
|
|
||||||
send "blow horn\n"
|
|
||||||
# expectit "You blow your horn"
|
|
||||||
expectit "The giant leaf slows as it arrives next to the dock."
|
|
||||||
|
|
||||||
send "boat\n"
|
|
||||||
expectit "The giant leaf gently bobs in the surf of this island, allowing you to disembark."
|
|
||||||
|
|
||||||
send "disembark\n"
|
send "disembark\n"
|
||||||
expectit "Lonely Island"
|
expectit "Lonely Island"
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue