refactor: spezifiziere das Bauteile-Lager
This commit is contained in:
Executable
+96
@@ -0,0 +1,96 @@
|
||||
import enum
|
||||
|
||||
from mech_factory.component_storage.items import Gyroskope, Item, ItemStatus
|
||||
|
||||
|
||||
class ZoneNames(enum.Enum):
|
||||
HEAD = 'Kopf'
|
||||
MIDDLE_TORSO_FRONT = 'Torso Mitte Vorn'
|
||||
MIDDLE_TORSO_REAR = 'Torso Mitte Rücken'
|
||||
RIGHT_TORSO_FRONT = 'Rechter Torso Vorn'
|
||||
RIGHT_TORSO_REAR = 'Rechter Torso Rücken'
|
||||
LEFT_TORSO_FRONT = 'Linker Torso Vorn'
|
||||
LEFT_TORSO_REAR = 'Linker Torso Rücken'
|
||||
RIGHT_LEG = 'Rechtes Bein'
|
||||
RIGHT_ARM = 'Rechter Arm'
|
||||
LEFT_LEG = 'Linkes Bein'
|
||||
LEFT_ARM = 'Linker Arm'
|
||||
|
||||
|
||||
class AreaNames(enum.Enum):
|
||||
HEAD = 'Kopf'
|
||||
MIDDLE_TORSO = 'Torso Mitte'
|
||||
RIGHT_TORSO = 'Rechter Torso'
|
||||
LEFT_TORSO = 'Linker Torso'
|
||||
RIGHT_LEG = 'Rechtes Bein'
|
||||
RIGHT_ARM = 'Rechter Arm'
|
||||
LEFT_LEG = 'Linkes Bein'
|
||||
LEFT_ARM = 'Linker Arm'
|
||||
|
||||
|
||||
class AreaStatus(enum.Flag):
|
||||
FINE = 0
|
||||
DAMAGED = 1
|
||||
DESTROYED = 2
|
||||
|
||||
|
||||
class Zone:
|
||||
|
||||
def __init__(self):
|
||||
self.__dict__['_armor'] = 0
|
||||
self.__dict__['_parent'] = None
|
||||
self.__dict__['_state'] = AreaStatus.FINE
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
self.__dict__['_' + key] = value
|
||||
|
||||
def __getattr__(self, item):
|
||||
return self.__dict__['_' + item]
|
||||
|
||||
|
||||
class Area(Zone):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.__dict__['_outer_amor'] = list()
|
||||
self.__dict__['_children'] = list()
|
||||
self.__dict__['_items'] = dict()
|
||||
|
||||
|
||||
class OuterAmor(Zone):
|
||||
|
||||
def __init__(self, area: Area):
|
||||
super().__init__()
|
||||
self.__dict__['_parent'] = area
|
||||
self.__dict__['_area'] = area
|
||||
|
||||
|
||||
class InnerStructure:
|
||||
|
||||
def __init__(self, tonnage: float, gyroskope: Gyroskope):
|
||||
self._gyroskope = gyroskope
|
||||
self._tonnage = tonnage
|
||||
self._areas = dict()
|
||||
self._zones = dict()
|
||||
|
||||
@property
|
||||
def tonnage(self) -> float:
|
||||
return self._tonnage
|
||||
|
||||
@property
|
||||
def gyroskope(self) -> Gyroskope:
|
||||
return self._gyroskope
|
||||
|
||||
@property
|
||||
def areas(self) -> dict[AreaNames, Area]:
|
||||
return self._areas
|
||||
|
||||
def add_area(self, index: AreaNames, area: Area):
|
||||
self._areas[index] = area
|
||||
|
||||
@property
|
||||
def zones(self) -> dict[ZoneNames, OuterAmor]:
|
||||
return self._zones
|
||||
|
||||
def add_zone(self, index: ZoneNames, zone: OuterAmor):
|
||||
self._zones[index] = zone
|
||||
@@ -0,0 +1,105 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user