2024-02-10 17:11:28 +00:00
|
|
|
from config.game.player_config import warrior_stats, mage_stats, tank_stats
|
|
|
|
from config.game.monster_config import monster_data
|
2023-10-04 02:37:28 +00:00
|
|
|
|
|
|
|
|
2023-09-27 18:03:37 +00:00
|
|
|
class StatsHandler:
|
|
|
|
|
2023-11-13 12:34:22 +00:00
|
|
|
def __init__(self, sprite_type, role=None, monster_name=None):
|
2023-10-04 02:37:28 +00:00
|
|
|
|
|
|
|
if sprite_type == 'player':
|
|
|
|
|
2023-11-13 12:34:22 +00:00
|
|
|
if role == 'warrior':
|
|
|
|
self.stats = warrior_stats
|
|
|
|
elif role == 'tank':
|
|
|
|
self.stats = tank_stats
|
|
|
|
elif role == 'mage':
|
|
|
|
self.stats = mage_stats
|
2023-10-04 02:37:28 +00:00
|
|
|
|
2023-11-13 12:34:22 +00:00
|
|
|
self.role_id = self.stats['role_id']
|
2023-10-04 02:37:28 +00:00
|
|
|
self.health = self.stats['health']
|
|
|
|
self.energy = self.stats['energy']
|
|
|
|
self.attack = self.stats['attack']
|
|
|
|
self.magic = self.stats['magic']
|
|
|
|
self.speed = self.stats['speed']
|
2023-11-13 12:34:22 +00:00
|
|
|
self.exp = 0
|
2023-10-04 02:37:28 +00:00
|
|
|
|
|
|
|
if sprite_type == 'enemy':
|
|
|
|
|
|
|
|
self.monster_info = monster_data[monster_name]
|
2023-11-13 12:34:22 +00:00
|
|
|
self.monster_id = self.monster_info['id']
|
2023-10-04 02:37:28 +00:00
|
|
|
self.health = self.monster_info['health']
|
|
|
|
self.attack = self.monster_info['attack']
|
|
|
|
self.attack_type = self.monster_info['attack_type']
|
|
|
|
self.attack_radius = self.monster_info['attack_radius']
|
|
|
|
self.speed = self.monster_info['speed']
|
|
|
|
self.knockback = self.monster_info['knockback']
|
|
|
|
self.notice_radius = self.monster_info['notice_radius']
|
|
|
|
self.exp = self.monster_info['exp']
|
2023-09-27 18:03:37 +00:00
|
|
|
|
|
|
|
def energy_recovery(self):
|
|
|
|
if self.energy < self.stats['energy']:
|
2023-10-04 02:37:28 +00:00
|
|
|
self.energy += 0.01 * self.magic
|
2023-09-27 18:03:37 +00:00
|
|
|
else:
|
|
|
|
self.energy = self.stats['energy']
|
|
|
|
|
2023-11-23 11:44:23 +00:00
|
|
|
def health_recovery(self):
|
|
|
|
if self.energy < self.stats['health']:
|
|
|
|
self.energy += 0.15
|
|
|
|
else:
|
|
|
|
self.energy = self.stats['energy']
|
|
|
|
|
2023-09-27 18:03:37 +00:00
|
|
|
def get_value_by_index(self, index):
|
|
|
|
return list(self.stats.values())[index]
|
|
|
|
|
|
|
|
def get_cost_by_index(self, index):
|
|
|
|
return list(self.upgrade_costs.values())[index]
|