feature: der Mech kann springen

This commit is contained in:
2026-07-23 20:34:24 +02:00
parent 39f6e090d6
commit e5bbb8bd9f
8 changed files with 260 additions and 133 deletions
+14 -15
View File
@@ -1,17 +1,16 @@
from typing import Any
from mech_factory.store import InnerAmorStore
from mech_factory.component_storage import AreaNames, InnerStructure
from mech_factory.component_storage.items import BigItem
class Watcher:
def __init__(self, tonnage: float):
def __init__(self, tonnage: float, inner_armor_store: InnerAmorStore):
self._tonnage = tonnage
self._weight_watcher = WeightWatcher(tonnage)
self._amor_watcher = ArmorWatcher()
self._amor_watcher = ArmorWatcher(inner_armor_store)
def add_item(self, item: Any) -> Any:
if isinstance(item, InnerStructure):
self._amor_watcher.set_inner_structure(item)
return self._weight_watcher.add_item(item)
@property
@@ -27,8 +26,8 @@ class Watcher:
class ArmorWatcher:
def __init__(self):
self._inner_structure = None
def __init__(self, inner_armor_store: InnerAmorStore):
self._inner_armor_store = inner_armor_store
self._areas = {}
@property
@@ -38,15 +37,15 @@ class ArmorWatcher:
raise ValueError('Armor is not valid')
return actual_armor / 16
def set_inner_structure(self, inner_structure: InnerStructure):
self._inner_structure = inner_structure
def add_armor(self, area: AreaNames, armor: int):
max_armor = self._inner_structure.areas[area].armor * 2
if area is AreaNames.HEAD and armor > 9:
raise ValueError(AreaNames.HEAD.name + 'Armor cannot be greater than 9')
elif armor > max_armor:
raise ValueError(AreaNames.HEAD.name + 'Armor cannot be greater than ' + str(max_armor))
match area:
case AreaNames.HEAD:
if armor > 9:
raise ValueError(AreaNames.HEAD.name + 'Armor cannot be greater than 9')
case _:
max_armor = self._inner_armor_store.get_armor_for_area(area) * 2
if armor > max_armor:
raise ValueError(AreaNames.HEAD.name + 'Armor cannot be greater than ' + str(max_armor))
self._areas[area] = armor
class WeightWatcher:
@@ -62,7 +61,7 @@ class WeightWatcher:
def add_item(self, item: Any) -> Any:
if isinstance(item, BigItem):
self._items[item] = item.tonnage
if isinstance(item, InnerStructure):
elif isinstance(item, InnerStructure):
self._items[item] = item.tonnage
return item