Figured the give and take system
Now the Knocker will only accept the ring, and not berries.
This commit is contained in:
parent
c50f36bffc
commit
542e140013
5 changed files with 67 additions and 32 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -56,3 +56,5 @@ nosetests.xml
|
||||||
.vscode
|
.vscode
|
||||||
/.venv/
|
/.venv/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/server/ssh-private.key
|
||||||
|
/server/ssh-public.key
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,25 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from commands.command import Command
|
from commands.command import Command
|
||||||
|
from evennia.commands.default.general import NumberedTargetCommand
|
||||||
|
|
||||||
|
class CmdTake(Command, NumberedTargetCommand):
|
||||||
class CmdTake(Command):
|
|
||||||
"""
|
"""
|
||||||
Steals an object from another.
|
Steals an object from another.
|
||||||
Added to the default_cmdsets.
|
Added to the default_cmdsets.
|
||||||
"""
|
"""
|
||||||
key = "take"
|
key = "take"
|
||||||
aliases = ["steal"]
|
aliases = ["steal"]
|
||||||
# only allow this command if command.obj is carried by caller.
|
rhs_split = ("=", " from ")
|
||||||
# locks = "cmd:holds()"
|
|
||||||
|
|
||||||
def func(self):
|
def func(self):
|
||||||
"""
|
"""
|
||||||
Implements the take command. Since this command is designed
|
Implements the take command. Since this command is designed
|
||||||
to work on the object, we operate only on self.obj.
|
to work on the object, we operate only on self.obj.
|
||||||
"""
|
"""
|
||||||
# logger.log_info(f"Dealing with {self.caller.key}")
|
if not self.args:
|
||||||
self.caller.do_take(self.args)
|
self.msg("What do you want to take?")
|
||||||
|
elif not self.rhs:
|
||||||
|
self.msg(f"You want to take {self.lhs}, but from whom?")
|
||||||
|
else:
|
||||||
|
self.caller.do_take(self.lhs, self.rhs)
|
||||||
|
|
|
||||||
|
|
@ -72,18 +72,10 @@ class Character(Object, DefaultCharacter):
|
||||||
letter.db.inside = READ_LETTER.format(self.name.capitalize())
|
letter.db.inside = READ_LETTER.format(self.name.capitalize())
|
||||||
letter.location = self
|
letter.location = self
|
||||||
|
|
||||||
def do_take(self, args):
|
def do_take(self, to_take, from_whom):
|
||||||
"""
|
"""
|
||||||
A character has a _steal_command. What are the limitations?
|
A character has a _steal_command. What are the limitations?
|
||||||
"""
|
"""
|
||||||
args = Token(args)
|
|
||||||
if args.empty():
|
|
||||||
self.msg("What do you want to take?")
|
|
||||||
elif len(args.words) == 1:
|
|
||||||
self.msg(f"You want to take {args.words[0]}, but from whom?")
|
|
||||||
else:
|
|
||||||
to_take = args.words[0]
|
|
||||||
from_whom = args.words[-1]
|
|
||||||
victim = self.search(from_whom)
|
victim = self.search(from_whom)
|
||||||
if victim:
|
if victim:
|
||||||
thing = victim.has(to_take)
|
thing = victim.has(to_take)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from evennia import create_script
|
from evennia import create_script
|
||||||
from evennia.utils import logger
|
from evennia.utils import logger, delay
|
||||||
|
|
||||||
from .scripts import KnockScript
|
from .scripts import KnockScript
|
||||||
from .objects import Object
|
from .objects import Object
|
||||||
|
|
@ -11,6 +11,17 @@ from utils.word_list import routput
|
||||||
from random import choice, random
|
from random import choice, random
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
class Ring(Object):
|
||||||
|
def move_to(self, destination, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
The ring should only go to the door knocker...
|
||||||
|
"""
|
||||||
|
if destination.is_typeclass("typeclasses.things.Knocker") or \
|
||||||
|
destination.is_typeclass("typeclasses.characters.Character"):
|
||||||
|
super().move_to(destination)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class Stick(Object):
|
class Stick(Object):
|
||||||
def at_object_creation(self):
|
def at_object_creation(self):
|
||||||
|
|
@ -309,8 +320,30 @@ class Knocker(Object):
|
||||||
super().msg(text=text, from_obj=from_obj, **kwargs)
|
super().msg(text=text, from_obj=from_obj, **kwargs)
|
||||||
|
|
||||||
def at_object_leave(self, obj, target_location, **kwargs):
|
def at_object_leave(self, obj, target_location, **kwargs):
|
||||||
|
"""
|
||||||
|
If the ring is removed, we make a comment.
|
||||||
|
"""
|
||||||
if obj.key == "brass ring" and target_location != self:
|
if obj.key == "brass ring" and target_location != self:
|
||||||
self.at_say("Oh my, that feels better.")
|
self.at_say("Oh my, that feels better.")
|
||||||
else:
|
|
||||||
self.at_say("Umph")
|
def at_pre_object_receive(self, arriving_object,
|
||||||
|
source_location, **kwargs):
|
||||||
|
"""
|
||||||
|
The knocker only accepts the ring as a gift.
|
||||||
|
"""
|
||||||
|
return True if arriving_object.key == "brass ring" else False
|
||||||
|
|
||||||
|
def at_object_receive(self, obj, source_location,
|
||||||
|
move_type, **kwargs):
|
||||||
|
"""
|
||||||
|
If the ring is returned, we make a comment.
|
||||||
|
"""
|
||||||
|
if obj.key == "brass ring":
|
||||||
|
delay(2, self.chewing)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def chewing(self):
|
||||||
|
"""
|
||||||
|
Make a muffled comment.
|
||||||
|
"""
|
||||||
|
self.at_say(choice(self.muffled_responses))
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,13 @@ def character_has(holder, item):
|
||||||
return i
|
return i
|
||||||
|
|
||||||
def god_msg(msg, sender=None, location=None):
|
def god_msg(msg, sender=None, location=None):
|
||||||
|
"""
|
||||||
|
Bit of a debugging tool that allows messages to my character.
|
||||||
|
"""
|
||||||
dabbler = Character.objects.search_object("#1")[0]
|
dabbler = Character.objects.search_object("#1")[0]
|
||||||
dabbler.msg(f"{msg} {'from ' + sender if sender else ''} {'at ' + location if location else ''}")
|
send_msg = ('from ' + sender.name) if sender else ''
|
||||||
|
loc_msg = ('at ' + location.name) if location else ''
|
||||||
|
dabbler.msg(f"{msg} {send_msg} {loc_msg}")
|
||||||
|
|
||||||
def debug(msg, sender=None, location=None):
|
def debug(msg, sender=None, location=None):
|
||||||
god_msg(f"DEBUG: {msg}", sender, location)
|
god_msg(f"DEBUG: {msg}", sender, location)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue