diff --git a/game.py b/game.py index 1f2c116..a333c94 100644 --- a/game.py +++ b/game.py @@ -2,28 +2,45 @@ 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 + def __init__(self, strength: float, dexterity: float, constitution: float, wisdom: float, intelligence: float, charisma: float): + self.strength: float = strength + self.dexterity: float = dexterity + self.constitution: float = constitution + self.wisdom: float = wisdom + self.intelligence: float = intelligence + self.charisma: float = charisma @abstractmethod - def calculate_max_health(self): + def calculate_max_health(self) -> float: pass @abstractmethod - def calculate_damage(self): + def calculate_damage(self) -> float: pass @abstractmethod - def calculate_defense(self): + def calculate_defense(self) -> float: pass +# class Spell(ABC): +# def __init__(self, name: str, damage: float, mana_cost: float): +# self.name: str = name +# self.damage: float = damage +# self.mana_cost: float = mana_cost + +# @abstractmethod +# def cast(self): +# pass + class Monster(Unit): + def __init__(self, strength: float, dexterity: float, constitution: float, wisdom: float, intelligence: float, charisma: float): + super().__init__(strength, dexterity, constitution, wisdom, intelligence, charisma) + self.max_health: float = self.calculate_max_health() + self.defense: float = self.calculate_max_health() + self.damage: float = self.calculate_damage() + + @override def calculate_damage(self): return self.strength * 2 + self.constitution / 5 @@ -36,15 +53,48 @@ class Monster(Unit): def calculate_defense(self): return self.constitution * 1.2 + self.strength / 5 + class Character(Unit): + def __init__(self, strength: float, dexterity: float, constitution: float, wisdom: float, intelligence: float, charisma: float, char_class: str): + super().__init__(strength, dexterity, constitution, wisdom, intelligence, charisma) + self.character_class: str = char_class + self.max_health: float = self.calculate_max_health() + self.defense: float = self.calculate_max_health() + self.damage: float = self.calculate_damage() + # self.max_mana: float = self.calculate_max_mana() + @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 + def calculate_damage(self) -> float: + if self.character_class == "warrior": + return self.strength * 2.2 + self.constitution / 3 + elif self.character_class == "mage": + return self.intelligence * 2.5 + self.wisdom / 2 + elif self.character_class == "hunter": + return self.dexterity * 1.9 + self.strength / 3 + else: + return 0 @override def calculate_defense(self): - return self.constitution * 1.5 + self.dexterity / 3 + if self.character_class == "warrior": + return self.constitution * 1.8 + self.strength / 4 + elif self.character_class == "mage": + return self.wisdom * 1.3 + self.intelligence / 6 + elif self.character_class == "hunter": + return self.dexterity * 1.6 + self.constitution / 5 + else: + return 0 + + # def calculate_max_mana(self): + # if self.character_class == "warrior": + # return self.intelligence + self.strength // 2 + # elif self.character_class == "mage": + # return self.wisdom * 3 + self.intelligence + # elif self.character_class == "hunter": + # return self.dexterity * 1.5 + self.wisdom // 2 + # else: + # return 0