Пример #1
0
    def doInteraction(self, user, msg, parsed, *recipients):
        """Use actor's stats to apply each action to all targets"""
        assert recipients, "interaction with no recipients"
        if parsed.actor:
            actor = parsed.actor.character_name
        else:
            actor = user

        strings = []
        for vp in parsed.verb_phrases:
            if len(parsed.targets) == 0:
                formatted = alias.resolve(actor,
                                          tuple(vp.verbs),
                                          vp.dice,
                                          vp.temp_modifier)
                if formatted is not None:
                    strings.append(formatted)
            else:
                for item in parsed.targets:
                    target = item.target
                    formatted = alias.resolve(actor,
                                              tuple(vp.verbs),
                                              vp.dice,
                                              vp.temp_modifier,
                                              target)
                    if formatted is not None:
                        strings.append(formatted)
        if strings:
            text = '\n'.join(strings)
            return Response(text, msg, *recipients)
Пример #2
0
    def doInteraction(self, user, msg, parsed, *recipients):
        """Use actor's stats to apply each action to all targets"""
        assert recipients, "interaction with no recipients"
        if parsed.actor:
            actor = parsed.actor.character_name
        else:
            actor = user

        strings = []
        for vp in parsed.verb_phrases:
            if len(parsed.targets) == 0:
                formatted = alias.resolve(actor, tuple(vp.verbs), vp.dice,
                                          vp.temp_modifier)
                if formatted is not None:
                    strings.append(formatted)
            else:
                for item in parsed.targets:
                    target = item.target
                    formatted = alias.resolve(actor, tuple(vp.verbs), vp.dice,
                                              vp.temp_modifier, target)
                    if formatted is not None:
                        strings.append(formatted)
        if strings:
            text = '\n'.join(strings)
            return Response(text, msg, *recipients)
Пример #3
0
 def respondTo_DICE(self, channel, user, exp):
     """{d1ce} expressions
     Understands all the expressions in dice.py
     Also understands aliases, for example:
     <bob> {battleaxe 1d20+3} => rolls 1d20+3, and remembers that bob's
         alias {battleaxe} is 1d20+3
     When defining an alias, the dice expression must not contain spaces
     """
     result = alias.resolve(user, exp)
     if result is not None:
         response = '%s, you rolled: %s' % (user, result)
         self.msg(channel, response)
Пример #4
0
 def respondTo_DICE(self, channel, user, exp):
     """{d1ce} expressions
     Understands all the expressions in dice.py
     Also understands aliases, for example:
     <bob> {battleaxe 1d20+3} => rolls 1d20+3, and remembers that bob's
         alias {battleaxe} is 1d20+3
     When defining an alias, the dice expression must not contain spaces
     """
     result = alias.resolve(user, exp)
     if result is not None:
         response = '%s, you rolled: %s' % (user, result)
         self.msg(channel, response)