minor cleanup
This commit is contained in:
parent
4c1c309877
commit
63ab8605d0
4 changed files with 36 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
return "UNKNOWN"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue