55 lines
2.1 KiB
GDScript
55 lines
2.1 KiB
GDScript
class_name PawnBoostTile
|
|
extends Tile
|
|
|
|
var boosted_pawns: Array[int] = []
|
|
func _init(button: Button, is_white: bool, d: int) -> void:
|
|
super._init(button, is_white, d)
|
|
tile_name = "Pawn Boost"
|
|
description = "While a Bishop is here, friendly pawns can move 2 spots"
|
|
type = TileType.GLOBAL
|
|
target_piece_type = "Bishop"
|
|
tile_owner = TileOwner.GAME
|
|
duration = d
|
|
|
|
func apply_effect(piece: Pawn = null) -> void:
|
|
print("APPLY PawnBoostTile")
|
|
if piece && is_effect_active() && piece.name == "Bishop":
|
|
# Get all pawns of the same color as the bishop
|
|
var bishop_color = piece.Item_Color
|
|
|
|
# Clear previous boosts
|
|
boosted_pawns.clear()
|
|
|
|
# Find all pawns of the same color
|
|
for child in game.boardContainer.get_children():
|
|
if child is PieceContainer:
|
|
var pawn = child.get_piece()
|
|
if pawn && pawn.name == "Pawn" && pawn.Item_Color == bishop_color:
|
|
var pawn_id = pawn.get_instance_id()
|
|
if !boosted_pawns.has(pawn_id):
|
|
# Add double movement effect
|
|
var double_time = DoubleTimeCard.new()
|
|
double_time.duration = 1 # Just for this turn
|
|
game.deckManager.playEffect(double_time, pawn, null, game)
|
|
pawn.on_card_effect_changed()
|
|
boosted_pawns.append(pawn_id)
|
|
|
|
func remove_effect(piece: Pawn = null) -> void:
|
|
# Clean up any remaining boosts
|
|
boosted_pawns.clear()
|
|
|
|
func update_appearance() -> void:
|
|
if is_effect_active() && base_button:
|
|
var style = StyleBoxFlat.new()
|
|
var tile_color = Color(0, 0.8, 0) # Green for boost
|
|
var base_color = Color(0.8, 0.8, 0.8) if base_is_white else Color(0.2, 0.2, 0.2)
|
|
|
|
style.bg_color = Color(
|
|
(base_color.r + tile_color.r) / 2,
|
|
(base_color.g + tile_color.g) / 2,
|
|
(base_color.b + tile_color.b) / 2
|
|
)
|
|
base_button.add_theme_stylebox_override("normal", style)
|
|
else:
|
|
restore_base_appearance()
|
|
|