feature: zentralisiere die Bauteile-Ausgabe

This commit is contained in:
2026-07-10 20:36:59 +02:00
parent e4ed45e2fb
commit af2d943094
4 changed files with 102 additions and 55 deletions
+26 -36
View File
@@ -1,13 +1,12 @@
from hangar.mech import Mech
from mech_factory.component_storage import InnerStructure, Area, AreaNames, OuterAmor, ZoneNames
from mech_factory.component_storage.items import Activator, Cockpit, Gyroskope, Joint, Reaktor, Sensors, Sustainment
from mech_factory.reader import ComponentReader
from mech_factory.store import ItemStore, ComponentStore, InnerAmorStore
class MechFabrik(object):
def __init__(self, name: str, tonnage: float, movement_rate: int):
self.__components = ComponentReader()
self.__tonnage = tonnage
self.__reactor_value = int(movement_rate * tonnage)
self.__areas = {
@@ -33,26 +32,24 @@ class MechFabrik(object):
ZoneNames.LEFT_LEG: OuterAmor(self.__areas[AreaNames.LEFT_LEG]),
ZoneNames.RIGHT_LEG: OuterAmor(self.__areas[AreaNames.RIGHT_LEG]),
}
self.__build_inner_structure(tonnage, movement_rate)
self._item_store = ItemStore()
self._component_store = ComponentStore(tonnage, movement_rate)
self._inner_amor_store = InnerAmorStore(tonnage)
self._inner_structure = self._component_store.get_inner_structure()
self.__build_head_area()
self.__build_middle_torso_area(self._inner_structure.gyroskope)
self._mech = Mech(name, tonnage, movement_rate, self._inner_structure)
def __build_inner_structure(self, tonnage: float, movement_rate: int) -> None:
reactor_value = int(movement_rate * tonnage)
gyroscope = Gyroskope(float(round(reactor_value / 100)))
self._inner_structure = InnerStructure(self.__components.inner_structure_from(tonnage), gyroscope)
self.__build_head_area()
self.__build_middle_torso_area(gyroscope)
def __build_head_area(self) -> None:
cockpit = Cockpit()
cockpit = self._item_store.get_cockpit()
self.__areas[AreaNames.HEAD].cockpit = cockpit
self.__areas[AreaNames.HEAD].items = {
(1, 1): Sustainment(),
(1, 2): Sensors(),
(1, 1): self._item_store.get_sustainment(),
(1, 2): self._item_store.get_sensors(),
(1, 3): cockpit,
(1, 4): None,
(1, 5): Sensors(),
(1, 6): Sustainment(),
(1, 5): self._item_store.get_sensors(),
(1, 6): self._item_store.get_sustainment(),
}
self.__areas[AreaNames.HEAD].armor = 3
self.__areas[AreaNames.HEAD].parent = self.__areas[AreaNames.MIDDLE_TORSO]
@@ -60,7 +57,7 @@ class MechFabrik(object):
def __build_middle_torso_area(self, gyroscope: Gyroskope) -> None:
self.__areas[AreaNames.LEFT_TORSO].parent = self.__areas[AreaNames.MIDDLE_TORSO]
self.__areas[AreaNames.RIGHT_TORSO].parent = self.__areas[AreaNames.MIDDLE_TORSO]
reactor = Reaktor(self.__reactor_value, self.__components.reactor_tonnage_from(self.__reactor_value))
reactor = self._component_store.get_reaktor()
self.__areas[AreaNames.MIDDLE_TORSO].reactor = reactor
self.__areas[AreaNames.MIDDLE_TORSO].children = [
self.__areas[AreaNames.RIGHT_TORSO],
@@ -80,16 +77,9 @@ class MechFabrik(object):
(2, 5): None,
(2, 6): None,
}
self.__areas[AreaNames.MIDDLE_TORSO].armor = self.__components.inner_amor_for_tonnage_and_area(
self.__tonnage,
AreaNames.MIDDLE_TORSO
)
self.__areas[AreaNames.LEFT_TORSO].armor = self.__components.inner_amor_for_tonnage_and_area(
self.__tonnage, AreaNames.LEFT_TORSO)
self.__areas[AreaNames.RIGHT_TORSO].armor = self.__components.inner_amor_for_tonnage_and_area(
self.__tonnage,
AreaNames.RIGHT_TORSO
)
self.__areas[AreaNames.MIDDLE_TORSO].armor = self._inner_amor_store.get_middle_torso_amor()
self.__areas[AreaNames.LEFT_TORSO].armor = self._inner_amor_store.get_side_torso_amor()
self.__areas[AreaNames.RIGHT_TORSO].armor = self._inner_amor_store.get_side_torso_amor()
self.__build_arm(self.__areas[AreaNames.RIGHT_TORSO], AreaNames.RIGHT_ARM)
self.__build_leg(self.__areas[AreaNames.RIGHT_TORSO], AreaNames.RIGHT_LEG)
self.__build_arm(self.__areas[AreaNames.LEFT_TORSO], AreaNames.LEFT_ARM)
@@ -98,10 +88,10 @@ class MechFabrik(object):
def __build_arm(self, parent: Area, index: AreaNames):
self.__areas[index].parent = parent
self.__areas[index].items = {
(1, 1): Joint(),
(1, 2): Activator(),
(1, 3): Activator(),
(1, 4): Activator(),
(1, 1): self._item_store.get_joint(),
(1, 2): self._item_store.get_activator(),
(1, 3): self._item_store.get_activator(),
(1, 4): self._item_store.get_activator(),
(1, 5): None,
(1, 6): None,
(2, 1): None,
@@ -111,20 +101,20 @@ class MechFabrik(object):
(2, 5): None,
(2, 6): None,
}
self.__areas[index].armor = self.__components.inner_amor_for_tonnage_and_area(self.__tonnage, index)
self.__areas[index].armor = self._inner_amor_store.get_arm_amore()
parent.children.append(self.__areas[index])
def __build_leg(self, parent: Area, index: AreaNames):
self.__areas[index].parent = parent
self.__areas[index].items = {
(1, 1): Joint(),
(1, 2): Activator(),
(1, 3): Activator(),
(1, 4): Activator(),
(1, 1): self._item_store.get_joint(),
(1, 2): self._item_store.get_activator(),
(1, 3): self._item_store.get_activator(),
(1, 4): self._item_store.get_activator(),
(1, 5): None,
(1, 6): None,
}
self.__areas[index].armor = self.__components.inner_amor_for_tonnage_and_area(self.__tonnage, index)
self.__areas[index].armor = self._inner_amor_store.get_leg_amore()
parent.children.append(self.__areas[index])
def auslieferung(self) -> Mech: