feat(trails): render authoritative player route trails
This commit is contained in:
@@ -324,12 +324,48 @@ static void test_default_map_chunk_bounds(void) {
|
||||
(unsigned int)chunks, (unsigned int)largest_chunk);
|
||||
}
|
||||
|
||||
static void test_authoritative_trails_and_visibility(void) {
|
||||
maze32_maze_t maze;
|
||||
open_test_grid(&maze);
|
||||
maze.starts[1] = (maze32_cell_t){2U, 1U};
|
||||
maze32_game_t game = initialized_game(&maze);
|
||||
maze32_game_set_phase(&game, MAZE32_GAME_PHASE_ACTIVE);
|
||||
uint32_t sequence = 0U;
|
||||
assert(maze32_game_enqueue_move(&game, MAZE32_GAME_ROLE_PLAYER_ONE, MAZE32_GAME_DIRECTION_EAST,
|
||||
200U, &sequence) == MAZE32_GAME_RESULT_ACCEPTED);
|
||||
assert(maze32_game_process_next(&game).result == MAZE32_GAME_RESULT_ACCEPTED);
|
||||
assert(maze32_game_enqueue_move(&game, MAZE32_GAME_ROLE_PLAYER_TWO, MAZE32_GAME_DIRECTION_WEST,
|
||||
200U, &sequence) == MAZE32_GAME_RESULT_ACCEPTED);
|
||||
assert(maze32_game_process_next(&game).result == MAZE32_GAME_RESULT_ACCEPTED);
|
||||
|
||||
maze32_view_t observer;
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_OBSERVER, &observer) ==
|
||||
MAZE32_GAME_RESULT_ACCEPTED);
|
||||
uint16_t origin = index_of(1U, 1U);
|
||||
int found = 0;
|
||||
for (uint16_t index = 0U; index < observer.cell_count; ++index) {
|
||||
if (observer.cells[index].cell_index == origin) {
|
||||
assert(observer.cells[index].trail_east == 3U);
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
assert(found);
|
||||
maze32_view_t player;
|
||||
assert(maze32_game_project_view(&game, MAZE32_GAME_ROLE_PLAYER_ONE, &player) ==
|
||||
MAZE32_GAME_RESULT_ACCEPTED);
|
||||
for (uint16_t index = 0U; index < player.cell_count; ++index) {
|
||||
assert(player.cells[index].trail_east <= 3U && player.cells[index].trail_south <= 3U);
|
||||
}
|
||||
puts("authoritative trail ownership and visibility: PASS");
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
test_movement_cooldown_and_ordering();
|
||||
test_bounded_queue();
|
||||
test_shared_cell_meeting();
|
||||
test_visibility_and_serialization();
|
||||
test_default_map_chunk_bounds();
|
||||
test_authoritative_trails_and_visibility();
|
||||
puts("game core tests: PASS");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user