Esempio n. 1
0
    def send_message_to_attacker(self, attacker_summaries):
        """
        Sends a summary of damage to whomever is responsible for dealing it.

            Args:
                attacker_summaries (list): List of strings that show victim and
                    the outcome of attack. When the resulting message is for an
                    attacker, strings are verbose with dice/damage numbers.

        Example for self.inflictor:
        'The trap springs! You inflict 30. Bob is harmed for critical damage, Bill is unharmed,
        and Jane is harmed for minor damage.'

        Example for self.attacker:
        'YOU attack Bob 32 vs 4: graze for minor damage (6), Jane -16 vs 4: parry,
        and Bill -32 vs 17: riposte for minor damage.'
        """
        if self.inflictor:
            self.inflictor.msg(
                "%s%sYou inflict %s. %s." % (
                    self.story,
                    self.story_spacer,
                    self.damage,
                    list_to_string(attacker_summaries),
                ),
                options={"roll": True},
            )
        elif self.attacker:
            self.attacker.msg(
                "YOU attack %s." % list_to_string(attacker_summaries),
                options={"roll": True},
            )
Esempio n. 2
0
 def vote_string(self):
     """Get string of any who have voted to end, and who still has to vote for combat to end"""
     mess = ""
     if self.ndb.votes_to_end:
         mess += "{wCurrently voting to end combat:{n %s\n" % list_to_string(
             self.ndb.votes_to_end)
         mess += "{wFor the fight to end, the following characters must also use +end_combat:{n "
         mess += "%s" % list_to_string(self.not_voted)
     return mess
Esempio n. 3
0
    def equip_or_remove(self, verb, item_list=None):
        """
        A list of items is worn, wielded, or removed from a character.

            Args:
                verb (str): the method to call
                item_list (list): objects we attempt to call method in

        Will try to call the method matching our verb for each list item. If no
        list is given, we build list from character contents. A message is
        crafted for success or exception (failure). Total success means results
        are messaged to self. Otherwise result is raised as an EquipError.
        """
        cscript = self.location.ndb.combat_manager
        if (cscript and cscript.ndb.phase != 1
                and cscript.check_character_is_combatant(self)):
            from typeclasses.scripts.combat.combat_settings import CombatError

            raise CombatError(
                "Equipment changes are only allowed in combat's setup phase.")
        if verb in ("wear", "sheathe"):
            alt = verb if verb == "sheathe" else "put on"
            verb = "wear"
        elif verb == "wield":
            alt = "brandish"
        else:
            verb, alt = "remove", "remove"
        if not item_list:
            item_list = self.get_item_list_to_equip(verb)
            if not item_list:
                raise EquipError("You have nothing to %s." % verb)
        successes, failures = [], []
        for item in item_list:
            try:
                getattr(item, verb)(self)
            except AttributeError:
                failures.append("%s |w(wrong item type)|n" % item)
            except EquipError as err:
                failures.append("%s |w(%s)|n" % (item, err))
            else:
                successes.append(str(item))
        msg = ""
        if failures:
            msg += "Could not %s %s.\n" % (
                alt, list_to_string(failures, endsep="or"))
        if successes:
            msg += "You %s %s." % (alt, list_to_string(successes))
        elif len(item_list
                 ) > 1:  # no successes and also multiple items attempted
            msg += "|yYou %s nothing.|n" % alt
        if failures:
            raise EquipError(msg)
        else:
            self.msg(msg)
Esempio n. 4
0
 def list_display(self):
     """A cached string simply listing outfit components & model info."""
     if not hasattr(self, '_cached_outfit_display'):
         from server.utils.arx_utils import list_to_string
         msg = "|w[|n" + str(self) + "|w]|n"
         weapons = list(self.weapons)
         apparel = list(self.apparel)
         if weapons:
             msg += " weapons: " + list_to_string(weapons)
         if apparel:
             msg += "\nattire: " + list_to_string(apparel)
         if self.modeled:
             msg += "\n" + self.model_info
             # TODO: Include existing event info :)
             # TODO: Include existing fashion judge votes & comments!
         self._cached_outfit_display = msg
     return self._cached_outfit_display
Esempio n. 5
0
 def get_initiative_list(self):
     """Displays who the acting character is and the remaining order"""
     acting_char = self.ndb.active_character
     msg = ""
     if acting_char:
         msg += "{wIt is {c%s's {wturn.{n " % acting_char.name
     if self.ndb.initiative_list:
         msg += "{wTurn order for remaining characters:{n %s" % list_to_string(
             self.ndb.initiative_list)
     return msg
Esempio n. 6
0
    def build_and_broadcast_story(self, attack_prefix, hits_and_misses):
        """
        Takes a dict of targets/outcomes of this attack & transform into a story.

            Args:
                attack_prefix (string): Introduces the attacker.
                hits_and_misses (dict): Each target's list of responses to attacks.

        Counts attacks against a target and groups the outcomes thereafter. Example:
        'Emerald attacks Bob 2 times (hit for major damage, parry), Jane (graze for no damage),
        and Bill (riposte for no damage).'
        """
        if not hits_and_misses:
            raise WalrusJudgement
        all_target_msgs = []
        for victim, list_of_attacks in hits_and_misses.items():
            msg = "{c%s{n" % victim
            if len(list_of_attacks) > 1:
                msg += " %s times" % len(list_of_attacks)
            msg += " (%s)" % list_to_string(list_of_attacks)
            all_target_msgs.append(msg)
        message = attack_prefix + list_to_string(all_target_msgs) + "."
        self.story = self.story_spacer + message
        self.send_story_to_combat()