fixede card recovery on peice lost and game ending
This commit is contained in:
parent
92c349e7f2
commit
4c1c309877
2 changed files with 34 additions and 18 deletions
|
|
@ -758,6 +758,7 @@ func updatePointsAndCapture(capturedPiece: Pawn, animate: bool = true) -> void:
|
||||||
# Enemy captured a player piece
|
# Enemy captured a player piece
|
||||||
print("winConditionManager and capturedPiece.Item_Color == 0")
|
print("winConditionManager and capturedPiece.Item_Color == 0")
|
||||||
if winConditionManager and capturedPiece.Item_Color == 0: # Player piece (white)
|
if winConditionManager and capturedPiece.Item_Color == 0: # Player piece (white)
|
||||||
|
recover_cards_from_player_piece(capturedPiece)
|
||||||
print("ENemy captured an player piece ")
|
print("ENemy captured an player piece ")
|
||||||
winConditionManager.on_piece_lost(capturedPiece)
|
winConditionManager.on_piece_lost(capturedPiece)
|
||||||
|
|
||||||
|
|
@ -796,11 +797,8 @@ func animatePieceCapture(capturedPiece: Pawn) -> void:
|
||||||
await capturedPiece.animate_capture()
|
await capturedPiece.animate_capture()
|
||||||
container.remove_piece()
|
container.remove_piece()
|
||||||
|
|
||||||
func recover_cards_from_player_pieces():
|
|
||||||
for y in range(boardYSize):
|
|
||||||
for x in range(boardXSize):
|
|
||||||
var piece = (boardContainer.get_node(str(x) + "-" + str(y)) as PieceContainer).get_piece()
|
|
||||||
|
|
||||||
|
func recover_cards_from_player_piece(piece: Pawn):
|
||||||
if piece != null and piece.Item_Color == 0:
|
if piece != null and piece.Item_Color == 0:
|
||||||
var piece_id = piece.get_instance_id()
|
var piece_id = piece.get_instance_id()
|
||||||
|
|
||||||
|
|
@ -816,9 +814,15 @@ func recover_cards_from_player_pieces():
|
||||||
deckManager.deck.append(card)
|
deckManager.deck.append(card)
|
||||||
print("Recovered Rank 3 card to deck: ", card.cardName)
|
print("Recovered Rank 3 card to deck: ", card.cardName)
|
||||||
|
|
||||||
# Remove from attached_cards
|
|
||||||
deckManager.attached_cards.erase(piece_id)
|
deckManager.attached_cards.erase(piece_id)
|
||||||
|
|
||||||
|
|
||||||
|
func recover_cards_from_player_pieces():
|
||||||
|
for y in range(boardYSize):
|
||||||
|
for x in range(boardXSize):
|
||||||
|
var piece = (boardContainer.get_node(str(x) + "-" + str(y)) as PieceContainer).get_piece()
|
||||||
|
recover_cards_from_player_piece(piece)
|
||||||
|
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
# FEN NOTATION AND POSITION TRACKING
|
# FEN NOTATION AND POSITION TRACKING
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,8 @@ func initialize(options = null):
|
||||||
player_gold = options.gold
|
player_gold = options.gold
|
||||||
if options.has("reward") and options.reward.has("selection") and options.reward.selection is Array:
|
if options.has("reward") and options.reward.has("selection") and options.reward.selection is Array:
|
||||||
available_cards = options.reward.selection.duplicate()
|
available_cards = options.reward.selection.duplicate()
|
||||||
|
else:
|
||||||
|
available_cards = []
|
||||||
if options.has("is_escape") and options.is_escape is bool:
|
if options.has("is_escape") and options.is_escape is bool:
|
||||||
is_escape = options.is_escape
|
is_escape = options.is_escape
|
||||||
if options.has("reward") and options.reward.has("gold") and options.reward.gold is int:
|
if options.has("reward") and options.reward.has("gold") and options.reward.gold is int:
|
||||||
|
|
@ -85,11 +87,21 @@ func initialize(options = null):
|
||||||
card_selection_limit = options.reward.selection_limit
|
card_selection_limit = options.reward.selection_limit
|
||||||
screen_title.text = "Select Reward (" + str(options.reward.selection_limit) + ")"
|
screen_title.text = "Select Reward (" + str(options.reward.selection_limit) + ")"
|
||||||
select_button.visible = true
|
select_button.visible = true
|
||||||
|
select_button.disabled = false
|
||||||
else:
|
else:
|
||||||
screen_title.text = "Reward :" + str(options.reward.gold) + " gold"
|
screen_title.text = "Reward :" + str(options.reward.gold) + " gold"
|
||||||
select_button.visible = false
|
select_button.visible = false
|
||||||
card_selection_counter = 0
|
card_selection_counter = 0
|
||||||
|
|
||||||
|
if not available_cards.is_empty():
|
||||||
|
var new_index = min(selected_index, available_cards.size() - 1)
|
||||||
|
select_card(new_index)
|
||||||
|
else:
|
||||||
|
selected_card = null
|
||||||
|
selected_index = -1
|
||||||
|
if card_preview:
|
||||||
|
card_preview.hide_preview()
|
||||||
|
|
||||||
player_gold = board.gold
|
player_gold = board.gold
|
||||||
# Update display
|
# Update display
|
||||||
update_gold_display()
|
update_gold_display()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue