ChessBuilder/Systems/Tiles/DoubleMovement.gd

34 lines
1.3 KiB
GDScript

class_name DoubleMovementTile
extends Tile
func _init(button: Button, is_white: bool, d: int) -> void:
super._init(button, is_white, d)
tile_name = "Double Movement"
description = "Any unit that starts its turn here gets double movement for 2 turns"
type = TileType.GENERAL
tile_owner = TileOwner.GAME
duration = d # Permanent tile
func apply_effect(piece: Pawn = null) -> void:
print("APPLY DoubleMovementTile")
if piece && is_effect_active():
# Add double movement effect to the piece
var deck_manager = piece.get_parent().get_parent().get_parent().deckManager
var double_time = DoubleTimeCard.new()
double_time.duration = 2
deck_manager.playCard(double_time, piece)
func update_appearance() -> void:
if is_effect_active() && base_button:
var style = StyleBoxFlat.new()
var tile_color = Color(0, 0.8, 0.8) # Cyan for speed
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()