From 63ab8605d0bcff2512f413caa5977291c5021a03 Mon Sep 17 00:00:00 2001 From: 2ManyProjects Date: Sat, 8 Mar 2025 15:31:08 -0600 Subject: [PATCH] minor cleanup --- Systems/Cards/Explosiveboots.gd | 2 +- Systems/Game/ChessGame.gd | 38 ++++++++++++++++++++++++----- Systems/Game/WinConditionManager.gd | 3 ++- map_screen.tscn | 2 +- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Systems/Cards/Explosiveboots.gd b/Systems/Cards/Explosiveboots.gd index 1af3718..f741fa5 100644 --- a/Systems/Cards/Explosiveboots.gd +++ b/Systems/Cards/Explosiveboots.gd @@ -110,7 +110,7 @@ func setup_persistent_effect(game_state): game_state.connect("turn_changed", on_turn_changed) func on_turn_changed(): - # print("TURN CHANGED ==================", attached_piece, " | ", remaining_turns, ) + print("TURN CHANGED ==================", stored_game_state.isPlayerTurn() ) if stored_game_state.isPlayerTurn() and attached_piece and remaining_turns > 0: var piece = attached_piece diff --git a/Systems/Game/ChessGame.gd b/Systems/Game/ChessGame.gd index 8f039ac..e55ac31 100644 --- a/Systems/Game/ChessGame.gd +++ b/Systems/Game/ChessGame.gd @@ -59,6 +59,8 @@ var currentNode = null; @onready var menuContainer = get_node_or_null("/root/Board/MenuContainer") @onready var mapContainer = get_node_or_null("/root/Board/MapScreen") +var captured_pieces_this_turn: Array = [] +var player_pieces_lost_this_turn: Array = [] var winConditionManager: WinConditionManager var currentWinCondition = Utils.WinConditionType.CAPTURE_UNIT var currentLossCondition = Utils.LossConditionType.UNIT_LOST @@ -105,6 +107,8 @@ func _ready() -> void: # 2rnbqkbnr1R/2ppp1pppp2/5p6/75/66/66/66/66/66/66/2PPPPPPPP2/2RNBQKBN3 b KQkq - 0 3 func _on_new_game_requested(options = {}): print("ChessGame received new_game_requested signal ", is_initialized) + captured_pieces_this_turn = [] + player_pieces_lost_this_turn = [] turnIndicator.visible = true if options and "fen" in options.metadata: currentFen = options.metadata.fen @@ -403,15 +407,15 @@ func setupTilesFromFEN() -> void: else: var loc = str(x) + "-" + str(board_y); if tileManager.portalString.find(c) > -1: - var char = c + var chr = c # shjould we lowercase? - if char in matchedPortals: - if !("p2" in matchedPortals[char]): - matchedPortals[char].p2 = loc - tileManager.place_portal_pair(matchedPortals[char].p1, matchedPortals[char].p2, portalCnt) + if chr in matchedPortals: + if !("p2" in matchedPortals[chr]): + matchedPortals[chr].p2 = loc + tileManager.place_portal_pair(matchedPortals[chr].p1, matchedPortals[chr].p2, portalCnt) portalCnt += 1; else: - matchedPortals[char] = { "p1": loc } + matchedPortals[chr] = { "p1": loc } x += 1 else: var tile = getFENTile(c, loc) @@ -617,6 +621,7 @@ func resolveMoveEffects() -> void: resetHighlights() hasMoved = false currentlyMovingPiece = null + check_captured_pieces_conditions() emit_signal("turn_changed") Turn = 1 if Turn == 0 else 0 updateTurnIndicator() @@ -751,12 +756,19 @@ func updatePointsAndCapture(capturedPiece: Pawn, animate: bool = true) -> void: if winConditionManager and capturedPiece.Item_Color == 1: # Enemy piece (black) print("Player captured an enemy piece ") winConditionManager.on_piece_captured(capturedPiece) + # captured_pieces_this_turn.append(capturedPiece.duplicate(true)) + else: # Enemy's turn p2Points += capturedPiece.Points p2String.text = str(p2Points) # Enemy captured a player piece print("winConditionManager and capturedPiece.Item_Color == 0") + # recover_cards_from_player_piece(capturedPiece) + + # Add to player pieces lost array for loss condition checking + # player_pieces_lost_this_turn.append(capturedPiece.duplicate(true)) + if winConditionManager and capturedPiece.Item_Color == 0: # Player piece (white) recover_cards_from_player_piece(capturedPiece) print("ENemy captured an player piece ") @@ -768,6 +780,20 @@ func updatePointsAndCapture(capturedPiece: Pawn, animate: bool = true) -> void: gamecheckMate = true +func check_captured_pieces_conditions(): + # Process captured enemy pieces (possible win condition) + print("&&&&&&&&&&&&&&&&77check_captured_pieces_conditions&&&&&&&&&&&&&&&") + for piece in captured_pieces_this_turn: + if winConditionManager: + winConditionManager.on_piece_captured(piece) + print(captured_pieces_this_turn) + captured_pieces_this_turn = [] + # Process captured player pieces (possible loss condition) + for piece in player_pieces_lost_this_turn: + if winConditionManager: + winConditionManager.on_piece_lost(piece) + print(player_pieces_lost_this_turn) + player_pieces_lost_this_turn = [] func _on_win_condition_met(condition_data): print("Win condition met: ", condition_data) diff --git a/Systems/Game/WinConditionManager.gd b/Systems/Game/WinConditionManager.gd index ba74198..32dc2bb 100644 --- a/Systems/Game/WinConditionManager.gd +++ b/Systems/Game/WinConditionManager.gd @@ -112,6 +112,7 @@ func _on_turn_changed(): check_conditions() func on_piece_captured(piece): + print("on_piece_captured ISEnemy ", piece) var is_enemy_piece = piece.Item_Color == (1 if chess_game.Turn == 0 else 0) print("on_piece_captured ISEnemy ", is_enemy_piece) if is_enemy_piece: @@ -274,4 +275,4 @@ func _loss_condition_type_to_string(type: Utils.LossConditionType) -> String: Utils.LossConditionType.TURN_NUMBER: return "TURN_NUMBER" _: - return "UNKNOWN" \ No newline at end of file + return "UNKNOWN" diff --git a/map_screen.tscn b/map_screen.tscn index cbaa65f..cee819a 100644 --- a/map_screen.tscn +++ b/map_screen.tscn @@ -109,7 +109,7 @@ offset_right = 377.0 offset_bottom = -24.0 grow_horizontal = 2 grow_vertical = 0 -text = "After a boss the player selects 1 found card to keep" +text = "Some Subtitle text, maybe to alert the player to something" horizontal_alignment = 1 vertical_alignment = 1 autowrap_mode = 3