From e4afca559b4bb2d8058ca3cd39e678393e0c2cd2 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Thu, 23 Apr 2026 20:53:15 -0700 Subject: [PATCH] More bug fixes --- commands/say.py | 4 ++ typeclasses/alchemy.py | 3 ++ typeclasses/consumables.py | 6 +++ typeclasses/pets.py | 6 +-- typeclasses/sailing.py | 7 +-- world/test-run.exp | 91 +++++++++++++++++++++++++++++++------- world/version1.ev | 39 +++++++++++++++- 7 files changed, 131 insertions(+), 25 deletions(-) diff --git a/commands/say.py b/commands/say.py index 8088136..deca863 100755 --- a/commands/say.py +++ b/commands/say.py @@ -305,6 +305,10 @@ class CmdSay(Command): """ # Speak to everyone in the room: if not target: + # Not sure how this is possible: + if not speaker or not speaker.location or not speaker.location.contents: + return + for char in speaker.location.contents: if hasattr(char, 'other_say') and callable(char.other_say): logger.info(f"to_puppets: all: {char}") diff --git a/typeclasses/alchemy.py b/typeclasses/alchemy.py index d68669e..539307a 100755 --- a/typeclasses/alchemy.py +++ b/typeclasses/alchemy.py @@ -405,6 +405,9 @@ class LaughterSpell(Spell): self.send_random_message() def send_random_message(self): + if not self.obj: + return + self.obj.announce_action( choice([ "$You() $conj(erupt) into laughter, a deep, rolling sound that fills the room and makes everyone turn to see what’s so funny.", diff --git a/typeclasses/consumables.py b/typeclasses/consumables.py index 50f9e00..3315d7d 100755 --- a/typeclasses/consumables.py +++ b/typeclasses/consumables.py @@ -10,6 +10,7 @@ from evennia.prototypes.spawner import spawn from commands.consumables import CmdSetTrolley, CmdSetMakeConsumable from typeclasses.exits import Opener from typeclasses.objects import Object +from utils.scoring import Scores from utils.word_list import routput # , choices @@ -60,6 +61,11 @@ class Consumable(Litterable): msg = "You take a bite." eater.msg(routput(msg)) + if self.key == 'candy': + eater.score(Scores.eat_candy) + eater.announce_action("$You() $conj(eat) some candy.", + exclude=eater) + if self.db.amount <= 0: if self.db.finish_msgs: msg = random.choice(self.db.finish_msgs) diff --git a/typeclasses/pets.py b/typeclasses/pets.py index fc05e39..7522edd 100755 --- a/typeclasses/pets.py +++ b/typeclasses/pets.py @@ -558,12 +558,10 @@ class WeeBeastie(Friendly, Familiar, Listener, AI): msg = f"{noun} {how_sniff} sniffs $your() << hand holding a ^>> {edible}. It {how_eat} eats it, and {and_then}." self.adjust_character(feeder, 100) edible.delete() + feeder.announce_action(msg) else: msg = f"{noun} doesn't appear interested in anything you have." - - if msg: - feeder.announce_action(msg) - + feeder.msg(msg) class BHB(Friendly): diff --git a/typeclasses/sailing.py b/typeclasses/sailing.py index 1e92865..42af903 100755 --- a/typeclasses/sailing.py +++ b/typeclasses/sailing.py @@ -347,10 +347,11 @@ class Boat(Script): "colossal trees on the horizon.", 1) self.send_to(boat, "In the shadows of the trees sits a dock.", 2) - - if num_dockers == 0: + # Since we can assume that raven is always perched on tree + # near the dock, we will always have one too many figures: + if num_dockers < 2: msg = "You can make out an inviting chair perched on the dock." - elif num_dockers == 1: + elif num_dockers == 2: msg = "You can see a figure on the dock." else: msg = f"You can see {int2str(num_dockers)} figures standing on the dock." diff --git a/world/test-run.exp b/world/test-run.exp index 4bbe5d6..a3bdb88 100755 --- a/world/test-run.exp +++ b/world/test-run.exp @@ -5,18 +5,29 @@ set timeout 30 # Open the log file log_file results.txt +# Rename the original 'send' to 'real_send' +rename send real_send + +# Define a new 'send' procedure +proc send {args} { + puts -nonewline ">> " + flush stdout + # 'uplevel' ensures it executes in the right context + uplevel 1 real_send $args +} + proc expectit {pattern} { expect { $pattern { return } timeout { - puts "Error: Expected response '$pattern' not received." + puts "ERROR: Expected response '$pattern' not received." send "quit\n" exit 1 } eof { - puts "Error: Connection closed unexpectedly." + puts "ERROR: Connection closed unexpectedly." send "quit\n" exit 1 } @@ -128,7 +139,7 @@ expect { set phase "night" } timeout { - puts "Error: Expected time response not received." + puts "ERROR: Expected time response not received." send "quit\n" exit 1 } @@ -151,7 +162,7 @@ switch $phase { expect "night sky" } default { - puts "Error: Unexpected phase value '$phase'." + puts "ERROR: Unexpected phase value '$phase'." send "quit\n" exit 1 } @@ -191,7 +202,7 @@ expect { expect "You drop a stick." } timeout { - puts "Error: Expected response for 'get stick' not received." + puts "ERROR: Expected response for 'get stick' not received." send "quit\n" exit 1 } @@ -406,14 +417,13 @@ expect { } timeout { if {$phase == "night"} { - puts "The beast is in bed now." + puts "NOTE: The beast is in bed now." } else { - puts "Where is the beast? It is $phase?" + puts "NOTE: Where is the beast? It is $phase?" } } } -puts "Where the hell are we?" send "east\n" expectit "Glittering Glade" @@ -438,6 +448,43 @@ sleep 1 send "blue door\n" expectit "Wyldwood Bar" +send "read sign\n" +expectit "Cocktails" + +send "get sign\n" +expectit "impossible to remove" + +send "say to bartender Good day, sir. May I have a Sylvan Serenade, please?\n" +expectit "Sylvan Serenade" + +send "drink\n" +expectit "You" + +send "drink\n" +expectit "You" + +send "drink\n" +expectit "You" + +send "drink\n" +expectit "You" + +send "drink\n" +expectit "You have nothing to drink" + +send "say Thank you, sir\n" +expectit "Thank you" + +send "get candy\n" +expectit "You grab a candy" + +send "eat candy\n" +expectit "\n" + +# Let's keep a candy to feed the wee beastie +send "get candy\n" +expectit "You grab a candy" + # Until we write tests for the bar... send "leave\n" expectit "Glittering Glade" @@ -489,7 +536,7 @@ send "hut\n" expectit "The door, and its landing, are still too high and out of reach" # Let's wait to make sure that the hut eventually breaks free ... -puts "Waiting for the hut to break free of its bonds..." +puts "NOTE: Waiting for the hut to break free of its bonds..." set timeout 90 expectit "The hut, straining against its bounds, finally breaks free" set timeout 30 @@ -830,6 +877,9 @@ expectit "You are in a cozy and casual place" send "pet beastie\n" expectit "beastie" +send "feed beastie\n" +expectit "candy" + send "feed beastie\n" expectit "beastie doesn't appear interested in anything you have." @@ -846,6 +896,10 @@ send "eat scone\n" # Too much variableness here. # expectit "You" +# Get another scone for the road ... and to feed the beast. +send "get scone\n" +expect -re "You get.*scone" + send "make green\n" expectit "You make a teapot" @@ -964,7 +1018,7 @@ expect -re "Imp" # We left our tester in the Secret room, so ... send "leave\n" -expectit "Cozy House" +expect "Cozy House" send "look up stairs\n" expectit "Ornate black irons banister outline the thick wood planks that form steps leading to some lofty alcove." @@ -1018,7 +1072,7 @@ expectit "A curious figure wearing dark robes and a gleaming white skull of a ma send "look ears\n" expectit "They look real, and twitch as if alive." -puts "Waiting to get a pipe as a gift." +puts "NOTE: Waiting to get a pipe as a gift." set timeout 240 expectit "gives you a pipe" set timeout 20 @@ -1058,6 +1112,9 @@ expectit "Grove of the Matriarchs" send "east\n" expectit "Frog Meadow" +send "feed beast\n" +expectit "scone" + send "look tickleweed\n" expectit "Patches of this vivid grass vibrates as if giggling." @@ -1124,7 +1181,7 @@ send "leave\n" expectit "Grotto" send "fill bottle\n" -expectit "fresh spring water" +expectit "still water" send "east\n" expectit "Grove" @@ -1138,8 +1195,8 @@ expectit "Lair" send "look mushrooms\n" expectit "Slender blue tendrils" -send "get mushrooms\n" -expectit "sack of mushrooms" +send "get mushroom\n" +expectit "dreamshade mushroom" send "leave\n" expectit "Frog Meadow" @@ -1148,7 +1205,7 @@ send "south\n" expectit "Mellow Marsh" send "get glitter\n" -expectit "sack of pixie dust" +expectit "wad of pixie dust" send "north\n" expectit "Frog Meadow" @@ -1159,6 +1216,7 @@ expectit "Grove" send "south\n" expectit "Lazy Dock" +set timeout 120 send "blow horn\n" # expectit "You blow your horn" expectit "The giant leaf slows as it arrives next to the dock." @@ -1169,7 +1227,7 @@ expectit "The giant leaf gently bobs in the surf of this island, allowing you to send "disembark\n" expectit "Lonely Island" -send "pick moonberry\n" +send "get moonberry\n" expectit "You collect a handful of moonberries" # While we are here, we should solve the puzzle...but... @@ -1178,6 +1236,7 @@ expectit "The giant leaf slows as it arrives and docks allowing you to disembark send "disembark\n" expectit "Lazy Dock" +set timeout 30 send "north\n" expectit "Grove" diff --git a/world/version1.ev b/world/version1.ev index 86b2d1f..810120f 100644 --- a/world/version1.ev +++ b/world/version1.ev @@ -1270,17 +1270,36 @@ py me.search("squirrel").backstory("squirrel") +# And all the RP system stuff: + + +# [[file:../../../projects/mud.org::*Bartender][Bartender:3]] +@set bartender/gender = "male" +# Bartender:3 ends here + + + # As well as the automation: -# [[file:../../../projects/mud.org::*Bartender][Bartender:8]] +# [[file:../../../projects/mud.org::*Bartender][Bartender:9]] py me.search("bartender").backstory("tavern") -# Bartender:8 ends here +# Bartender:9 ends here # [[file:../../../projects/mud.org::*Automated Responses][Automated Responses:2]] @set bartender/arrive = "4 ;; say Welcome to the |wWyldwood Bar|n. Read the sign for a list of our cocktails, and let me know what you'd like to drink." # Automated Responses:2 ends here +# Let’s convert the Bartender to a Chatbot using [[file:~/src/moss-n-puddles/personalities/tavern.md][tavern.md]]. This way, talking to the Bartender *answers* from everyone. + + +# [[file:../../../projects/mud.org::*Puppeting][Puppeting:1]] +@set bartender/personality = "tavern" +# +@set bartender/personality_file = "personalities/tavern.md" +# Puppeting:1 ends here + + # Need a channel to chat about the game: @@ -2090,6 +2109,22 @@ py timed_script = evennia.create_script(key="Create Horns", @py bt = self.search('old lady'); bt.sdesc.add('old lady'); bt.db.pose = 'playing with a deck of cards' # Trampoli the Witch:3 ends here + + +# Let’s set this Chatbot to use [[file:~/src/moss-n-puddles/personalities/witch.md][witch.md]]. + + +# [[file:../../../projects/mud.org::*Trampoli the Witch][Trampoli the Witch:4]] +@set bartender/personality = "witch" +# +@set bartender/personality_file = "personalities/witch.md" +# Trampoli the Witch:4 ends here + + + +# And some poses: + + # [[file:../../../projects/mud.org::*Trampoli the Witch][Trampoli the Witch:5]] @set old lady/pose_sleep = "napping soundly in bed on the upstairs loft" #