Puppets gift characters with magical items
This commit is contained in:
parent
02c640c7ad
commit
e5e1b41be5
5 changed files with 115 additions and 9 deletions
|
|
@ -25,7 +25,8 @@ from commands.everyone import (CmdTake, CmdThink, CmdSay,
|
|||
CmdUse, CmdPush, CmdPull)
|
||||
from commands.misc import CmdLight
|
||||
from typeclasses.tutorial import CmdTutorial
|
||||
from commands.wizards import CmdGM, CmdSpell, CmdGMTrigger, CmdMakeCocktail
|
||||
from commands.wizards import (CmdGM, CmdSpell, CmdGMTrigger,
|
||||
CmdMakeCocktail, CmdGift)
|
||||
|
||||
|
||||
class CharacterCmdSet(default_cmds.CharacterCmdSet):
|
||||
|
|
@ -62,6 +63,7 @@ class CharacterCmdSet(default_cmds.CharacterCmdSet):
|
|||
self.add(CmdSpell)
|
||||
self.add(CmdGMTrigger)
|
||||
self.add(CmdMakeCocktail)
|
||||
self.add(CmdGift)
|
||||
|
||||
|
||||
class AccountCmdSet(default_cmds.AccountCmdSet):
|
||||
|
|
|
|||
|
|
@ -88,12 +88,19 @@ class CmdPush(Command):
|
|||
|
||||
def func(self):
|
||||
"""Call the 'do_push' method."""
|
||||
item = self.caller.search(self.args.strip())
|
||||
pusher = self.caller
|
||||
to_push = self.args.strip()
|
||||
|
||||
if to_push == "":
|
||||
pusher.msg("What do you want to push?")
|
||||
return
|
||||
|
||||
item = pusher.search(self.args.strip())
|
||||
if item:
|
||||
if item.has_method('do_push'):
|
||||
item.do_push(self.caller)
|
||||
item.do_push(pusher)
|
||||
else:
|
||||
self.caller.msg(f"You can't push {item.name}.")
|
||||
pusher.msg(f"You can't push {item.name}.")
|
||||
|
||||
|
||||
class CmdPull(Command):
|
||||
|
|
@ -109,12 +116,19 @@ class CmdPull(Command):
|
|||
|
||||
def func(self):
|
||||
"""Call the 'do_pull' method."""
|
||||
item = self.caller.search(self.args.strip())
|
||||
puller = self.caller
|
||||
to_pull = self.args.strip()
|
||||
|
||||
if to_pull == "":
|
||||
puller.msg("What do you want to pull?")
|
||||
return
|
||||
|
||||
item = puller.search(to_pull)
|
||||
if item:
|
||||
if item.has_method('do_pull'):
|
||||
item.do_pull(self.caller)
|
||||
item.do_pull(puller)
|
||||
else:
|
||||
self.caller.msg(f"You can't pull {item.name}.")
|
||||
puller.msg(f"You can't pull {item.name}.")
|
||||
|
||||
|
||||
class CmdOpen(Command):
|
||||
|
|
|
|||
|
|
@ -122,6 +122,27 @@ class CmdMakeCocktail(MuxCommand):
|
|||
Cocktail.make(dest, self.caller, self.lhs)
|
||||
|
||||
|
||||
class CmdGift(MuxCommand):
|
||||
"""
|
||||
Give a special gift to a character.
|
||||
|
||||
Usage:
|
||||
|
||||
gift <gift> to <char> [ : name : desc ]
|
||||
"""
|
||||
key = "gift"
|
||||
locks = "cmd:perm(gm) or perm(Admin)"
|
||||
|
||||
def func(self):
|
||||
m = match(r"([A-z]+) *?( to|=)? *(.+)( *: *[A-z]+( *: *[A-z]+)?)?",
|
||||
self.args.strip())
|
||||
if m:
|
||||
logger.info(f"Groups: {m.group(1)}, {m.group(2)}, {m.group(3)}")
|
||||
self.caller.do_gift(m.group(3), m.group(1), m.group(4), m.group(5))
|
||||
else:
|
||||
self.caller.msg("Usage: gift <gift> to <char> [ : name : desc ]")
|
||||
|
||||
|
||||
class CmdGM(MuxCommand):
|
||||
"""
|
||||
The gm command allows anything to be emoted into a room.
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from re import split, match, sub, IGNORECASE
|
|||
from shutil import copyfile
|
||||
|
||||
from evennia import CmdSet
|
||||
from evennia.prototypes.spawner import spawn
|
||||
from evennia.utils import logger
|
||||
|
||||
from commands.command import Command
|
||||
|
|
@ -82,6 +83,74 @@ class Puppet(Character, Listener):
|
|||
else:
|
||||
return self.db.desc_unpuppeted if self.db.desc_unpuppeted else self.db.desc
|
||||
|
||||
def do_gift(self, recipient, gift, name=None, desc=None):
|
||||
"""
|
||||
Give a 'gift' by name to a 'recipient'.
|
||||
|
||||
This doesn't give the gift if the recipient has already
|
||||
received the gift.
|
||||
"""
|
||||
gifts = {
|
||||
'purse': {"typeclass": "typeclasses.things.CoinPurse",
|
||||
"key": name or gift,
|
||||
"desc": desc or "Small leather coin purse, with a gold clasp.",
|
||||
},
|
||||
'ball': {"typeclass": "typeclasses.things.CrystalBall",
|
||||
"key": name or "crystal ball",
|
||||
"desc": desc or "Swirling glass ball of colored ectoplasm.",
|
||||
},
|
||||
'dice': {"typeclass": "typeclasses.things.Dice",
|
||||
"key": name or "pair of dice",
|
||||
"desc": desc or "Two bone knuckles with painted dots.",
|
||||
"attr": {
|
||||
"number": 2
|
||||
}
|
||||
},
|
||||
'pipe': {"typeclass": "typeclasses.things.Pipe",
|
||||
"key": name or gift,
|
||||
"desc": desc or "Smoking pipe carved with esoteric symbols.",
|
||||
},
|
||||
'wand': {"typeclass": "typeclasses.things.Wand",
|
||||
"key": name or gift,
|
||||
"desc": desc or "Curiously crafted wand carved with runes: ᛑ ᛒ ᚱ",
|
||||
},
|
||||
'bag': {"typeclass": "typeclasses.things.BagofJunk",
|
||||
"key": name or "sack",
|
||||
"desc": desc or "Small cloth bag with a leather drawstring.|/You could probably |grummage|n around in that, and maybe |gkeep|n something.",
|
||||
},
|
||||
'junk': {"typeclass": "typeclasses.things.BagofJunk",
|
||||
"key": name or "sack",
|
||||
"desc": desc or "Small cloth bag with a leather drawstring.|/You could probably |grummage|n around in that, and maybe |gkeep|n something.",
|
||||
"attr": {
|
||||
"stuff": "human"
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
receiver = self.search(recipient)
|
||||
if not receiver:
|
||||
return None
|
||||
|
||||
if gift in gifts.keys() and \
|
||||
not receiver.attributes.get(f"received_{gift}"):
|
||||
details = gifts[gift]
|
||||
obj = spawn(details)[0]
|
||||
for attr, value in enumerate(details.get("attr", {})):
|
||||
obj.attributes.add(attr, value)
|
||||
obj.location = receiver
|
||||
receiver.attributes.add(f"received_{gift}", True)
|
||||
|
||||
their_name = receiver.get_display_name(self)
|
||||
self.announce_action(f"$You() $conj(give) something to {their_name}.",
|
||||
exclude=receiver)
|
||||
|
||||
my_name = self.get_display_name(receiver)
|
||||
receiver.msg(f"{my_name} gives you a {obj.name}.")
|
||||
return True
|
||||
|
||||
self.msg(f"You can't give '{gift}' to {receiver.key}... {gifts.keys()}")
|
||||
return None
|
||||
|
||||
|
||||
class CmdShrubSay(Command):
|
||||
"""Erase and write on the shrub's chalkboard.
|
||||
|
|
|
|||
|
|
@ -237,10 +237,10 @@ class Muttering(Script):
|
|||
formats = self.refresh_mutter_formats()
|
||||
zip_list = zip(sequences, cycle(formats)) \
|
||||
if len(sequences) > len(formats) \
|
||||
else zip(sequences, formats[:len(sequences)])
|
||||
else zip(sequences, formats[:len(sequences)])
|
||||
|
||||
for idx, tup in enumerate(zip_list):
|
||||
logger.info(f"delay({idx} * {self.db.mutter_delay_gap}, self.mutter, {tup[0]}, {tup[1]})")
|
||||
# logger.info(f"delay({idx} * {self.db.mutter_delay_gap}, self.mutter, {tup[0]}, {tup[1]})")
|
||||
delay(idx * self.db.mutter_delay_gap,
|
||||
self.mutter, tup[0], tup[1])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue