From 0ad4936f48c6196053ff541afb82b64e009d1ec1 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Thu, 7 Aug 2025 22:18:52 -0700 Subject: [PATCH] Feed command is now global And not tied to a pet. --- commands/default_cmdsets.py | 3 +- commands/everyone.py | 67 +++++++++++++++ typeclasses/pets.py | 14 ++-- world/test-run.exp | 8 +- world/version1.ev | 161 ++++++++++++++++++++++++++++-------- 5 files changed, 213 insertions(+), 40 deletions(-) diff --git a/commands/default_cmdsets.py b/commands/default_cmdsets.py index 7ddcb4b..022d0a5 100644 --- a/commands/default_cmdsets.py +++ b/commands/default_cmdsets.py @@ -23,7 +23,7 @@ from commands.sittables import CmdNoSitStand from commands.everyone import (CmdTake, CmdThink, CmdSay, CmdWhisper, CmdRead, CmdEat, CmdDrink, CmdUse, CmdPush, CmdPull, - CmdOpen, CmdClose) + CmdOpen, CmdClose, CmdFeed) from commands.hint import CmdHint from commands.misc import CmdLight from commands.wizards import (CmdGM, CmdSpell, CmdGMTrigger, @@ -69,6 +69,7 @@ class CharacterCmdSet(default_cmds.CharacterCmdSet): self.add(CmdGMTrigger) self.add(CmdMakeCocktail) self.add(CmdGift) + self.add(CmdFeed) class AccountCmdSet(default_cmds.AccountCmdSet): diff --git a/commands/everyone.py b/commands/everyone.py index c1e5fbe..e83c16c 100755 --- a/commands/everyone.py +++ b/commands/everyone.py @@ -3,6 +3,7 @@ from random import random from re import split, sub, MULTILINE +from django.core.exceptions import ObjectDoesNotExist from evennia.commands.default.general import CmdGet, NumberedTargetCommand from evennia.commands.default.muxcommand import MuxCommand from evennia.contrib.rpg.rpsystem import send_emote @@ -660,3 +661,69 @@ class CmdEat(Command): self.eat_item(goal) else: self.eat_anything() + + +class CmdFeed(MuxCommand): + """ + Feed or give something to an object that can eat. + Typically this is used to feed wood to a fire, or + berries to a beast. + + Usage: + + |gfeed |n + + Or: + + |gfeed to |n + + Where 'food' is something you have in your inventory, + and target is a pet or something that wants to eat. + + If you don't specify the 'food', the target will eat + what you might have they're interested in. + """ + key = "feed" + rhs_split = ("=", " to ") + + def func(self): + """ + Implements the feed (or give) command. + """ + if not self.args: + self.caller.msg("Feed what?") + return + + feeder = self.caller + if self.rhs: + eater = feeder.search(self.rhs) + food = feeder.search(self.lhs) + else: + eater = feeder.search(self.lhs) + food = None + + if eater: + if eater.has_method('feed'): + eater.feed(feeder, food) + if food: + try: + food.delete() + # Allow the eater to delete the object. + except ObjectDoesNotExist: + pass + else: + name = eater.get_display_name(feeder) + feeder.msg(f"You can't feed, {name}.") + else: + feeder.msg(f"Don't see a '{self.lhs}' to feed.") + + # Pass this off to CmdGive? + # + # feeder.execute_cmd("give " + self.args) + # + # supercmd = CmdGive() + # supercmd.caller = feeder + # supercmd.args = self.args + # supercmd.lhs = self.lhs + # supercmd.rhs = self.rhs + # supercmd.func() diff --git a/typeclasses/pets.py b/typeclasses/pets.py index 919ceb8..1cf7d16 100755 --- a/typeclasses/pets.py +++ b/typeclasses/pets.py @@ -21,8 +21,6 @@ from evennia.utils.gametime import schedule from typeclasses.objects import Object from typeclasses.characters import Character -# from typeclasses.lightables import LightSource -from commands.feedables import CmdFeedSet from commands.pets import CmdPetSet from utils.word_list import squish, choices @@ -66,8 +64,6 @@ class Pet(Object): Called when object is first created. We set up a ticker to update hunger levels regularly. """ - self.cmdset.add_default(CmdFeedSet) - self.db.hunger_level = Hunger.FULL.value # Update the state (whatever that may mean), each minute: @@ -118,7 +114,15 @@ class Pet(Object): return f"{self.db.desc} {self.hunger_appearance()}" def feed(self, giver, obj=None): - pass + """ + General feed method must be overridden. + As it just responds with a _no interest_ message. + """ + if obj: + giver.msg(f"{self.name} doesn't appear interested in {obj}.") + else: + giver.msg(f"{self.name} doesn't appear interested in anything you have.") + # ------------------------------------------------------------ # Fireplace, both a pet that is hungry and consumes food, diff --git a/world/test-run.exp b/world/test-run.exp index af7812a..29fa2fb 100755 --- a/world/test-run.exp +++ b/world/test-run.exp @@ -579,7 +579,7 @@ send "look cabbage\n" expectit "Large glossy green leaves with big yellow flowers that looks like cobras in drag" send "look ferns\n" -expectit "Mostly sword ferns interrupted by Maiden Hair ferns that sing to the stream." +expectit "Mostly sword ferns interrupted by Maiden Hairs that sing to the stream." send "pick berries\n" expectit "You pick" @@ -637,6 +637,12 @@ expectit "The trees shown in the third and fourth scenes" send "look whispering\n" expectit "This curious aspect" +send "get wood\n" +expectit "You get a small log from the wood rack." + +send "feed log to fire\n" +expectit "You give a log to fireplace." + send "look trinkets\n" send "look books\n" diff --git a/world/version1.ev b/world/version1.ev index 6dbd3bb..5104bfe 100644 --- a/world/version1.ev +++ b/world/version1.ev @@ -1061,7 +1061,7 @@ py timed_script = evennia.create_script(key="Create Sticks", # [[file:../../../projects/mud.org::*Mellow Marsh][Mellow Marsh:4]] @teleport mp08 # -@desc here = The river spreads into a muddy marsh full of |Ygrass|n and tall, white-topped |Yreeds|n. Colorful |Ybirds|n in the sparse tree surrounding the marsh yell out a loud chorus. Purple herons and other marsh |Ybirds|n hunt in the tall swamp grass. Glowing |Yfireflies|n create a synchronized light show over the swamp grass in the deepening dusk. Giant pink and purple |Ymoths|n flutter over the dark flowers.|/A small |Yhut|n, perched on three stilts to keep it dry, stands in middle of the slough. +@desc here = The river spreads into a muddy marsh full of |Ygrass|n and tall, white-topped |Yreeds|n. Colorful |Ybirds|n in the sparse tree surrounding the marsh yell out a loud chorus. Purple herons and other marsh |Ybirds|n hunt in the tall swamp grass. Glowing |Yfireflies|n create a synchronized light show over the swamp grass in the deepening dusk. Giant pink and purple |Ymoths|n flutter over the dark flowers.|/A small |Yhut|n, perched on three |Ystilts|n to keep it dry, stands in middle of the slough. # Mellow Marsh:4 ends here @@ -1097,33 +1097,37 @@ py timed_script = evennia.create_script(key="Create Sticks", # [[file:../../../projects/mud.org::*Mellow Marsh][Mellow Marsh:8]] -@detail birds = Birds of every color on the rainbow and beyond fly and squawk around you, but keep their distance. +@detail stilts;stilt = Those stilts are scaly...and clawed...and, are they chicken legs? How expected. # Mellow Marsh:8 ends here # [[file:../../../projects/mud.org::*Mellow Marsh][Mellow Marsh:9]] -@detail moths;moth = On closer inspection, the moths are really |Ysprites|n playing a strange chasing game. +@detail birds = Birds of every color on the rainbow and beyond fly and squawk around you, but keep their distance. # Mellow Marsh:9 ends here # [[file:../../../projects/mud.org::*Mellow Marsh][Mellow Marsh:10]] -@detail sprites;sprite = Seems that sprites with pink wings are on one team, and purple winged sprits on the other. The game became exciting as one sprite, holding aloft a flag is trying to avoid others as it streaks to the far side of the marsh. +@detail moths;moth = On closer inspection, the moths are really |Ysprites|n playing a strange chasing game. # Mellow Marsh:10 ends here # [[file:../../../projects/mud.org::*Mellow Marsh][Mellow Marsh:11]] -@detail fireflies = A passing firefly shows it to actually be a |Ypixie|n holding two colorful lanterns. +@detail sprites;sprite = Seems that sprites with pink wings are on one team, and purple winged sprits on the other. The game became exciting as one sprite, holding aloft a flag is trying to avoid others as it streaks to the far side of the marsh. # Mellow Marsh:11 ends here # [[file:../../../projects/mud.org::*Mellow Marsh][Mellow Marsh:12]] -@detail pixie;pixies = The pixies ignore you as their coreography keeps them focused on their dance. +@detail fireflies = A passing firefly shows it to actually be a |Ypixie|n holding two colorful lanterns. # Mellow Marsh:12 ends here # [[file:../../../projects/mud.org::*Mellow Marsh][Mellow Marsh:13]] -@detail grass = Guess this kind of grass doesn't mind the wet environment. +@detail pixie;pixies = The pixies ignore you as their coreography keeps them focused on their dance. # Mellow Marsh:13 ends here # [[file:../../../projects/mud.org::*Mellow Marsh][Mellow Marsh:14]] -@detail mud = Pretty brown and sticky. +@detail grass = Guess this kind of grass doesn't mind the wet environment. # Mellow Marsh:14 ends here +# [[file:../../../projects/mud.org::*Mellow Marsh][Mellow Marsh:15]] +@detail mud = Pretty brown and sticky. +# Mellow Marsh:15 ends here + # Purple Heron # Create a puppet of the bird hunting frogs and pixies. :-D @@ -1697,8 +1701,8 @@ py bt = self.search('old lady'); bt.db.pose = 'playing with a deck of cards' # And describe this. # [[file:../../../projects/mud.org::*The Dock][The Dock:6]] -@desc here = The dock you stand on juts into a sea the color of lavender flowers. Mesmerizing and calming from the way the sound of the waves lap along the shore. -Someone has set a nice chair for viewing. +@desc here = The dock you stand on juts into a |Ysea|n the color of |Ylavender flowers|n. Mesmerizing and calming from the way the sound of the |Ywaves|n lap along the |Yshore|n. +Someone has set a nice |Ychair|n for viewing. # The Dock:6 ends here @@ -1868,7 +1872,7 @@ Someone has set a nice chair for viewing. # [[file:../../../projects/mud.org::*Grotto][Grotto:6]] -@desc here = The trickling sound of a small stream drops down a lush hill between ferns and brambleberry bushes. The path ends at a small bridge that leads to a red door embedded at the base of a giant tree. A carved sign over the door reads, |wDabblers|n. +@desc here = The trickling sound of a small stream drops down a lush hill between |Yferns|n and brambleberry |Ybushes|n. The path ends at a small |Ybridge|n that leads to a red door embedded at the base of a giant |Ytree|n. A carved sign over the door reads, |wDabblers|n. # Grotto:6 ends here @@ -1902,7 +1906,7 @@ Someone has set a nice chair for viewing. # [[file:../../../projects/mud.org::*Grotto][Grotto:10]] -@detail bridge = A small wooden bridge leads over a tiny stream. Hard to see the water on account of the giant leafed skunk cabbages. +@detail bridge = A small wooden bridge leads over a tiny |Ystream|n. Hard to see the water on account of the giant leafed skunk |Ycabbages|n. # Grotto:10 ends here @@ -1911,9 +1915,9 @@ Someone has set a nice chair for viewing. # [[file:../../../projects/mud.org::*Grotto][Grotto:11]] -@detail cabbage;cabbages;skunk cabbage;skunk cabbages = Large glossy green leaves with big yellow flowers that looks like cobras in drag. They hiss as you cross the bridge. +@detail cabbage;cabbages;skunk cabbage;skunk cabbages = Large glossy green leaves with big yellow flowers that looks like cobras in drag. They hiss as you cross the |Ybridge|n. # -@detail fern;ferns = Mostly sword ferns interrupted by Maiden Hair ferns that sing to the stream. +@detail fern;ferns = Sword ferns rattling sabers against the wards from the Maiden Hairs' flailing their fronds. # Grotto:11 ends here # Berry Bush @@ -2216,7 +2220,8 @@ Someone has set a nice chair for viewing. -# And the best description ever: +# And the best description ever that we don’t use: + # [[file:../../../projects/mud.org::*Inside][Inside:2]] @desc here = An enormous stone hearth overshadows this round room with dark paneling. A subtle smell of tea and incense. Large, overstuffed chairs sit invitingly by the fireplace. Oddly angled shelves with books and knickknackery adorn the walls and the smell of fresh-baked scones come from the kitchen. @@ -2231,36 +2236,47 @@ Someone has set a nice chair for viewing. @set here/initial_desc = "You found a cozy, cornerless room." # Ravenous State -@set here/fire_out = "The room is dim, lit by a single candle in a sconce attached to the wall. You see large, overstuffed chairs placed by a dark fireplace in a large stone hearth. Perhaps you could light a fire?" +@set here/fire_out = "The room is dim, lit by a single |Ycandle|n in a |Ysconce|n attached to the wall. You see large, overstuffed |Ychairs|n placed by a dark |Yfireplace|n in a large stone |Yhearth|n. Perhaps you could light a fire?" # Hungry State -@set here/fire_dim = "Large, overstuffed chairs sit invitingly close to the dimly glowing embers in the fireplace of a stone hearth." +@set here/fire_dim = "Large, overstuffed |Ychairs|n sit invitingly close to the dimly glowing embers in the |Yfireplace|n of a stone |Yhearth|n." # Fed State -@set here/fire_on = "Large, overstuffed chairs sit invitingly by a fire casting shadows that dance on the dark paneling." +@set here/fire_on = "Large, overstuffed |Ychairs|n sit invitingly by a |Yfire|n casting shadows that dance on the dark paneling." # Full State -@set here/fire_full = "Large, overstuffed chairs slightly shield you from the bright light of the roaring fire in the fireplace of a stone hearth." +@set here/fire_full = "Large, overstuffed |Ychairs|n slightly shield you from the bright light of the roaring fire in the |Yfireplace|n of a stone |Yhearth|n." # And a final description: -@set here/final_desc = "Oddly angled shelves with books and knickknackery adorn the walls around a tapestry. The subtle smell of wood smoke, incense and fresh-baked scones from the kitchen." +@set here/final_desc = "Oddly angled |Yshelves|n with |Ybooks|n and |Yknickknackery|n adorn the walls around a |Ytapestry|n. The subtle smell of wood smoke, incense and fresh-baked scones from the |Ykitchen|n." # Inside:3 ends here +# And details: + + +# [[file:../../../projects/mud.org::*Inside][Inside:4]] +@detail hearth = An enormous stone hearth overshadows this round room with dark |Ypaneling|n. |YStairs|n lead up and behind it. +# +@detail paneling = The seamless paneling, stretches from floor up into the darkness above. +# Inside:4 ends here + + + # Touch up the exit: -# [[file:../../../projects/mud.org::*Inside][Inside:4]] +# [[file:../../../projects/mud.org::*Inside][Inside:5]] @desc leave = A wood door with a large brass knob leads to the outside. # @set leave/traverse_msg = "You open the door and step outside..." -# Inside:4 ends here +# Inside:5 ends here # Tapestry Story # The tapestry should tell our /creation myth/. # [[file:../../../projects/mud.org::*Tapestry Story][Tapestry Story:1]] -@detail tapestry = The muted colors of the tapestry either show its age or its location over the sometimes smokey hearth. It depicts four scenes... |/|/The first scene shows a small, old |Yman|n with blue hair watering a wilted |Yrose|n in a desert landscape. |/|/The second scene shows the man and the rose next to a radiant |Yqueen|n handing the man a |Ypaper|n with a gold seal. |/|/The third scene shows the man standing between two |Ytrees|n, The final scene shows the man |Ywhispering|n to one of the trees, now visually further apart than in the third scene. +@detail tapestry = The muted colors of the tapestry either show its age or its location over the sometimes smokey |Yhearth|n. It depicts four scenes... |/|/The first scene shows a small, old |Yman|n with blue hair watering a wilted |Yrose|n in a desert landscape. |/|/The second scene shows the man and the rose next to a radiant |Yqueen|n handing the man a |Ypaper|n with a gold seal. |/|/The third scene shows the man standing between two |Ytrees|n, The final scene shows the man |Ywhispering|n to one of the trees, now visually further apart than in the third scene. # @detail man = The old man in the |Ytapestry|n is small, sporting a white vandyke-styles beard and blue tipped hair. He wears spectacles and a brown cloak covering his bright red jacket. Looks familiar. # @@ -2294,7 +2310,7 @@ Someone has set a nice chair for viewing. # And a description that will be overridden: # [[file:../../../projects/mud.org::*Fireplace][Fireplace:3]] -@desc fireplace = A stone fireplace with a carved wooden mantel supporting small pictures, some books and a black statue. +@desc fireplace = A stone fireplace with a carved wooden mantel supporting small |Ypictures|n, some |Ybooks|n and a black |Ystatue|n. # Fireplace:3 ends here @@ -2318,9 +2334,84 @@ Someone has set a nice chair for viewing. # I imagine a giant picture over the fireplace … need to do something interesting with it. # [[file:../../../projects/mud.org::*Fireplace][Fireplace:6]] -@detail picture = Above the fireplace is a large, somewhat abstract painting stretching its arm-like branches with shadowing that looks like a yawn. +@detail picture = Above the |Yfireplace|n is a large, somewhat abstract |Ypainting|n stretching its arm-like branches with shadowing that looks like a yawn. # Fireplace:6 ends here +# Wood Rack +# Need a way to produce wood for the fireplace. + + +# [[file:../../../projects/mud.org::*Wood Rack][Wood Rack:1]] +@create/drop wood rack;log rack;log holder;wood holder;wood;log :typeclasses.consumables.Producer +# Wood Rack:1 ends here + +# [[file:../../../projects/mud.org::*Wood Rack][Wood Rack:2]] +@desc wood rack = Steel and leather hammock for a small pile of cut logs, perfect for |gfeed|ning to the |gfire|n. +# Wood Rack:2 ends here + + + +# We have to have the wood rack describe what it /makes/: + + +# [[file:../../../projects/mud.org::*Wood Rack][Wood Rack:3]] +@set wood rack/make_name = "log" +# +@set wood rack/make_aliase = ["wood"] +# Wood Rack:3 ends here + + + +# And a verb when they /get/ the consumable: + + +# [[file:../../../projects/mud.org::*Wood Rack][Wood Rack:4]] +@set wood rack/make_verb = "$conj(get) a small" +# Wood Rack:4 ends here + + + +# And a commentary: + + +# [[file:../../../projects/mud.org::*Wood Rack][Wood Rack:5]] +@set wood rack/make_note = " from the wood rack" +# Wood Rack:5 ends here + + + +# This one is optional as it defaults to Consumable: + +# [[file:../../../projects/mud.org::*Wood Rack][Wood Rack:6]] +@set wood rack/make_class = "typeclasses.things.Wood" +# Wood Rack:6 ends here + + + +# And the wood rack needs to know the /description/ of the Consumable, so that it can attach that: + +# [[file:../../../projects/mud.org::*Wood Rack][Wood Rack:7]] +@set wood rack/make_desc = "Cut wood, perfect for feeding to the fire." +# Wood Rack:7 ends here + + + +# How much is there when you pick them? + +# [[file:../../../projects/mud.org::*Wood Rack][Wood Rack:8]] +@set wood rack/make_amount = 1 +# Wood Rack:8 ends here + + + +# Hide from immediate view: + +# [[file:../../../projects/mud.org::*Wood Rack][Wood Rack:9]] +@set wood rack/hidden_tag = "hidden_woodrack" +# +@lock wood rack = view:tag(hidden_woodrack) +# Wood Rack:9 ends here + # Knickknacks # What sort of non-books do we want to look at? @@ -2585,7 +2676,7 @@ pose gnome/default = smoking his pipe # [[file:../../../projects/mud.org::*Journal][Journal:3]] @desc journal = Leather-bound book, cracked and worn from ages. # - @give journal = gnome +@give journal = gnome # Journal:3 ends here # Stoat @@ -2599,6 +2690,8 @@ pose gnome/default = smoking his pipe # [[file:../../../projects/mud.org::*Stoat][Stoat:1]] @create/drop wee beastie;Mochi;stoat: typeclasses.pets.Friendly +# +# @typeclass/force/reset wee beastie # Stoat:1 ends here @@ -3398,7 +3491,7 @@ py bt = self.search('imp'); bt.db.pose = 'sitting on an ornate perch' # [[file:../../../projects/mud.org::*Bedroom][Bedroom:3]] @teleport/quiet mp13 # -@desc here = Like the shadows that dance here, this oddly shaped room hugs its contents: a thick wooden framed bed piled high with blankets and pillows to keep out the chill; a thick burgundy carpet sporting a pair of slippers; and a wardrobe decorated with ornate leaves and berries. +@desc here = Like the shadows that dance here, this oddly shaped room hugs its contents: a thick wooden framed |Ybed|n piled high with |Yblankets|n and |Ypillows|n to keep out the chill; a thick burgundy |Ycarpet|n sporting a pair of |Yslippers|n; and a |Ywardrobe|n decorated with ornate leaves and berries. # Bedroom:3 ends here @@ -3519,7 +3612,7 @@ py bt = self.search('imp'); bt.db.pose = 'sitting on an ornate perch' # [[file:../../../projects/mud.org::*Southwest Prairie][Southwest Prairie:1]] @teleport/quiet mp14 # -@desc here = On the edge of a small knoll with a copse of trees, the space stretches to a rolling dawnclear, blue skies pushing down the horizona distant sunset attempting to pull the sky down with it bright, star painted skies. +@desc here = On the edge of a small |Yknoll|n with a |Ycopse|n of trees, the space stretches to a rolling dawnclear, blue skies pushing down the horizona distant sunset attempting to pull the sky down with it bright, star painted skies. # Southwest Prairie:1 ends here @@ -3528,7 +3621,7 @@ py bt = self.search('imp'); bt.db.pose = 'sitting on an ornate perch' # [[file:../../../projects/mud.org::*Southwest Prairie][Southwest Prairie:2]] -@desc copse = A copse of trees covers the top of the knoll. Hanging from a tree, a lit lantern, as if showing the way to another world. +@desc copse = A copse of trees covers the top of the knoll. Hanging from a tree, a lit |Ylantern|n, as if showing the way to another world. # @set copse/traverse_msg = "You push through the tree's long pine needles to then push through the cloaks and jackets to exit the wardrobe." # Southwest Prairie:2 ends here @@ -3541,7 +3634,7 @@ py bt = self.search('imp'); bt.db.pose = 'sitting on an ornate perch' # [[file:../../../projects/mud.org::*Southwest Prairie][Southwest Prairie:3]] @detail knoll;hillock;knell = The land stretches and buckles in small rolls. You find yourself and one of the high points, allowing you to absorb the immense view. # -@detail latern = Curious iron worked latern sways in the subtle breeze. +@detail lantern = Curious iron worked lantern sways in the subtle breeze. # @detail campfire;fire = Only a thin wisp of smoke escapes to the skies; fragrating the air. # Southwest Prairie:3 ends here @@ -3569,13 +3662,15 @@ py bt = self.search('imp'); bt.db.pose = 'sitting on an ornate perch' # [[file:../../../projects/mud.org::*Mare’s Head][Mare’s Head:3]] -py bt = self.search('head'); bt.db.pose = 'sitting next to a small campfire' +py bt = self.search('head'); bt.db.pose = 'sitting next to a small |Ycampfire|n' # Mare’s Head:3 ends here # [[file:../../../projects/mud.org::*Mare’s Head][Mare’s Head:4]] @set mares head/_sdesc = "curious figure" # -@set mares head/pose_sleep = "sitting next to a small campfire" +@set mares head/pose_sleep = "sitting next to a small |Ycampfire|n" +# +@set mares head/pose_default = "sitting next to a small |Ycampfire|n" # @pose default mares head = sitting next to a small campfire # Mare’s Head:4 ends here @@ -3586,7 +3681,7 @@ py bt = self.search('head'); bt.db.pose = 'sitting next to a small campfire' # [[file:../../../projects/mud.org::*Mare’s Head][Mare’s Head:5]] -@desc mares head = A curious figure wearing dark robes and a gleaming white skull of a mare. Interestingly, the skull has velvety horse ears. +@desc mares head = A curious figure wearing dark robes and a gleaming white skull of a mare. Interestingly, the skull has velvety horse |Years|n. # Mare’s Head:5 ends here # [[file:../../../projects/mud.org::*Mare’s Head][Mare’s Head:6]]