online multiplayer chess game (note server currently down)
Diffstat (limited to 'SanParse/Move.gd')
| -rw-r--r-- | SanParse/Move.gd | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/SanParse/Move.gd b/SanParse/Move.gd index f5e40d8..afa07a9 100644 --- a/SanParse/Move.gd +++ b/SanParse/Move.gd @@ -61,6 +61,8 @@ func compile() -> String: # compiles the structure to a san # print(Utils.to_algebraic(make_long(SanParse.parse("N1xc3").move_kind.data, false, SanParser.KNIGHT)[0]) == "b1") ### fix short san func make_long(): + if move_kind.type == MoveKind.CASTLE: + return var newvecs: PoolVector2Array = [] var vectors = move_kind.data @@ -85,21 +87,25 @@ func long_helper(vec: Vector2, attack: bool, move: bool, touch: Vector2): if vec.y == -1 and vec.x != -1: for y in range(8): var spot = Piece.at_pos(Vector2(vec.x, y)) - if Utils.spotispiece(piece, spot) and spot.can_touch(touch, attack, move): + if long_helper_helper(spot, touch, attack, move): return Vector2(vec.x, y) elif vec.x == -1 and vec.y != -1: for x in range(8): var spot = Piece.at_pos(Vector2(x, vec.y)) - if Utils.spotispiece(piece, spot) and spot.can_touch(touch, attack, move): + if long_helper_helper(spot, touch, attack, move): return Vector2(x, vec.y) elif vec == Vector2(-1, -1): for x in range(8): for y in range(8): var spot = Piece.at_pos(Vector2(x, y)) - if Utils.spotispiece(piece, spot) and spot.can_touch(touch, attack, move): + if long_helper_helper(spot, touch, attack, move): return Vector2(x, y) +func long_helper_helper(spot, touch, attack, move): + return Utils.spotispiece(piece, spot) and spot.white == Globals.turn and spot.can_touch(touch, attack, move) + + class MoveKind: extends Resource enum CASTLETYPES { NONE, QUEEN_SIDE, KING_SIDE } |