summaryrefslogtreecommitdiff
path: root/lib/board.c
diff options
context:
space:
mode:
authorRaúl Benencia <rul@kalgan.cc>2015-03-31 15:33:24 -0300
committerRaúl Benencia <rul@kalgan.cc>2015-03-31 15:33:24 -0300
commit9ad93043d107926b48196b9c9ba9588ded5f4b64 (patch)
tree6d344646bb390c3d7212fcb4ac7f26bfc555c2a8 /lib/board.c
parentc81bc656c6226883b7e3cae5269532123c7dea76 (diff)
board make move
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