- 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.
17 lines
547 B
GDScript
17 lines
547 B
GDScript
class_name DiscardHandler
|
|
extends RefCounted
|
|
|
|
const BattleEventTypeScript = preload("res://Game/Runtime/Queue/BattleEventType.gd")
|
|
|
|
func handle(task, state) -> Array:
|
|
var all_hand: bool = bool(task.payload.get("all_hand", false))
|
|
if all_hand:
|
|
while not state.hand.is_empty():
|
|
var card = state.hand.pop_back()
|
|
state.discard_pile.append(card)
|
|
state.event_bus.publish(BattleEventTypeScript.CARD_DISCARDED, {
|
|
"card_id": card.card_def.id if card.card_def != null else "",
|
|
"discard_size": state.discard_pile.size()
|
|
})
|
|
return []
|