# HG changeset patch # User Mike Becker # Date 1396340888 -7200 # Node ID 4d030da07c88dc6b8870228d0798bb2363bcfe3a # Parent 824c9522ce6600e21ac3c373638ca504727f0530 implemented queen diff -r 824c9522ce66 -r 4d030da07c88 src/chess/queen.c --- a/src/chess/queen.c Mon Mar 31 15:03:25 2014 +0200 +++ b/src/chess/queen.c Tue Apr 01 10:28:08 2014 +0200 @@ -28,19 +28,43 @@ */ #include "rules.h" +#include "rook.h" +#include "bishop.h" #include "queen.h" _Bool queen_chkrules(Move* move) { - // TODO: implement - return 0; + return bishop_chkrules(move) || rook_chkrules(move); } _Bool queen_isblocked(GameState *gamestate, Move *move) { - // TODO: implement - return 1; + if (rook_chkrules(move)) { + return rook_isblocked(gamestate, move); + } else { + return bishop_isblocked(gamestate, move); + } } int queen_getlocation(GameState *gamestate, Move *move) { - // TODO: implement - return INVALID_MOVE_SYNTAX; + + Move moveasrook = *move; + int rookaspect = rook_getlocation(gamestate, &moveasrook); + + Move moveasbishop = *move; + int bishopaspect = bishop_getlocation(gamestate, &moveasbishop); + + if (rookaspect == VALID_MOVE_SYNTAX && bishopaspect == VALID_MOVE_SYNTAX) { + return AMBIGUOUS_MOVE; + } + + if (rookaspect == VALID_MOVE_SYNTAX) { + *move = moveasrook; + return VALID_MOVE_SYNTAX; + } + + if (bishopaspect == VALID_MOVE_SYNTAX) { + *move = moveasbishop; + return VALID_MOVE_SYNTAX; + } + + return INVALID_POSITION; }