Пример #1
0
def apply_defence(defence):
    if not prereqs_test(defence.get('prereqs', [])):
        return
    if callable(defence['up']):
        up_action, up_args = defence['up'], []
    else:
        up_action, up_args = defence['up'][0], defence['up'][1:]
    if not up_action.possible(*up_args) or p.action_already_active(up_action, *up_args):
        return
    p.debug("Applying defence: %s" % defence['name'])
    p.act(up_action, *up_args)
Пример #2
0
def cure_affliction(affliction):
    if not prereqs_test(affliction.get('prereqs', [])):
        return
    if callable(affliction['down']):
        down_action, down_args = affliction['down'], []
    else:
        down_action, down_args = affliction['down'][0], affliction['down'][1:]
    if (not down_action.possible(*down_args)
        or p.action_already_active(down_action, *down_args)):
        return
    p.debug("Curing affliction: %s" % affliction['name'])
    p.act(down_action, *down_args)