- 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.
30 lines
889 B
GDScript
30 lines
889 B
GDScript
class_name OnDamageTakenGainBlockTrigger
|
|
extends RefCounted
|
|
|
|
const BattleEventTypeScript = preload("res://Game/Runtime/Queue/BattleEventType.gd")
|
|
const BattleEventTaskScript = preload("res://Game/Runtime/Queue/BattleEventTask.gd")
|
|
|
|
var block_amount: int = 1
|
|
|
|
func _init(p_block_amount: int = 1) -> void:
|
|
block_amount = max(0, p_block_amount)
|
|
|
|
func matches(task, _state, owner) -> bool:
|
|
if task == null or owner == null:
|
|
return false
|
|
if task.event_type != BattleEventTypeScript.DAMAGE_APPLIED:
|
|
return false
|
|
if int(task.payload.get("amount", 0)) <= 0:
|
|
return false
|
|
return task.payload.get("target", null) == owner
|
|
|
|
func build_events(task, _state, owner) -> Array:
|
|
if block_amount <= 0:
|
|
return []
|
|
return [
|
|
BattleEventTaskScript.new(BattleEventTypeScript.BLOCK_REQUESTED, {
|
|
"target": owner,
|
|
"amount": block_amount
|
|
}, task.chain_id, "OnDamageTakenGainBlockTrigger")
|
|
]
|