working updates
This commit is contained in:
@@ -23,6 +23,7 @@ class UndoAction:
|
||||
# Additional data depending on action type
|
||||
var cp_element: Enums.Element = Enums.Element.FIRE
|
||||
var cp_amount: int = 0
|
||||
var cp_spent: Dictionary = {} # Tracks CP spent by element for proper refund
|
||||
var previous_card_state: Enums.CardState = Enums.CardState.ACTIVE
|
||||
var from_zone: Enums.ZoneType = Enums.ZoneType.HAND
|
||||
var to_zone: Enums.ZoneType = Enums.ZoneType.FIELD_FORWARDS
|
||||
@@ -69,13 +70,14 @@ func record_dull_backup_for_cp(player_index: int, card: CardInstance, element: E
|
||||
undo_available_changed.emit(true)
|
||||
|
||||
## Record playing a card
|
||||
func record_play_card(player_index: int, card: CardInstance, to_zone: Enums.ZoneType, _cp_spent: Dictionary) -> void:
|
||||
func record_play_card(player_index: int, card: CardInstance, to_zone: Enums.ZoneType, cp_spent: Dictionary) -> void:
|
||||
var action = UndoAction.new()
|
||||
action.type = ActionType.PLAY_CARD
|
||||
action.player_index = player_index
|
||||
action.card = card
|
||||
action.from_zone = Enums.ZoneType.HAND
|
||||
action.to_zone = to_zone
|
||||
action.cp_spent = cp_spent # Store actual CP spent for proper refund
|
||||
action.description = "Play " + card.get_display_name()
|
||||
|
||||
last_action = action
|
||||
@@ -177,12 +179,16 @@ func _undo_play_card(action: UndoAction) -> bool:
|
||||
card.state = Enums.CardState.ACTIVE
|
||||
card.turns_on_field = 0
|
||||
|
||||
# Refund the CP (we don't track exact CP spent, so this is simplified)
|
||||
# In a full implementation, we'd track what CP was spent
|
||||
# For now, we'll add back CP equal to the card cost
|
||||
var cost = card.card_data.cost
|
||||
var element = card.get_element()
|
||||
player.cp_pool.add_cp(element, cost)
|
||||
# Refund the actual CP spent (by element)
|
||||
if action.cp_spent.is_empty():
|
||||
# Fallback: refund card cost as primary element (legacy behavior)
|
||||
var cost = card.card_data.cost
|
||||
var element = card.get_element()
|
||||
player.cp_pool.add_cp(element, cost)
|
||||
else:
|
||||
# Refund each element's CP properly
|
||||
for element in action.cp_spent:
|
||||
player.cp_pool.add_cp(element, action.cp_spent[element])
|
||||
|
||||
return true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user