diff --git a/general.h b/general.h index 0546286..216d6bb 100644 --- a/general.h +++ b/general.h @@ -3,7 +3,7 @@ * --------------------------------------------------------- * Exercise Number: n/a * Title: general.h - * Author: P. Bauer, S. Schraml, *//* + * Author: P. Bauer, S. Schraml, Marc Tismonar * ---------------------------------------------------------- * Description: * General usable definitions and types. @@ -29,23 +29,30 @@ typedef unsigned short ColAddr; typedef char RowAddr; /** CellMarker: The enumeration of cell markers. */ +typedef enum { NONE, /* cell is not marked */ MINE_DETECTED, /* cell carries a mine */ MINE_SUSPECTED /* cell is suspected to carry a mine */ +} CellMarker; /** GameMode: The enumeration of defined game modes (sizes) */ +typedef enum { BEGINNER, /* a 'small' game, e.g. 8x8 cells having a low number of mines (e.g. 10) */ ADVANCED, /* a 'medium' game, e.g. 16x16 cells having a medium number of mines (e.g. 40) */ EXPERT, /* a 'large' game, e.g. 26x18 cells having a high number of mines (e.g. 99) */ CUSTOM, /* a customized game, number of columns, rows, and mines are defined by the user */ +} GameMode; /** GameState: The enumeration of game states. */ +typedef enum { INVALID, /* default state */ IN_PROGRESS, /* the game is currently played */ SOLVED, /* the game was successfully completed */ FAILED /* the game was not successfully completed */ +} GameState; /** Action: The enumeration of possible user input actions. */ +typedef enum { UNKNOWN, /* default state, input was not recognized */ CELL_SELECT, /* the user entered a (possibly invalid) cell address. */ MARK_MINE, /* the action to mark the selected cell having a mine */ @@ -53,6 +60,7 @@ typedef char RowAddr; CLEAR_MARKER, /* the action for removing a marker on the selected cell */ UNCOVER, /* the action to uncover a (possibly) selected cell */ QUIT_GAME, /* the action to terminate the game */ +} Action; /** Convenience macro do get maximum of two numbers */ #define MAX(x, y) ((x) > (y) ? (x) : (y)) diff --git a/ms_board.c b/ms_board.c index bf5cb85..bdd525b 100644 --- a/ms_board.c +++ b/ms_board.c @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: B1 * Title: Mine Sweeper Board implementation - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Implementation of ms_board.h. diff --git a/ms_board.h b/ms_board.h index a3be1b2..0c623ec 100644 --- a/ms_board.h +++ b/ms_board.h @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: B1 * Title: Mine Sweeper - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * The declaration of an Abstract Data Type representing @@ -11,7 +11,17 @@ * ---------------------------------------------------------- */ +#ifndef ___MS_BOARD_H +#define ___MS_BOARD_H + +#include + +#include "config.h" +#include "general.h" +#include "ms_cell.h" + /** MsBoard: Declares type for the 'Mine Sweeper' board */ +typedef struct MsBoardData* MsBoard; /** * Provides the instance of the 'Mine Sweeper' board. @@ -20,6 +30,7 @@ * * @return The board instance. */ +MsBoard msb_get_board(); /** * Initializes the only Mine Sweeper board: @@ -31,7 +42,7 @@ * @param column_count The number of cell columns of the board. * @param row_count The number of cell row of the board. */ - msb_init_board(); +void msb_init_board(MsBoard board, Count column_count, Count row_count); /** * Determines whether or not the given board is valid. @@ -42,7 +53,7 @@ * @param board The board instance in focus. * @return True if the given board is valid, false otherwise. */ - msb_is_valid(); +bool msb_is_valid(MsBoard board); /** * Provides the cell at the given coordinates. @@ -52,7 +63,7 @@ * @param row_idx The index of the row of the addressed cell. * @return The addressed cell or 0, if the coordinates are not in range. */ - msb_get_cell(); +MsCell msb_get_cell(MsBoard board, CellIdx col_idx, CellIdx row_idx); /** * Provides the number of columns used by the current game (of the 'active' area). @@ -61,7 +72,7 @@ * @return The number of columns used for the current board configuration or 0, * if the board is not configured or invalid. */ - msb_get_column_count(); +Count msb_get_column_count(MsBoard board); /** * Provides the number of rows used by the current game (of the 'active' area). @@ -70,4 +81,6 @@ * @return The number of columns used for the current board configuration or 0, * if the board is not configured or invalid. */ - msb_get_row_count(); +Count msb_get_row_count(MsBoard board); + +#endif \ No newline at end of file diff --git a/ms_cell.c b/ms_cell.c index e933c61..0a30241 100644 --- a/ms_cell.c +++ b/ms_cell.c @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: B1 * Title: Mine Sweeper Cell implementation - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Implementation of ms_cell.h. diff --git a/ms_cell.h b/ms_cell.h index 8b7d3ab..62a67c7 100644 --- a/ms_cell.h +++ b/ms_cell.h @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: B1 * Title: Mine Sweeper - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * The declaration of an Abstract Data Type representing @@ -11,6 +11,9 @@ * ---------------------------------------------------------- */ +#ifndef ___MS_CELL_H +#define ___MS_CELL_H + /* Note: The 'CellMarker' enumeration is declared in 'general.h' to enable mapping between enum and presentation in 'ms_ui_utils' */ @@ -114,3 +117,5 @@ * @param marker The marker to apply. */ msc_set_marker(); + +#endif \ No newline at end of file diff --git a/ms_game.c b/ms_game.c index 337cdfb..39f66f4 100644 --- a/ms_game.c +++ b/ms_game.c @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: B1 - * Title: Mine Sweeper GAme implementation - * Author: *//* + * Title: Mine Sweeper Game implementation + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Implementation of ms_game.h. diff --git a/ms_game.h b/ms_game.h index faca44c..c43ab2f 100644 --- a/ms_game.h +++ b/ms_game.h @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: B1 * Title: Mine Sweeper - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * The declaration of an Abstract Data Type representing diff --git a/ms_main_driver.c b/ms_main_driver.c index b3b83f7..70cbf83 100644 --- a/ms_main_driver.c +++ b/ms_main_driver.c @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Klasse: n/a + * HTBLA-Leonding / Klasse: 2IHIF * --------------------------------------------------------- * Exercise Number: B1 * Title: Mine Sweeper - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * The Mine Sweeper Application. diff --git a/ms_ui_utils.c b/ms_ui_utils.c index 11c89d3..60bf537 100644 --- a/ms_ui_utils.c +++ b/ms_ui_utils.c @@ -1,9 +1,9 @@ /*---------------------------------------------------------- - * HTBLA-Leonding / Class: + * HTBLA-Leonding / Class: 2IHIF * --------------------------------------------------------- * Exercise Number: B1 * Title: Mine Sweeper User Interface Utilities - * Author: *//* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * Implementation of ms_ui_utils.h. diff --git a/ms_ui_utils.h b/ms_ui_utils.h index 97dd4b2..35f63e6 100644 --- a/ms_ui_utils.h +++ b/ms_ui_utils.h @@ -1,9 +1,9 @@ -/*---------------------------------------------------------- - * HTBLA-Leonding / Class: +/* + * Author: Marc Tismonar * ---------------------------------------------------------- * Description: * The declaration of a library providing utility functions