X-Git-Url: https://git.cworth.org/git?p=dvonn;a=blobdiff_plain;f=dvonn-board.h;fp=dvonn-board.h;h=b0ee8cc46a449dfd5d7d4f4201b68140520567fe;hp=c1c82707c180904fd7a96387a86fbc27716a2b1c;hb=0eff3c58b93ea73e7f1aa866f6e317714479dd6e;hpb=eff695079bc44eb96226db9db6fd6cacc9497b9b diff --git a/dvonn-board.h b/dvonn-board.h index c1c8270..b0ee8cc 100644 --- a/dvonn-board.h +++ b/dvonn-board.h @@ -37,6 +37,7 @@ typedef enum { typedef enum { DVONN_CELL_BLACK = DVONN_PLAYER_BLACK, DVONN_CELL_WHITE = DVONN_PLAYER_WHITE, + DVONN_CELL_RED, DVONN_CELL_EMPTY, DVONN_CELL_INVALID } dvonn_cell_type_t; @@ -49,16 +50,32 @@ typedef struct { #define DVONN_BOARD_X_SIZE 11 #define DVONN_BOARD_Y_SIZE 5 +typedef enum { + DVONN_PHASE_PLACEMENT, + DVONN_PHASE_MOVEMENT +} dvonn_phase_t; + typedef struct { dvonn_cell_t cells[DVONN_BOARD_X_SIZE][DVONN_BOARD_Y_SIZE]; - + dvonn_phase_t phase; dvonn_player_t player; + int moves; } dvonn_board_t; /* Initialize a board for a new game of DVONN. */ void dvonn_board_init (dvonn_board_t *board); +/* Place a piece at (x,y) where (0,0) is at the upper-left corner of + * the board. Returns TRUE if the move is legal and is performed. If + * the move is not legal this function returns FALSE, no change will + * be performed on the board, and *error will be set to a string + * describing why the move is illegal.*/ +int +dvonn_board_place (dvonn_board_t *board, + int x, int y, + char **error); + /* Move a piece from (x1,y1) to (x2,y2) where (0,0) is at the * upper-left corner of the board. Returns TRUE if the move is legal * and is performed. If the move is not legal this function returns