2024-02-10 17:11:28 +00:00
|
|
|
from config.game.weapon_config import weapon_data
|
|
|
|
from config.game.spell_config import magic_data
|
2023-09-27 18:03:37 +00:00
|
|
|
|
2024-04-23 18:43:39 +00:00
|
|
|
from effects.magic_effects import MagicPlayer
|
|
|
|
from effects.particle_effects import AnimationPlayer
|
|
|
|
from effects.weapon_effects import Weapon
|
|
|
|
|
2023-09-27 18:03:37 +00:00
|
|
|
|
|
|
|
|
2023-10-04 02:37:28 +00:00
|
|
|
|
2024-04-23 18:43:39 +00:00
|
|
|
class CombatHandler:
|
|
|
|
|
|
|
|
def __init__(self):
|
2023-09-27 18:03:37 +00:00
|
|
|
|
|
|
|
# Setup Combat
|
2024-04-23 18:43:39 +00:00
|
|
|
self.magic_player = MagicPlayer(AnimationPlayer())
|
2023-09-27 18:03:37 +00:00
|
|
|
self.current_attack = None
|
|
|
|
|
|
|
|
# Spell and Weapon Rotation
|
|
|
|
self.weapon_index = 0
|
|
|
|
self.weapon = list(weapon_data.keys())[self.weapon_index]
|
|
|
|
|
|
|
|
self.magic_index = 0
|
|
|
|
self.magic = list(magic_data.keys())[self.magic_index]
|
|
|
|
|
|
|
|
# Damage Timer
|
|
|
|
self.vulnerable = True
|
|
|
|
self.hurt_time = None
|
|
|
|
self.invulnerability_duration = 300
|
|
|
|
|
2024-04-23 18:43:39 +00:00
|
|
|
def create_attack_sprite(self):
|
2023-09-27 18:03:37 +00:00
|
|
|
self.current_attack = Weapon(
|
2024-04-23 18:43:39 +00:00
|
|
|
self, [self.visible_sprites, self.attack_sprites])
|
2023-09-27 18:03:37 +00:00
|
|
|
|
|
|
|
def delete_attack_sprite(self):
|
|
|
|
if self.current_attack:
|
|
|
|
self.current_attack.kill()
|
|
|
|
self.current_attack = None
|
|
|
|
|
2024-04-23 18:43:39 +00:00
|
|
|
def create_magic_sprite(self, style, strength, cost):
|
2023-09-27 18:03:37 +00:00
|
|
|
if style == 'heal':
|
2024-04-23 18:43:39 +00:00
|
|
|
self.magic_player.heal(self, strength, cost, [
|
|
|
|
self.visible_sprites])
|
2023-09-27 18:03:37 +00:00
|
|
|
|
|
|
|
if style == 'flame':
|
|
|
|
self.magic_player.flame(
|
2024-04-23 18:43:39 +00:00
|
|
|
self, cost, [self.visible_sprites, self.attack_sprites])
|