fixed supernova checkmate
This commit is contained in:
parent
19e75c60f9
commit
27c4db3622
5 changed files with 11 additions and 27 deletions
|
|
@ -11,11 +11,9 @@ func _init():
|
||||||
|
|
||||||
func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
if !super.apply_effect(target_piece, board_flow, game_state):
|
if !super.apply_effect(target_piece, board_flow, game_state):
|
||||||
print("FAILED DEFAULT FN")
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if !target_piece or !board_flow or !game_state:
|
if !target_piece or !board_flow or !game_state:
|
||||||
print("FAILED DEFAULT FN 2")
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,15 @@ func _init():
|
||||||
remaining_turns = duration
|
remaining_turns = duration
|
||||||
|
|
||||||
func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
print(cardName, " APPLY EFFECT ")
|
|
||||||
attached_piece = target_piece
|
attached_piece = target_piece
|
||||||
if !target_piece or !board_flow or !game_state:
|
if !target_piece or !board_flow or !game_state:
|
||||||
print(cardName, " missing input param ")
|
print(cardName, " missing input param ")
|
||||||
return false
|
return false
|
||||||
|
|
||||||
# Get king's position
|
|
||||||
var king_pos = target_piece.get_parent().name.split("-")
|
var king_pos = target_piece.get_parent().name.split("-")
|
||||||
var king_x = int(king_pos[0])
|
var king_x = int(king_pos[0])
|
||||||
var king_y = int(king_pos[1])
|
var king_y = int(king_pos[1])
|
||||||
|
|
||||||
# Calculate tiles as before...
|
|
||||||
var tiles_to_check = []
|
var tiles_to_check = []
|
||||||
for dx in range(-CAPTURE_RADIUS, CAPTURE_RADIUS + 1):
|
for dx in range(-CAPTURE_RADIUS, CAPTURE_RADIUS + 1):
|
||||||
for dy 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)
|
tile.add_child(overlay)
|
||||||
overlay.show()
|
overlay.show()
|
||||||
|
|
||||||
# Handle piece capture
|
|
||||||
if tile.get_child_count() > 1: # > 1 because we just added the overlay
|
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:
|
if piece.Item_Color != target_piece.Item_Color:
|
||||||
game_state.updatePoints(piece)
|
game_state.updatePoints(piece)
|
||||||
piece.queue_free()
|
piece.queue_free()
|
||||||
|
|
@ -108,7 +104,7 @@ func on_turn_changed():
|
||||||
# print("TURN CHANGED ==================", attached_piece, " | ", remaining_turns, )
|
# print("TURN CHANGED ==================", attached_piece, " | ", remaining_turns, )
|
||||||
|
|
||||||
if attached_piece.get_parent().get_parent().owner.isPlayerTurn() and attached_piece and remaining_turns > 0:
|
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 piece = attached_piece
|
||||||
var flow = attached_piece.get_parent().get_parent()
|
var flow = attached_piece.get_parent().get_parent()
|
||||||
var state = attached_piece.get_parent().get_parent().owner
|
var state = attached_piece.get_parent().get_parent().owner
|
||||||
|
|
|
||||||
|
|
@ -42,15 +42,6 @@ func drawStartingHand():
|
||||||
|
|
||||||
func drawCard():
|
func drawCard():
|
||||||
if deck.is_empty() && !discard.is_empty():
|
if deck.is_empty() && !discard.is_empty():
|
||||||
print("*******************************")
|
|
||||||
print("*******************************")
|
|
||||||
print("*******************************")
|
|
||||||
print("*******************************")
|
|
||||||
print("********ADDING DISCARD TO DECK*")
|
|
||||||
print("*******************************")
|
|
||||||
print("*******************************")
|
|
||||||
print("*******************************")
|
|
||||||
print("*******************************")
|
|
||||||
deck = discard.duplicate()
|
deck = discard.duplicate()
|
||||||
discard.clear()
|
discard.clear()
|
||||||
shuffleDeck()
|
shuffleDeck()
|
||||||
|
|
@ -88,27 +79,25 @@ func updateCardDurations():
|
||||||
for piece_id in attached_cards:
|
for piece_id in attached_cards:
|
||||||
var card = attached_cards[piece_id]
|
var card = attached_cards[piece_id]
|
||||||
card.update_duration()
|
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:
|
if card.remaining_turns <= 0:
|
||||||
expired_cards.append(piece_id)
|
expired_cards.append(piece_id)
|
||||||
|
|
||||||
|
|
||||||
match card.rank:
|
match card.rank:
|
||||||
Card.Rank.RANK_0:
|
Card.Rank.RANK_0:
|
||||||
# Burned permanently
|
print("Rank 3 Burned permanently")
|
||||||
pass
|
pass
|
||||||
Card.Rank.RANK_1:
|
Card.Rank.RANK_1:
|
||||||
# Burned until next match
|
print("Rank 3 Burned until next match")
|
||||||
pass
|
pass
|
||||||
Card.Rank.RANK_2:
|
Card.Rank.RANK_2:
|
||||||
print("Rank 2 add to Discard")
|
print("Rank 2 add to Discard")
|
||||||
discard.append(card)
|
discard.append(card)
|
||||||
# continue
|
|
||||||
pass
|
pass
|
||||||
Card.Rank.RANK_3:
|
Card.Rank.RANK_3:
|
||||||
deck.append(card)
|
deck.append(card)
|
||||||
# continue
|
print("Rank 3 add to Deck")
|
||||||
print("Rank 1 add to Deck")
|
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
var piece_node = instance_from_id(piece_id)
|
var piece_node = instance_from_id(piece_id)
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,10 @@ func updatePoints(capturedPiece: Node) -> void:
|
||||||
p2Points += capturedPiece.Points
|
p2Points += capturedPiece.Points
|
||||||
p2String.text = str(p2Points)
|
p2String.text = str(p2Points)
|
||||||
|
|
||||||
|
if capturedPiece.name == "King":
|
||||||
|
print("Game Over!")
|
||||||
|
gamecheckMate = true
|
||||||
|
|
||||||
func parseLocation(location: String) -> void:
|
func parseLocation(location: String) -> void:
|
||||||
var number = 0
|
var number = 0
|
||||||
locationX = ""
|
locationX = ""
|
||||||
|
|
|
||||||
|
|
@ -165,16 +165,13 @@ func handleCapture(node: Node) -> void:
|
||||||
var piece = game.get_node("Flow/" + game.selectedNode).get_child(0)
|
var piece = game.get_node("Flow/" + game.selectedNode).get_child(0)
|
||||||
var capturedPiece = node.get_child(0)
|
var capturedPiece = node.get_child(0)
|
||||||
|
|
||||||
game.updatePoints(capturedPiece)
|
|
||||||
|
|
||||||
piece.reparent(node)
|
piece.reparent(node)
|
||||||
piece.position = Vector2(25, 25)
|
piece.position = Vector2(25, 25)
|
||||||
piece.position = Vector2(25, 25)
|
piece.position = Vector2(25, 25)
|
||||||
game.currentlyMovingPiece = piece
|
game.currentlyMovingPiece = piece
|
||||||
game.resolveMoveEffects()
|
game.resolveMoveEffects()
|
||||||
if capturedPiece.name == "King":
|
game.updatePoints(capturedPiece)
|
||||||
print("Game Over!")
|
|
||||||
game.gamecheckMate = true
|
|
||||||
capturedPiece.free()
|
capturedPiece.free()
|
||||||
|
|
||||||
func handleRegularMove(node: Node, consume: bool) -> void:
|
func handleRegularMove(node: Node, consume: bool) -> void:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue