173 lines
3.6 KiB
Python
Executable File
173 lines
3.6 KiB
Python
Executable File
import enum
|
|
from typing import Any
|
|
|
|
|
|
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
|
|
CRITICAL_STRIKE = 1
|
|
DESTROYED = 2
|
|
|
|
|
|
class ItemTypes(enum.Enum):
|
|
COCKPIT = 1
|
|
REAKTOR = 2
|
|
GYROSKOPE = 3
|
|
ACTIVATOR = 4
|
|
JOINT = 5
|
|
SENSORS = 6
|
|
SUSTAINMENT = 7
|
|
|
|
|
|
class Item(object):
|
|
def __init__(self, type: ItemTypes):
|
|
self._type = type
|
|
|
|
@property
|
|
def type(self):
|
|
return self._type
|
|
|
|
|
|
class BigItem(Item):
|
|
|
|
def __init__(self, type: ItemTypes, tonnage: float):
|
|
super().__init__(type)
|
|
self._tonnage = tonnage
|
|
|
|
@property
|
|
def tonnage(self) -> float:
|
|
return self._tonnage
|
|
|
|
|
|
class Cockpit(BigItem):
|
|
def __init__(self):
|
|
super().__init__(ItemTypes.COCKPIT, 3.0)
|
|
|
|
|
|
class Reaktor(BigItem):
|
|
|
|
def __init__(self, value: int, tonnage: float):
|
|
super().__init__(ItemTypes.REAKTOR, tonnage)
|
|
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(Item):
|
|
def __init__(self):
|
|
super().__init__(ItemTypes.SENSORS)
|
|
|
|
|
|
class Sustainment(Item):
|
|
def __init__(self):
|
|
super().__init__(ItemTypes.SUSTAINMENT)
|
|
|
|
|
|
class Area:
|
|
_content: dict[str, Any]
|
|
|
|
def __init__(self):
|
|
self.__dict__['_content'] = {
|
|
'children': [],
|
|
'items': {},
|
|
'armor': 0,
|
|
}
|
|
|
|
def __setattr__(self, key, value):
|
|
self.__dict__['_content'][key] = value
|
|
|
|
def __getattr__(self, item):
|
|
return self.__dict__['_content'].get(item)
|
|
|
|
|
|
class Gyroskope:
|
|
def __init__(self, tonnage: float):
|
|
self._tonnage = tonnage
|
|
|
|
@property
|
|
def tonnage(self) -> float:
|
|
return self._tonnage
|
|
|
|
|
|
class InnerStructure:
|
|
|
|
def __init__(self, tonnage: float, gyroskope: Gyroskope):
|
|
self._gyroskope = gyroskope
|
|
self._tonnage = tonnage
|
|
self._areas = dict()
|
|
|
|
@property
|
|
def tonnage(self) -> float:
|
|
return self._tonnage
|
|
|
|
@property
|
|
def gyroskope(self) -> Gyroskope:
|
|
return self._gyroskope
|
|
|
|
@property
|
|
def areas(self) -> dict:
|
|
return self._areas
|
|
|
|
def add_area(self, index: AreaNames, area: Area):
|
|
self._areas[index] = area
|
|
|
|
|
|
class Mech(object):
|
|
|
|
def __init__(self, name: str, tonnage: float, movement_rate: int, inner_structure: InnerStructure):
|
|
self._movement_rate = movement_rate
|
|
self._tonnage = tonnage
|
|
self._name = name
|
|
self._inner_structure = inner_structure
|
|
|
|
@property
|
|
def name(self) -> str:
|
|
return self._name
|
|
|
|
@property
|
|
def tonnage(self) -> float:
|
|
return self._tonnage
|
|
|
|
@property
|
|
def inner_structure(self) -> InnerStructure:
|
|
return self._inner_structure
|
|
|
|
@property
|
|
def movement_rate(self) -> int:
|
|
return self._movement_rate
|
|
|
|
def set_item(self, key: tuple, item: Item):
|
|
pass
|
|
|
|
def strike(self, area_name, hits: int):
|
|
area = self._inner_structure.areas.get(area_name)
|
|
if area.armor > hits:
|
|
area.armor -= hits
|
|
return
|
|
hits_rest = hits - area.armor
|
|
if area.inner_armor > hits_rest:
|
|
area.inner_armor -= hits_rest
|
|
area.armor = 0
|