from core.template import Substitute, Template

import siege.component


class Customization(Template):
    def __init__(self, name, group, sheetKey='', **kwargs):
        Template.__init__(self, name, **kwargs)
        self.add(siege.component.Customization(group, kwargs.get('canColor', True)))
        if 'visuals' not in kwargs:
            kwargs['visuals'] = [Substitute(sheetKey or group.lower())]
        self.setComponentVisuals(self.customization, kwargs['visuals'])
        self.customization.bodies = kwargs.get('bodyTypes', [])


class Hair(Customization):
    def __init__(self, name, **kwargs):
        Customization.__init__(self, name, "Hair", **kwargs)


class Shirt(Customization):
    def __init__(self, name, **kwargs):
        Customization.__init__(self, name, "Shirt", **kwargs)


class Pants(Customization):
    def __init__(self, name, **kwargs):
        Customization.__init__(self, name, "Pants", **kwargs)


class Shoes(Customization):
    def __init__(self, name, **kwargs):
        Customization.__init__(self, name, "Shoes", sheetKey='boot', **kwargs)


class Accessory(Customization):
    def __init__(self, name, slot=1, **kwargs):
        if 'visuals' not in kwargs:
            kwargs['visuals'] = [Substitute('accessory/{}.png'.format(slot))]
        Customization.__init__(self, name, "Accessory {}".format(slot), **kwargs)
