void trn_game_move_to_bottom(TrnGame * const game) { while (true) { if (!trn_game_try_to_move_down(game)) { break; } } }
void stack_some_pieces() { int numberOfRows = 20; int numberOfColumns = 10; int delay = 500; int imove; TrnGame* game = trn_game_new(numberOfRows, numberOfColumns, delay); // TrnPiece 0. While the piece is falling: // Rotate it 3 times. for (imove = 0; imove < 3; imove++) { CU_ASSERT_TRUE( trn_game_try_to_move_down(game) ); CU_ASSERT_TRUE( trn_game_try_to_rotate_clockwise(game) ); } // Move piece to left. CU_ASSERT_TRUE( trn_game_try_to_move_down(game) ); CU_ASSERT_TRUE( trn_game_try_to_move_left(game) ); // Reach bottom. while (true) { if (! trn_game_try_to_move_down(game)) break; } // TrnPiece 1. While the piece is falling: // Rotate it 1 times. CU_ASSERT_TRUE( trn_game_try_to_move_down(game) ); CU_ASSERT_TRUE( trn_game_try_to_rotate_clockwise(game) ); // Move piece to left. for (imove = 0; imove < 4; imove++) { CU_ASSERT_TRUE( trn_game_try_to_move_down(game) ); CU_ASSERT_TRUE( trn_game_try_to_move_left(game) ); } // Reach bottom. while (true) { if (! trn_game_try_to_move_down(game)) break; } // TrnPiece 2. While the piece is falling: // Rotate it 1 times. CU_ASSERT_TRUE( trn_game_try_to_move_down(game) ); CU_ASSERT_TRUE( trn_game_try_to_rotate_clockwise(game) ); // Move piece to left. for (imove = 0; imove < 2; imove++) { CU_ASSERT_TRUE( trn_game_try_to_move_down(game) ); CU_ASSERT_TRUE( trn_game_try_to_move_left(game) ); } // Reach bottom. while (true) { if (! trn_game_try_to_move_down(game)) break; } // TrnPiece 3. While the piece is falling: // Rotate it 3 times. for (imove = 0; imove < 3; imove++) { CU_ASSERT_TRUE( trn_game_try_to_move_down(game) ); CU_ASSERT_TRUE( trn_game_try_to_rotate_clockwise(game) ); } // Move piece to left. for (imove = 0; imove < 3; imove++) { CU_ASSERT_TRUE( trn_game_try_to_move_down(game) ); CU_ASSERT_TRUE( trn_game_try_to_move_left(game) ); } // Reach bottom. while (true) { if (! trn_game_try_to_move_down(game)) break; } int rowIndex; int columnIndex; TrnPositionInGrid pos; TrnGrid* expected_grid = trn_grid_new(numberOfRows, numberOfColumns); // Expected expected_grid type for pieces 0 and 2 for (rowIndex = numberOfRows-4 ; rowIndex < numberOfRows ; rowIndex++) { pos.rowIndex = rowIndex; for (columnIndex = 2 ; columnIndex < 4 ; columnIndex++) { pos.columnIndex = columnIndex; trn_grid_set_cell(expected_grid, pos, TRN_TETROMINO_J); } } // Expected expected_grid type for pieces 1 and 3 for (rowIndex = numberOfRows-4 ; rowIndex < numberOfRows ; rowIndex++) { pos.rowIndex = rowIndex; for (columnIndex = 0 ; columnIndex < 2 ; columnIndex++) { pos.columnIndex = columnIndex; trn_grid_set_cell(expected_grid, pos, TRN_TETROMINO_L); } } /* CU_ASSERT_TRUE( trn_grid_equal(game->grid, expected_grid) ); */ trn_game_destroy(game); }