drunk driving respects tile passablity
This commit is contained in:
parent
cc18ab32d8
commit
43fe315083
1 changed files with 16 additions and 1 deletions
|
|
@ -32,8 +32,22 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
tiles_to_check.append(str(current_x) + "-" + str(y))
|
tiles_to_check.append(str(current_x) + "-" + str(y))
|
||||||
y += y_direction
|
y += y_direction
|
||||||
|
|
||||||
|
# Find final position (stop before any impassable tile)
|
||||||
|
var final_y = target_y
|
||||||
|
for tile_name in tiles_to_check:
|
||||||
|
var tile = game_state.tileManager.get_tile(tile_name)
|
||||||
|
if tile && !tile.passable:
|
||||||
|
# Stop at the tile before this one
|
||||||
|
var tile_y = int(tile_name.split("-")[1])
|
||||||
|
final_y = tile_y - y_direction
|
||||||
|
break
|
||||||
# Process pieces in path
|
# Process pieces in path
|
||||||
for tile_name in tiles_to_check:
|
for tile_name in tiles_to_check:
|
||||||
|
var tile_y = int(tile_name.split("-")[1])
|
||||||
|
# Only process tiles up to where we're stopping
|
||||||
|
if (y_direction > 0 && tile_y > final_y) || (y_direction < 0 && tile_y < final_y):
|
||||||
|
break
|
||||||
|
|
||||||
var container = board_flow.get_node(tile_name) as PieceContainer
|
var container = board_flow.get_node(tile_name) as PieceContainer
|
||||||
if container.has_piece():
|
if container.has_piece():
|
||||||
var piece_to_capture = container.get_piece()
|
var piece_to_capture = container.get_piece()
|
||||||
|
|
@ -41,7 +55,8 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||||
container.remove_piece()
|
container.remove_piece()
|
||||||
|
|
||||||
# Move piece to final position
|
# Move piece to final position
|
||||||
var final_container = board_flow.get_node(str(current_x) + "-" + str(target_y)) as PieceContainer
|
var final_container = board_flow.get_node(str(current_x) + "-" + str(final_y)) as PieceContainer
|
||||||
|
|
||||||
|
|
||||||
# Important: Need to remove the piece from its current container first
|
# Important: Need to remove the piece from its current container first
|
||||||
# AND keep a reference to it
|
# AND keep a reference to it
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue