#!/usr/bin/env python from typeclasses.objects import Object from commands.drinkables import CmdSetTeapot, CmdSetTeacup from utils.word_list import routput, character_has, Token import random TEACUP_DESCS = [ "A rustic, clay teacup carefully crafted on a wheel. Beautiful [dark red|olive green|navy blue] glaze.", "A fine example of Royal Albert teacup, sporting a design of violet azaleas. Perfect for a black tea.", "A Wings of Grace style teacup with blue butterflies. Perfect for some Earl Grey.", "A dark brown Yixing clay teacup. Perfect for an Oolong tea.", "A light jade green handle-less teacup. A good choice for a green tea.", ] FILL_MSGS = [ "You fill your [teacup|cup] with {1}.", "You pour [some|] {0} tea into your [teacup|cup].", ] DRINK_MSGS = [ "You take a sip of {0} tea.", "You take a sip of {0} tea [in|from] your [teacup|cup].", "You [sip|sample|drink] from your [teacup|cup].", "You savor {1} in your [teacup|cup].", ] EMPTY_MSGS = [ "Your [teacup|cup] is empty. Perhaps you can |bmake|n some |btea|n?", "Your cup certainly doesn't runneth over, as it be quite empty.", "Alas, you find your cup devoid of any sort of watery infusion.", "You notice your cup is empty.", "It appears that you need to refill your tea cup." ] TEA_TYPES = { "black": "a rich and fragrant black tea", "green": "a subtle green tea", "oolong": "a complex and earthy oolong", "macha": "a frothy macha", "herbal": "an herbal infusion", "earl": "a flowery Earl Gray", "unknown": "tea", } class TeaCup(Object): fill_amount = 4 sip_amount = 1 def at_object_creation(self): self.cmdset.add_default(CmdSetTeacup) def do_drink(self, drinker): amount = self.db.amount or 0 tea_type = self.db.tea_type or "tea" tea_details = self.db.tea_details if amount > 0: self.db.amount = self.db.amount - self.sip_amount drinker.msg(routput(random.choice(DRINK_MSGS).format(tea_type, tea_details))) else: drinker.msg(routput(random.choice(EMPTY_MSGS).format(tea_type, tea_details))) def do_fill(self, drinker, tea_type, tea_details): self.db.tea_type = tea_type self.db.tea_details = tea_details self.db.amount = self.fill_amount drinker.msg(routput(random.choice(FILL_MSGS).format(tea_type, tea_details))) # Spam the room? Maybe not. # self.location.msg_contents(f"{drinker.name} refills a {self.key}.", # exclude=drinker) class Teapot(Object): def at_object_creation(self): """ called at creation """ self.cmdset.add_default(CmdSetTeapot, persistent=True) def do_make_tea(self, drinker, args): words = Token(args) tea_choice = [tea for tea in TEA_TYPES.keys() if words.contains(tea)][0] if tea_choice: self.db.tea_type = tea_choice elif words.empty(): self.db.tea_type = random.choice(TEA_TYPES.keys()) else: self.db.tea_type = "unknown" desc = TEA_TYPES[self.db.tea_type] self.db.desc = f"A large, brown teapot full of {desc}." drinker.msg(f"You make a teapot of {desc}.") self.location.msg_contents(f"{drinker.name} makes a pot of tea.", exclude=drinker) def do_fill(self, drinker): teacup = character_has(drinker, "teacup") if teacup: teacup.do_fill(drinker, self.db.tea_type, TEA_TYPES[self.db.tea_type])