feat: implement and exhaustively test the game domain core
This commit is contained in:
+13
-1
@@ -17,7 +17,17 @@ enum { MODE_HUMAN, MODE_BOT };
|
||||
typedef struct { uint8_t x; uint8_t y; } coordinate_t;
|
||||
typedef struct { uint8_t x; uint8_t y; uint8_t length; uint8_t hits; bool horizontal; } ship_t;
|
||||
typedef struct { cell_t cells[kBoardCellCount]; ship_t ships[kFleetShipCount]; uint8_t ships_alive; } board_t;
|
||||
typedef struct { uint32_t game_id; uint32_t version; phase_t phase; game_mode_t mode; uint8_t current_player; board_t boards[kPlayerCapacity]; } game_state_t;
|
||||
typedef struct { uint16_t shots; uint16_t hits; uint16_t misses; uint8_t ships_sunk; } match_statistics_t;
|
||||
typedef struct {
|
||||
uint32_t game_id;
|
||||
uint32_t version;
|
||||
phase_t phase;
|
||||
game_mode_t mode;
|
||||
uint8_t current_player;
|
||||
uint8_t winner;
|
||||
board_t boards[kPlayerCapacity];
|
||||
match_statistics_t statistics[kPlayerCapacity];
|
||||
} game_state_t;
|
||||
|
||||
_Static_assert(kBoardCellCount == 100, "board contract changed");
|
||||
_Static_assert(kFleetShipCount == 10, "fleet contract changed");
|
||||
@@ -25,3 +35,5 @@ _Static_assert(kSessionCapacity == 10, "session contract changed");
|
||||
_Static_assert(sizeof(coordinate_t) == 2, "coordinate must remain compact");
|
||||
_Static_assert(sizeof(ship_t) <= 6, "ship grew beyond fixed budget");
|
||||
_Static_assert(sizeof(board_t) <= 164, "board grew beyond fixed budget");
|
||||
_Static_assert(sizeof(match_statistics_t) <= 8, "statistics grew beyond fixed budget");
|
||||
_Static_assert(sizeof(game_state_t) <= 360, "game state grew beyond fixed budget");
|
||||
|
||||
Reference in New Issue
Block a user