feature: zentralisiere die Bauteile-Ausgabe
This commit is contained in:
+26
-36
@@ -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:
|
||||
|
||||
+11
-17
@@ -1,15 +1,13 @@
|
||||
import csv
|
||||
import os.path
|
||||
|
||||
from mech_factory import AreaNames
|
||||
|
||||
|
||||
# noinspection SpellCheckingInspection
|
||||
class CsvDialect (csv.Dialect):
|
||||
lineterminator='\r\n'
|
||||
class CsvDialect(csv.Dialect):
|
||||
lineterminator = '\r\n'
|
||||
delimiter = ','
|
||||
quotechar = '"'
|
||||
quoting=csv.QUOTE_NONNUMERIC
|
||||
quoting = csv.QUOTE_NONNUMERIC
|
||||
|
||||
|
||||
class ComponentReader:
|
||||
@@ -38,15 +36,11 @@ class ComponentReader:
|
||||
def reactor_tonnage_from(self, reactor_value: int) -> float:
|
||||
return float(self._reactor_data.get(reactor_value, {}).get('Tonnage', 0.0))
|
||||
|
||||
def inner_amor_for_tonnage_and_area(self, tonnage: float, area: AreaNames) -> int:
|
||||
match area:
|
||||
case AreaNames.HEAD:
|
||||
return 3
|
||||
case AreaNames.MIDDLE_TORSO:
|
||||
return int(self._inner_structure_data.get(tonnage, {}).get('TorsoMitte', 0))
|
||||
case AreaNames.RIGHT_TORSO | AreaNames.LEFT_TORSO:
|
||||
return int(self._inner_structure_data.get(tonnage, {}).get('TorsoSeite', 0))
|
||||
case AreaNames.RIGHT_ARM | AreaNames.LEFT_ARM:
|
||||
return int(self._inner_structure_data.get(tonnage, {}).get('Arm', 0))
|
||||
case AreaNames.RIGHT_LEG | AreaNames.LEFT_LEG:
|
||||
return int(self._inner_structure_data.get(tonnage, {}).get('Bein', 0))
|
||||
def inner_amor_for_tonnage(self, tonnage: float) -> dict[str, int]:
|
||||
return {
|
||||
'head': 3,
|
||||
'middle_torso': int(self._inner_structure_data.get(tonnage, {}).get('TorsoMitte', 0)),
|
||||
'side_torso': int(self._inner_structure_data.get(tonnage, {}).get('TorsoSeite', 0)),
|
||||
'arm': int(self._inner_structure_data.get(tonnage, {}).get('Arm', 0)),
|
||||
'leg': int(self._inner_structure_data.get(tonnage, {}).get('Bein', 0)),
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
from mech_factory import InnerStructure, Joint, Sustainment
|
||||
from mech_factory.component_storage.items import Activator, Cockpit, Gyroskope, Reaktor, Sensors
|
||||
from mech_factory.reader import ComponentReader
|
||||
|
||||
|
||||
class ComponentStore(object):
|
||||
def __init__(self, tonnage: float, movement_rate: int):
|
||||
self.__components_reader = ComponentReader()
|
||||
self.__tonnage = tonnage
|
||||
self.__reactor_value = int(movement_rate * tonnage)
|
||||
|
||||
def get_reaktor(self) -> Reaktor:
|
||||
return Reaktor(self.__reactor_value, self.__components_reader.reactor_tonnage_from(self.__reactor_value))
|
||||
|
||||
def get_gyroskope(self) -> Gyroskope:
|
||||
return Gyroskope(float(round(self.__reactor_value / 100)))
|
||||
|
||||
def get_inner_structure(self) -> InnerStructure:
|
||||
gyroscope = self.get_gyroskope()
|
||||
return InnerStructure(self.__components_reader.inner_structure_from(self.__tonnage), gyroscope)
|
||||
|
||||
|
||||
# noinspection PyMethodMayBeStatic
|
||||
class ItemStore(object):
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def get_cockpit(self) -> Cockpit:
|
||||
return Cockpit()
|
||||
|
||||
def get_sustainment(self) -> Sustainment:
|
||||
return Sustainment()
|
||||
|
||||
def get_sensors(self) -> Sensors:
|
||||
return Sensors()
|
||||
|
||||
def get_joint(self) -> Joint:
|
||||
return Joint()
|
||||
|
||||
def get_activator(self) -> Activator:
|
||||
return Activator()
|
||||
|
||||
|
||||
class InnerAmorStore:
|
||||
|
||||
def __init__(self, tonnage: float):
|
||||
self.__inner_structure_data = ComponentReader().inner_amor_for_tonnage(tonnage)
|
||||
|
||||
def get_head_amor(self) -> int:
|
||||
return self.__inner_structure_data['head']
|
||||
|
||||
def get_middle_torso_amor(self) -> int:
|
||||
return self.__inner_structure_data['middle_torso']
|
||||
|
||||
def get_side_torso_amor(self) -> int:
|
||||
return self.__inner_structure_data['side_torso']
|
||||
|
||||
def get_arm_amore(self) -> int:
|
||||
return self.__inner_structure_data['arm']
|
||||
|
||||
def get_leg_amore(self) -> int:
|
||||
return self.__inner_structure_data['leg']
|
||||
Reference in New Issue
Block a user