# HG changeset patch # User Mike Becker # Date 1395505387 -3600 # Node ID 1347e4dabac0ab3a9567064ff4e8a919c6ab8eb2 # Parent 4e4f156bba58fe4de1626f35f34645690da76654 prepared code base for implementing rules diff -r 4e4f156bba58 -r 1347e4dabac0 Makefile --- a/Makefile Sat Mar 22 16:25:49 2014 +0100 +++ b/Makefile Sat Mar 22 17:23:07 2014 +0100 @@ -30,11 +30,15 @@ all: clean compile -compile: build +compile: build build/rules cd src; $(MAKE) build: $(MKDIR) build + +build/rules: + $(MKDIR) build/rules clean: $(RM) -f -R build + $(RM) -f -R build/rules diff -r 4e4f156bba58 -r 1347e4dabac0 src/Makefile --- a/src/Makefile Sat Mar 22 16:25:49 2014 +0100 +++ b/src/Makefile Sat Mar 22 17:23:07 2014 +0100 @@ -35,6 +35,13 @@ SRC += client.c SRC += game.c +SRC += rules/pawn.c +SRC += rules/rook.c +SRC += rules/knight.c +SRC += rules/bishop.c +SRC += rules/queen.c +SRC += rules/king.c + OBJ = $(SRC:%.c=../build/%$(OBJ_EXT)) all: $(OBJ) diff -r 4e4f156bba58 -r 1347e4dabac0 src/game.c --- a/src/game.c Sat Mar 22 16:25:49 2014 +0100 +++ b/src/game.c Sat Mar 22 17:23:07 2014 +0100 @@ -29,6 +29,7 @@ #include "game.h" #include "input.h" +#include "rules/rules.h" #include #include @@ -91,16 +92,39 @@ } static _Bool validate_move(Board board, uint8_t mycolor, Move *move) { - _Bool result = TRUE; + _Bool result; /* does piece exist */ - result &= board[move->fromrow][move->fromfile] == move->piece; + result = board[move->fromrow][move->fromfile] == move->piece; - /* does move comply to rules */ - // TODO: make it so - - /* is piece blocked */ - // TODO: make it so + switch (move->piece & PIECE_MASK) { + case PAWN: + result = result && pawn_chkrules(board, move); + result = result && !pawn_isblocked(board, move); + break; + case ROOK: + result = result && rook_chkrules(board, move); + result = result && !rook_isblocked(board, move); + break; + case KNIGHT: + result = result && knight_chkrules(board, move); + result = result && !knight_isblocked(board, move); + break; + case BISHOP: + result = result && bishop_chkrules(board, move); + result = result && !bishop_isblocked(board, move); + break; + case QUEEN: + result = result && queen_chkrules(board, move); + result = result && !queen_isblocked(board, move); + break; + case KING: + result = result && king_chkrules(board, move); + result = result && !king_isblocked(board, move); + break; + default: + result = FALSE; + } /* is piece pinned */ // TODO: make it so @@ -122,28 +146,17 @@ if (len == 2) { /* pawn move (e.g. "e4") */ if (isfile(mstr[0]) && isrow(mstr[1])) { - move->piece = PAWN; - move->fromfile = move->tofile = fileidx(mstr[0]); + move->piece = PAWN|mycolor; + move->tofile = fileidx(mstr[0]); move->torow = rowidx(mstr[1]); - move->fromrow = rowidx(mstr[1]) + (mycolor == WHITE ? -1 : 1); - if (move->fromrow > 6) { + if (!pawn_getlocation(board, move)) { move->piece = 0; - } else { - /* advanced first move */ - if (move->fromrow == (mycolor == WHITE ? 2 : 5) && - board[move->fromrow][move->fromfile] != (mycolor|PAWN)) { - - move->fromrow += (mycolor == WHITE ? -1 : 1); - if (move->fromrow > 6) { - move->piece = 0; - } - } } } } else if (len == 3) { if (strcmp(mstr, "O-O") == 0) { /* king side castling */ - move->piece = KING; + move->piece = KING|mycolor; move->fromfile = fileidx('e'); move->tofile = fileidx('g'); move->fromrow = move->torow = mycolor == WHITE ? 0 : 7; @@ -159,7 +172,7 @@ } else if (len == 5) { if (strcmp(mstr, "O-O-O") == 0) { /* queen side castling "O-O-O" */ - move->piece = KING; + move->piece = KING|mycolor; move->fromfile = fileidx('e'); move->tofile = fileidx('c'); move->fromrow = move->torow = mycolor == WHITE ? 0 : 7; @@ -174,12 +187,7 @@ /* long notation capture (e.g. "Nc5xf3") */ } - if (move->piece) { - move->piece |= mycolor; - return TRUE; - } else { - return FALSE; - } + return move->piece != 0; } static int sendmove(Board board, uint8_t mycolor, int opponent) { diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/bishop.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/bishop.c Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,45 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "bishop.h" + +_Bool bishop_chkrules(Board board, Move* move) { + // TODO: implement + return TRUE; +} + +_Bool bishop_isblocked(Board board, Move *move) { + // TODO: implement + return FALSE; +} + +_Bool bishop_getlocation(Board board, Move *move) { + // TODO: implement + return TRUE; +} diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/bishop.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/bishop.h Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,48 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef BISHOP_H +#define BISHOP_H + +#include "../game.h" + +#ifdef __cplusplus +extern "C" { +#endif + +_Bool bishop_chkrules(Board board, Move *move); +_Bool bishop_isblocked(Board board, Move *move); +_Bool bishop_getlocation(Board board, Move *move); + +#ifdef __cplusplus +} +#endif + +#endif /* BISHOP_H */ + diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/king.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/king.c Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,45 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "king.h" + +_Bool king_chkrules(Board board, Move* move) { + // TODO: implement + return TRUE; +} + +_Bool king_isblocked(Board board, Move *move) { + // TODO: implement + return FALSE; +} + +_Bool king_getlocation(Board board, Move *move) { + // TODO: implement + return TRUE; +} diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/king.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/king.h Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,49 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef KING_H +#define KING_H + +#include "../game.h" + +#ifdef __cplusplus +extern "C" { +#endif + +_Bool king_chkrules(Board board, Move *move); +_Bool king_isblocked(Board board, Move *move); +_Bool king_getlocation(Board board, Move *move); + +#ifdef __cplusplus +} +#endif + +#endif /* KING_H */ + diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/knight.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/knight.c Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,45 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "knight.h" + +_Bool knight_chkrules(Board board, Move *move) { + // TODO: implement + return TRUE; +} + +_Bool knight_isblocked(Board board, Move *move) { + // TODO: implement + return FALSE; +} + +_Bool knight_getlocation(Board board, Move *move) { + // TODO: implement + return TRUE; +} diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/knight.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/knight.h Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,48 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef KNIGHT_H +#define KNIGHT_H + +#include "../game.h" + +#ifdef __cplusplus +extern "C" { +#endif + +_Bool knight_chkrules(Board board, Move *move); +_Bool knight_isblocked(Board board, Move *move); +_Bool knight_getlocation(Board board, Move *move); + +#ifdef __cplusplus +} +#endif + +#endif /* KNIGHT_H */ + diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/pawn.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/pawn.c Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,61 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "pawn.h" + +_Bool pawn_chkrules(Board board, Move *move) { + // TODO: implement + return TRUE; +} + +_Bool pawn_isblocked(Board board, Move *move) { + // TODO: implement + return FALSE; +} + +_Bool pawn_getlocation(Board board, Move *move) { + int8_t d = ((move->piece & COLOR_MASK) == WHITE ? -1 : 1); + + move->fromfile = move->tofile; + move->fromrow = move->torow + d; + if (move->fromrow > 6) { + return FALSE; + } else { + /* advanced first move */ + if (move->fromrow == (d < 0 ? 2 : 5) && + board[move->fromrow][move->fromfile] != move->piece) { + + move->fromrow += d; + if (move->fromrow > 6) { + return FALSE; + } + } + } + return TRUE; +} diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/pawn.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/pawn.h Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,48 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef PAWN_H +#define PAWN_H + +#include "../game.h" + +#ifdef __cplusplus +extern "C" { +#endif + +_Bool pawn_chkrules(Board board, Move *move); +_Bool pawn_isblocked(Board board, Move *move); +_Bool pawn_getlocation(Board board, Move *move); + +#ifdef __cplusplus +} +#endif + +#endif /* PAWN_H */ + diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/queen.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/queen.c Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,45 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "queen.h" + +_Bool queen_chkrules(Board board, Move* move) { + // TODO: implement + return TRUE; +} + +_Bool queen_isblocked(Board board, Move *move) { + // TODO: implement + return FALSE; +} + +_Bool queen_getlocation(Board board, Move *move) { + // TODO: implement + return TRUE; +} diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/queen.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/queen.h Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,48 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef QUEEN_H +#define QUEEN_H + +#include "../game.h" + +#ifdef __cplusplus +extern "C" { +#endif + +_Bool queen_chkrules(Board board, Move *move); +_Bool queen_isblocked(Board board, Move *move); +_Bool queen_getlocation(Board board, Move *move); + +#ifdef __cplusplus +} +#endif + +#endif /* QUEEN_H */ + diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/rook.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/rook.c Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,45 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "rook.h" + +_Bool rook_chkrules(Board board, Move *move) { + // TODO: implement + return TRUE; +} + +_Bool rook_isblocked(Board board, Move *move) { + // TODO: implement + return FALSE; +} + +_Bool rook_getlocation(Board board, Move *move) { + // TODO: implement + return TRUE; +} diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/rook.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/rook.h Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,48 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef ROOK_H +#define ROOK_H + +#include "../game.h" + +#ifdef __cplusplus +extern "C" { +#endif + +_Bool rook_chkrules(Board board, Move *move); +_Bool rook_isblocked(Board board, Move *move); +_Bool rook_getlocation(Board board, Move *move); + +#ifdef __cplusplus +} +#endif + +#endif /* ROOK_H */ + diff -r 4e4f156bba58 -r 1347e4dabac0 src/rules/rules.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rules/rules.h Sat Mar 22 17:23:07 2014 +0100 @@ -0,0 +1,41 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef RULES_H +#define RULES_H + +#include "pawn.h" +#include "rook.h" +#include "knight.h" +#include "bishop.h" +#include "queen.h" +#include "king.h" + +#endif /* RULES_H */ +