Add 'use' to the fishing pole

Which does both the `cast` and `reel` commands.
The fishing messages are alos public notices.
This commit is contained in:
Howard Abrams 2025-09-14 11:40:51 -07:00
parent b45e906f58
commit c7eb10cc81
2 changed files with 28 additions and 18 deletions

View file

@ -66,7 +66,6 @@ class CmdThrow(Command):
"""
key = "throw"
locks = "holds(stick)"
# locks = "cmd:holds()"
def func(self):
self.obj.do_throw(self.caller)

View file

@ -8,6 +8,7 @@ from evennia import (
create_script,
)
from evennia.prototypes.spawner import spawn
from evennia.utils import delay
from enum import Enum
from urllib.request import urlopen
@ -160,9 +161,9 @@ class Fish(CarriableNPC):
"""
A visual way to delete the fish.
"""
if fisher.location == fisher.search("Lazy Dock", quiet=True):
fisher.msg(routput("You <<toss ^ heave ^ throw>> the fish back into the <<water ^ sea>>."))
fisher.msg(routput("The fish says, \"Bye for now. If you want to talk again, just drop me a line!\""))
if fisher.location.key == "Lazy Dock" or fisher.location.key == "Shore":
fisher.announce_action("$You() <<$conj(toss) ^ $conj(heave) ^ $conj(throw)>> the fish back into the <<water ^ sea>>.")
fisher.location.msg_contents("The fish says, \"Bye for now. If you want to talk again, just drop me a line!\"")
else:
fisher.msg(routput("You <<toss ^ heave ^ throw>> the fish, and an << eagle ^ hawk >> swoops << down ^ >> and snatches it. I'm sure it will carry the fish back to the sea for you."))
self.delete()
@ -196,29 +197,39 @@ class FishingPole(Object):
Can produce a Fish.
"""
failure_msgs = [
"You reel in an empty line.",
"You didn't catch anything.",
"Caught nothing but a bit of weeds, yeck.",
"Caught nothing, but this sure is enjoyable.",
"Did you catch a boot? Nah, it isn't even that good.",
"Anything better that sitting on the dock of the bay?",
"$You() $conj(reel) in an empty line.",
"$You() didn't catch anything.",
"$You() caught nothing but a bit of weeds, yeck.",
"$You() caught nothing, but this sure is enjoyable.",
"Did $you() catch a boot? Nah, the fishing isn't even that good.",
"While $you() didn't catch anything, could there be anything better that sitting on the dock of the bay? Watching the clouds roll away?",
]
def at_object_creation(self):
self.cmdset.add_default(CmdSetFishing)
def do_use(self, user, _):
if self.location != user:
user.announce_action("$You() $conj(pick) up the pole to go fishing.")
delay(6, user.announce_action, "$You() $conj(return) the pole << next to the chair ^ >>.")
if self.do_cast(user):
delay(5, self.do_reel, user)
def do_cast(self, fisher):
if fisher.location.key != "Lazy Dock":
fisher.msg("You can't do that without being near the water.")
if fisher.location.key != "Lazy Dock" and fisher.location.key != "Shore":
fisher.msg("You can't do that without being near a large body of water.")
return False
elif fisher.db.fishing == Fishing.CAST:
fisher.msg("You need to reel the line in first.")
return False
else:
fisher.db.fishing = Fishing.CAST
fisher.msg(routput(random.choice([
"You cast out far into the <<water ^ sea>>.",
"You cast close to the <<dock ^ shore>>.",
"You cast off to the <<right ^ left>> where you <<think you ^ >> see a dark pocket.",
fisher.announce_action(routput(random.choice([
"$You() $conj(cast) << out ^ >> << far ^ >> into the <<water ^ sea>>.",
"$You() $conj(cast) close to the <<dock ^ shore>>.",
"$You() $conj(cast) off to the <<right ^ left>> where you <<think you ^ >> see a dark pocket.",
])))
return True
def do_reel(self, fisher):
if fisher.db.fishing != Fishing.CAST:
@ -228,7 +239,7 @@ class FishingPole(Object):
if random.randint(1, 100) < 35:
self.give_fish(fisher)
else:
fisher.msg(random.choice(self.failure_msgs))
fisher.announce_action(random.choice(self.failure_msgs))
def give_fish(self, fisher):
fish = spawn({
@ -238,5 +249,5 @@ class FishingPole(Object):
"desc": Fish.get_desc(),
})[0]
fish.location = fisher
fisher.msg(f"You caught a fish!")
fisher.announce_action(f"$You() caught a fish!")
fisher.score(Scores.catch_fish)