示例#1
0
boolean
mon_damage(object *monster, short damage)
{
	const char *mn;
	short row, col;

	monster->hp_to_kill -= damage;

	if (monster->hp_to_kill <= 0) {
		row = monster->row;
		col = monster->col;
		dungeon[row][col] &= ~MONSTER;
		mvaddch(row, col, (int)get_dungeon_char(row, col));

		fight_monster = NULL;
		cough_up(monster);
		mn = mon_name(monster);
		sprintf(hit_message+strlen(hit_message), "defeated the %s", mn);
		message(hit_message, 1);
		hit_message[0] = 0;
		add_exp(monster->kill_exp, 1);
		take_from_pack(monster, &level_monsters);

		if (monster->m_flags & HOLDS) {
			being_held = 0;
		}
		free_object(monster);
		return(0);
	}
	return(1);
}
示例#2
0
void
mon_hit(object *monster)
{
	short damage, hit_chance;
	const char *mn;
	float minus;

	if (fight_monster && (monster != fight_monster)) {
		fight_monster = NULL;
	}
	monster->trow = NO_ROOM;
	if (cur_level >= (AMULET_LEVEL * 2)) {
		hit_chance = 100;
	} else {
		hit_chance = monster->m_hit_chance;
		hit_chance -= (((2 * rogue.exp) + (2 * ring_exp)) - r_rings);
	}
	if (wizard) {
		hit_chance /= 2;
	}
	if (!fight_monster) {
		interrupted = 1;
	}
	mn = mon_name(monster);

	if (!rand_percent(hit_chance)) {
		if (!fight_monster) {
			sprintf(hit_message + strlen(hit_message), "the %s misses", mn);
			message(hit_message, 1);
			hit_message[0] = 0;
		}
		return;
	}
	if (!fight_monster) {
		sprintf(hit_message + strlen(hit_message), "the %s hit", mn);
		message(hit_message, 1);
		hit_message[0] = 0;
	}
	if (!(monster->m_flags & STATIONARY)) {
		damage = get_damage(monster->m_damage, 1);
		if (cur_level >= (AMULET_LEVEL * 2)) {
			minus = (float)((AMULET_LEVEL * 2) - cur_level);
		} else {
			minus = (float)get_armor_class(rogue.armor) * 3.00;
			minus = minus / 100.00 * (float)damage;
		}
		damage -= (short)minus;
	} else {
		damage = monster->stationary_damage++;
	}
	if (wizard) {
		damage /= 3;
	}
	if (damage > 0) {
		rogue_damage(damage, monster, 0);
	}
	if (monster->m_flags & SPECIAL_HIT) {
		special_hit(monster);
	}
}
示例#3
0
// Show the events details
void event_details(int z_index) {
	erase();
	titlebar();
	refresh();
	resize_term(25, 80);

	attron(COLOR_PAIR(3));
	mvprintw(2, 1, "View Details");
	mvprintw(3, 1, "------------");

	mvprintw(5, 1, "Event Name\t: %s", myVector[z_index].name);
	mvprintw(7, 1, "Date\t\t: %i %s %i", myVector[z_index].day, mon_name(myVector[z_index].nmon), myVector[z_index].year);
	mvprintw(9, 1, "Time\t\t: ");
	formatted_time(9, 18, myVector[z_index].hour, myVector[z_index].min);
	mvprintw(11, 1, "Location\t: %s", myVector[z_index].loc);
	//mvprintw(13, 1, "Description\t: ");
	attron(COLOR_PAIR(6));
	mvprintw(17, 1, "Press ESC to go back...");
	refresh();

	/*WINDOW *wdesc;
	wdesc = newwin(3, 60, 13, 18);
	wattron(wdesc, COLOR_PAIR(3));
	mvwprintw(wdesc, 0, 0, "%s", myVector[z_index].desc);
	wrefresh(wdesc);*/

	int key;
	do {
		key = getch();
	} while (key != 27);
	list_events();
}
示例#4
0
// Show the data saved at the "create new event" page
// It will only show the data saved in the data class of myevent
void view_event() {
	erase();
	titlebar();
	refresh();

	attron(COLOR_PAIR(3));
	mvprintw(2, 1, "View saved event");
	mvprintw(3, 1, "----------------");
	mvprintw(5, 1, "Date\t\t: %i %s %i", myVector[0].day, mon_name(myVector[0].nmon), myVector[0].year);
	mvprintw(6, 1, "Event name\t: %s", myVector[0].name);
	mvprintw(7, 1, "Location\t: %s", myVector[0].loc);
	mvprintw(8, 1, "Description\t:");

	mvprintw(12, 1, "Press ESC to go back.");
	refresh();

	// Create a small window for placing description
	/*WINDOW *wdesc_2;
	wdesc_2 = newwin(3, 60, 8, 18);
	wattron(wdesc_2, COLOR_PAIR(3));
	mvwprintw(wdesc_2, 0, 0, "%s", myVector[0].desc);
	wrefresh(wdesc_2);*/
	
	int key;
	while (1) {
		key = getch();
		if (key == 27) menu();
	}
}
示例#5
0
int
check_imitator(object *monster)
{
    char msg[80];

    if (monster->m_flags & IMITATES) {
	wake_up(monster);
	if (!blind) {
	    mvaddch_rogue(monster->row, monster->col,
			  get_dungeon_char(monster->row, monster->col));
	    check_message();
	    sprintf(msg, mesg[206], mon_name(monster));
	    message(msg, 1);
	}
	return 1;
    }
    return 0;
}
示例#6
0
int
m_confuse(object *monster)
{
    char msg[80];

    if (!rogue_can_see(monster->row, monster->col)) {
	return 0;
    }
    if (rand_percent(45)) {
	monster->m_flags &= (~CONFUSES);	/* will not confuse the rogue */
	return 0;
    }
    if (rand_percent(55)) {
	monster->m_flags &= (~CONFUSES);
	sprintf(msg, mesg[209], mon_name(monster));
	message(msg, 1);
	confuse();
	return 1;
    }
    return 0;
}
示例#7
0
void
sting(object *monster)
{
    short sting_chance = 35;
    char msg[80];

    if ((rogue.str_current <= 3) || sustain_strength) {
	return;
    }
    sting_chance += (6 * (6 - get_armor_class(rogue.armor)));

    if ((rogue.exp + ring_exp) > 8) {
	sting_chance -= (6 * ((rogue.exp + ring_exp) - 8));
    }
    if (rand_percent(sting_chance)) {
	sprintf(msg, mesg[207], mon_name(monster));
	message(msg, 0);
	rogue.str_current--;
	print_stats(STAT_STRENGTH);
    }
}
示例#8
0
void list_events(int day_filter, int mon_filter, int year_filter) {
	unsigned int current_page = 1, max_page, index_page = 0;
	unsigned int mod = myVector.size() % 12;
	int key, n_keys = 0, selected_event_index;
	char type_keys[66];

	erase();
	titlebar();
	refresh();
	resize_term(40, 80);

	attron(COLOR_PAIR(3));
	mvprintw(2, 1, "List Event(s)");
	mvprintw(3, 1, "-------------");

	// Draw table
	mvvline(5, 1, 0, 29);
	mvvline(5, 6, 0, 29);
	mvvline(5, 51, 0, 29);
	mvvline(5, 70, 0, 29);
	mvvline(5, 78, 0, 29);
	mvhline(5, 1, 0, 78);
	mvhline(7, 1, 0, 78);
	mvhline(33, 1, 0, 78);

	// Print out some text
	mvprintw(6, 3, "No");
	mvprintw(6, 8, "Event Name");
	mvprintw(6, 53, "Date");
	mvprintw(6, 72, "Time");

	refresh();

	WINDOW *wID, *wNAME, *wDATE, *wTIME, *wDET, *wSTAT;

	wID = newwin(25, 4, 8, 2);
	wrefresh(wID);

	wNAME = newwin(25, 42, 8, 8);
	wrefresh(wNAME);

	wDATE = newwin(25, 18, 8, 52);
	wrefresh(wDATE);

	wTIME = newwin(25, 7, 8, 71);
	wrefresh(wTIME);

	wDET = newwin(4, 78, 36, 1);
	wattron(wDET, COLOR_PAIR(6));
	mvwprintw(wDET, 0, 0, "Press LEFT or RIGHT to change the page. Type any event number and press E to \nedit, D to delete, R to swap two events or ENTER for more details.\nOr you can press S to sort all the events. To go back, press ESC.");
	wrefresh(wDET);

	wSTAT = newwin(1, 78, 39, 1);
	wrefresh(wSTAT);

	// Declare variable for filter purpose
	std::vector<my_event> filter;
	std::vector<my_event> *list;
	my_event temp;

	// Apply filter for saved events. Copy data to the temporary local vector and print to the list.
	// Optional function. Maybe not implemented for now.
	// Since the code is identical, only the logical expression different. So it can be simpified but not for now.
	if (day_filter != 0 || mon_filter != 0 || year_filter != 0) {
		for (unsigned int z = 0; z < myVector.size(); z++) {
			if (year_filter != 0) {
				if (myVector[z].year == year_filter) {
					temp.hour = myVector[z].hour;
					temp.min = myVector[z].min;
					temp.day = myVector[z].day;
					temp.nmon = myVector[z].nmon;
					temp.year = myVector[z].year;
					temp.save_name(myVector[z].name);
					temp.save_loc(myVector[z].loc);
					//temp.save_desc(myVector[z].desc);
					filter.push_back(temp);
				}
			}
			if (mon_filter != 0) {
				if (myVector[z].nmon == mon_filter) {
					temp.hour = myVector[z].hour;
					temp.min = myVector[z].min;
					temp.day = myVector[z].day;
					temp.nmon = myVector[z].nmon;
					temp.year = myVector[z].year;
					temp.save_name(myVector[z].name);
					temp.save_loc(myVector[z].loc);
					//temp.save_desc(myVector[z].desc);
					filter.push_back(temp);
				}
			}
			if (day_filter != 0) {
				if (myVector[z].day == day_filter) {
					temp.hour = myVector[z].hour;
					temp.min = myVector[z].min;
					temp.day = myVector[z].day;
					temp.nmon = myVector[z].nmon;
					temp.year = myVector[z].year;
					temp.save_name(myVector[z].name);
					temp.save_loc(myVector[z].loc);
					//temp.save_desc(myVector[z].desc);
					filter.push_back(temp);
				}
			}
			if (day_filter != 0 && mon_filter != 0) {
				if (myVector[z].day == day_filter && myVector[z].nmon == mon_filter) {
					temp.hour = myVector[z].hour;
					temp.min = myVector[z].min;
					temp.day = myVector[z].day;
					temp.nmon = myVector[z].nmon;
					temp.year = myVector[z].year;
					temp.save_name(myVector[z].name);
					temp.save_loc(myVector[z].loc);
					//temp.save_desc(myVector[z].desc);
					filter.push_back(temp);
				}
			}
			if (year_filter != 0 && mon_filter != 0) {
				if (myVector[z].year == year_filter && myVector[z].nmon == mon_filter) {
					temp.hour = myVector[z].hour;
					temp.min = myVector[z].min;
					temp.day = myVector[z].day;
					temp.nmon = myVector[z].nmon;
					temp.year = myVector[z].year;
					temp.save_name(myVector[z].name);
					temp.save_loc(myVector[z].loc);
					//temp.save_desc(myVector[z].desc);
					filter.push_back(temp);
				}
			}
			if (day_filter != 0 && mon_filter != 0 && year_filter != 0) {
				if (myVector[z].day == day_filter && myVector[z].nmon == mon_filter && myVector[z].year == year_filter) {
					temp.hour = myVector[z].hour;
					temp.min = myVector[z].min;
					temp.day = myVector[z].day;
					temp.nmon = myVector[z].nmon;
					temp.year = myVector[z].year;
					temp.save_name(myVector[z].name);
					temp.save_loc(myVector[z].loc);
					//temp.save_desc(myVector[z].desc);
					filter.push_back(temp);
				}
			}
		}
		list = &filter;
	}
	else list = &myVector;

	if (mod != 0) max_page = (int)(ceil((*list).size() / 12)) + 1;
	else max_page = (*list).size() / 12;

	while (1) {

		werase(wID);
		werase(wNAME);
		werase(wDATE);
		werase(wTIME);
		mvprintw(34, 1, "Page: %i/%i", current_page, max_page);

		int n_line = 1;
		for (unsigned int i = index_page; i < index_page + 12; i++) {
			if (i < (*list).size()) {
				mvwprintw(wID, n_line, 1, "%i", i + 1);
				mvwprintw(wNAME, n_line, 0, "%s", (*list)[i].name);
				mvwprintw(wDATE, n_line, 1, "%i %s %i", (*list)[i].day, mon_name((*list)[i].nmon), (*list)[i].year);
				wformatted_time(wTIME, n_line, 1, (*list)[i].hour, (*list)[i].min);
				wrefresh(wID);
				wrefresh(wNAME);
				wrefresh(wDATE);
				wrefresh(wTIME);
				n_line += 2;
			}
		}

		key = getch();
		//mvprintw(39, 1, "%i", key);

		if (key == 115 || key == 83) {
			werase(wDET);
			wattron(wDET, COLOR_PAIR(6));
			mvwprintw(wDET, 0, 0, "Press 1 to sort by Day, 2 to sort by Month or 3 to sort by Year.\nPress ESC to go back.");
			wattroff(wDET, COLOR_PAIR(6));
			wrefresh(wDET);
			werase(wSTAT);
			while (1) {
				key = getch();
				if (!(key >= 49 && key <= 51) || key != 27) {
					werase(wDET);
					wattron(wDET, COLOR_PAIR(5));
					mvwprintw(wDET, 0, 0, "Invalid selection...");
					wattroff(wDET, COLOR_PAIR(5));
					wrefresh(wDET);
				}
				if (key == 49) {
					std::sort(myVector.begin(), myVector.end(), SortDay());
					break;
				}
				if (key == 50) {
					std::sort(myVector.begin(), myVector.end(), SortMonth());
					break;
				}
				if (key == 51) {
					std::sort(myVector.begin(), myVector.end(), SortYear());
					break;
				}
				if (key == 27) break;
			}
			break;
		}

		if ((key >= 48 && key <= 57) || key == 8) {
			if (key >= 48 && key <= 57) {
				if (n_keys <= 66) {
					werase(wSTAT);
					type_keys[n_keys] = char(key);
					n_keys++;

					wattron(wSTAT, COLOR_PAIR(3));
					mvwprintw(wSTAT, 0, 0, "Event No: ");
					wattroff(wSTAT, COLOR_PAIR(3));

					wattron(wSTAT, COLOR_PAIR(7));
					for (int o = 0; o < n_keys; o++) wprintw(wSTAT, "%c", type_keys[o]);		// Show the user for any typed numbers
					wrefresh(wSTAT);
					wattroff(wSTAT, COLOR_PAIR(7));
				}
			}
			if (key == 8) {
				if (n_keys > 1) {
					werase(wSTAT);
					type_keys[n_keys] = ' ';
					type_keys[n_keys - 1] = ' ';
					n_keys--;

					wattron(wSTAT, COLOR_PAIR(3));
					mvwprintw(wSTAT, 0, 0, "Event No: ");
					wattroff(wSTAT, COLOR_PAIR(3));

					wattron(wSTAT, COLOR_PAIR(7));
					for (int o = 0; o < n_keys; o++) wprintw(wSTAT, "%c", type_keys[o]);
					wrefresh(wSTAT);
					wattroff(wSTAT, COLOR_PAIR(7));
				}
				else {
					werase(wSTAT);
					wrefresh(wSTAT);
					n_keys = 0;
				}
			}
		}

		// User pressed enter/E/D (all caps)
		if (key == 13 || key == 100 || key == 68 || key == 69 || key == 101 || key == 82 || key == 114) {
			if (n_keys > 0) {
				selected_event_index = atol(&type_keys[0]);
				if (selected_event_index >= 1 && selected_event_index <= int((*list).size())) break;
				else {
					werase(wSTAT);
					wrefresh(wSTAT);
					werase(wDET);
					wattron(wDET, COLOR_PAIR(5));
					mvwprintw(wDET, 0, 0, "Invalid number or out of range.\nPlease try again...");
					wattroff(wDET, COLOR_PAIR(5));
					wrefresh(wDET);
					for (int o = 0; o <= 66; o++) type_keys[o] = ' ';						// Clear the array
					n_keys = 0;																// Reset the number of key typed
				}
			}
		}

		if (key == 27) menu();

		if (key == KEY_RIGHT) {
			if (current_page < max_page) {
				index_page += 12;
				current_page++;
				continue;
			}
		}

		if (key == KEY_LEFT) {
			if (current_page > 1) {
				index_page -= 12;
				current_page--;
				continue;
			}
		}

		if (key == KEY_F(2)) {
			mvprintw(5, 1, "%i", myVector.size());
			//refresh();
		}

		if (key == KEY_F(1)) exit(0);
	}

	if (key == 13) data.show_details(selected_event_index - 1);
	if (key == 100 || key == 68) data.delete_event(selected_event_index - 1);
	if (key == 101 || key == 69) data.edit_event(selected_event_index - 1);

	// Sorting Lab 4
//	if (key == 82 || key == 114) {
		
	//}

	// Swapping Lab 3
	if (key == 82 || key == 114) {
		werase(wDET);
		wattron(wDET, COLOR_PAIR(6));
		mvwprintw(wDET, 0, 0, "Now enter the second event number to replace.\nPress ESC to cancel.");
		wattroff(wDET, COLOR_PAIR(6));
		wrefresh(wDET);
		werase(wSTAT);
		mvwprintw(wSTAT, 0, 0, "Event No To Replace: ");
		wrefresh(wSTAT);
		for (int o = 0; o <= 66; o++) type_keys[o] = ' ';						// Clear the array
		n_keys = 0;
		while (1) {
			key = getch();
			if (key == 27) break;
			if (key >= 48 && key <= 57) {
				if (n_keys <= 66) {
					werase(wSTAT);
					type_keys[n_keys] = char(key);
					n_keys++;

					wattron(wSTAT, COLOR_PAIR(3));
					mvwprintw(wSTAT, 0, 0, "Event No To Replace: ");
					wattroff(wSTAT, COLOR_PAIR(3));

					wattron(wSTAT, COLOR_PAIR(7));
					for (int o = 0; o < n_keys; o++) wprintw(wSTAT, "%c", type_keys[o]);		// Show the user for any typed numbers
					wrefresh(wSTAT);
					wattroff(wSTAT, COLOR_PAIR(7));
				}
			}
			if (key == 8) {
				if (n_keys > 1) {
					werase(wSTAT);
					type_keys[n_keys] = ' ';
					type_keys[n_keys - 1] = ' ';
					n_keys--;

					wattron(wSTAT, COLOR_PAIR(3));
					mvwprintw(wSTAT, 0, 0, "Event No To Replace: ");
					wattroff(wSTAT, COLOR_PAIR(3));

					wattron(wSTAT, COLOR_PAIR(7));
					for (int o = 0; o < n_keys; o++) wprintw(wSTAT, "%c", type_keys[o]);
					wrefresh(wSTAT);
					wattroff(wSTAT, COLOR_PAIR(7));
				}
				else {
					werase(wSTAT);
					wrefresh(wSTAT);
					n_keys = 0;
				}
			}

			if (key == 13 || key == 100) {
				if (n_keys > 0) {
					int sec_selected_event_index;
					sec_selected_event_index = atol(&type_keys[0]);
					if (sec_selected_event_index >= 1 && sec_selected_event_index <= int((*list).size()) && selected_event_index != sec_selected_event_index) {
						/*mvwprintw(wSTAT, 0, 0, "selected: %i, second: %i",selected_event_index,sec_selected_event_index);
						wrefresh(wSTAT);
						getch();*/
						swap(selected_event_index - 1, sec_selected_event_index - 1);
						break;
					}
					else {
						werase(wSTAT);
						wrefresh(wSTAT);
						werase(wDET);
						wattron(wDET, COLOR_PAIR(5));
						mvwprintw(wDET, 0, 0, "Invalid number or out of range.\nPlease try again...");
						wattroff(wDET, COLOR_PAIR(5));
						wrefresh(wDET);
						for (int o = 0; o <= 66; o++) type_keys[o] = ' ';						// Clear the array
						n_keys = 0;																// Reset the number of key typed
						werase(wSTAT);
						mvwprintw(wSTAT, 0, 0, "Event No To Replace: ");
						wrefresh(wSTAT);
					}
				}
			}
		}

	}

	list_events();
}
示例#9
0
// Function to save all events to file. Without filter day / month / year. Filtering isn't implemented yet.
void save_to_file() {
	std::ofstream the_file("My Events.txt", std::ios::app);
	for (unsigned int o = 0; o < myVector.size(); o++) the_file << "Event #" << o + 1 << "\nTitle\t\t: " << myVector[o].name << "\nDate\t\t: " << std::setw(2) << std::setfill('0') << myVector[o].day << ' ' << mon_name(myVector[o].nmon) << ' ' << myVector[o].year << "\nTime\t\t: " << std::setw(2) << std::setfill('0') << myVector[o].hour << ":" << std::setw(2) << std::setfill('0') << myVector[o].min << "\nLocation\t: " << myVector[o].loc << "\n\n";
	the_file.close();
}
示例#10
0
// Menu function
void menu() {
	int key;

	resize_term(25, 80);
	erase();
	titlebar();
	noecho();

	attron(COLOR_PAIR(3));
	mvprintw(2, 1, "Menu");
	mvprintw(3, 1, "----");
	mvprintw(5, 1, "1) Create a new event");
	mvprintw(6, 1, "2) View or edit event");
	mvprintw(7, 1, "3) Change month / year (Selected: %s %i)", mon_name(selected_mon), selected_year);
	mvprintw(8, 1, "4) Save all events to file");
	mvprintw(9, 1, "Q) Quit program");
	//mvprintw(23, 1, "Created by Ijat (172205)");
	attron(COLOR_PAIR(8));
	mvprintw(23, 1, "(c) 2014 Ijat.my");
	attron(COLOR_PAIR(3));
	mvprintw(11, 1, "Your selection: ");
	refresh();

	// Check user input
	while (1) {
		key = getch();
		//mvprintw(23, 1, "%i", key);

		// Pressed 1
		if (key == 49) { create_new_event(false); }

		// Pressed 2
		if (key == 50) {
			if (event_saved == false) {
				attron(COLOR_PAIR(5));
				mvhline(23, 1, ' ', 78);
				mvprintw(23, 1, "No event(s) saved. Nothing to view. Please create a new event first!");
				refresh();
				attroff(COLOR_PAIR(5));
			}
			else if (event_saved == true) { //view_event(); 
				list_events();
			}
		}

		// Pressed 3
		if (key == 51) change_mon(); 

		if (key == 52) {
			if (event_saved == true) {
				attron(COLOR_PAIR(6));
				mvprintw(23, 1, "Saved to \"My Events.txt\"");
				data.print_details();
				attroff(COLOR_PAIR(6));
			}
			else {
				attron(COLOR_PAIR(5));
				mvhline(23, 1, ' ', 78);
				mvprintw(23, 1, "No event(s) to save. Please create a event first!");
				attroff(COLOR_PAIR(5));
			}
		}

		// Pressed Q
		if (key == 113 || key == 81) exit(0);
	}
}
示例#11
0
// A function to create the "create new event" page.
// This function is the most crucial part in the program which is handling user inputs/data
void create_new_event(bool edit, int z_index ) {
	// This will enable the input to be shown to the user when type.
	resize_term(40, 80);
	echo();

	// Variables
	char rawday, rawname, rawloc, rawhour, rawminute;	// Raw variables used for pdcurses function
	int confirmation;
	bool eventloop = false;									// Indicator for the loop
	int n_day, n_hour, n_minute;							// Day variable which is to be selected by the user

	// Loop until get a data to be saved in data object
	while (eventloop == false) {
		// Empty the console, add titlebar and redraw all.
		erase();
		titlebar();
		refresh();
		raw();

		attron(COLOR_PAIR(3));
		if (edit == true) {
			mvprintw(2, 1, "Edit Event");
			mvprintw(3, 1, "----------");
		}
		else {
			mvprintw(2, 1, "Create New Event");
			mvprintw(3, 1, "----------------");
		}

		mvprintw(20, 1, "Date\t\t:");
		mvprintw(22, 1, "Time\t\t:");
		mvprintw(24, 1, "Event name\t:");
		mvprintw(26, 1, "Location\t:");
		//mvprintw(28, 1, "Description\t:");
		
		// Disabled due to BUG002
		// A small window for description to fit in the text in nice allignment.
		/*WINDOW *wdesc;
		wdesc = newwin(3, 60, 28, 18);
		wattron(wdesc, COLOR_PAIR(3));*/

		// Show calendar, without any inputs
		mvprintw(4, 36, "Calendar");
		show_calendar(false, 14, 6);

		// Show status window (used to deliver message to the user about error, etc.)
		statuswin();

		// Update text in status window
		update_status("Please select the day for the event...\n\nTo go back, press ESC and ENTER",6);
		//refresh();

		// Do this loop until the program obtained a valid day

		do {
			mvhline(20, 18, ' ', 3);											// Clear a small portion of the console
			mvprintw(20, 21, "%s %i", mon_name(selected_mon), selected_year);	// Print the month and year
			mvgetnstr(20, 18, &rawday, 2);										// User input of the day
			if (rawday == 27) menu();												// If user pressed esc and enter, the program will go back to main menu
			n_day = atoi(&rawday);
			//n_day = day;														// A C-function to convert char * to int
			if (n_day == 0 || n_day > max_day_in_month) { update_status("Invalid day. Please enter a valid DAY in the selected month.\n\nTo go back, press ESC and ENTER.",5); }			// Inform user if the day not valid
			refresh();															// Redraw
		} while (n_day == 0 || n_day > max_day_in_month);						// Check if the day valid or not

		// Got a nice and valid n_day and print again to the screen.
		mvhline(20, 18, ' ', 60);												// Refresh the line
		mvprintw(20, 18, "%i %s %i", n_day, mon_name(selected_mon), selected_year);

		// Update to the current status.
		update_status("Please enter the hour in 24 hours...\nIf you enter some string, the result will be 0.", 6);

		// A loop that handle the time input. Runs loop until it gets the valid time.
		do {

			mvhline(22, 18, ' ', 6);											// Clear the line
			mvgetnstr(22, 18, &rawhour, 2);										// Get hour from user
			if (rawhour == 27) menu();											// If user input is ESC then go back to menu
			n_hour = atoi(&rawhour);											// Convert from char to int
			if ( !(n_hour >= 0 && n_hour < 24) ) {								// Check for valid hour
				update_status("Invalid hour. Enter a number in between 0-23. Please try again...", 5);
				continue;
			}
			else {
				mvprintw(22, 20, ":");
				update_status("Please enter the minute...\nIf you enter some string, the result will be 0.", 6);
				do {
					mvhline(22, 21, ' ', 3);
					mvgetnstr(22, 21, &rawminute, 2);
					if (rawminute == 27) menu();
					n_minute = atoi(&rawminute);								// Convert from char to int
					if (!(n_minute >= 0 && n_minute < 60)) {					// Check for valid minutes
						update_status("Invalid minute. Type a number in between 0-59. Please try again...", 5);
						continue;
					}
					else break;
				} while (1);
				break;
			}
		} while (1);

		// Print the time nicely.
		mvhline(22, 18, ' ', 6);
		formatted_time(22, 18, n_hour, n_minute);		// Print time in formatted form xx:yy

		// Update the status
		update_status("Now fill the name, location and description of the event.");

		// Get event name, location and description		// BUG001
		mvgetnstr(24, 18, &rawname, 28);				// First program bug detected here (Read below for more)
		data.save_name(&rawname);						// This function is used to copy rawname char * to another variable in normal char type. It copy the data to a more reliable variable.
														// This is because to prevent memory leak or maybe something else that causes the data in other the pointer (this is bad due to it affect other variable as well) overwritten by the typed data. Approximate more than 11 characters will cause the memory leak -- TESTED)
		mvgetnstr(26, 18, &rawloc, 28);					// Also, to prevent this bug, this function data.save_*** is called right after the user input the data.
		data.save_loc(&rawloc);							// This problem maybe related to the pdcurses library bug that cause the memory leak which affect other variables too.

		//mvwgetnstr(wdesc, 0, 0, &rawdesc, 28);		// BUG002
		//data.save_desc(&rawdesc);						// The program will crash when number of characters more than 28 chars. The cause still unknown. To fix whether to create another custom function to handle input (which is long) or decrease the numbers of characters (which is the quickest way to solve).

		refresh();

		// Clear status
		werase(wstatus);
		wrefresh(wstatus);

		// User confirmation
		mvprintw(32, 1, "Are you sure? (Y/N): ");
		refresh();

		// A loop to check only y/Y/n/N are allowed as a user input
		while (1) {
			mvhline(32, 22, ' ', 1);
			confirmation = getch();
			if (confirmation == 780 || confirmation == 110 || confirmation == 121 || confirmation == 891) { break; }
		}

		// If user type y/Y, the the loop ends
		if (confirmation == 121 || confirmation == 891){
			eventloop = true;								// To ensure that this will break the loop and will not continue anymore
			data.day = n_day;								// Save user inputs
			data.year = selected_year;
			data.nmon = selected_mon;

			// LAB-2
			data.hour = n_hour;
			data.min = n_minute;

			if (edit == true) {
				myVector.erase(myVector.begin() + z_index);
				myVector.insert(myVector.begin() + z_index, data);
				list_events();
			}
			else {
				myVector.push_back(data);
				event_saved = true;								// Tells the program about the saved data
				break;
			}
		}
	}

	if (edit == false) menu();
}