- Added BattleState class to manage battle flow, including turn management and event handling. - Introduced BuffInstance class to represent buffs applied to combatants. - Created CardInstance class to handle card definitions and cost calculations. - Developed CombatantState class to manage combatant attributes and actions. - Implemented EffectRegistry to apply effects based on event specifications. - Added various handlers (BlockHandler, DamageHandler, DrawHandler, etc.) to process specific events. - Created IntentPlanner and IntentState classes to manage enemy actions and intents. - Established a queue system for handling battle events with BattleEventQueue and BattleEventTask. - Introduced triggers for applying effects based on game events (e.g., OnCardDrawnGainBlockTrigger). - Added necessary UID files for new scripts to ensure proper resource management.
56 lines
1.3 KiB
GDScript
56 lines
1.3 KiB
GDScript
class_name CombatantState
|
|
extends RefCounted
|
|
|
|
const BuffInstanceScript = preload("res://Game/Runtime/Buffs/BuffInstance.gd")
|
|
|
|
var display_name: String = ""
|
|
var max_hp: int = 1
|
|
var hp: int = 1
|
|
var block: int = 0
|
|
var strength: int = 0
|
|
var weak_turns: int = 0
|
|
var speed_weight: int = 100
|
|
|
|
var buffs: Array = []
|
|
var _next_acquire_index: int = 0
|
|
|
|
func _init(name_text: String = "Unit", max_hp_value: int = 1) -> void:
|
|
display_name = name_text
|
|
max_hp = max(1, max_hp_value)
|
|
hp = max_hp
|
|
|
|
func take_damage(raw_amount: int) -> int:
|
|
var amount: int = max(0, raw_amount)
|
|
var absorbed: int = min(block, amount)
|
|
block -= absorbed
|
|
var final_damage: int = amount - absorbed
|
|
hp = max(0, hp - final_damage)
|
|
return final_damage
|
|
|
|
func gain_block(amount: int) -> void:
|
|
block += max(0, amount)
|
|
|
|
func apply_weak(turns: int) -> void:
|
|
weak_turns += max(0, turns)
|
|
|
|
func tick_end_of_turn() -> void:
|
|
weak_turns = max(0, weak_turns - 1)
|
|
|
|
func add_buff(buff: BuffInstance) -> void:
|
|
if buff == null:
|
|
return
|
|
buff.owner = self
|
|
buff.acquire_index = _next_acquire_index
|
|
_next_acquire_index += 1
|
|
buffs.append(buff)
|
|
|
|
func get_buffs_in_order() -> Array:
|
|
var ordered: Array = buffs.duplicate()
|
|
ordered.sort_custom(func(a, b) -> bool:
|
|
return int(a.acquire_index) < int(b.acquire_index)
|
|
)
|
|
return ordered
|
|
|
|
func is_dead() -> bool:
|
|
return hp <= 0
|