60 lines
No EOL
1.8 KiB
GDScript
60 lines
No EOL
1.8 KiB
GDScript
class_name DrunkDrivingCard extends Card
|
|
|
|
func _init():
|
|
super._init()
|
|
cardName = "Drunk Driving"
|
|
rank = Rank.RANK_1
|
|
duration = 1
|
|
effectType = EffectType.SPECIAL_ACTION
|
|
description = "Force Rook to careen towards the enemy side, capturing all pieces in its path"
|
|
unitWhitelist = ["Rook"]
|
|
|
|
func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
|
if !super.apply_effect(target_piece, board_flow, game_state):
|
|
print("FAILED DEFAULT FN")
|
|
return false
|
|
|
|
if !target_piece or !board_flow or !game_state:
|
|
print("FAILED DEFAULT FN 2")
|
|
return false
|
|
|
|
|
|
var current_pos = target_piece.get_parent().name.split("-")
|
|
var current_x = int(current_pos[0])
|
|
var current_y = int(current_pos[1])
|
|
|
|
|
|
var target_y = 7 if target_piece.Item_Color == 1 else 0
|
|
|
|
|
|
var y_direction = 1 if target_y > current_y else -1
|
|
|
|
|
|
var tiles_to_check = []
|
|
var y = current_y + y_direction
|
|
while y != target_y + y_direction:
|
|
tiles_to_check.append(str(current_x) + "-" + str(y))
|
|
y += y_direction
|
|
|
|
|
|
for tile_name in tiles_to_check:
|
|
var tile = board_flow.get_node(tile_name)
|
|
if tile.get_child_count() > 0:
|
|
var piece_to_capture = tile.get_child(0)
|
|
game_state.updatePoints(piece_to_capture)
|
|
piece_to_capture.queue_free()
|
|
|
|
|
|
var final_tile = board_flow.get_node(str(current_x) + "-" + str(target_y))
|
|
target_piece.reparent(final_tile)
|
|
target_piece.position = Vector2(25, 25)
|
|
|
|
|
|
game_state.currentlyMovingPiece = target_piece
|
|
|
|
burned = true
|
|
|
|
game_state.resolveMoveEffects();
|
|
game_state.stateMachine.transitionToNextState(Constants.POST_MOVE)
|
|
|
|
return true |