added explosive boots, removed certain effects from applying twice on the first turn
This commit is contained in:
parent
27c4db3622
commit
98a56d9e5e
3 changed files with 139 additions and 9 deletions
126
Systems/Cards/Explosiveboots.gd
Normal file
126
Systems/Cards/Explosiveboots.gd
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
class_name ExplosiveBootsCard extends Card
|
||||||
|
|
||||||
|
const CAPTURE_RADIUS = 1
|
||||||
|
var valid = false;
|
||||||
|
func _init():
|
||||||
|
duration = 1
|
||||||
|
super._init()
|
||||||
|
cardName = "Explosive Boots"
|
||||||
|
rank = Rank.RANK_2
|
||||||
|
effectType = EffectType.PIECE_EFFECT
|
||||||
|
description = "All enemy units within 1 radius of the moving peice are captured"
|
||||||
|
unitWhitelist = ["Pawn", "Knight", "King"]
|
||||||
|
remaining_turns = duration
|
||||||
|
|
||||||
|
func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
|
attached_piece = target_piece
|
||||||
|
if !target_piece or !board_flow or !game_state:
|
||||||
|
print(cardName, " missing input param ")
|
||||||
|
return false
|
||||||
|
setup_persistent_effect(game_state)
|
||||||
|
# dont apply on card attachment
|
||||||
|
if !valid:
|
||||||
|
return true
|
||||||
|
var piece_pos = target_piece.get_parent().name.split("-")
|
||||||
|
var piece_x = int(piece_pos[0])
|
||||||
|
var piece_y = int(piece_pos[1])
|
||||||
|
|
||||||
|
var tiles_to_check = []
|
||||||
|
for dx in range(-CAPTURE_RADIUS, CAPTURE_RADIUS + 1):
|
||||||
|
for dy in range(-CAPTURE_RADIUS, CAPTURE_RADIUS + 1):
|
||||||
|
if max(abs(dx), abs(dy)) > CAPTURE_RADIUS:
|
||||||
|
continue
|
||||||
|
|
||||||
|
var target_x = piece_x + dx
|
||||||
|
var target_y = piece_y + dy
|
||||||
|
|
||||||
|
if target_x < 0 or target_x >= 8 or target_y < 0 or target_y >= 8:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if dx == 0 and dy == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
tiles_to_check.append(str(target_x) + "-" + str(target_y))
|
||||||
|
|
||||||
|
# Process tiles and add overlay
|
||||||
|
for tile_name in tiles_to_check:
|
||||||
|
var tile = board_flow.get_node(tile_name)
|
||||||
|
|
||||||
|
var existing_overlay = tile.get_node_or_null("ExplosiveBootsOverlay")
|
||||||
|
if existing_overlay:
|
||||||
|
existing_overlay.queue_free()
|
||||||
|
|
||||||
|
var overlay = ColorRect.new()
|
||||||
|
overlay.name = "ExplosiveBootsOverlay"
|
||||||
|
overlay.color = Color(1, 0, 0, 0.3)
|
||||||
|
overlay.size = tile.size
|
||||||
|
overlay.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
|
tile.add_child(overlay)
|
||||||
|
overlay.show()
|
||||||
|
|
||||||
|
if tile.get_child_count() > 1: # > 1 because we just added the overlay
|
||||||
|
var piece = tile.get_child(0)
|
||||||
|
if piece.Item_Color != target_piece.Item_Color:
|
||||||
|
game_state.updatePoints(piece)
|
||||||
|
piece.queue_free()
|
||||||
|
|
||||||
|
# Setup timer to remove overlays
|
||||||
|
var timer = Timer.new()
|
||||||
|
board_flow.add_child(timer)
|
||||||
|
timer.wait_time = 0.5
|
||||||
|
timer.one_shot = true
|
||||||
|
timer.timeout.connect(func():
|
||||||
|
for tile_name in tiles_to_check:
|
||||||
|
var tile = board_flow.get_node(tile_name)
|
||||||
|
var overlay = tile.get_node_or_null("ExplosiveBootsOverlay")
|
||||||
|
if overlay:
|
||||||
|
overlay.queue_free()
|
||||||
|
timer.queue_free()
|
||||||
|
)
|
||||||
|
timer.start()
|
||||||
|
|
||||||
|
return true
|
||||||
|
|
||||||
|
func reset_tile_styles(board_flow, tiles_to_check):
|
||||||
|
for tile_name in tiles_to_check:
|
||||||
|
var tile = board_flow.get_node(tile_name)
|
||||||
|
if !tile:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Reset to original chess board pattern
|
||||||
|
var coords = tile_name.split("-")
|
||||||
|
var isWhite = (int(coords[0]) + int(coords[1])) % 2 == 0
|
||||||
|
var style = StyleBoxFlat.new()
|
||||||
|
style.bg_color = Color(0.8, 0.8, 0.8, 1) if isWhite else Color(0.2, 0.2, 0.2, 1)
|
||||||
|
tile.add_theme_stylebox_override("normal", style)
|
||||||
|
|
||||||
|
|
||||||
|
func setup_persistent_effect(game_state):
|
||||||
|
# Connect to the turn change signal if not already connected
|
||||||
|
if !game_state.is_connected("turn_changed", on_turn_changed):
|
||||||
|
game_state.connect("turn_changed", on_turn_changed)
|
||||||
|
|
||||||
|
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)
|
||||||
|
var piece = attached_piece
|
||||||
|
var flow = attached_piece.get_parent().get_parent()
|
||||||
|
var state = attached_piece.get_parent().get_parent().owner
|
||||||
|
|
||||||
|
# print("Debug values:")
|
||||||
|
# print("- Piece: ", piece, " is null? ", piece == null)
|
||||||
|
# print("- Board Flow: ", flow, " is null? ", flow == null)
|
||||||
|
# print("- Game State: ", state, " is null? ", state == null)
|
||||||
|
|
||||||
|
# Now try apply_effect with these values
|
||||||
|
valid = true
|
||||||
|
apply_effect(piece, flow, state)
|
||||||
|
|
||||||
|
func remove_effect():
|
||||||
|
if attached_piece:
|
||||||
|
var game_state = attached_piece.get_parent().get_parent().owner
|
||||||
|
if game_state.is_connected("turn_changed", on_turn_changed):
|
||||||
|
game_state.disconnect("turn_changed", on_turn_changed)
|
||||||
|
super.remove_effect()
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
class_name SupernovaCard extends Card
|
class_name SupernovaCard extends Card
|
||||||
|
|
||||||
const CAPTURE_RADIUS = 3
|
const CAPTURE_RADIUS = 3
|
||||||
var started = false;
|
var valid = false;
|
||||||
func _init():
|
func _init():
|
||||||
duration = 5
|
duration = 5
|
||||||
super._init()
|
super._init()
|
||||||
cardName = "Supernova"
|
cardName = "Supernova"
|
||||||
rank = Rank.RANK_0
|
rank = Rank.RANK_0
|
||||||
effectType = EffectType.PIECE_EFFECT
|
effectType = EffectType.PIECE_EFFECT
|
||||||
description = "All enemy units within 3 radius are captured"
|
description = "All enemy units within 3 radius of the king are captured"
|
||||||
unitWhitelist = ["King"]
|
unitWhitelist = ["King"]
|
||||||
remaining_turns = duration
|
remaining_turns = duration
|
||||||
|
|
||||||
|
|
@ -17,6 +17,10 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
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
|
||||||
|
setup_persistent_effect(game_state)
|
||||||
|
# dont apply on card attachment
|
||||||
|
if !valid:
|
||||||
|
return true
|
||||||
|
|
||||||
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])
|
||||||
|
|
@ -43,17 +47,15 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
for tile_name in tiles_to_check:
|
for tile_name in tiles_to_check:
|
||||||
var tile = board_flow.get_node(tile_name)
|
var tile = board_flow.get_node(tile_name)
|
||||||
|
|
||||||
# Remove any existing overlay
|
|
||||||
var existing_overlay = tile.get_node_or_null("SupernovaOverlay")
|
var existing_overlay = tile.get_node_or_null("SupernovaOverlay")
|
||||||
if existing_overlay:
|
if existing_overlay:
|
||||||
existing_overlay.queue_free()
|
existing_overlay.queue_free()
|
||||||
|
|
||||||
# Create new overlay
|
|
||||||
var overlay = ColorRect.new()
|
var overlay = ColorRect.new()
|
||||||
overlay.name = "SupernovaOverlay"
|
overlay.name = "SupernovaOverlay"
|
||||||
overlay.color = Color(1, 0, 0, 0.3)
|
overlay.color = Color(1, 0, 0, 0.3)
|
||||||
overlay.size = tile.size
|
overlay.size = tile.size
|
||||||
overlay.mouse_filter = Control.MOUSE_FILTER_IGNORE # Make sure overlay doesn't block input
|
overlay.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
tile.add_child(overlay)
|
tile.add_child(overlay)
|
||||||
overlay.show()
|
overlay.show()
|
||||||
|
|
||||||
|
|
@ -78,7 +80,6 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
)
|
)
|
||||||
timer.start()
|
timer.start()
|
||||||
|
|
||||||
setup_persistent_effect(game_state)
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
func reset_tile_styles(board_flow, tiles_to_check):
|
func reset_tile_styles(board_flow, tiles_to_check):
|
||||||
|
|
@ -115,6 +116,7 @@ func on_turn_changed():
|
||||||
# print("- Game State: ", state, " is null? ", state == null)
|
# print("- Game State: ", state, " is null? ", state == null)
|
||||||
|
|
||||||
# Now try apply_effect with these values
|
# Now try apply_effect with these values
|
||||||
|
valid = true
|
||||||
apply_effect(piece, flow, state)
|
apply_effect(piece, flow, state)
|
||||||
|
|
||||||
func remove_effect():
|
func remove_effect():
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ const DoubleTimeCard = preload("res://Systems/Cards/Doubletime.gd")
|
||||||
const HopscotchCard = preload("res://Systems/Cards/Hopscotch.gd")
|
const HopscotchCard = preload("res://Systems/Cards/Hopscotch.gd")
|
||||||
const DrunkDrivingCard = preload("res://Systems/Cards/Drunkdriving.gd")
|
const DrunkDrivingCard = preload("res://Systems/Cards/Drunkdriving.gd")
|
||||||
const SupernovaCard = preload("res://Systems/Cards/Supernova.gd")
|
const SupernovaCard = preload("res://Systems/Cards/Supernova.gd")
|
||||||
|
const ExplosiveBootsCard = preload("res://Systems/Cards/Explosiveboots.gd")
|
||||||
var deck: Array = []
|
var deck: Array = []
|
||||||
var hand: Array = []
|
var hand: Array = []
|
||||||
var discard: Array = []
|
var discard: Array = []
|
||||||
|
|
@ -25,8 +25,10 @@ func _init():
|
||||||
|
|
||||||
func initializeStartingDeck():
|
func initializeStartingDeck():
|
||||||
deck.clear();
|
deck.clear();
|
||||||
for i in range(2):
|
# for i in range(2):
|
||||||
deck.append(DoubleTimeCard.new())
|
# deck.append(DoubleTimeCard.new())
|
||||||
|
deck.append(ExplosiveBootsCard.new())
|
||||||
|
deck.append(DoubleTimeCard.new())
|
||||||
deck.append(DrunkDrivingCard.new())
|
deck.append(DrunkDrivingCard.new())
|
||||||
deck.append(HopscotchCard.new())
|
deck.append(HopscotchCard.new())
|
||||||
deck.append(SupernovaCard.new())
|
deck.append(SupernovaCard.new())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue