From 9ad93043d107926b48196b9c9ba9588ded5f4b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Tue, 31 Mar 2015 15:33:24 -0300 Subject: board make move --- lib/board.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib') diff --git a/lib/board.c b/lib/board.c index 774bfd5..a53c356 100644 --- a/lib/board.c +++ b/lib/board.c @@ -3,6 +3,7 @@ #include "board.h" #include "coordinate.h" +#include "move.h" #include "piece.h" static Board _setup_colors(Board b) { @@ -148,3 +149,20 @@ Board board_set_square(Board b, Coord c, Square s) { return b; } + +Board board_make_move(Board b, Move m) { + /* Get piece from orig square coordinate */ + Square s = board_get_square(b, move_get_orig(m)); + Piece *p = s.piece; + + /* Empty orig square */ + s.piece = NULL; + board_set_square(b, move_get_orig(m), s); + + /* Set piece on dest square */ + s = board_get_square(b, move_get_dest(m)); + s.piece = p; + board_set_square(b, move_get_dest(m), s); + + return b; +} -- cgit v1.2.3