summaryrefslogtreecommitdiff
path: root/lib/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/board.c')
-rw-r--r--lib/board.c18
1 files changed, 18 insertions, 0 deletions
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;
+}
nihil fit ex nihilo