- 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.
34 lines
902 B
GDScript
34 lines
902 B
GDScript
class_name TriggerDispatchHandler
|
|
extends RefCounted
|
|
|
|
func handle(task, state) -> Array:
|
|
if task == null:
|
|
return []
|
|
|
|
var follow_ups: Array = []
|
|
for owner in _get_owners_in_order(state):
|
|
if owner == null:
|
|
continue
|
|
for buff in owner.get_buffs_in_order():
|
|
for subscriber in buff.subscribers:
|
|
if subscriber == null:
|
|
continue
|
|
if subscriber.matches(task, state, owner):
|
|
var produced = subscriber.build_events(task, state, owner)
|
|
if produced is Array and not produced.is_empty():
|
|
follow_ups.append_array(produced)
|
|
return follow_ups
|
|
|
|
func _get_owners_in_order(state) -> Array:
|
|
var owners: Array = []
|
|
if state.player != null:
|
|
owners.append(state.player)
|
|
if state.enemy != null:
|
|
owners.append(state.enemy)
|
|
owners.sort_custom(func(a, b) -> bool:
|
|
if a.speed_weight == b.speed_weight:
|
|
return false
|
|
return a.speed_weight > b.speed_weight
|
|
)
|
|
return owners
|