cs162/assignments/assignment1/magic.cpp
/*********************************************************************
 * ** Function: effect_sort
 * ** Description: This function is the driver function for when the user chooses to sort spells by effect, it runs the show
 * ** Parameters: wizard *wiz, int wiz_index, spellbook *spells, int num_books
 * ** Pre-Conditions: the user has logged in and has chosen to sort spells by effect
 * ** Post-Conditions: spells have been sorted by effect correctly and outcome was print3ed/saved correctly
 * *********************************************************************/
effect_sort
Description: This function is the driver function for when the user chooses to sort spells by effect, it runs the show
Parameters: wizard *wiz, int wiz_index, spellbook *spells, int num_books
Pre-Conditions: the user has logged in and has chosen to sort spells by effect
Post-Conditions: spells have been sorted by effect correctly and outcome was print3ed/saved correctly
effect_sort Description : This function is the driver function for when the user chooses to sort spells by effect it runs the show Parameters : wizard * wiz int wiz_index spellbook * spells int num_books Pre - Conditions : the user has logged in and has chosen to sort spells by effect Post - Conditions : spells have been sorted by effect correctly and outcome was print3ed / saved correctly
void effect_sort(wizard *wiz, int wiz_index, spellbook *spells, int num_books) {
	int numb_spells = 0, bubbles = 0, memory_losses = 0, fires = 0, poisons = 0, deaths = 0;
	for(int i = 0; i < num_books; i++) {
		numb_spells += spells[i].num_spells;
	}
	spell *spell_list_temp = create_temp_list(numb_spells, spells, num_books);
	count_temp_list(numb_spells, spell_list_temp, bubbles, memory_losses, fires, poisons, deaths);
	spell *bubble = create_bubble(bubbles, spell_list_temp, numb_spells);
	spell *memory_loss = create_memory_loss(memory_losses, spell_list_temp, numb_spells);
	spell *fire = create_fire(fires, spell_list_temp, numb_spells);
	spell *poison = create_poison(poisons, spell_list_temp, numb_spells);
	spell *death = create_death(deaths, spell_list_temp, numb_spells);
	if(wiz[wiz_index].position_title == "Student") {
		print_or_file_effect_student(numb_spells, poisons, deaths, bubbles, memory_losses, fires, bubble, memory_loss, fire);
	}
	else {
		print_or_file_effect_not_student(numb_spells, bubbles, memory_losses, fires, poisons, deaths, bubble, memory_loss, fire, poison, death);
	}
	delete_lists(spell_list_temp, bubble, memory_loss, fire, poison, death);
}
void effect_sort ( wizard * wiz , int wiz_index , spellbook * spells , int num_books ) { int numb_spells = 0 , bubbles = 0 , memory_losses = 0 , fires = 0 , poisons = 0 , deaths = 0 ; for ( int i = 0 ; i < num_books ; i ++ ) { numb_spells += spells [ i ] . num_spells ; } spell * spell_list_temp = create_temp_list ( numb_spells , spells , num_books ) ; count_temp_list ( numb_spells , spell_list_temp , bubbles , memory_losses , fires , poisons , deaths ) ; spell * bubble = create_bubble ( bubbles , spell_list_temp , numb_spells ) ; spell * memory_loss = create_memory_loss ( memory_losses , spell_list_temp , numb_spells ) ; spell * fire = create_fire ( fires , spell_list_temp , numb_spells ) ; spell * poison = create_poison ( poisons , spell_list_temp , numb_spells ) ; spell * death = create_death ( deaths , spell_list_temp , numb_spells ) ; if ( wiz [ wiz_index ] . position_title == " " ) { print_or_file_effect_student ( numb_spells , poisons , deaths , bubbles , memory_losses , fires , bubble , memory_loss , fire ) ; } else { print_or_file_effect_not_student ( numb_spells , bubbles , memory_losses , fires , poisons , deaths , bubble , memory_loss , fire , poison , death ) ; } delete_lists ( spell_list_temp , bubble , memory_loss , fire , poison , death ) ; }
** Function: effect_sort
 ** Description: This function is the driver function for when the user chooses to sort spells by effect, it runs the show
 ** Parameters: wizard *wiz, int wiz_index, spellbook *spells, int num_books
 ** Pre-Conditions: the user has logged in and has chosen to sort spells by effect
 ** Post-Conditions: spells have been sorted by effect correctly and outcome was print3ed/saved correctly
** Function : effect_sort ** Description : This function is the driver function for when the user chooses to sort spells by effect it runs the show ** Parameters : wizard * wiz int wiz_index spellbook * spells int num_books ** Pre - Conditions : the user has logged in and has chosen to sort spells by effect ** Post - Conditions : spells have been sorted by effect correctly and outcome was print3ed / saved correctly