Fix a bug in the teapot

This commit is contained in:
Howard Abrams 2025-02-02 00:14:02 -08:00
parent 37f3e8d479
commit 6197dd9d92

View file

@ -83,12 +83,12 @@ class Teapot(Object):
def do_make_tea(self, drinker, args): def do_make_tea(self, drinker, args):
words = Token(args) words = Token(args)
tea_choice = [tea for tea in TEA_TYPES.keys() if words.contains(tea)][0] if words.empty() or words.contains("tea"):
self.db.tea_type = random.choice(list(TEA_TYPES.keys()))
if tea_choice: else:
self.db.tea_type = tea_choice tea_choice = [tea for tea in TEA_TYPES.keys() if words.contains(tea)]
elif words.empty(): if len(tea_choice) > 0:
self.db.tea_type = random.choice(TEA_TYPES.keys()) self.db.tea_type = tea_choice[0]
else: else:
self.db.tea_type = "unknown" self.db.tea_type = "unknown"
desc = TEA_TYPES[self.db.tea_type] desc = TEA_TYPES[self.db.tea_type]