Light a fire in the fireplace and our pipe

The pipe can now be a light source.
This commit is contained in:
Howard Abrams 2026-09-03 22:44:12 -07:00
parent ed86572e54
commit a356b8273c
2 changed files with 32 additions and 2 deletions

View file

@ -98,12 +98,26 @@ class CmdLight(Command):
return
burnables = lighter.search(item, location=lighter, quiet=True)
in_room = lighter.search(item, quiet=True)
if burnables and len(burnables) > 0:
to_burn = burnables[0]
if to_burn.has_method("do_light"):
to_burn.do_light(self.caller)
else:
lighter.msg(f"The {burnables[0].key} isn't flammable.")
# What a weird exception is this ...
elif in_room and len(in_room) > 0:
to_light = in_room[0]
if to_light.is_typeclass("typeclasses.pets.Fire"):
if to_light.db.hunger_level == 0:
to_light.feed(lighter, 100)
else:
lighter.msg(f"The fire has been started. Perhaps you should |gfeed|n it some wood?")
else:
lighter.msg(f"The {to_light.key} isn't flammable.")
else:
lighter.msg(f"Can't find {item}.")

View file

@ -248,7 +248,7 @@ class Dice(Object):
"." + prepend)
class Pipe(LightSource):
class Pipe(Object):
"""
Simple abstraction for lighting and smoking actions.
@ -260,11 +260,27 @@ class Pipe(LightSource):
"""
def at_object_creation(self):
self.cmdset.add_default(CmdSetSmoke)
self.db.is_giving_light = False
def _burnout(self):
self.db.is_giving_light = False
# Do we want to announce that the pipe is out?
# self.location.msg("Your pipeweed is out.")
self.location.location.check_light_state()
def do_light(self, lighter):
self.db.is_giving_light = True
msg = choices(self.db.light_msg or f"$You() $conj(pack) and $conj(light) $pron(your) {self.name}.")
lighter.announce_action(msg)
self.db.is_giving_light = True
try:
self.location.location.check_light_state()
except AttributeError:
pass
finally:
self.deferred = delay(60 * 3, self._burnout)
def do_smoke(self, smoker):
msg = choices(self.db.smoke_msg or f"$You() << $conj(lean) back and ^ >> << $conj(puff) ^ $conj(smoke) >> $pron(your) {self.name}.")