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:
parent
b45e906f58
commit
c7eb10cc81
2 changed files with 28 additions and 18 deletions
|
|
@ -66,7 +66,6 @@ class CmdThrow(Command):
|
||||||
"""
|
"""
|
||||||
key = "throw"
|
key = "throw"
|
||||||
locks = "holds(stick)"
|
locks = "holds(stick)"
|
||||||
# locks = "cmd:holds()"
|
|
||||||
|
|
||||||
def func(self):
|
def func(self):
|
||||||
self.obj.do_throw(self.caller)
|
self.obj.do_throw(self.caller)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ from evennia import (
|
||||||
create_script,
|
create_script,
|
||||||
)
|
)
|
||||||
from evennia.prototypes.spawner import spawn
|
from evennia.prototypes.spawner import spawn
|
||||||
|
from evennia.utils import delay
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
@ -160,9 +161,9 @@ class Fish(CarriableNPC):
|
||||||
"""
|
"""
|
||||||
A visual way to delete the fish.
|
A visual way to delete the fish.
|
||||||
"""
|
"""
|
||||||
if fisher.location == fisher.search("Lazy Dock", quiet=True):
|
if fisher.location.key == "Lazy Dock" or fisher.location.key == "Shore":
|
||||||
fisher.msg(routput("You <<toss ^ heave ^ throw>> the fish back into the <<water ^ sea>>."))
|
fisher.announce_action("$You() <<$conj(toss) ^ $conj(heave) ^ $conj(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!\""))
|
fisher.location.msg_contents("The fish says, \"Bye for now. If you want to talk again, just drop me a line!\"")
|
||||||
else:
|
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."))
|
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()
|
self.delete()
|
||||||
|
|
@ -196,29 +197,39 @@ class FishingPole(Object):
|
||||||
Can produce a Fish.
|
Can produce a Fish.
|
||||||
"""
|
"""
|
||||||
failure_msgs = [
|
failure_msgs = [
|
||||||
"You reel in an empty line.",
|
"$You() $conj(reel) in an empty line.",
|
||||||
"You didn't catch anything.",
|
"$You() didn't catch anything.",
|
||||||
"Caught nothing but a bit of weeds, yeck.",
|
"$You() caught nothing but a bit of weeds, yeck.",
|
||||||
"Caught nothing, but this sure is enjoyable.",
|
"$You() caught nothing, but this sure is enjoyable.",
|
||||||
"Did you catch a boot? Nah, it isn't even that good.",
|
"Did $you() catch a boot? Nah, the fishing isn't even that good.",
|
||||||
"Anything better that sitting on the dock of the bay?",
|
"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):
|
def at_object_creation(self):
|
||||||
self.cmdset.add_default(CmdSetFishing)
|
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):
|
def do_cast(self, fisher):
|
||||||
if fisher.location.key != "Lazy Dock":
|
if fisher.location.key != "Lazy Dock" and fisher.location.key != "Shore":
|
||||||
fisher.msg("You can't do that without being near the water.")
|
fisher.msg("You can't do that without being near a large body of water.")
|
||||||
|
return False
|
||||||
elif fisher.db.fishing == Fishing.CAST:
|
elif fisher.db.fishing == Fishing.CAST:
|
||||||
fisher.msg("You need to reel the line in first.")
|
fisher.msg("You need to reel the line in first.")
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
fisher.db.fishing = Fishing.CAST
|
fisher.db.fishing = Fishing.CAST
|
||||||
fisher.msg(routput(random.choice([
|
fisher.announce_action(routput(random.choice([
|
||||||
"You cast out far into the <<water ^ sea>>.",
|
"$You() $conj(cast) << out ^ >> << far ^ >> into the <<water ^ sea>>.",
|
||||||
"You cast close to the <<dock ^ shore>>.",
|
"$You() $conj(cast) close to the <<dock ^ shore>>.",
|
||||||
"You cast off to the <<right ^ left>> where you <<think you ^ >> see a dark pocket.",
|
"$You() $conj(cast) off to the <<right ^ left>> where you <<think you ^ >> see a dark pocket.",
|
||||||
])))
|
])))
|
||||||
|
return True
|
||||||
|
|
||||||
def do_reel(self, fisher):
|
def do_reel(self, fisher):
|
||||||
if fisher.db.fishing != Fishing.CAST:
|
if fisher.db.fishing != Fishing.CAST:
|
||||||
|
|
@ -228,7 +239,7 @@ class FishingPole(Object):
|
||||||
if random.randint(1, 100) < 35:
|
if random.randint(1, 100) < 35:
|
||||||
self.give_fish(fisher)
|
self.give_fish(fisher)
|
||||||
else:
|
else:
|
||||||
fisher.msg(random.choice(self.failure_msgs))
|
fisher.announce_action(random.choice(self.failure_msgs))
|
||||||
|
|
||||||
def give_fish(self, fisher):
|
def give_fish(self, fisher):
|
||||||
fish = spawn({
|
fish = spawn({
|
||||||
|
|
@ -238,5 +249,5 @@ class FishingPole(Object):
|
||||||
"desc": Fish.get_desc(),
|
"desc": Fish.get_desc(),
|
||||||
})[0]
|
})[0]
|
||||||
fish.location = fisher
|
fish.location = fisher
|
||||||
fisher.msg(f"You caught a fish!")
|
fisher.announce_action(f"$You() caught a fish!")
|
||||||
fisher.score(Scores.catch_fish)
|
fisher.score(Scores.catch_fish)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue