feat(game): complete authoritative gameplay mechanics
This commit is contained in:
@@ -223,7 +223,7 @@ static void test_visibility_and_serialization(void) {
|
||||
game.players[0].position = (maze32_cell_t){3U, 3U};
|
||||
game.players[1].position = (maze32_cell_t){4U, 4U};
|
||||
maze.passages[index_of(3U, 3U)] = 0U;
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_PLAYER_ONE, 3U, &view) ==
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_PLAYER_ONE, &view) ==
|
||||
MAZE32_GAME_RESULT_ACCEPTED);
|
||||
assert(view.cell_count == 49U);
|
||||
assert(view_has_cell(&view, index_of(6U, 6U)));
|
||||
@@ -231,7 +231,7 @@ static void test_visibility_and_serialization(void) {
|
||||
|
||||
game.players[0].position = (maze32_cell_t){0U, 0U};
|
||||
game.players[1].position = (maze32_cell_t){7U, 7U};
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_PLAYER_ONE, 3U, &view) ==
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_PLAYER_ONE, &view) ==
|
||||
MAZE32_GAME_RESULT_ACCEPTED);
|
||||
assert(view.cell_count == 16U);
|
||||
assert(!view.opponent_visible && view.opponent_cell_index == UINT16_MAX);
|
||||
@@ -239,7 +239,7 @@ static void test_visibility_and_serialization(void) {
|
||||
assert(!view_has_object(&view, MAZE32_VIEW_OBJECT_KEY, index_of(7U, 7U)));
|
||||
serialize_and_inspect(&view, 1);
|
||||
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_PLAYER_TWO, 3U, &view) ==
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_PLAYER_TWO, &view) ==
|
||||
MAZE32_GAME_RESULT_ACCEPTED);
|
||||
assert(view.cell_count == 16U && view.self_cell_index == index_of(7U, 7U));
|
||||
assert(!view.opponent_visible && !view_has_cell(&view, index_of(0U, 0U)));
|
||||
@@ -256,18 +256,19 @@ static void test_visibility_and_serialization(void) {
|
||||
assert(strstr(player_two_payload, "[\"key\",0,0,10]") == NULL);
|
||||
}
|
||||
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_PLAYER_ONE, 6U, &view) ==
|
||||
game.players[0].vision_moves_remaining = 1U;
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_PLAYER_ONE, &view) ==
|
||||
MAZE32_GAME_RESULT_ACCEPTED);
|
||||
assert(view.cell_count == 49U);
|
||||
assert(!view_has_cell(&view, index_of(7U, 7U)));
|
||||
|
||||
game.players[0].position = (maze32_cell_t){3U, 3U};
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_PLAYER_ONE, 6U, &view) ==
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_PLAYER_ONE, &view) ==
|
||||
MAZE32_GAME_RESULT_ACCEPTED);
|
||||
assert(view.cell_count == 64U);
|
||||
assert(view.opponent_visible);
|
||||
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_OBSERVER, 0U, &view) ==
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_OBSERVER, &view) ==
|
||||
MAZE32_GAME_RESULT_ACCEPTED);
|
||||
assert(view.cell_count == 64U);
|
||||
assert(view.object_count == 10U);
|
||||
@@ -286,12 +287,24 @@ static void test_default_map_chunk_bounds(void) {
|
||||
assert(maze32_maze_generate(&maze, &workspace, &maze_config, UINT32_C(0x5a320006), &report) ==
|
||||
MAZE32_MAZE_OK);
|
||||
maze32_game_t game = initialized_game(&maze);
|
||||
game.phase = MAZE32_GAME_PHASE_FINISHED;
|
||||
game.final_result = MAZE32_GAME_FINAL_DRAW;
|
||||
game.state_sequence = UINT32_MAX;
|
||||
game.meeting_sequence = UINT32_MAX;
|
||||
for (uint8_t player = 0U; player < MAZE32_GAME_PLAYER_COUNT; ++player) {
|
||||
game.players[player].vision_moves_remaining = MAZE32_GAME_VISION_MOVES;
|
||||
game.players[player].compass_hint = MAZE32_GAME_COMPASS_NORTH_WEST;
|
||||
game.players[player].exited = 1U;
|
||||
game.exits[player].open = 1U;
|
||||
game.has_exit_time[player] = 1U;
|
||||
game.exit_times_ms[player] = UINT64_MAX - player;
|
||||
}
|
||||
maze32_view_t view;
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_OBSERVER, 0U, &view) ==
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_OBSERVER, &view) ==
|
||||
MAZE32_GAME_RESULT_ACCEPTED);
|
||||
assert(view.cell_count == 8192U && view.object_count == 30U);
|
||||
size_t chunks = maze32_game_view_chunk_count(&view);
|
||||
assert(chunks == 345U);
|
||||
assert(chunks == 688U);
|
||||
char payload[MAZE32_GAME_VIEW_CHUNK_BYTES];
|
||||
size_t largest_chunk = 0U;
|
||||
for (size_t chunk = 0U; chunk < chunks; ++chunk) {
|
||||
|
||||
Reference in New Issue
Block a user