#!/usr/bin/env python from random import choice from evennia.commands.default.muxcommand import MuxCommand from evennia import CmdSet from evennia.utils import logger from commands.command import Command from typeclasses.objects import Object class CmdEmpty(Command): """ Empty the cauldron. Usage: empty [ cauldron ] """ key = "empty" def func(self): self.obj.do_empty(self.caller) class CmdAdd(Command): """ Add an item_str from your inventory to the cauldron. Usage: add item_str [ to cauldron ] """ key = "add" aliases = "give" def func(self): self.obj.do_add(self.caller) class CmdCreate(Command): """ Create a potion from the contents of the cauldron. Usage: create """ key = "create" aliases = ["make", "mix", "cook"] def func(self): self.obj.do_create(self.caller) class CmdBottle(Command): """ Bottle the contents of the cauldron. Usage: bottle """ key = "bottle" def func(self): self.obj.do_bottle(self.caller) class CmdSetCauldron(CmdSet): def at_cmdset_creation(self): self.add(CmdEmpty) self.add(CmdAdd) self.add(CmdCreate) self.add(CmdBottle) class Cauldron(Object): """ A cauldron where we can collect and mix ingredients. - empty - add - mix - bottle """ def at_object_creation(self): self.cmdset.add_default(CmdSetCauldron) def do_empty(self, maker): msg = choice([ f"The imp <> down from its perch, <> the brew, then <> it, emptying the cauldron. Lethargically, it << hoists itself ^ climbs back >> to its branch.", "The imp produces a long metal straw and slurps up the brew from the cauldron.", "The imp pushes down a level, flushing the contents of cauldron.", "The imp << stokes the ^ breathes >> fire, quickly boiling the brew until it evaporates. It licks clean the remaining sludge, emptyig the cauldron." ]) maker.announce_action(msg) self.db.contents = [] def do_add(self, maker): item_str = self.args.strip() if item_str == "": maker.msg("What do you want to add to the cauldron?") return item = maker.search(item_str, location=maker) if item: maker.announce_action(f"$You() $conj(add) {item.name} to {self.name}.") self.attributes.add("contents", self.db.contents + [item_str]) item.delete() def do_create(self, create): """ Does this make a viable concoction? """ good = choice([ f"The imp <> down from its perch, <> the brew. Before returning to its roost, it << gives you a tiny thumbs up ^ nods ^ smiles >>.", ]) bad = choice([ f"The imp <> down from its perch, <> the brew. Before returning to its roost, it << shakes its head ^ grimaces ^ retches a bit >>.", ]) maker.announce_action(good) def do_bottle(self, maker): """ If the contents are viable, let's make a vial. """ title = "potion" bottle = spawn({ "typeclass": "typeclasses.alchemy.Vial", "key": title, "aliases": ["bottle", "vial"], "desc": details.get("desc") })[0] bottle.db.amount = 1 bottle.location = maker maker.announce_action(f"After stirring and crafting $pron(your) stew, $you() $conj(fill) a vial with $pron(your) concoction.") class Vial(Object): """ A vial with a single quaff, but cast a spell. """ def at_object_creation(self): """ Set up the database. """ self.db.amount = 0 self.db.empty_name = "empty vial" def do_drink(self, drinker): """ Called when owner calls the 'drink' command. """