コード例 #1
0
ファイル: game_lib.py プロジェクト: vilhelm/hypebot
    def _ComputeReforgedRuneCard(self, rune):
        # Make runes more dank.
        rune_name = util_lib.Dankify(rune.name)
        tooltip = util_lib.Dankify(rune.long_desc)
        var_table = client_vars.REFORGED_RUNE_VARS.get(rune.key, {})
        tooltip = re.sub(
            r'@.+?@',
            lambda match: var_table.get(match.group(0), r'¯\_(ツ)_/¯'), tooltip)
        slot = self._reforged_rune_slot[rune.key]
        path_description = '{} {}'.format(
            rune.rune_path_name,
            'Keystone' if slot == 0 else 'Tier {}'.format(slot))

        rune_strs = []

        rune_strs.append('{}: {}'.format(rune_name, path_description))

        tooltip_strs = []
        for line in tooltip.split('<br>'):
            if line:
                line = re.sub(r'<.+?>', '', line)
                tooltip_strs += self._CleanChampionWrap(line)
        rune_strs += tooltip_strs

        return rune_strs
コード例 #2
0
ファイル: game_lib.py プロジェクト: vilhelm/hypebot
    def _ComputeChampSkillCard(self, champ, skill_button):
        """Computes given skill for a given champion."""
        skill_button = skill_button.upper()

        skill = self.GetChampSkill(champ, skill_button)
        if skill is None:
            return 'Invalid skill name.'

        # Make skills more dank.
        skill_name = util_lib.Dankify(skill.name)
        tooltip = util_lib.Dankify(skill.sanitized_tooltip)

        skill_title = '{} {}: {}'.format(champ.name, skill_button, skill_name)
        skill_strs = []
        skill_strs.append(skill_title)

        skill_range = skill.range_burn
        if skill_range != 'self':
            skill_strs.append('Range: {}'.format(skill_range))

        resource = skill.resource
        if resource:
            cost = self._FillinSkillDescription(resource, skill)
            skill_strs.append('Cost: {}'.format(cost))

        skill_strs.append('CD: {}'.format(skill.cooldown_burn))

        skill_text = self._FillinSkillDescription(tooltip, skill)

        skill_info = ['; '.join(skill_strs)]
        # this description is sometimes too long.
        # split it into multiple lines if necessary.
        skill_info += self._CleanChampionWrap(skill_text)
        return skill_info
コード例 #3
0
ファイル: game_lib.py プロジェクト: vilhelm/hypebot
    def _ComputeChampPassiveCard(self, champ):
        passive = champ.passive

        # Make passives more dank.
        passive_name = util_lib.Dankify(passive.name)
        tooltip = util_lib.Dankify(passive.sanitized_description)

        passive_strs = []

        passive_title = '{} Passive: {}'.format(champ.name, passive_name)
        passive_strs.append(passive_title)
        passive_strs.append(tooltip)
        return '; '.join(passive_strs)
コード例 #4
0
    def __init__(self, alias_map, name_map, display_names=None, dankify=False):
        """NameComplete constructor.

    Args:
      alias_map: Map String->String of alias (nickname) to canonical name.
      name_map: Map String->Thing of canonical name to thing.
      display_names: (optional) Iterable of Strings. A list of display names.
        Every word of a display name will be used to map to the canonical name,
        as long as the word is unique among the list.
      dankify: Whether to make all things dank.
    """
        self._alias_to_name = {
            util_lib.CanonicalizeName(alias): util_lib.CanonicalizeName(name)
            for alias, name in alias_map.items()
        }
        self._name_to_thing = {
            util_lib.CanonicalizeName(name): thing
            for name, thing in name_map.items()
        }
        aliases_from_display_names = self._GetAliasesFromDisplayNames(
            display_names)
        for alias, name in aliases_from_display_names.items():
            self._alias_to_name[alias] = name
        if dankify:
            for alias, name in list(self._alias_to_name.items()):
                dank_alias = util_lib.Dankify(alias)
                if alias != dank_alias:
                    self._alias_to_name[dank_alias] = name
        self._possible_things = sorted(
            list(self._alias_to_name.keys()) + list(name_map.keys()))
コード例 #5
0
  def _ComputeChampPassiveCard(self, champ):
    passive = champ.passive

    # Make passives more dank.
    tooltip = util_lib.Dankify(self._Sanitize(passive.description))

    return message_pb2.Card(
        header={
            'title': util_lib.Dankify(passive.name),
            'subtitle': '{} Passive'.format(champ.name),
            'image': {
                'url': self.GetImageUrl('passive', passive.image.full),
            },
        },
        fields=[{
            'text': tooltip
        }])
コード例 #6
0
  def _ComputeChampSkillCard(self, champ, skill_button):
    """Computes given skill for a given champion."""
    skill_button = skill_button.upper()

    skill = self.GetChampSkill(champ, skill_button)
    if skill is None:
      return 'Invalid skill name.'

    # Make skills more dank.
    skill_name = util_lib.Dankify(skill.name)
    tooltip = util_lib.Dankify(self._Sanitize(skill.tooltip))

    skill_strs = []
    skill_strs.append('{} {}: {}'.format(champ.name, skill_button, skill_name))
    card = message_pb2.Card(
        header={
            'title': skill_name,
            'subtitle': '{} {}'.format(champ.name, skill_button),
            'image': {
                'url': self.GetImageUrl('spell', skill.image.full),
            },
        })

    skill_range = skill.range_burn
    if skill_range != 'self':
      skill_strs.append('Range: {}'.format(skill_range))
      card.fields.add(title='Range', text='{}'.format(skill_range))

    resource = skill.resource
    if resource:
      cost = self._FillinSkillDescription(resource, skill)
      skill_strs.append('Cost: {}'.format(cost))
      card.fields.add(title='Cost', text=cost)

    skill_strs.append('CD: {}'.format(skill.cooldown_burn))
    card.fields.add(title='Cooldown', text='{}'.format(skill.cooldown_burn))

    skill_text = self._FillinSkillDescription(tooltip, skill)
    card.fields.add(text=skill_text)

    skill_info = [u'; '.join(skill_strs)]
    # this description is sometimes too long.
    # split it into multiple lines if necessary.
    skill_info += self._CleanChampionWrap(skill_text)
    return message_pb2.Message(text=skill_info, card=card)