from django import template
from django.template.defaultfilters import stringfilter

register = template.Library()


@register.filter
@stringfilter
def pretty_stat(value):
    stat = value.split('.')
    parts = []
    for s in stat:
        s = s.replace('minecraft:', '')
        for part in s.split('_'):
            if part.lower() == 'custom':
                continue
            parts.append(part.title())
    return ' '.join(parts)


@register.filter
def pretty_score(value):
    return '{:,}'.format(value)
