From aaf73e14c1fe0dd776ca21d782dd278108ca9f1d Mon Sep 17 00:00:00 2001 From: Maxie <79106345+MaximIce1@users.noreply.github.com> Date: Sun, 6 Sep 2026 23:53:11 +0300 Subject: [PATCH] module 1 --- game.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 game.py diff --git a/game.py b/game.py new file mode 100644 index 0000000..1f2c116 --- /dev/null +++ b/game.py @@ -0,0 +1,50 @@ +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