critical_striks #1

Merged
TorstenHettstedt merged 10 commits from critical_striks into main 2026-07-12 17:36:07 +02:00
2 changed files with 33 additions and 5 deletions
Showing only changes of commit 0c985589a2 - Show all commits
+7 -1
View File
@@ -1,4 +1,4 @@
from MechFabrik.bauteile import InnerStructure, Item, StrikeEvent, ZoneNames
from MechFabrik.bauteile import CriticalStrikeEvent, InnerStructure, Item, StrikeEvent, ZoneNames
class Mech(object):
@@ -33,3 +33,9 @@ class Mech(object):
if zone is None:
raise Exception(f"Zone {zone_name} not found")
return StrikeEvent(zone, hits)
def critical_strike(self, zone_name: ZoneNames, index: tuple[int, int]) -> CriticalStrikeEvent:
zone = self._inner_structure.zones.get(zone_name)
if zone is None:
raise Exception(f"Zone {zone_name} not found")
return CriticalStrikeEvent(zone, index)
+26 -4
View File
@@ -1,6 +1,6 @@
import enum
from MechFabrik.bauteile.items import Item
from MechFabrik.bauteile.items import Item, ItemStatus
class ZoneNames(enum.Enum):
@@ -131,12 +131,34 @@ class InnerStructure:
self._areas[index] = area
@property
def zones(self) -> dict[ZoneNames, Zone]:
def zones(self) -> dict[ZoneNames, OuterAmor]:
return self._zones
def add_zone(self, index: ZoneNames, zone: Zone):
def add_zone(self, index: ZoneNames, zone: OuterAmor):
self._zones[index] = zone
class CriticalStrikeEvent:
pass
def __init__(self, zone: OuterAmor, index: tuple[int,int]):
self.__dict__['_zone'] = zone
self.__dict__['_area'] = zone.area
self.__dict__['_index'] = index
self.__dict__['_item_is_empty'] = None
@property
def area(self) -> Area:
return self.__dict__['_area']
def process_event(self) -> CriticalStrikeEvent:
self.__dict__['_zone'].state = AreaStatus.DAMAGED
self.__dict__['_area'].state = AreaStatus.DAMAGED
item = self.__dict__['_area'].items[self.__dict__['_index']]
if item is None:
self.__dict__['_item_is_empty'] = True
else:
self.__dict__['_item_is_empty'] = False
item.state = ItemStatus.DESTROYED
return self
def is_empty(self):
return self.__dict__['_item_is_empty']