/* create a one level game context for testing a level */ int client_game_init_testing( Level *level ) { local_game = game_create( GT_LOCAL, config.diff, 100 ); game_set_current( local_game ); game_set_convex_paddle( config.convex ); game_set_ball_auto_return( !config.return_on_click ); game_set_ball_random_angle( config.random_angle ); game_set_ball_accelerated_speed( config.maxballspeed_float ); local_game->localServerGame = 1; game = game_create( GT_LOCAL, config.diff, 100 ); game_set_current( game ); players_clear(); player_add( config.player_names[0], game->diff->lives, level ); cur_player = players_get_first(); bkgnd_ids[0] = 0; init_level( cur_player, PADDLE_BOTTOM ); client_state = CS_NONE; set_state( CS_PLAY ); return 1; }
Test(Player, look_empty) { player_t *pl = player_create_at((vector2d_t){9, 9}); game_t *gm = game_create(20, 20, 7, 5); cr_assert(pl); cr_assert(gm); game_add_team(gm, "pandas"); pl->p_teamname = strdup("pandas"); cr_assert_neq(game_register_player(gm, pl), -1); dynbuf_t *buf = player_look(pl, gm); cr_assert(buf); cr_log_info(buf->b_data); cr_assert(strstr(buf->b_data, "player")); cr_assert_eq(count_char(buf->b_data, ','), 3); pl->p_lvl = 2; dynbuf_delete(buf); buf = player_look(pl, gm); cr_log_info(buf->b_data); cr_assert(strstr(buf->b_data, "player")); cr_assert_eq(count_char(buf->b_data, ','), 8); dynbuf_delete(buf); pl->p_lvl = 3; buf = player_look(pl, gm); cr_log_info(buf->b_data); cr_assert(strstr(buf->b_data, "player")); cr_assert_eq(count_char(buf->b_data, ','), 15); dynbuf_delete(buf); game_delete(gm); }
Test(Player, look_up) { player_t *pl = player_create_at((vector2d_t){9, 9}); game_t *gm = game_create(20, 20, 7, 5); cr_assert(pl); cr_assert(gm); game_add_team(gm, "pandas"); pl->p_teamname = strdup("pandas"); cr_assert_neq(game_register_player(gm, pl), -1); pl->p_dir = (vector2d_t){0, -1}; board_put_resource(gm->ga_board, (vector2d_t){9, 9}, SIBUR); board_put_resource(gm->ga_board, (vector2d_t){8, 8}, THYSTAME); board_put_resource(gm->ga_board, (vector2d_t){9, 8}, LINEMATE); board_put_resource(gm->ga_board, (vector2d_t){10, 8}, DERAUMERE); board_inc_food(gm->ga_board, (vector2d_t){10, 8}); board_inc_food(gm->ga_board, (vector2d_t){10, 8}); dynbuf_t *buf = player_look(pl, gm); cr_assert(buf); cr_log_info(buf->b_data); cr_assert(strstr(buf->b_data, "player")); cr_assert_eq(count_char(buf->b_data, ','), 3); cr_assert_str_eq(buf->b_data, "[sibur player,thystame,linemate,food food deraumere]"); dynbuf_delete(buf); game_delete(gm); }
int client_game_init_network( char *opponent_name, int diff ) { /* create an empty one level levelset. the server will send * the data into the level everytime we play. */ game_set = levelset_create_empty( 1, "empty", "empty" ); /* create client game context */ game = game_create( GT_NETWORK, diff, 100 ); game_set_current( game ); game_round = 0; /* will be increased by init_next_round() */ game_over = 0; /* a network game communicates every 25 ms by default */ client_comm_delay = 25; no_comm_since = 0; /* initiate players */ players_clear(); player_add( client_name, game->diff->lives, levelset_get_first( game_set ) ); player_add( opponent_name, game->diff->lives, levelset_get_first( game_set ) ); cur_player = players_get_first(); display_text( font, "Receiving level data..." ); set_state( CS_RECV_LEVEL ); return 1; }
int main (int argc, char *argv[]) { game_t *game = game_create (); game_start (game); setup_board_every_gem_different (game); int **old_board = copy_board (game); int m = game->n_rows; int n = game->n_cols; replace_gem (game, 2, 2, 999999); replace_gem (game, 3, 2, 1999999); replace_gem (game, 4, 2, 999999); int i; for (i = 0; i < 50 * 2; ++i) { game_loop (game); } for (i = 0; i < m; ++i) { fail_if (game->board[3][i] == old_board[3][i]); } for (i = 0; i < n; ++i) { if (i == 3) continue; fail_if (game->board[i][1] != old_board[i][0]); fail_if (game->board[i][0] == old_board[i][0]); } setup_board_every_gem_different (game); old_board = copy_board (game); replace_gem (game, 2, 2, 999999); replace_gem (game, 2, 3, 1999999); replace_gem (game, 2, 4, 999999); for (i = 0; i < 50 * 2; ++i) { game_loop (game); } for (i = 0; i < m; ++i) { fail_if (game->board[2][i] == old_board[2][i]); } for (i = 0; i < n; ++i) { if (i == 2) continue; fail_if (game->board[i][1] != old_board[i][0]); fail_if (game->board[i][0] == old_board[i][0]); } game_destroy (game); return 0; }
int main (int argc, char *argv[]) { game_t *game = game_create (); fail_if (game->state != SPLASH_STATE); game_destroy (game); return 0; }
int main (int argc, char *argv[]) { game_t *game = game_create (); fail_if (game->frame != 0); game_destroy (game); return 0; }
int main() { t_game *game; game = game_create(); game_loop(game); game_quit(game); return (0); }
int main (int argc, char *argv[]) { game_t *game = game_create (); game->board = (int**)malloc (sizeof (int*) * 8); int i, j; for (i = 0; i < 8; ++i) { game->board[i] = (int*)malloc (sizeof (int) * 8); for (j = 0; j < 8; ++j) { game->board[i][j] = -1; } } game->n_gem_types = 4; gem_t *gem = (gem_t*)malloc (sizeof (gem_t)); gem->x = 0; gem->y = 0; gem->type = 0; gem->level = 0; game_add_gem (game, gem); fail_if (game->n_gems != 1); gem = (gem_t*)malloc (sizeof (gem_t)); gem->x = 24; gem->y = 48; gem->type = 2; gem->level = 3; game_add_gem (game, gem); fail_if (game->n_gems != 2); game_swap_gems (game, 0, 0, 1, 2); fail_if (game->board[0][0] != 14); fail_if (game->board[1][2] != 0); for (i = 0; i < game->n_gems; ++i) { gem_t *gem = game->gems[i]; if (gem->x / 24 == 0 && gem->y / 24 == 0) { fail_if (gem->type != 2 || gem->level != 3); } if (gem->x / 24 == 1 && gem->y / 24 == 2) { fail_if (gem->type != 0 || gem->level != 0); } } game_destroy (game); return 0; }
Test(Player, eject) { player_t *pl1 = player_create_at((vector2d_t){9, 9}); player_t *pl2 = player_create_at((vector2d_t){9, 9}); player_t *pl3 = player_create_at((vector2d_t){9, 9}); player_t *pl4 = player_create_at((vector2d_t){9, 15}); game_t *gm = game_create(20, 20, 7, 5); cr_assert(pl1); cr_assert(pl2); cr_assert(pl2); cr_assert(gm); game_add_team(gm, "pandas"); game_add_team(gm, "red-pandas"); pl1->p_teamname = strdup("pandas"); pl3->p_teamname = strdup("pandas"); pl2->p_teamname = strdup("red-pandas"); pl4->p_teamname = strdup("red-pandas"); cr_assert_neq(game_register_player(gm, pl1), -1); cr_assert_neq(game_register_player(gm, pl2), -1); cr_assert_neq(game_register_player(gm, pl3), -1); cr_assert_neq(game_register_player(gm, pl4), -1); pl2->p_dir = (vector2d_t){-1, 0}; player_eject(pl1, gm->ga_players, gm->ga_board); cr_expect_eq(pl2->p_pos.v_x, 8); cr_expect_eq(pl2->p_pos.v_y, 9); cr_expect_eq(pl3->p_pos.v_x, 10); cr_expect_eq(pl3->p_pos.v_y, 9); player_eject(pl1, gm->ga_players, gm->ga_board); cr_expect_eq(pl2->p_pos.v_x, 8); cr_expect_eq(pl2->p_pos.v_y, 9); cr_expect_eq(pl3->p_pos.v_x, 10); cr_expect_eq(pl3->p_pos.v_y, 9); player_delete(pl1); player_delete(pl2); player_delete(pl3); game_delete(gm); }
/* ** Prepares the selector for the game */ static int bstrap_stor(selector_t **stor, parser_t *parser) { *stor = selector_create(); if (!(*stor)) return (84); (*stor)->s_data = game_create(parser->width, parser->height, parser->freq, parser->client_nb); if (!(*stor)->s_data) { selector_delete((*stor)); return (84); } (*stor)->s_delete = game_delete; (*stor)->s_on_cycle = game_on_cycle; add_teams((*stor)->s_data, parser->team_name); if (listener_create((*stor), parser->port)) { perror("listener"); selector_delete((*stor)); return (84); } return (0); }
Test(Player, rite_check_tile) { player_t *pl1 = player_create_at((vector2d_t){9, 9}); player_t *pl2 = player_create_at((vector2d_t){9, 9}); player_t *pl3 = player_create_at((vector2d_t){9, 7}); player_t *pl4 = player_create_at((vector2d_t){9, 15}); game_t *gm = game_create(20, 20, 7, 5); cr_assert(pl1); cr_assert(pl2); cr_assert(pl2); cr_assert(gm); game_add_team(gm, "pandas"); game_add_team(gm, "red-pandas"); pl1->p_teamname = strdup("pandas"); pl3->p_teamname = strdup("pandas"); pl2->p_teamname = strdup("red-pandas"); pl4->p_teamname = strdup("red-pandas"); cr_assert_neq(game_register_player(gm, pl1), -1); cr_assert_neq(game_register_player(gm, pl2), -1); cr_assert_neq(game_register_player(gm, pl3), -1); cr_assert_neq(game_register_player(gm, pl4), -1); board_put_resource(gm->ga_board, (vector2d_t){9, 9}, 1); cr_expect(!player_rite_check_tile(pl1, gm)); pl2->p_pos.v_x = 19; cr_expect(player_rite_check_tile(pl1, gm)); board_put_resource(gm->ga_board, (vector2d_t){9, 9}, 4); cr_expect(!player_rite_check_tile(pl1, gm)); board_take_resource(gm->ga_board, (vector2d_t){9, 9}, 4); pl1->p_lvl = 2; pl2->p_pos.v_x = 9; pl2->p_lvl = 2; board_put_resource(gm->ga_board, (vector2d_t){9, 9}, 2); board_put_resource(gm->ga_board, (vector2d_t){9, 9}, 3); cr_expect(player_rite_check_tile(pl1, gm)); pl1->p_lvl = 42; cr_expect(!player_rite_check_tile(pl1, gm)); }
static void cmd_new(void) { callback_key++; stop_thinking(); mtx_lock(&game_mutex); game_destroy(game); if ((game = game_create()) == NULL) INTERNAL_ERROR(); reset_engine(current_position()); debug_engine_set_player_to_move(turn()); computer_side = black; set_thinking_done_cb(computer_move, ++callback_key); unset_search_depth_limit(); if (!(is_xboard || is_uci)) puts("New game - computer black"); game_started = false; is_force_mode = false; mtx_unlock(&game_mutex); }
int main (int argc, char *argv[]) { game_t *game = game_create (); fail_if (game->state != SPLASH_STATE); bool gets_to_menu = false; int i; for (i = 0; i < 50 * 30; ++i) { game_loop (game); if (game->state == MENU_STATE) { gets_to_menu = true; break; } } fail_if (!gets_to_menu); game->key_states[SDLK_ESCAPE] = true; game_loop (game); fail_if (game->state != QUIT_STATE); game_destroy (game); return 0; }
int main (int argc, char *argv[]) { game_t *game = game_create (); game_start (game); int n = game->n_rows; int m = game->n_cols; int i; game->n_gem_types = 1000000; // #@$%# ##### // #...# #@#%# // ##.## -> ##$## // ##.## ##.## // ##### ##### setup_board_every_gem_different (game); int **old_board = copy_board (game); replace_gem (game, 1, 1, 999999); replace_gem (game, 2, 1, 999999); replace_gem (game, 3, 1, 999999); replace_gem (game, 2, 2, 999999); replace_gem (game, 2, 3, 999999); bool old_ones_dropped = false; bool special_created = false; for (i = 0; i < 50 * 2; ++i) { game_loop (game); if (game->board[2][3] == 2999999) { special_created = true; } if (!old_ones_dropped) { if (game->board[1][1] == old_board[1][0] && game->board[2][2] == old_board[2][0] && game->board[3][1] == old_board[3][0] && game->board[1][0] != old_board[1][0] && game->board[2][1] != old_board[2][1] && game->board[2][0] != old_board[2][0] && game->board[3][0] != old_board[3][0]) { old_ones_dropped = true; } } if (old_ones_dropped && special_created) { break; } } fail_if (!old_ones_dropped || !special_created); // #@### ##### // #.$%# ##### // #...# -> #@$%# // #.### #.### // ##### ##### setup_board_every_gem_different (game); old_board = copy_board (game); replace_gem (game, 1, 1, 999999); replace_gem (game, 1, 2, 999999); replace_gem (game, 1, 3, 999999); replace_gem (game, 2, 2, 999999); replace_gem (game, 3, 2, 999999); old_ones_dropped = false; special_created = false; for (i = 0; i < 50 * 2; ++i) { game_loop (game); if (game->board[1][3] == 2999999) { special_created = true; } if (!old_ones_dropped) { if (game->board[1][2] == old_board[1][0] && game->board[2][2] == old_board[2][1] && game->board[3][2] == old_board[3][1] && game->board[1][0] != old_board[1][0] && game->board[1][1] != old_board[1][1] && game->board[2][0] != old_board[2][0] && game->board[2][1] != old_board[2][1] && game->board[3][0] != old_board[3][0] && game->board[3][1] != old_board[3][1]) { old_ones_dropped = true; } } if (old_ones_dropped && special_created) { break; } } fail_if (!old_ones_dropped || !special_created); // ##$## ##### // ##.## ##### // #@.%# -> ##$## // #...# #@.%# // ##### ##### setup_board_every_gem_different (game); old_board = copy_board (game); replace_gem (game, 1, 3, 999999); replace_gem (game, 2, 3, 999999); replace_gem (game, 3, 3, 999999); replace_gem (game, 2, 2, 999999); replace_gem (game, 2, 1, 999999); old_ones_dropped = false; special_created = false; for (i = 0; i < 50 * 2; ++i) { game_loop (game); if (game->board[2][3] == 2999999) { special_created = true; } if (!old_ones_dropped) { if (game->board[1][3] == old_board[1][2] && game->board[2][2] == old_board[2][0] && game->board[3][3] == old_board[3][2] && game->board[1][0] != old_board[1][0] && game->board[1][1] != old_board[1][1] && game->board[1][2] != old_board[1][2] && game->board[2][1] != old_board[2][1] && game->board[2][0] != old_board[2][0] && game->board[2][1] != old_board[2][1] && game->board[3][0] != old_board[3][0] && game->board[3][1] != old_board[3][1] && game->board[3][2] != old_board[3][2]) { old_ones_dropped = true; } } if (old_ones_dropped && special_created) { break; } } fail_if (!old_ones_dropped || !special_created); // ###%# ##### // #@$.# ##### // #...# -> #@$%# // ###.# ###.# // ##### ##### setup_board_every_gem_different (game); old_board = copy_board (game); replace_gem (game, 1, 2, 999999); replace_gem (game, 2, 2, 999999); replace_gem (game, 3, 1, 999999); replace_gem (game, 3, 2, 999999); replace_gem (game, 3, 3, 999999); old_ones_dropped = false; special_created = false; for (i = 0; i < 50 * 2; ++i) { game_loop (game); if (game->board[3][3] == 2999999) { special_created = true; } if (!old_ones_dropped) { if (game->board[1][2] == old_board[1][1] && game->board[2][2] == old_board[2][1] && game->board[3][2] == old_board[3][0] && game->board[1][0] != old_board[1][0] && game->board[1][1] != old_board[1][1] && game->board[2][0] != old_board[2][0] && game->board[2][1] != old_board[2][1] && game->board[3][0] != old_board[3][0] && game->board[3][1] != old_board[3][1]) { old_ones_dropped = true; } } if (old_ones_dropped && special_created) { break; } } fail_if (!old_ones_dropped || !special_created); game_destroy (game); return 0; }
/* create network/local game context and initiate game state: * network needs to receive the level data and a local game * has to load the next level */ int client_game_init_local( char *setname ) { Set_Chart *chart; int i, warp_limit; warp_limit = config.rel_warp_limit; allow_disintegrate = 1; /* the original levelsets do not need these workarounds */ if ( STRCMP( setname, "LBreakout2" ) || STRCMP( setname, "LBreakout1" ) ) { warp_limit = 100; allow_disintegrate = 0; } /* the approach for a local game is to use the same * settings as a network game. the receiving of packets * is simply faked by a local_game context that * runs the game locally. but to use only one game loop * we do not use it directly but apply its modificiations * to game which is visualized */ local_game = game_create( GT_LOCAL, config.diff, warp_limit ); game_set_current( local_game ); game_set_convex_paddle( config.convex ); game_set_ball_auto_return( !config.return_on_click ); game_set_ball_random_angle( config.random_angle ); game_set_ball_accelerated_speed( config.maxballspeed_float ); local_game->localServerGame = 1; /* load levels: * only required for local games. in network both players * just require a single level that can store the incoming * data that is send by the server via the net. */ if ( !strcmp( setname, TOURNAMENT ) ) game_set = levelset_load_all( levelset_names, gameSeed, config.addBonusLevels ); else game_set = levelset_load( setname, ((config.addBonusLevels)?gameSeed:0) ); if ( game_set == 0 ) return 0; /* load highest score so far if any */ chart = chart_set_query(setname); strcpy(best_name,"nobody"); best_score = 0; if (chart) { strcpy(best_name,chart->entries[0].name); best_score = chart->entries[0].score; } /* create client game context */ game = game_create( GT_LOCAL, config.diff, warp_limit ); game_set_current( game ); /* a local game is not limited in its communication */ client_comm_delay = 0; no_comm_since = 0; /* prepare warp icon at frame */ warp_blinks = 4; warp_blink = 1; /* set list of level background ids */ for ( i = 0; i < MAX_LEVELS; i++ ) bkgnd_ids[i] = rand() % bkgnd_count; /* initiate players */ players_clear(); for ( i = 0; i < config.player_count; i++ ) player_add( config.player_names[i], game->diff->lives, levelset_get_first( game_set ) ); cur_player = players_get_first(); /* init first level */ init_level( cur_player, PADDLE_BOTTOM ); /* if only one player don't show score table */ client_state = CS_NONE; if ( player_count > 1 ) set_state( CS_SCORE_TABLE ); else set_state( CS_PLAY ); /* one player starts immediately */ return 1; }
int main (int argc, char *argv[]) { game_t *game = game_create (); game_start (game); int **old_board = NULL; old_board = setup_board (game); game->board_cursor_x = 2; game->board_cursor_y = 4; game->board[3][4] = 999999; press_key_and_loop (game, SDLK_SPACE); fail_if (!game->cursor_locked); release_key_and_loop (game, SDLK_SPACE); press_key_and_loop (game, SDLK_RIGHT); release_key_and_loop (game, SDLK_RIGHT); wait (game, 50 * 2); fail_if (!success (old_board, game, 3, 4, 2, 4)); old_board = setup_board (game); game->board_cursor_x = 3; game->board_cursor_y = 4; game->board[3][4] = 999999; press_key_and_loop (game, SDLK_SPACE); fail_if (!game->cursor_locked); release_key_and_loop (game, SDLK_SPACE); press_key_and_loop (game, SDLK_LEFT); release_key_and_loop (game, SDLK_LEFT); wait (game, 50 * 2); fail_if (!success (old_board, game, 2, 4, 3, 4)); old_board = setup_board (game); game->board_cursor_x = 2; game->board_cursor_y = 4; game->board[2][5] = 999999; press_key_and_loop (game, SDLK_SPACE); fail_if (!game->cursor_locked); release_key_and_loop (game, SDLK_SPACE); press_key_and_loop (game, SDLK_DOWN); release_key_and_loop (game, SDLK_DOWN); wait (game, 50 * 2); fail_if (!success (old_board, game, 2, 5, 2, 4)); old_board = setup_board (game); game->board_cursor_x = 2; game->board_cursor_y = 5; game->board[2][5] = 999999; press_key_and_loop (game, SDLK_SPACE); fail_if (!game->cursor_locked); release_key_and_loop (game, SDLK_SPACE); press_key_and_loop (game, SDLK_UP); release_key_and_loop (game, SDLK_UP); wait (game, 50 * 2); fail_if (!success (old_board, game, 2, 4, 2, 5)); game_destroy (game); return 0; }
int main (int argc, char *argv[]) { game_t *game = game_create (); game_start (game); int n = game->n_rows; int m = game->n_cols; int i; int j; int k; setup_board_every_gem_different (game); int **old_board = copy_board (game); game->n_gem_types = 1000000; replace_gem (game, 0, n-1, 999999); replace_gem (game, 1, n-1, 999999); replace_gem (game, 2, n-1, 999999); replace_gem (game, m-1, n-1, 999999); replace_gem (game, m-2, n-1, 999999); replace_gem (game, m-3, n-1, 999999); bool old_ones_dropped_1 = false; bool old_ones_dropped_2 = false; game_loop_n (game, 100); old_ones_dropped_1 = true; for (k = 0; k < 3; ++k) { for (j = 1; j < n; ++j) { if (game->board[k][j] != old_board[k][j-1]) { old_ones_dropped_1 = false; } } } old_ones_dropped_2 = true; for (k = m-3; k < m; ++k) { for (j = 1; j < n; ++j) { if (game->board[k][j] != old_board[k][j-1]) { old_ones_dropped_1 = false; } } } fail_if (!old_ones_dropped_1 || !old_ones_dropped_2); bool new_gems_1 = false; bool new_gems_2 = false; if (game->board[0][0] != old_board[0][0] || game->board[1][0] != old_board[1][0] || game->board[2][0] != old_board[2][0]) { new_gems_1 = true; } if (game->board[m-3][0] != old_board[m-3][0] || game->board[m-2][0] != old_board[m-2][0] || game->board[m-1][0] != old_board[m-1][0]) { new_gems_2 = true; } fail_if (!new_gems_1 || !new_gems_2); game_destroy (game); return 0; }
int main (int argc, char *argv[]) { game_t *game = game_create (game); game_start (game); // Swapping to or from outside of the board is illegal fail_if (session_legal_move (game, 0, 0, -1, 0)); fail_if (session_legal_move (game, 0, 0, 0, -1)); fail_if (session_legal_move (game, game->n_cols - 1, 0, game->n_cols, 0)); fail_if (session_legal_move (game, game->n_cols - 1, 0, game->n_cols - 1, -1)); fail_if (session_legal_move (game, 0, game->n_rows - 1, 0, game->n_rows)); fail_if (session_legal_move (game, 0, game->n_rows - 1, -1, game->n_rows - 1)); fail_if (session_legal_move (game, game->n_cols - 1, game->n_rows - 1, game->n_cols - 1, game->n_rows)); fail_if (session_legal_move (game, game->n_cols - 1, game->n_rows - 1, game->n_cols, game->n_rows - 1)); // Swapping non-adjacent locations is illegal fail_if (session_legal_move (game, 0, 0, 1, 1)); fail_if (session_legal_move (game, 1, 1, 0, 0)); fail_if (session_legal_move (game, 3, 2, 0, 1)); fail_if (session_legal_move (game, 5, 4, 2, 2)); // Swap and neither location is part of row or col of 3 or more game->n_gem_types = 1000000; setup_board_every_gem_different (game); // Since every location is different, there can be no legal moves int i, j; for (i = 0; i < game->n_cols; ++i) { for (j = 0; j < game->n_rows; ++j) { fail_if (session_legal_move (game, i, j, i - 1, j)); fail_if (session_legal_move (game, i, j, i, j - 1)); fail_if (session_legal_move (game, i, j, i + 1, j)); fail_if (session_legal_move (game, i, j, i, j + 1)); } } // Swap into a row of three // On bottom setup_board_every_gem_different (game); game->board[2][2] = 999999; game->board[2][3] = 999999; game->board[2][4] = 0; game->board[3][4] = 999999; fail_if (!session_legal_move (game, 2, 4, 3, 4)); fail_if (!session_legal_move (game, 3, 4, 2, 4)); // In middle setup_board_every_gem_different (game); game->board[2][2] = 999999; game->board[2][3] = 0; game->board[2][4] = 1999999; game->board[3][3] = 999999; fail_if (!session_legal_move (game, 2, 3, 3, 3)); fail_if (!session_legal_move (game, 3, 3, 2, 3)); // On top setup_board_every_gem_different (game); game->board[2][2] = 0; game->board[2][3] = 999999; game->board[2][4] = 2999999; game->board[3][2] = 999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swap into a col of three // On right setup_board_every_gem_different (game); game->board[2][2] = 999999; game->board[3][2] = 3999999; game->board[4][2] = 0; game->board[4][3] = 999999; fail_if (!session_legal_move (game, 4, 2, 4, 3)); fail_if (!session_legal_move (game, 4, 3, 4, 2)); // In middle setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[3][2] = 0; game->board[4][2] = 999999; game->board[3][3] = 999999; fail_if (!session_legal_move (game, 3, 2, 3, 3)); fail_if (!session_legal_move (game, 3, 3, 3, 2)); // On left setup_board_every_gem_different (game); game->board[2][2] = 0; game->board[3][2] = 999999; game->board[4][2] = 999999; game->board[2][3] = 2999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); // Swapping a special1 with a special1 setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[2][3] = 1999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[3][2] = 1999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special1 with a special2 setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[2][3] = 2999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[3][2] = 2999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special2 with a special2 setup_board_every_gem_different (game); game->board[2][2] = 2999999; game->board[2][3] = 2999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 2999999; game->board[3][2] = 2999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special1 with a special3 setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[2][3] = 3999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 1999999; game->board[3][2] = 3999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special2 with a special3 setup_board_every_gem_different (game); game->board[2][2] = 2999999; game->board[2][3] = 3999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 2999999; game->board[3][2] = 3999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); // Swapping a special3 with a special3 setup_board_every_gem_different (game); game->board[2][2] = 3999999; game->board[2][3] = 3999999; fail_if (!session_legal_move (game, 2, 2, 2, 3)); fail_if (!session_legal_move (game, 2, 3, 2, 2)); setup_board_every_gem_different (game); game->board[2][2] = 3999999; game->board[3][2] = 3999999; fail_if (!session_legal_move (game, 2, 2, 3, 2)); fail_if (!session_legal_move (game, 3, 2, 2, 2)); game_destroy (game); return 0; }