- 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.
31 lines
1.1 KiB
GDScript
31 lines
1.1 KiB
GDScript
class_name DrawHandler
|
|
extends RefCounted
|
|
|
|
const BattleEventTypeScript = preload("res://Game/Runtime/Queue/BattleEventType.gd")
|
|
const BattleEventTaskScript = preload("res://Game/Runtime/Queue/BattleEventTask.gd")
|
|
|
|
func handle(task, state) -> Array:
|
|
var follow_ups: Array = []
|
|
var owner = task.payload.get("owner", state.player)
|
|
var count: int = int(task.payload.get("count", 1))
|
|
for _i in range(max(0, count)):
|
|
if state.draw_pile.is_empty() and not state.discard_pile.is_empty():
|
|
state.draw_pile = state.discard_pile.duplicate()
|
|
state.discard_pile.clear()
|
|
state.shuffle_draw_pile()
|
|
if state.draw_pile.is_empty():
|
|
break
|
|
var card = state.draw_pile.pop_back()
|
|
state.hand.append(card)
|
|
state.event_bus.publish(BattleEventTypeScript.CARD_DRAWN, {
|
|
"card_id": card.card_def.id if card.card_def != null else "",
|
|
"hand_size": state.hand.size()
|
|
})
|
|
follow_ups.append(BattleEventTaskScript.new(BattleEventTypeScript.CARD_DRAWN, {
|
|
"owner": owner,
|
|
"owner_name": owner.display_name if owner != null else "",
|
|
"card": card,
|
|
"card_id": card.card_def.id if card.card_def != null else ""
|
|
}, task.chain_id, "DrawHandler"))
|
|
return follow_ups
|