+ elif isinstance(obj, tables.Type):
+ reply_template = u"""{name}, a type. """
+
+ offensive_reply_factors = {
+ 200: u'\x03092×\x0f',
+ 50: u'\x0304½×\x0f',
+ 0: u'\x03140×\x0f',
+ }
+
+ offensive_modifiers = {}
+ for matchup in obj.damage_efficacies:
+ if matchup.damage_factor != 100:
+ offensive_modifiers.setdefault(matchup.damage_factor, []) \
+ .append(matchup.target_type.name)
+ if offensive_modifiers:
+ reply_template += u"""{offensive_modifiers}. """
+ for factor in offensive_modifiers:
+ offensive_modifiers[factor] = u'{factor} against {types}'.format(
+ factor=offensive_reply_factors[factor],
+ types=', '.join(sorted(offensive_modifiers[factor]))
+ )
+
+ defensive_reply_factors = {
+ 200: u'\x03042×\x0f',
+ 50: u'\x0309½×\x0f',
+ 0: u'\x03110×\x0f',
+ }
+
+ defensive_modifiers = {}
+ for matchup in obj.target_efficacies:
+ if matchup.damage_factor != 100:
+ defensive_modifiers.setdefault(matchup.damage_factor, []) \
+ .append(matchup.damage_type.name)
+ if defensive_modifiers:
+ reply_template += u"""{defensive_modifiers}. """
+ for factor in defensive_modifiers:
+ defensive_modifiers[factor] = u'{factor} from {types}'.format(
+ factor=defensive_reply_factors[factor],
+ types=', '.join(sorted(defensive_modifiers[factor]))
+ )
+
+ reply_template += u"""http://veekun.com/dex/types/{link_name}"""
+
+ self._reply(irc, reply_template.format(
+ name=obj.name.capitalize(),
+ offensive_modifiers='; '.join(offensive_modifiers[_]
+ for _ in sorted(offensive_modifiers)),
+ defensive_modifiers='; '.join(defensive_modifiers[_]
+ for _ in sorted(defensive_modifiers)),
+ link_name=urllib.quote(obj.name.lower().encode('utf8')),