50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
from abc import ABC, abstractmethod
|
|
from typing import override
|
|
|
|
class Unit(ABC):
|
|
def __init__(self, strength, dexterity, constitution, wisdom, intelligence, charisma):
|
|
self.strength = strength
|
|
self.dexterity = dexterity
|
|
self.constitution = constitution
|
|
self.wisdom = wisdom
|
|
self.intelligence = intelligence
|
|
self.charisma = charisma
|
|
|
|
@abstractmethod
|
|
def calculate_max_health(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def calculate_damage(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def calculate_defense(self):
|
|
pass
|
|
|
|
|
|
class Monster(Unit):
|
|
@override
|
|
def calculate_damage(self):
|
|
return self.strength * 2 + self.constitution / 5
|
|
|
|
@override
|
|
def calculate_max_health(self):
|
|
return self.constitution * 8 + self.strength / 3
|
|
|
|
@override
|
|
def calculate_defense(self):
|
|
return self.constitution * 1.2 + self.strength / 5
|
|
|
|
class Character(Unit):
|
|
@override
|
|
def calculate_max_health(self):
|
|
return self.constitution * 10 + self.strength / 2
|
|
|
|
@override
|
|
def calculate_damage(self):
|
|
return self.strength * 1.5 + self.dexterity / 4
|
|
|
|
@override
|
|
def calculate_defense(self):
|
|
return self.constitution * 1.5 + self.dexterity / 3
|