Skip to content
Permalink
73f844c7a6
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
263 lines (256 sloc) 17.8 KB
#include "../include/MainMenu.hpp"
#include "../include/Game.hpp"
#include <ncurses.h>
#include <locale.h>
#include <iostream>
#include <string>
#include <array>
#include "../include/GameWindow.hpp"
#include "../include/libsqlite.hpp"
#include "../include/Selection.hpp"
using namespace std;
void MainMenu()
{
setlocale(LC_ALL, "");
initscr();
cbreak();
noecho();
curs_set(0);
sqlite::sqlite db("Database/Game_Database.sqlite");
auto cur_heroes = db.get_statement();
auto cur_abilities= db.get_statement();
cur_heroes->set_sql("SELECT * FROM Heroes;");
cur_heroes->prepare();
cur_abilities->set_sql("SELECT * FROM Abilities;");
cur_abilities->prepare();
cur_abilities->step();
vector<string> choices ={"Start Battle","Help","Exit"/*,"Character selection"*/};
bool game_over=false;
while(game_over!=true)
{
//Once the game starts 2 boxes will be printed, one contains the title and the other the options for start,help or quit
GameWindow title_win(9, 52, 0, COLS/2 - 26);
GameWindow menu_win(5,52,10,COLS/2 - 26);
const char *c="______ _ _ ___ \n | ___ (_) | | / _ \\ \n | |_/ /___ _____| | / /_\\ \\_ __ ___ _ __ __ _ \n | __/| \\ \\/ / _ \\ | | _ | '__/ _ \\ '_ \\ / _` | \n | | | |> < __/ | | | | | | | __/ | | | (_| | \n \\_| |_/_/\\_\\___|_| \\_| |_/_| \\___|_| |_|\\__,_|";
title_win.Print(c);
vector<vector<string>> help =
{
{"How to play","This will show you the rules of the game"},
{"Heroes description","This will show you a quick description of all the heroes and their stats"},
{"Status effects","There are several types, select this for more info"},
{"Lore","This will tell you the story of all the various heroes that fight in the arena"},
{"Exit help","Return to the starting menu"}
};
int choice;
choice=menu_win.Menu(choices);
//if choice==2 then that means we choose to exit the game, 1 means help menu and 0 means start the game
if(choice==2) {title_win.Clear(false);menu_win.Clear(false);game_over=true;}
else if(choice==1)
{
title_win.Clear(false);
menu_win.Clear(false);
bool help_over=false;
while(help_over!=true)
{
//the next 2 windows are linked, the one at the top displays some options while the one at the bottom displays descriptions
GameWindow help_win(9,120,0,COLS/2-60);
GameWindow help_descr(5,120,9,COLS/2-60);
int help_choice;
help_choice=help_win.Menu(help,help_descr);
// help_choice==5 means we return to the previous menu
if (help_choice==4) {help_win.Clear(false);help_descr.Clear(false);help_over=true;}
else if (help_choice==1)
{
//1 means we go for the hero descriptions. Lines 65 to 98 are there so that we can retrieve info from the database like the descriptions and stats
help_win.Clear(false);
help_descr.Clear(false);
GameWindow hero_menu(4,120,0,COLS/2-60);
GameWindow hero_descr(7,120,4,COLS/2-60);
bool help2=false;
while(help2!=true)
{
int select_description;
vector <vector<string>> heroes={{"Exit","Select this when you want to return to the previous menu"}};
while(cur_heroes->step())
{
string c;
c+=cur_heroes->get_text(2);//Description of hero
c+=" Stats: \n Health points=";
c+=to_string(cur_heroes->get_int(3));//HP
c+=", Mana points=";
c+=to_string(cur_heroes->get_int(4));//MP
c+=", Stamina points=";
c+=to_string(cur_heroes->get_int(5));//SP
c+=", Speed=";
c+=to_string(cur_heroes->get_int(6));//SPD
c+=", Defence=";
c+=to_string(cur_heroes->get_int(7));//DEF
c+=". Abilities: 1)";
cur_abilities->step();
c+=cur_abilities->get_text(1);//Ability name
c+=" - ";
c+=cur_abilities->get_text(2);//Ability description
cur_abilities->step();
c+=" 2)";
c+=cur_abilities->get_text(1);
c+=" - ";
c+=cur_abilities->get_text(2);
heroes.push_back({cur_heroes->get_text(1),c});
}
select_description=hero_menu.Menu(heroes,hero_descr);
if(select_description==0) {
hero_descr.Clear(false);
hero_menu.Clear(false);
help2=true;
}
}
}
else if(help_choice==0)
{
//0 means that we go for "How to play" option which will teach you how the game is played
help_win.Clear(false);
help_descr.Clear(false);
GameWindow rules_win(3,120,0,COLS/2-60);
GameWindow rules_descr(8,120,3,COLS/2-60);
bool rules=false;
while(rules!=true)
{
int select_option;
vector<vector<string>> rules_vector{
{"rules","Each player has to select 5 heroes, 3 of them will be on the battlefield while the remaining 2 are backup. \n The player with the fastest hero starts.\n After this the next player's turn comes and so on. \n The players are not allowed to select the hero with which they attack.\n Instead the selected hero is decided by the speed stat and the fastest hero will go first followed by the second fastest and so on.\n The fight ends when all the heroes on one team are dead and the player that still has someone in his team alive is declared the winner.\n "},
{"exit","Go back to the previous menu"}
};
select_option=rules_win.Menu(rules_vector,rules_descr);
if(select_option==1){
rules_win.Clear(false);
rules_descr.Clear(false);
rules=true;
}
}
}
else if(help_choice==2)
{
//this menu is here to help people understand what all of these status effects mean
help_win.Clear(false);
help_descr.Clear(false);
GameWindow status_win(3,120,0,COLS/2-60);
GameWindow status_descr(3,120,3,COLS/2-60);
bool status_over=false;
while(status_over!=true)
{
int status_select;
vector<vector<string>> status_list
{
{"Exit","Return to previous menu"},
{"Burning","Does fire damage to the hero affected by it"},
{"Bleeding","The aflicted hero is slowly losing blood"},
{"Poisoned","The hero has been poisoned and is slowly dying"},
{"Stuned","The stunned hero won't be able to move for a few turns"},
{"Cursed","The aflicted hero is debuffed(Attack,speed and defence are lowered)"},
{"Blessed","The hero is buffed(Damage,speed and defence are raised)"}
};
status_select=status_win.Menu(status_list,status_descr);
if(status_select==0)
{
status_descr.Clear(false);
status_win.Clear(false);
status_over=true;
}
}
}
else if(help_choice==3)
{
// we have decide that instead of having a story we will go the dark souls route and add lore for all of the 9 heroes
help_win.Clear(false);
help_descr.Clear(false);
GameWindow lore_hero(3,120,0,COLS/2-60);
GameWindow lore_descr(11,120,3,COLS/2-60);
bool lore_over=false;
while(lore_over!=true)
{
int lore_select;
vector<vector<string>> lore_list=
{
// Adding all of the lore won't give me any more marks so I have taken it out of the submited code
{"Exit","Go back to the previous menu"},
{"Warrior","This man was once part of a covenant made with a god of war that would allow his followers to hurl lightning spears at their foes. Sadly the warriors of sunlight were disbanded and they lost they're powers for the god of war had committed a great crime. As punishment the god of war was banished and stripped of his deific status and his name stricken the annals of history. Nowadays his followers roam the land as mercenaries. This one has chosen to fight on as a gladiator in this very arena and has achieved the status of champion among 8 others. "},
{"Mage","This ancient one was once part of the Dragon academy of magic arts where he was once a student and then a teacher. As he grew older his lust for more knowledge grew as well, it is because of this reason that he left the legendary academy to search for even more powerful sorceries. Sadly he was never able to discover any new spells as he was captured and enslaved not long after he left the academy. Now he fights in the arena hoping to earn back his freedom however in his years of fighting the arena he has become one of it's nine champions and now has no chance of escape. The leader of the arena would never lose such a priceless slave. "},
{"Thief","Once a citizen of the great city, now just another slave forced to fight in it's arena. This man was once part of the famous thieves guild however he bit more than he could chew when he tried to steal from a noble. Just when he was about to get away with his prize he had been seen and caught by a guard that was not at his post. This was the end of his career as a thief and the beginning of his reign in the arena as one of the 9 champions."},
{"Knight","Once this man was part of a glorious order of knights serving under a deity simply known as the Darksun. Their role was to hunt down and punish the wicked however one of this so called sinners managed to infiltrate the order and kill their god. Now without a master and cause this knight offers himself to the arena not caring whether he survives the next fight or meets his end. After many years in the arena he too has achieved the rank of champion. "},
{"Cleric","Once a high ranking member of the church now just a gladiator. This man relies on the miracles he can perform in order to win his fights. After reaching the rank of bishop within his faith he was framed and accused for the murder of a minor church official which with he had many fights. Despite his fate the man didnt give up on his god and now he has achieved the rank of champion. He has also become the doctor of the arena. "},
{"Hunter","This hunter of beasts has now become a hunter of man. After being given the contract of killing a great beast and succeeding in his task he was imprisoned by the greedy landlord who would not pay the reward. The hunter fought back and even managed to kill the lord during his arrest however this only sealed his fate. Now after years of killing in the arena he has been named as one of the 9 champions. "},
{"Paladin","He was born in the slums and raised by the church as an enforcer . This man has become a fanatic over the years in service to the gods and he does not care for the standing of his victims whether they are noble or poor, man of woman, adult or child. Because of his devotion he was made a paladin however after 3 decades of service under them even the church could not back up this fanatic tendencies and instead have enslaved him and sent him to the arena. The man still as devout as ever now sees his imprisonment within the arena as a sign that he is supposed to show to everyone the power of god through the people he kills."},
{"Alchemist","As a child the alchemist would always spend her time learning more about different plants, anatomy and the occult. When she was old enough she began travelling the world and soon enough found what she was looking for, someone to take her as an apprentice. After years of being taught more and more about the healing arts the alchemist was finally ready for her final challenge. Become a doctor in the capital and find an apprentice of her own. Unfortunately fate was not kind to her. On the way to the capital she was enslaved and made to fight in the arena. Her whole world has been knocked upside down, instead of healing she would be the cause others die and yet when the masters of the arena saw her talent they decided that as long as she would heal all of the injured gladiators she would not be forced to fight, would be given all the resources she needs to do her work. She hastily accepted and was given an honorary title: the ninth champion of the arena. "},
{"Beastman","After committing a great crime this man was exiled in to the wilderness. Although he had not tools or weapons by his side he managed to adapt to the situation by forsaking his humanity and letting the beast inside take over. After 3 decades of living as a wild animal he was found by some slavers and sold of as an exotic animal to the arena. Because of his time during the forest people actually believed that he was a mix between human and beast, he wore stag antlers on his head, different animal pelts and had many scars all over his body. After he become a slave in service to the arena he become a champion to his great savagery when fighting and become one of the nine champions"}
};
lore_select=lore_hero.Menu(lore_list,lore_descr);
if(lore_select==0){
lore_hero.Clear(false);
lore_descr.Clear(false);
lore_over=true;
}
}
}
}
}
//This will start the battle, however we have no character selection menu yet
else if (choice==0)
{
Selection();
}
/*This option is not gonna be in the final version of the game
I decided to make an extra option to try and make a character selection menu however it is not yet done*/
/*else if (choice==3)
{
title_win.Clear(false);
menu_win.Clear(false);
GameWindow player1_choose(5,0,0,0);
player1_choose.Print("Player 1 choose will chose 5 heroes");
GameWindow hero_win(5,130,5,COLS/2-65);
GameWindow selected_descrption(10,130,10,COLS/2-65);
//GameWindow hero_stats(0,0,10,0);
bool char_selection_over=false;
while(char_selection_over!=true)
{
string c;
int char_select=0,i=0;
vector<vector<string>> characters;
while(cur_heroes->step())
{
c+=cur_heroes->get_text(2);//Description of hero
c+=" Stats: Health points=";
c+=to_string(cur_heroes->get_int(3));//Hp
c+=", Mana points=";
c+=to_string(cur_heroes->get_int(4));//MP
c+=", Stamina points=";
c+=to_string(cur_heroes->get_int(5));//SP
c+=", Speed=";
c+=to_string(cur_heroes->get_int(6));//SPD
c+=", Defence=";
c+=to_string(cur_heroes->get_int(7));//DEF
c+=". Abilities: 1)";
cur_abilities->step();
c+=cur_abilities->get_text(1);//Ability name
c+="-";
c+=cur_abilities->get_text(2);//Ability description
cur_abilities->step();
c+=" 2)";
c+=cur_abilities->get_text(1);
c+="-";
c+=cur_abilities->get_text(2);
characters.push_back({cur_heroes->get_text(1),c});
}
vector<int> player1;
vector<int> player2;
while(player1.size()!=5 && player2.size()!=5)
{
char_select=hero_win.Menu(characters,selected_descrption);
if(char_select>=0 && char_select<=8)
if(player1.size()!=5) {player1.push_back(cur_heroes->get_int(0)); cur_heroes->step();}
else{player2.push_back(cur_heroes->get_int(0)); cur_heroes->step();}
}
}
}*/
}
endwin();
}