ChessBuilder/Systems/Tiles/FireWall.gd

50 lines
No EOL
1.8 KiB
GDScript

class_name FireWallTile
extends Tile
func _init(button: Button, is_white: bool, d: int, owner: TileOwner = TileOwner.GAME) -> void:
super._init(button, is_white, d)
tile_name = "Fire Wall"
description = "Captures any piece that moves through"
type = TileType.GENERAL
duration = d
tile_owner = owner
func apply_effect(piece: Pawn = null) -> void:
if piece && is_effect_active():
# Only affect enemy pieces based on tile owner
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
if container:
game.updatePointsAndCapture(piece)
func update_appearance() -> void:
if is_effect_active() && base_button:
var style = StyleBoxFlat.new()
var tile_color = Color(1, 0.4, 0) # Default orange-ish color for effects
var base_color = Utils.LIGHT_CELL if base_is_white else Utils.DARK_CELL
# Blend the tile effect color with the base chess board color
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
)
# Apply the style using theme override
base_button.add_theme_stylebox_override("normal", style)
else:
restore_base_appearance()