From 27c4db362262a3a859704a005d9fe1d2e0dc1064 Mon Sep 17 00:00:00 2001 From: 2ManyProjects Date: Sat, 1 Feb 2025 10:54:31 -0600 Subject: [PATCH] fixed supernova checkmate --- Systems/Cards/Drunkdriving.gd | 2 -- Systems/Cards/Supernova.gd | 8 ++------ Systems/DeckManager.gd | 19 ++++--------------- Systems/Game/ChessGame.gd | 4 ++++ Systems/StateMachine/GameStates/Movement.gd | 5 +---- 5 files changed, 11 insertions(+), 27 deletions(-) diff --git a/Systems/Cards/Drunkdriving.gd b/Systems/Cards/Drunkdriving.gd index 8050ef9..6bcbbb6 100644 --- a/Systems/Cards/Drunkdriving.gd +++ b/Systems/Cards/Drunkdriving.gd @@ -11,11 +11,9 @@ func _init(): func apply_effect(target_piece = null, board_flow = null, game_state = null): if !super.apply_effect(target_piece, board_flow, game_state): - print("FAILED DEFAULT FN") return false if !target_piece or !board_flow or !game_state: - print("FAILED DEFAULT FN 2") return false diff --git a/Systems/Cards/Supernova.gd b/Systems/Cards/Supernova.gd index c8977ff..dd143ac 100644 --- a/Systems/Cards/Supernova.gd +++ b/Systems/Cards/Supernova.gd @@ -13,18 +13,15 @@ func _init(): remaining_turns = duration func apply_effect(target_piece = null, board_flow = null, game_state = null): - print(cardName, " APPLY EFFECT ") attached_piece = target_piece if !target_piece or !board_flow or !game_state: print(cardName, " missing input param ") return false - # Get king's position var king_pos = target_piece.get_parent().name.split("-") var king_x = int(king_pos[0]) var king_y = int(king_pos[1]) - # Calculate tiles as before... var tiles_to_check = [] for dx in range(-CAPTURE_RADIUS, CAPTURE_RADIUS + 1): for dy in range(-CAPTURE_RADIUS, CAPTURE_RADIUS + 1): @@ -60,9 +57,8 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null): tile.add_child(overlay) overlay.show() - # Handle piece capture if tile.get_child_count() > 1: # > 1 because we just added the overlay - var piece = tile.get_child(0) # Piece should still be first child + var piece = tile.get_child(0) if piece.Item_Color != target_piece.Item_Color: game_state.updatePoints(piece) piece.queue_free() @@ -108,7 +104,7 @@ func on_turn_changed(): # print("TURN CHANGED ==================", attached_piece, " | ", remaining_turns, ) if attached_piece.get_parent().get_parent().owner.isPlayerTurn() and attached_piece and remaining_turns > 0: - print(attached_piece.get_parent().get_parent(), attached_piece.get_parent().get_parent().owner) + # print(attached_piece.get_parent().get_parent(), attached_piece.get_parent().get_parent().owner) var piece = attached_piece var flow = attached_piece.get_parent().get_parent() var state = attached_piece.get_parent().get_parent().owner diff --git a/Systems/DeckManager.gd b/Systems/DeckManager.gd index 65c31f3..5d410ec 100644 --- a/Systems/DeckManager.gd +++ b/Systems/DeckManager.gd @@ -42,15 +42,6 @@ func drawStartingHand(): func drawCard(): if deck.is_empty() && !discard.is_empty(): - print("*******************************") - print("*******************************") - print("*******************************") - print("*******************************") - print("********ADDING DISCARD TO DECK*") - print("*******************************") - print("*******************************") - print("*******************************") - print("*******************************") deck = discard.duplicate() discard.clear() shuffleDeck() @@ -88,27 +79,25 @@ func updateCardDurations(): for piece_id in attached_cards: var card = attached_cards[piece_id] card.update_duration() - print("Card: ", card.id, " | ", card.cardName, " | ", card.remaining_turns) + # print("Card: ", card.id, " | ", card.cardName, " | ", card.remaining_turns) if card.remaining_turns <= 0: expired_cards.append(piece_id) match card.rank: Card.Rank.RANK_0: - # Burned permanently + print("Rank 3 Burned permanently") pass Card.Rank.RANK_1: - # Burned until next match + print("Rank 3 Burned until next match") pass Card.Rank.RANK_2: print("Rank 2 add to Discard") discard.append(card) - # continue pass Card.Rank.RANK_3: deck.append(card) - # continue - print("Rank 1 add to Deck") + print("Rank 3 add to Deck") pass else: var piece_node = instance_from_id(piece_id) diff --git a/Systems/Game/ChessGame.gd b/Systems/Game/ChessGame.gd index 432567a..ef55769 100644 --- a/Systems/Game/ChessGame.gd +++ b/Systems/Game/ChessGame.gd @@ -151,6 +151,10 @@ func updatePoints(capturedPiece: Node) -> void: p2Points += capturedPiece.Points p2String.text = str(p2Points) + if capturedPiece.name == "King": + print("Game Over!") + gamecheckMate = true + func parseLocation(location: String) -> void: var number = 0 locationX = "" diff --git a/Systems/StateMachine/GameStates/Movement.gd b/Systems/StateMachine/GameStates/Movement.gd index 8c40935..57996d0 100644 --- a/Systems/StateMachine/GameStates/Movement.gd +++ b/Systems/StateMachine/GameStates/Movement.gd @@ -165,16 +165,13 @@ func handleCapture(node: Node) -> void: var piece = game.get_node("Flow/" + game.selectedNode).get_child(0) var capturedPiece = node.get_child(0) - game.updatePoints(capturedPiece) piece.reparent(node) piece.position = Vector2(25, 25) piece.position = Vector2(25, 25) game.currentlyMovingPiece = piece game.resolveMoveEffects() - if capturedPiece.name == "King": - print("Game Over!") - game.gamecheckMate = true + game.updatePoints(capturedPiece) capturedPiece.free() func handleRegularMove(node: Node, consume: bool) -> void: