feat(armor): add Loot 2.0 decay mechanics to armor_system.py
- Linear decay per damage point (0.05 PEC per HP) - Plate only decays for damage it actually absorbs - Added block_chance support for upgraded plates - Improved documentation
This commit is contained in:
parent
66f36b4a89
commit
5b4a8f07ea
|
|
@ -127,34 +127,58 @@ class ArmorPlate:
|
|||
"""
|
||||
Armor plating that attaches to armor pieces.
|
||||
Plates act as a shield layer - they take damage FIRST.
|
||||
|
||||
Loot 2.0 Mechanics (June 2017):
|
||||
- Plate decay is LINEAR per damage point absorbed
|
||||
- Base economy: 20 hp/pec (0.05 pec per hp)
|
||||
- Plate decays ONLY for damage it actually absorbs
|
||||
"""
|
||||
name: str
|
||||
item_id: str
|
||||
decay_per_hit: Decimal # Decay in PEC per hit absorbed
|
||||
decay_per_hp: Decimal # Decay in PEC per HP absorbed (typically ~0.05 for 20 hp/pec)
|
||||
protection: ProtectionProfile = field(default_factory=ProtectionProfile)
|
||||
durability: int = 10000 # Plate durability (hits it can take)
|
||||
block_chance: Decimal = Decimal("0") # Chance to nullify hit completely (no decay)
|
||||
|
||||
# Loot 2.0: Economy standard is 20 hp/pec = 0.05 pec/hp
|
||||
DEFAULT_ECONOMY: Decimal = Decimal("0.05") # 20 hp per pec
|
||||
|
||||
def get_total_protection(self) -> Decimal:
|
||||
"""Get total protection value."""
|
||||
return self.protection.get_total()
|
||||
|
||||
def get_decay_for_hit(self, damage_absorbed: Decimal) -> Decimal:
|
||||
def get_decay_for_damage(self, damage_absorbed: Decimal) -> Decimal:
|
||||
"""
|
||||
Calculate decay for absorbing damage.
|
||||
In Entropia: Plate decay = base_decay + (damage_absorbed * decay_factor)
|
||||
Simplified: Fixed decay per hit when plate absorbs damage.
|
||||
|
||||
Loot 2.0 Formula:
|
||||
- Decay is LINEAR per damage point
|
||||
- Plate only decays for damage it ACTUALLY absorbs
|
||||
- Base: 20 hp/pec = 0.05 pec per hp absorbed
|
||||
|
||||
Args:
|
||||
damage_absorbed: Amount of damage the plate actually absorbed
|
||||
|
||||
Returns:
|
||||
Decay in PEC
|
||||
"""
|
||||
# Base decay plus a small amount per damage point
|
||||
return self.decay_per_hit + (damage_absorbed * Decimal("0.001"))
|
||||
if damage_absorbed <= 0:
|
||||
return Decimal("0")
|
||||
return damage_absorbed * self.decay_per_hp
|
||||
|
||||
def get_effective_protection(self, damage_type: str) -> Decimal:
|
||||
"""Get protection value for a specific damage type."""
|
||||
return self.protection.get_effective_against(damage_type)
|
||||
|
||||
def to_dict(self) -> Dict:
|
||||
"""Convert to dictionary."""
|
||||
return {
|
||||
'name': self.name,
|
||||
'item_id': self.item_id,
|
||||
'decay_per_hit': str(self.decay_per_hit),
|
||||
'decay_per_hp': str(self.decay_per_hp),
|
||||
'protection': self.protection.to_dict(),
|
||||
'durability': self.durability,
|
||||
'block_chance': str(self.block_chance),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
@ -163,9 +187,10 @@ class ArmorPlate:
|
|||
return cls(
|
||||
name=data['name'],
|
||||
item_id=data['item_id'],
|
||||
decay_per_hit=Decimal(data['decay_per_hit']),
|
||||
decay_per_hp=Decimal(data['decay_per_hp']),
|
||||
protection=ProtectionProfile.from_dict(data.get('protection', {})),
|
||||
durability=data.get('durability', 10000),
|
||||
block_chance=Decimal(data.get('block_chance', '0')),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue