Compare commits
No commits in common. "75cd2fbe79d37d472d4d2e867906ca33efee9407" and "7012ea4f169fe17a9fea10ef44e9c4462611a008" have entirely different histories.
75cd2fbe79
...
7012ea4f16
10 changed files with 46 additions and 143 deletions
|
|
@ -1,78 +0,0 @@
|
||||||
class_name FieryCapeCard extends Card
|
|
||||||
|
|
||||||
var previous_position: String = ""
|
|
||||||
var fire_tiles: Array[String] = []
|
|
||||||
|
|
||||||
func _init():
|
|
||||||
super._init()
|
|
||||||
cardName = "Fiery Cape"
|
|
||||||
rank = Rank.RANK_2
|
|
||||||
effectType = EffectType.PIECE_EFFECT
|
|
||||||
description = "Leaves a trail of fire that lasts 4 turns. Owner's pieces can pass safely."
|
|
||||||
duration = 3 # Card effect lasts 3 turns
|
|
||||||
unitWhitelist = ["Pawn", "Bishop", "Queen", "King", "Rook"] # Any piece can wear the cape
|
|
||||||
|
|
||||||
func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
|
||||||
if !super.apply_effect(target_piece, board_flow, game_state):
|
|
||||||
return false
|
|
||||||
|
|
||||||
# Store the current position as previous position
|
|
||||||
previous_position = target_piece.get_parent().name
|
|
||||||
setup_persistent_effect(game_state)
|
|
||||||
return true
|
|
||||||
|
|
||||||
func setup_persistent_effect(game_state):
|
|
||||||
if !game_state.is_connected("turn_changed", on_turn_changed):
|
|
||||||
game_state.connect("turn_changed", on_turn_changed)
|
|
||||||
|
|
||||||
func on_turn_changed():
|
|
||||||
if !attached_piece || remaining_turns <= 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
var piece = attached_piece
|
|
||||||
var board_flow = piece.get_parent().get_parent()
|
|
||||||
var current_pos = piece.get_parent().name
|
|
||||||
|
|
||||||
# If the piece has moved, place fire tiles
|
|
||||||
if current_pos != previous_position:
|
|
||||||
var current_coords = current_pos.split("-")
|
|
||||||
var prev_coords = previous_position.split("-")
|
|
||||||
var current_x = int(current_coords[0])
|
|
||||||
var current_y = int(current_coords[1])
|
|
||||||
var prev_x = int(prev_coords[0])
|
|
||||||
var prev_y = int(prev_coords[1])
|
|
||||||
|
|
||||||
# Calculate all positions between previous and current (excluding current)
|
|
||||||
var positions_to_mark = []
|
|
||||||
var dx = sign(current_x - prev_x)
|
|
||||||
var dy = sign(current_y - prev_y)
|
|
||||||
var x = prev_x
|
|
||||||
var y = prev_y
|
|
||||||
|
|
||||||
# Start with the previous position
|
|
||||||
positions_to_mark.append(previous_position)
|
|
||||||
|
|
||||||
# Add intermediate positions (but not the final position)
|
|
||||||
while (x + dx != current_x || y + dy != current_y):
|
|
||||||
x += dx
|
|
||||||
y += dy
|
|
||||||
positions_to_mark.append(str(x) + "-" + str(y))
|
|
||||||
|
|
||||||
# Place fire tiles
|
|
||||||
var tile_owner = Tile.TileOwner.PLAYER if piece.Item_Color == 0 else Tile.TileOwner.ENEMY
|
|
||||||
for pos in positions_to_mark:
|
|
||||||
var container = board_flow.get_node(pos) as PieceContainer
|
|
||||||
if container:
|
|
||||||
var is_white = (int(pos.split("-")[0]) + int(pos.split("-")[1])) % 2 == 0
|
|
||||||
var fire_tile = FireWallTile.new(container, is_white, 4, tile_owner)
|
|
||||||
board_flow.get_parent().tileManager.add_tile(pos, fire_tile)
|
|
||||||
fire_tiles.append(pos)
|
|
||||||
|
|
||||||
previous_position = current_pos
|
|
||||||
|
|
||||||
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,6 +1,11 @@
|
||||||
extends Node
|
extends Node
|
||||||
class_name DeckManager
|
class_name DeckManager
|
||||||
|
|
||||||
|
const DoubleTimeCard = preload("res://Systems/Cards/Doubletime.gd")
|
||||||
|
const HopscotchCard = preload("res://Systems/Cards/Hopscotch.gd")
|
||||||
|
const DrunkDrivingCard = preload("res://Systems/Cards/Drunkdriving.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 = []
|
||||||
|
|
@ -22,7 +27,6 @@ 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(FieryCapeCard.new())
|
|
||||||
deck.append(ExplosiveBootsCard.new())
|
deck.append(ExplosiveBootsCard.new())
|
||||||
deck.append(DoubleTimeCard.new())
|
deck.append(DoubleTimeCard.new())
|
||||||
deck.append(DrunkDrivingCard.new())
|
deck.append(DrunkDrivingCard.new())
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ func _ready() -> void:
|
||||||
|
|
||||||
|
|
||||||
func initializeTiles() -> void:
|
func initializeTiles() -> void:
|
||||||
tileManager = TileManager.new($Flow, self)
|
tileManager = TileManager.new()
|
||||||
add_child(tileManager)
|
add_child(tileManager)
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
tileManager.initialize(boardContainer)
|
tileManager.initialize(boardContainer)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,5 @@ func enter(_previous: String, _data := {}) -> void:
|
||||||
# game.resolveMoveEffects()
|
# game.resolveMoveEffects()
|
||||||
|
|
||||||
if (game.isPlayerTurn()):
|
if (game.isPlayerTurn()):
|
||||||
game.updateEffectDurations()
|
game.deckManager.updateCardDurations()
|
||||||
# if (game.isPlayerTurn()):
|
|
||||||
# game.deckManager.updateCardDurations()
|
|
||||||
finished.emit(Constants.EVALUATE_POSITION)
|
finished.emit(Constants.EVALUATE_POSITION)
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@ extends "res://Systems/StateMachine/ChessGameState.gd"
|
||||||
|
|
||||||
func enter(_previous: String, _data := {}) -> void:
|
func enter(_previous: String, _data := {}) -> void:
|
||||||
print("ENTERING STATE ", Constants.PERSISTENT_EFFECTS)
|
print("ENTERING STATE ", Constants.PERSISTENT_EFFECTS)
|
||||||
|
game.updateEffectDurations()
|
||||||
finished.emit(Constants.TILE_EFFECTS)
|
finished.emit(Constants.TILE_EFFECTS)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ enum TileOwner {
|
||||||
ENEMY, # Black player
|
ENEMY, # Black player
|
||||||
GAME # Neutral/game-owned
|
GAME # Neutral/game-owned
|
||||||
}
|
}
|
||||||
var game: ChessGame
|
|
||||||
var tile_name: String = ""
|
var tile_name: String = ""
|
||||||
var description: String = ""
|
var description: String = ""
|
||||||
var duration: int = -1 # -1 for permanent tiles
|
var duration: int = -1 # -1 for permanent tiles
|
||||||
|
|
@ -25,10 +25,10 @@ var base_is_white: bool # Original tile color
|
||||||
|
|
||||||
signal effect_expired
|
signal effect_expired
|
||||||
|
|
||||||
func _init(button: Button, is_white: bool, d: int) -> void:
|
func _init(button: Button, is_white: bool) -> void:
|
||||||
base_button = button
|
base_button = button
|
||||||
base_is_white = is_white
|
base_is_white = is_white
|
||||||
remaining_turns = d
|
remaining_turns = duration
|
||||||
|
|
||||||
func is_effect_active() -> bool:
|
func is_effect_active() -> bool:
|
||||||
return duration == -1 || remaining_turns > 0
|
return duration == -1 || remaining_turns > 0
|
||||||
|
|
@ -47,9 +47,9 @@ func can_affect_piece(piece: Pawn) -> bool:
|
||||||
# Check owner alignment
|
# Check owner alignment
|
||||||
match tile_owner:
|
match tile_owner:
|
||||||
TileOwner.PLAYER:
|
TileOwner.PLAYER:
|
||||||
return piece.Item_Color == 1 # White
|
return piece.Item_Color == 0 # White
|
||||||
TileOwner.ENEMY:
|
TileOwner.ENEMY:
|
||||||
return piece.Item_Color == 0 # Black
|
return piece.Item_Color == 1 # Black
|
||||||
TileOwner.GAME:
|
TileOwner.GAME:
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,14 @@ extends Node
|
||||||
|
|
||||||
var active_tiles: Dictionary = {} # location: Tile
|
var active_tiles: Dictionary = {} # location: Tile
|
||||||
var board_flow: FlowContainer
|
var board_flow: FlowContainer
|
||||||
var game: ChessGame
|
|
||||||
|
|
||||||
const DoubleMovementTile = preload("res://Systems/Tiles/DoubleMovement.gd")
|
const DoubleMovementTile = preload("res://Systems/Tiles/DoubleMovement.gd")
|
||||||
const FireWallTile = preload("res://Systems/Tiles/FireWall.gd")
|
const FireWallTile = preload("res://Systems/Tiles/FireWall.gd")
|
||||||
const PawnBoostTile = preload("res://Systems/Tiles/PawnBoost.gd")
|
const PawnBoostTile = preload("res://Systems/Tiles/PawnBoost.gd")
|
||||||
func _init(flow: FlowContainer = null, chess_game: ChessGame = null) -> void:
|
func _init(flow: FlowContainer = null) -> void:
|
||||||
if flow:
|
if flow:
|
||||||
initialize(flow)
|
initialize(flow)
|
||||||
|
|
||||||
game = chess_game
|
|
||||||
|
|
||||||
func initialize(flow: FlowContainer) -> void:
|
func initialize(flow: FlowContainer) -> void:
|
||||||
board_flow = flow
|
board_flow = flow
|
||||||
clear_tiles()
|
clear_tiles()
|
||||||
|
|
@ -31,7 +28,6 @@ func add_tile(location: String, tile: Tile) -> void:
|
||||||
# Remove any existing tile
|
# Remove any existing tile
|
||||||
remove_tile(location)
|
remove_tile(location)
|
||||||
|
|
||||||
tile.game = game
|
|
||||||
# Add new tile
|
# Add new tile
|
||||||
active_tiles[location] = tile
|
active_tiles[location] = tile
|
||||||
tile.effect_expired.connect(func(): remove_tile(location))
|
tile.effect_expired.connect(func(): remove_tile(location))
|
||||||
|
|
@ -51,8 +47,7 @@ func update_tile_durations() -> void:
|
||||||
return
|
return
|
||||||
|
|
||||||
var expired_locations = []
|
var expired_locations = []
|
||||||
var locations = active_tiles.keys()
|
for location in active_tiles:
|
||||||
for location in locations:
|
|
||||||
var tile = active_tiles[location]
|
var tile = active_tiles[location]
|
||||||
tile.update_duration()
|
tile.update_duration()
|
||||||
if !tile.is_effect_active():
|
if !tile.is_effect_active():
|
||||||
|
|
@ -79,7 +74,7 @@ func clear_tiles() -> void:
|
||||||
remove_tile(location)
|
remove_tile(location)
|
||||||
|
|
||||||
# Function to place random game tiles at the start of each match
|
# Function to place random game tiles at the start of each match
|
||||||
func place_random_game_tiles(num_tiles: int = 6) -> void:
|
func place_random_game_tiles(num_tiles: int = 3) -> void:
|
||||||
if !board_flow:
|
if !board_flow:
|
||||||
push_error("TileManager not initialized with board_flow")
|
push_error("TileManager not initialized with board_flow")
|
||||||
return
|
return
|
||||||
|
|
@ -107,11 +102,11 @@ func place_random_game_tiles(num_tiles: int = 6) -> void:
|
||||||
|
|
||||||
var tile: Tile
|
var tile: Tile
|
||||||
match tile_type:
|
match tile_type:
|
||||||
0: # DoubleMovementTile tile
|
0: # Double Movement tile
|
||||||
tile = FireWallTile.new(container, is_white, 3)
|
tile = DoubleMovementTile.new(container, is_white)
|
||||||
1: # FireWallTile
|
1: # FireWallTile
|
||||||
tile = FireWallTile.new(container, is_white, 3)
|
tile = FireWallTile.new(container, is_white)
|
||||||
2: # PawnBoostTile tile
|
2: # Pawn Boost tile
|
||||||
tile = FireWallTile.new(container, is_white, 3)
|
tile = PawnBoostTile.new(container, is_white)
|
||||||
|
|
||||||
add_tile(pos, tile)
|
add_tile(pos, tile)
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
class_name DoubleMovementTile
|
class_name DoubleMovementTile
|
||||||
extends Tile
|
extends Tile
|
||||||
|
|
||||||
func _init(button: Button, is_white: bool, d: int) -> void:
|
func _init(button: Button, is_white: bool) -> void:
|
||||||
super._init(button, is_white, d)
|
super._init(button, is_white)
|
||||||
tile_name = "Double Movement"
|
tile_name = "Double Movement"
|
||||||
description = "Any unit that starts its turn here gets double movement for 2 turns"
|
description = "Any unit that starts its turn here gets double movement for 2 turns"
|
||||||
type = TileType.GENERAL
|
type = TileType.GENERAL
|
||||||
tile_owner = TileOwner.GAME
|
tile_owner = TileOwner.GAME
|
||||||
duration = d # Permanent tile
|
duration = -1 # Permanent tile
|
||||||
|
|
||||||
func apply_effect(piece: Pawn = null) -> void:
|
func apply_effect(piece: Pawn = null) -> void:
|
||||||
print("APPLY DoubleMovementTile")
|
|
||||||
if piece && is_effect_active():
|
if piece && is_effect_active():
|
||||||
# Add double movement effect to the piece
|
# Add double movement effect to the piece
|
||||||
var deck_manager = piece.get_parent().get_parent().get_parent().deckManager
|
var deck_manager = piece.get_parent().get_parent().get_parent().deckManager
|
||||||
|
|
@ -30,5 +29,3 @@ func update_appearance() -> void:
|
||||||
(base_color.b + tile_color.b) / 2
|
(base_color.b + tile_color.b) / 2
|
||||||
)
|
)
|
||||||
base_button.add_theme_stylebox_override("normal", style)
|
base_button.add_theme_stylebox_override("normal", style)
|
||||||
else:
|
|
||||||
restore_base_appearance()
|
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,41 @@
|
||||||
class_name FireWallTile
|
class_name FireWallTile
|
||||||
extends Tile
|
extends Tile
|
||||||
|
|
||||||
func _init(button: Button, is_white: bool, d: int, owner: TileOwner = TileOwner.GAME) -> void:
|
func _init(button: Button, is_white: bool) -> void:
|
||||||
super._init(button, is_white, d)
|
super._init(button, is_white)
|
||||||
tile_name = "Fire Wall"
|
tile_name = "Fire Wall"
|
||||||
description = "Captures any piece that moves through"
|
description = "Captures any piece that moves through"
|
||||||
type = TileType.GENERAL
|
type = TileType.GENERAL
|
||||||
duration = d
|
duration = 3
|
||||||
tile_owner = owner
|
|
||||||
|
|
||||||
func apply_effect(piece: Pawn = null) -> void:
|
func apply_effect(piece: Pawn = null) -> void:
|
||||||
if piece && is_effect_active():
|
if piece && is_effect_active():
|
||||||
# Only affect enemy pieces based on tile owner
|
# Get the parent container and remove the piece
|
||||||
var is_enemy = false
|
|
||||||
print("--------___CHECKING FIREWALL")
|
|
||||||
print(tile_owner, " ", piece.Item_Color)
|
|
||||||
match tile_owner:
|
|
||||||
TileOwner.PLAYER: # White
|
|
||||||
print("PLAYER OWNER")
|
|
||||||
is_enemy = piece.Item_Color == 1 # Black pieces are enemy
|
|
||||||
TileOwner.ENEMY: # Black
|
|
||||||
is_enemy = piece.Item_Color == 0 # White pieces are enemy
|
|
||||||
TileOwner.GAME:
|
|
||||||
is_enemy = true # Game-owned fire affects all
|
|
||||||
|
|
||||||
if is_enemy:
|
|
||||||
|
|
||||||
var container = piece.get_parent() as PieceContainer
|
var container = piece.get_parent() as PieceContainer
|
||||||
if container:
|
if container:
|
||||||
game.updatePoints(piece)
|
var board = container.get_parent().get_parent() as ChessGame
|
||||||
|
board.updatePoints(piece)
|
||||||
container.remove_piece()
|
container.remove_piece()
|
||||||
|
|
||||||
func update_appearance() -> void:
|
func update_appearance() -> void:
|
||||||
if is_effect_active() && base_button:
|
if is_effect_active() && base_button:
|
||||||
var style = StyleBoxFlat.new()
|
var style = StyleBoxFlat.new()
|
||||||
var tile_color = Color(1, 0.4, 0) # Default orange-ish color for effects
|
var tile_color = Color(1, 0.4, 0) # Orange for fire
|
||||||
var base_color = Color(0.8, 0.8, 0.8) if base_is_white else Color(0.2, 0.2, 0.2)
|
var base_color = Color(0.8, 0.8, 0.8) if base_is_white else Color(0.2, 0.2, 0.2)
|
||||||
|
|
||||||
# Blend the tile effect color with the base chess board color
|
|
||||||
style.bg_color = Color(
|
style.bg_color = Color(
|
||||||
(base_color.r + tile_color.r) / 2,
|
(base_color.r + tile_color.r) / 2,
|
||||||
(base_color.g + tile_color.g) / 2,
|
(base_color.g + tile_color.g) / 2,
|
||||||
(base_color.b + tile_color.b) / 2
|
(base_color.b + tile_color.b) / 2
|
||||||
)
|
)
|
||||||
|
|
||||||
# Apply the style using theme override
|
# Add overlay effect for fire
|
||||||
base_button.add_theme_stylebox_override("normal", style)
|
var overlay = ColorRect.new()
|
||||||
|
overlay.name = "FireOverlay"
|
||||||
|
overlay.color = Color(1, 0.4, 0, 0.3) # Semi-transparent orange
|
||||||
|
overlay.size = base_button.size
|
||||||
|
overlay.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||||
|
|
||||||
|
base_button.add_child(overlay)
|
||||||
else:
|
else:
|
||||||
restore_base_appearance()
|
restore_base_appearance()
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
class_name PawnBoostTile
|
class_name PawnBoostTile
|
||||||
extends Tile
|
extends Tile
|
||||||
|
|
||||||
func _init(button: Button, is_white: bool, d: int) -> void:
|
func _init(button: Button, is_white: bool) -> void:
|
||||||
super._init(button, is_white, d)
|
super._init(button, is_white)
|
||||||
tile_name = "Pawn Boost"
|
tile_name = "Pawn Boost"
|
||||||
description = "While a Bishop is here, friendly pawns can move 2 spots"
|
description = "While a Bishop is here, friendly pawns can move 2 spots"
|
||||||
type = TileType.GLOBAL
|
type = TileType.GLOBAL
|
||||||
target_piece_type = "Bishop"
|
target_piece_type = "Bishop"
|
||||||
tile_owner = TileOwner.GAME
|
tile_owner = TileOwner.GAME
|
||||||
duration = d
|
duration = -1
|
||||||
|
|
||||||
func apply_effect(piece: Pawn = null) -> void:
|
func apply_effect(piece: Pawn = null) -> void:
|
||||||
print("APPLY PawnBoostTile")
|
|
||||||
if piece && is_effect_active() && piece.name == "Bishop":
|
if piece && is_effect_active() && piece.name == "Bishop":
|
||||||
# This would be implemented in the pawn movement calculation
|
# This would be implemented in the pawn movement calculation
|
||||||
pass
|
pass
|
||||||
|
|
@ -28,6 +27,3 @@ func update_appearance() -> void:
|
||||||
(base_color.b + tile_color.b) / 2
|
(base_color.b + tile_color.b) / 2
|
||||||
)
|
)
|
||||||
base_button.add_theme_stylebox_override("normal", style)
|
base_button.add_theme_stylebox_override("normal", style)
|
||||||
else:
|
|
||||||
restore_base_appearance()
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue