106 lines
2.2 KiB
Python
106 lines
2.2 KiB
Python
import enum
|
|
|
|
|
|
class ItemTypes(enum.Enum):
|
|
COCKPIT = 1
|
|
REAKTOR = 2
|
|
GYROSKOPE = 3
|
|
ACTIVATOR = 4
|
|
JOINT = 5
|
|
SENSORS = 6
|
|
SUSTAINMENT = 7
|
|
|
|
|
|
class ItemStatus(enum.Flag):
|
|
FINE = 0
|
|
DAMAGED = 1
|
|
DESTROYED = 2
|
|
|
|
|
|
class Item(object):
|
|
def __init__(self, item_type: ItemTypes, **another: dict):
|
|
self._type = item_type
|
|
self._state = ItemStatus.FINE
|
|
|
|
@property
|
|
def type(self):
|
|
return self._type
|
|
|
|
@property
|
|
def state(self):
|
|
return self._state
|
|
|
|
@state.setter
|
|
def state(self, new_state: ItemStatus):
|
|
self._state = new_state
|
|
|
|
def process_strike(self):
|
|
self._state = ItemStatus.DESTROYED
|
|
|
|
|
|
class BigItem(Item):
|
|
|
|
def __init__(self, item_type: ItemTypes, tonnage: float, **another: dict):
|
|
super().__init__(item_type, **another)
|
|
self._tonnage = tonnage
|
|
|
|
@property
|
|
def tonnage(self) -> float:
|
|
return self._tonnage
|
|
|
|
|
|
class DurableItem(Item):
|
|
|
|
def __init__(self, item_type: ItemTypes, max_strike: int, **another):
|
|
super().__init__(item_type)
|
|
self._max_strike = max_strike
|
|
|
|
@property
|
|
def max_strike(self):
|
|
return self._max_strike
|
|
|
|
def process_strike(self):
|
|
self._max_strike -= 1
|
|
self._state = ItemStatus.DAMAGED if self._max_strike > 0 else ItemStatus.DESTROYED
|
|
|
|
|
|
class Gyroskope(BigItem, DurableItem):
|
|
def __init__(self, tonnage: float):
|
|
super().__init__(item_type = ItemTypes.GYROSKOPE, tonnage=tonnage, max_strike=2)
|
|
|
|
|
|
class Cockpit(BigItem):
|
|
def __init__(self):
|
|
super().__init__(ItemTypes.COCKPIT, 3.0)
|
|
|
|
|
|
class Reaktor(BigItem, DurableItem):
|
|
|
|
def __init__(self, value: int, tonnage: float):
|
|
super().__init__(item_type = ItemTypes.REAKTOR, tonnage=tonnage, max_strike=3)
|
|
self._value = value
|
|
|
|
@property
|
|
def value(self):
|
|
return self._value
|
|
|
|
|
|
class Activator(Item):
|
|
def __init__(self):
|
|
super().__init__(ItemTypes.ACTIVATOR)
|
|
|
|
|
|
class Joint(Item):
|
|
def __init__(self):
|
|
super().__init__(ItemTypes.JOINT)
|
|
|
|
|
|
class Sensors(DurableItem):
|
|
def __init__(self):
|
|
super().__init__(ItemTypes.SENSORS, 2)
|
|
|
|
|
|
class Sustainment(Item):
|
|
def __init__(self):
|
|
super().__init__(ItemTypes.SUSTAINMENT)
|