375 lines
14 KiB
Python
Executable file
375 lines
14 KiB
Python
Executable file
#!/usr/bin/env python
|
||
|
||
from evennia.prototypes.spawner import spawn
|
||
from evennia.utils import logger
|
||
|
||
from typeclasses.objects import Object
|
||
from commands.consumables import CmdSetTeapot
|
||
from utils.word_list import routput, choices
|
||
|
||
import re
|
||
import random
|
||
|
||
TEA_TYPES = {
|
||
'black': 'a rich, bold and <<malty ^ fragrant ^ almost spicy>> black tea',
|
||
'green': 'a green tea with <<grassy ^ floral ^ vanilla ^ vegetal>> notes',
|
||
'oolong': 'a complex and <<earthy ^ floral>> oolong',
|
||
'matcha': 'a frothy and aromatic matcha of the most vibrant green',
|
||
'white': 'a subtle tea with notes of <<rose ^ berries ^ chamomile flowers>>',
|
||
'pu-erh': 'an earthy, almost mushroom flavored, pu-erh tea',
|
||
'puerh': 'an earthy, almost mushroom flavored, pu-erh tea',
|
||
'barley': 'a nutty herbal infusion of barley with just a hint of smokiness',
|
||
'chaga': 'an earthy, mushroomy chaga infusion',
|
||
'hibiscus': 'a dark red, tart herbal infusion of roselle flowers',
|
||
'chai': 'a spicy chai tea, tempered with milk and sweetness',
|
||
'herbal': 'an herbal infusion of <<chamomile ^ mint ^ chicory root ^ lavender>>',
|
||
'earl': 'a flowery Earl Grey tea',
|
||
'chamomile': 'a relaxing, yet subtle infusion of chamomile flowers that makes you want to go to sleep',
|
||
'mint': 'a blend of peppermint and spearmint to create the ultimate minty herbal infusion',
|
||
'chrysanthemum': 'a lovely, floral infusion of chrysanthemum flowers',
|
||
'dandelion': 'a roasted herbal infusion of dandelions that tastes a bit like coffee',
|
||
'rooibos': 'an almost <<sweet and ^ >> <<woody ^ nutty ^ vanilla-y>> rooibos herbal infusion',
|
||
# Why limit to teas ... sure, this tea pot could make coffee ...
|
||
}
|
||
|
||
FILL_TEA_MSGS = [
|
||
'You fill your <<teacup ^ cup>> with {1}.',
|
||
'You pour <<some ^ >> {0} tea into your <<teacup ^ cup>>.',
|
||
]
|
||
|
||
DRINK_TEA_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_TEA_MSGS = [
|
||
'Your <<teacup ^ cup>> is empty. Perhaps you can |gmake|n some |gtea|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.'
|
||
]
|
||
|
||
|
||
class TeaCup(Object):
|
||
fill_amount = 4
|
||
sip_amount = 1
|
||
|
||
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(choices(DRINK_TEA_MSGS, tea_type, tea_details))
|
||
else:
|
||
drinker.msg(choices(EMPTY_TEA_MSGS, 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(choices(FILL_TEA_MSGS, tea_type, tea_details))
|
||
|
||
def at_pre_drop(self, dropper):
|
||
if dropper.location.key == "Dabbler's House":
|
||
dropper.msg("You place the teacup on the trolley with the others.")
|
||
self.delete()
|
||
else:
|
||
return True
|
||
|
||
class Teapot(Object):
|
||
def at_object_creation(self):
|
||
"""
|
||
called at creation
|
||
"""
|
||
self.cmdset.add_default(CmdSetTeapot, persistent=True)
|
||
|
||
def do_make_tea(self, drinker, words):
|
||
"""
|
||
Make tea.
|
||
|
||
If 'args', try to make a particular type of tea, otherwise,
|
||
pick one at random.
|
||
"""
|
||
tea_choice = []
|
||
if not words.empty():
|
||
tea_choice = [tea for tea in TEA_TYPES.keys() if words.contains(tea)]
|
||
|
||
if len(tea_choice) > 0:
|
||
self.db.tea_type = tea_choice[0]
|
||
else:
|
||
self.db.tea_type = random.choice(list(TEA_TYPES.keys()))
|
||
desc = routput(TEA_TYPES[self.db.tea_type])
|
||
|
||
self.db.desc = f"A large, brown teapot full of {desc}."
|
||
drinker.announce_action(f"$You() $conj(make) a teapot of {desc}.")
|
||
|
||
def do_fill(self, drinker):
|
||
teatype = self.db.tea_type
|
||
if not teatype:
|
||
drinker.msg("You need to |gmake tea|n first.")
|
||
return
|
||
|
||
teacup = drinker.has("teacup")
|
||
if teacup:
|
||
teacup.do_fill(drinker, teatype, TEA_TYPES[teatype])
|
||
else:
|
||
drinker.msg("You need to |gget teacup|n first.")
|
||
|
||
|
||
COCKTAILS = [
|
||
{
|
||
"title": "Moonlit Mirage",
|
||
"type": "cocktail",
|
||
"desc": "A shimmering, colorful drink, garnished with glitter and a twist of tart, almost sour fruit.",
|
||
"flavors": ["lemon", "tartness", "sweetness"],
|
||
"effects": [
|
||
"You notice the swirling glitter make a pattern.",
|
||
"Your cocktail just changed color to << red ^ pink ^ orange ^ yellow ^ blue ^ purple >>."
|
||
]
|
||
},
|
||
{
|
||
"title": "Puck's Revenge",
|
||
"type": "cocktail",
|
||
"desc": "A vibrant concoction of fruit juices and sparkling fairy dust, served in a glass shaped like a flower.",
|
||
"flavors": ["fruity", "... fairy dust?"],
|
||
"effects": [
|
||
"Wow, this drink really packs a punch.",
|
||
"You feel a little light-headed.",
|
||
]
|
||
},
|
||
{
|
||
"title": "Glimmering Gossamer",
|
||
"type": "cocktail",
|
||
"desc": "A delicate blend of elderflower liqueur and sparkling wine, adorned with a butterfly-shaped ice cube.",
|
||
"flavors": ["elderflower"],
|
||
"effects": ["The butterfly shaped ice cube just started fluttering, and flew away."]
|
||
},
|
||
{
|
||
"title": "Whimsical Willow",
|
||
"type": "cocktail",
|
||
"desc": "A herbal infusion of gin, rosemary, and elderberry, served with a sprig of fresh mint and a splash of tonic.",
|
||
"flavors": ["fresh mint", "rosemary", "elderberry"],
|
||
"effects": [
|
||
"Hrm ... did the bartender always have flowers in his hair?",
|
||
"Hrm ... why are vines sprouting from everyone's hair?",
|
||
]
|
||
},
|
||
{
|
||
"title": "Charmed Chalice",
|
||
"type": "cocktail",
|
||
"desc": "A mysterious potion that glows softly, made with enchanted spirits and a hint of honey, served in a chalice that changes shape.",
|
||
"flavors": ["honey"],
|
||
"effects": [
|
||
"Your cocktail glass just changed into a flute for sparkling wine.",
|
||
"Your glass has changed shape into a small vase. Good thing the drink is still in it.",
|
||
"Your glass has changes shape into a glass bowl, still holding the contents of your drink.",
|
||
]
|
||
},
|
||
{
|
||
"title": "Enchanted Elixir",
|
||
"type": "cocktail",
|
||
"desc": "A deep blue drink with hints of blueberry and a touch of magic, served with a glowing ice sphere.",
|
||
"flavors": ["blueberry", "blue"],
|
||
"effects": [
|
||
"The ice sphere in the glass pulses with light and energy.",
|
||
"You see stars everywhere in the room.",
|
||
"The room became brighter...maybe that it just because you can see stars.",
|
||
]
|
||
# - Glowing orbs of light spin about the drinker’s head
|
||
# - Drinker sees stars … SPELL?
|
||
},
|
||
{
|
||
"title": "Sylvan Serenade",
|
||
"type": "cocktail",
|
||
"desc": "A melodic blend of apple cider and spiced rum, garnished with a cinnamon stick and a slice of star fruit.",
|
||
"flavors": ["apple", "cider", "spices", "cinnamon"],
|
||
"effects": [
|
||
"You hear the song of a distant choir.",
|
||
"You hear the distant sounds of flutes and tambourines.",
|
||
],
|
||
},
|
||
{
|
||
"title": "Brambleberry Bliss",
|
||
"type": "cocktail",
|
||
"desc": "A sweet and tart mix of brambleberries and gin, served over crushed ice with a sprinkle of edible flowers.",
|
||
"flavors": ["brambleberries", "berry", "floral"],
|
||
"effects": [
|
||
"The flowers floating in the glass whispers to you, \"I'm always getting into trouble. I guess that's because I'm a wild flower.\"",
|
||
"A flower floating in the drink whispers to you, \"I got a promotion. I guess I was just outstanding in my field.\"",
|
||
"The flowers in the cocktail whispers to you, \"I like to drive fast. I guess I'm always putting the petal to the metal.\"",
|
||
],
|
||
# - The flowers talk .. maybe tell jokes.
|
||
},
|
||
{
|
||
"title": "Twilight Tonic",
|
||
"type": "cocktail",
|
||
"desc": "A dark, mysterious drink made with blackcurrant and tonic water, served with a slice of lime and a hint of mint.",
|
||
"flavors": ["lime", "blackcurrant", "mint"],
|
||
"effects": [
|
||
"A shadow falls on your face making you look seductively mysterious.",
|
||
"The room briefly grows dim.",
|
||
]
|
||
},
|
||
{
|
||
"title": "Bee Knees",
|
||
"type": "mead",
|
||
"desc": "Slightly fizzy, slightly sweet, served with a wedge of honeycomb.",
|
||
"flavors": ["honey", "vanilla"],
|
||
"effects": [
|
||
"You feel like a dwarf in a tunnel digging a hole. Diggy, diggy hole!",
|
||
"Just like being in the Mud World."
|
||
]
|
||
},
|
||
{
|
||
"title": "whisky",
|
||
"type": "whisky",
|
||
"desc": "A dram of smokey, amber ambrosia.",
|
||
"flavors": ["tar", "peat", "smoke", "brine", "vanilla", "toffee"],
|
||
"effects": [
|
||
"This reminds you of your travels in the Mud World.",
|
||
"Lovely.",
|
||
"Friendships and conversations distilled in a glass.",
|
||
"A dram to << certainly ^ >> << savor ^ cherish ^ enjoy>>.",
|
||
"Here's to friends that aren't here to share."
|
||
]
|
||
},
|
||
{
|
||
"title": "whiskey",
|
||
"type": "whiskey",
|
||
"desc": "A dram of strong, amber ambrosia.",
|
||
"flavors": ["vanilla", "toffee"],
|
||
"effects": [
|
||
"This reminds you of your travels in the Mud World.",
|
||
"Lovely.",
|
||
"Friendships and conversations distilled in a glass.",
|
||
"A dram to << certainly ^ >> << savor ^ cherish ^ enjoy>>.",
|
||
"Here's to friends that aren't here to share."
|
||
]
|
||
},
|
||
{
|
||
"title": "ale",
|
||
"type": "beer",
|
||
"desc": "A malty, only slightly carbonated, opaque beverage with overt herbal notes.",
|
||
"flavors": ["rosemary", "bog myrtle", "yarrow"],
|
||
"effects": [
|
||
"Wonder where they got the recipe, twelfth century England?",
|
||
"Tastes like drinking a loaf of bread."
|
||
]
|
||
},
|
||
{
|
||
"title": "red wine",
|
||
"type": "wine",
|
||
"desc": "A rich glass a blood red color with notes of raspberries and toffee.",
|
||
"flavors": ["earthiness", "toffee", "raspberries"],
|
||
"effects": [
|
||
"Ah, what was the name of the land in the Mud World where you first had this vintage?",
|
||
"You swirl your glass and watch the legs return to the bottom.",
|
||
]
|
||
},
|
||
{
|
||
"title": "water",
|
||
"type": "water",
|
||
"desc": "A clean cocktail with absolutely no taste.",
|
||
"flavors": ["water", "blandness"],
|
||
"effects": [
|
||
"Wow, this drink really packs a punch...NOT",
|
||
"Refreshing.",
|
||
"Unintoxicating.",
|
||
"Your liver is thanking you."
|
||
]
|
||
},
|
||
]
|
||
|
||
DRINK_COCKTAIL_MSGS = [
|
||
# 0 -> drink title or name
|
||
# 1 -> type of drink, e.g. cocktail or whiskey
|
||
# 2 -> one of the flavors
|
||
'You take a <<sip ^ sample ^ drink>> of your << |w{0}|n ^ {1} ^ drink >>.',
|
||
'You <<sip ^ sample ^ drink>> your << |w{0}|n ^ {1} ^ drink >>.',
|
||
'You << notice ^ savor ^ relish ^ enjoy >> the {2}.',
|
||
]
|
||
|
||
EMPTY_COCKTAIL_MSGS = [
|
||
'That {1} went down fast.',
|
||
'Hrm ... did you enjoy that {1}?',
|
||
'You drain your glass.',
|
||
"You've finished that concoction.",
|
||
]
|
||
|
||
|
||
class Cocktail(Object):
|
||
fill_amount = 4
|
||
sip_amount = 1
|
||
|
||
def make(owner, name=None):
|
||
"""
|
||
Create for 'owner', a drink that matches 'name'.
|
||
If name doesn't match, get a random one.
|
||
"""
|
||
if name:
|
||
rx = r".*" + name + r".*"
|
||
details = [c for c in COCKTAILS
|
||
if re.match(rx, c.get("title"), re.IGNORECASE)]
|
||
if len(details) > 0:
|
||
details = details[0]
|
||
else:
|
||
details = random.choice(COCKTAILS)
|
||
|
||
drink = spawn({
|
||
"typeclass": "typeclasses.drinkables.Cocktail",
|
||
"key": details.get("title"),
|
||
"aliases": ["drink", "glass", "cocktail"],
|
||
"desc": details.get("desc")
|
||
})[0]
|
||
drink.db.cocktail_type = details.get("type")
|
||
drink.db.flavors = details.get("flavors")
|
||
drink.db.effects = details.get("effects")
|
||
drink.db.amount = Cocktail.fill_amount
|
||
drink.location = owner
|
||
|
||
drink.location.msg(f"You now have a {drink.name}.")
|
||
|
||
theroom = drink.location.location
|
||
char = owner.db._sdesc or owner.get_display_name(theroom)
|
||
logger.info(drink.db.cocktail_type)
|
||
msg = routput("The << bartender ^ barkeep ^ elf >> << passes ^ slides ^ gives ^ hands >> a {0} to {1}.",
|
||
drink.db.cocktail_type, char)
|
||
theroom.msg_contents(msg, exclude=owner)
|
||
|
||
def do_drink(self, drinker):
|
||
"""
|
||
Called when owner calls the 'drink' command.
|
||
"""
|
||
amount = self.db.amount or 0
|
||
cocktail_type = self.db.cocktail_type or "cocktail"
|
||
cocktail_flavors = self.db.flavors
|
||
|
||
if amount > 2:
|
||
flavor = random.choice(cocktail_flavors)
|
||
drinker.msg(choices(DRINK_COCKTAIL_MSGS, self.key, cocktail_type, flavor))
|
||
elif amount > 0:
|
||
drinker.msg(choices(self.db.effects, self.key, cocktail_type))
|
||
else:
|
||
self.key = f"{self.db.cocktail_type} glass"
|
||
self.aliases.add('glass')
|
||
self.db.desc = f"An empty {self.db.cocktail_type} glass"
|
||
drinker.msg(choices(EMPTY_COCKTAIL_MSGS, self.key, cocktail_type))
|
||
|
||
self.db.amount = self.db.amount - self.sip_amount
|
||
|
||
def at_pre_drop(self, dropper):
|
||
if dropper.location.key == 'Wyldwood Bar':
|
||
dropper.msg(routput(f"<< A ^ The >> mushroom << man ^ person >> << bounces ^ shimmies over ^ appears >> and takes the {self.name} << from you ^ >>."))
|
||
self.delete()
|
||
elif dropper.location.key == "Dabbler's House":
|
||
dropper.msg(routput(f"The {self.db.cocktail_type} << falls ^ drops >> to the << floor ^ ground >> and shatters! A dust ball from under the chair forms into a little impish-looking fellow, who cleans it all before disappearing."))
|
||
self.delete()
|
||
else:
|
||
return True
|