module 1
This commit is contained in:
commit
aaf73e14c1
1 changed files with 50 additions and 0 deletions
50
game.py
Normal file
50
game.py
Normal file
|
|
@ -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
|
||||
Loading…
Reference in a new issue