


class Component:
    """The fundamental ship component blueprint.
    Component health states and stats will impact ship performance"""

    #not normally modified in any active engagement. represent component characteristics.
    class_dict = 'protection parent'
    total_health = 1 #health is tied directly to component performance
    total_hitpoints = 10 #hitpoints represent the damage state of the component. This value impacts health, though the impact
    #is modulated by other factors (e.g. subsystems, skills)
    component_size = 1 #used to control which components can fit into which ships
    component_weight = 1 #separate from size, this is used to control how many of a component/total components may fit onto one ship.
    #e.g. some components may only be able to be placed once and will have a value far exceeding some ship allowances


    def __init__(self, current_health=total_health, current_hitpoints=total_hitpoints, component_status=1):

        """These values may change over the course of a battle"""

        self.current_health = current_health
        self.current_hitpoints = current_hitpoints
        self.component_status = component_status

class Shields(Component):

    """Shields require energy and protect the armor/hull and components/subsystems from direct weapon damage.
    Once shields fail, armor and hull may start taking damage which will progressively affect component/subsystem health."""

    class_dict = "shield parent"

    def __init__(self):
        super().__init__()

    # Establish base capacitor requirement
    capacitor_threshold = 1
    # Drain the capacitor by this value after weapon fire at the end of the ship's combat round.
    capacitor_shield_use_drain = 1

    def capacitor_use(self,ship):
        #Check if capacitor has enough energy to run the shields
        if ship.capacitor<self.capacitor_threshold:
            self.component_status = 0


class LightShields(Shields):

    """Simple, lightly-powered shields with no bells or whistles."""

    def __init__(self):
        super().__init__()

    class_dict = {'identifier': 'light shields', 'power': Shields.total_hitpoints,
                  'capacitor drain': Shields.capacitor_shield_use_drain, 'capacitor threshold': Shields.capacitor_threshold,
                  'size': Shields.component_size, 'weight': Shields.component_weight}

class HeavyShields(Shields):

    """A stronger, more energy hungry version of the light shields."""

    def __init__(self):
        super().__init__()

    capacitor_threshold = 2

    class_dict = {'identifier': 'heavy shields', 'power': Shields.total_hitpoints,
                  'capacitor drain': Shields.capacitor_shield_use_drain, 'capacitor threshold': capacitor_threshold,
                  'size': Shields.component_size, 'weight':Shields.component_weight}


#######################------------------------------------------------------------#####################################

class Power(Component):

    """Power are components which provide energy and capacitor power for most ship components to function.
    Variations include PowerPlant, Capacitor."""

    def __init__(self):
        super().__init__()

class Capacitor(Power):

    """Capacitor: provides the immediate-use energy needed to activate components/weapons. Feeds on a larger storehouse
    of energy from the power plant."""

    def __init__(self):
        super().__init__()



class LightCapacitor(Capacitor):

    """A small capacitor capable of drawing limited power per activation."""

    def __init__(self):
        super().__init__()

    # establishes max capacitor draw per activation
    capacitor_draw = 10
    capacitor_recharge = 3

    class_dict = {'identifier': 'light capacitor', 'power': capacitor_draw,
                  'size': Capacitor.component_size, 'weight': Capacitor.component_weight, 'recharge':capacitor_recharge}

class PowerPlant(Power):

    """PowerPlant: generates and stores the vast energy reserves required for the ship to function, and from which
    the capacitor draws energy."""

    def __init__(self):
        super().__init__()

class SmallPowerPlant(Power):

    """Produces and stores a small amount of power. Recharge is slow."""

    def __init__(self):
        super().__init__()

    #The total amount of power capable of being stored
    power_storage = 50
    #The amount of power regenerated by the plant each round
    power_regeneration = 4

class Accuracy(Component):

    def __init__(self):
        super().__init__()

    total_hitpoints = 8

    class_dict = {'identifier': 'accuracy', 'power': total_hitpoints}

class Defense(Component):

    def __init__(self):
        super().__init__()

    class_dict = {'identifier': 'defense', 'power': Component.total_hitpoints}

powerplant = SmallPowerPlant()
# print('powerplant', powerplant.component_size)

class Engine(Component):

    def __init__(self):
        super().__init__()

    class_dict = {'identifier': 'engine', 'power': Component.total_hitpoints}



#######################------------------------------------------------------------#####################################

my_component_class_dict = {'shields':{'light shields':LightShields, 'heavy shields':HeavyShields},
                           'capacitor':{'light capacitor':LightCapacitor}, 'powerplant':{'small power plant':SmallPowerPlant},
                           'accuracy':{'light accuracy': Accuracy}, 'defense': {'light defense': Defense},
                           'mobility':{'light engine': Engine}}

# mytest = my_component_class_dict.get('light shields')
# workingtest = mytest.component_dict.get('capacitor threshold')
# print(mytest)
# print(workingtest)

lightshield = LightShields()
heavyshield = HeavyShields()
# print('light shield capacitor_threshold',lightshield.capacitor_threshold)
# print('heavy shield capacitor_threshold',heavyshield.capacitor_threshold)