def set_commands(cls, *commands): cls.commands = [] for command in commands: cls.commands.append(command) CommandRegistry.register(command)
@command_context def get_actions(self, ctx): yield UnPack if ctx(UnPack): yield UnEquip class Remove(Command): description = "remove an item" defaults = ("R",) @command_context def get_actions(self, ctx): yield UnEquip if ctx(UnEquip): yield Pack CommandRegistry.register(Wear, Remove) """Components.""" class Equipment(Component): """Allows an Agent to equip Agents on itself.""" commands = [] @ignore_results def get_worn(self): """Get a list representation of the Agent's worn Equipment.""" return self.owner.values("Body", "get_worn") @ignore_results def get_containers(self): """Get a nested representation of the Actor's Containers and their contents."""
defaults = ("t",) @command_context def get_actions(self, ctx): yield TakeMentalCommand class IssueCommand(Command): """Issue a command to a target.""" description = "issue a command to a target" defaults = ("C",) @command_context def get_actions(self, ctx): yield IssueMentalCommand CMD.register(TakeCommand, IssueCommand) """Components.""" class Commander(Component): """Component that handles an Agent's command capabilities.""" commands = [] domain = "Command" def __init__(self, owner, commanded=[]): super(Commander, self).__init__(owner) self.commanded = commanded def get_commands(self, context):
# ("ready", "item"), # ("contact", "target", "item"), # ("use_at", "target", "item") # ), """Commands.""" class Attack(Command): description = "attack" defaults = ("a",) @command_context def get_actions(self, ctx): yield AttackWithWielded CommandRegistry.register(Attack) class Combat(Component): """Allows an Agent to engage in combat with other Agents.""" commands = [] def __init__(self, owner): super(Combat, self).__init__(owner) self.weapons = deque() self.attack_options = deque() self.parries = deque() def trigger(self, *triggers): """Respond to triggers.""" if "rebuild" in triggers:
@command_context def get_actions(self, ctx): yield Pickup if ctx(Pickup): yield Pack class GetAll(Command): """Pick up multiple nearby items.""" description = "pick up all items" defaults = ("G",) @command_context def get_actions(self, ctx): yield Pickup yield Pack CMD.register(Get, GetAll) """Change how an item is manipulated.""" class ReadyWeapon(Command): short_desc = "ready" description = "ready an unreadied weapon" defaults = ("r",) # TODO: Distinct Ready action? @command_context def get_actions(self, ctx): yield Wield class WieldWeapon(Command): short_desc = "wield"