critical_striks #1
+7
-1
@@ -1,4 +1,4 @@
|
|||||||
from MechFabrik.bauteile import InnerStructure, Item, StrikeEvent, ZoneNames
|
from MechFabrik.bauteile import CriticalStrikeEvent, InnerStructure, Item, StrikeEvent, ZoneNames
|
||||||
|
|
||||||
|
|
||||||
class Mech(object):
|
class Mech(object):
|
||||||
@@ -33,3 +33,9 @@ class Mech(object):
|
|||||||
if zone is None:
|
if zone is None:
|
||||||
raise Exception(f"Zone {zone_name} not found")
|
raise Exception(f"Zone {zone_name} not found")
|
||||||
return StrikeEvent(zone, hits)
|
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)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import enum
|
import enum
|
||||||
|
|
||||||
from MechFabrik.bauteile.items import Item
|
from MechFabrik.bauteile.items import Item, ItemStatus
|
||||||
|
|
||||||
|
|
||||||
class ZoneNames(enum.Enum):
|
class ZoneNames(enum.Enum):
|
||||||
@@ -131,12 +131,34 @@ class InnerStructure:
|
|||||||
self._areas[index] = area
|
self._areas[index] = area
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def zones(self) -> dict[ZoneNames, Zone]:
|
def zones(self) -> dict[ZoneNames, OuterAmor]:
|
||||||
return self._zones
|
return self._zones
|
||||||
|
|
||||||
def add_zone(self, index: ZoneNames, zone: Zone):
|
def add_zone(self, index: ZoneNames, zone: OuterAmor):
|
||||||
self._zones[index] = zone
|
self._zones[index] = zone
|
||||||
|
|
||||||
|
|
||||||
class CriticalStrikeEvent:
|
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']
|
||||||
|
|||||||
Reference in New Issue
Block a user