Skip to content
Permalink
Browse files
Fixed annoying file name/function inconsistencies, sorry about that.
  • Loading branch information
wlodarsb committed Mar 5, 2019
1 parent 33d3706 commit 12d06b305d222745f1f20cf2ae98cd5ad32ddb7c
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 131 deletions.
@@ -27,5 +27,5 @@ target_link_libraries(main menu game window ${CURSES_LIBRARIES})
find_library(sqlite3 NAMES sqlite3 PATHS ${/usr/lib/x86_64-linux-gnu})

add_compile_options(-lsqlite3)
add_executable(hero ${CMAKE_SOURCE_DIR}/src/hero.cpp)
add_executable(hero ${CMAKE_SOURCE_DIR}/src/Hero.cpp)
target_link_libraries(hero ability effect sqlite3)
@@ -7,11 +7,11 @@
#include <ctime>
#include <tuple>
#include "libsqlite.hpp"
#include "effect.hpp"
#include "Effect.hpp"
#include <cstdlib>
using namespace std;

class Ability
class Ability
{
private:
string Ability_Name, Ability_Description;
File renamed without changes.
@@ -2,17 +2,7 @@
#define GAME_HPP

#include <ncurses.h>
/*
class Game
{
public:
static int gv_line_count;
WINDOW *game_view, *statuses, *abilities;
public:
Game(bool cbreak_present);
};
*/

void mainGame();
void MainGame();

#endif
#endif
@@ -7,15 +7,15 @@
#include <ctime>
#include <tuple>
#include "libsqlite.hpp"
#include "ability.hpp"
#include "Ability.hpp"
#include <map>
#include <vector>
using namespace std;

class Hero
class Hero
{
private:
string Hero_Name, Hero_Description;
string Hero_Name, Hero_Description;
int HP, SP, MP, SPD, DEF;
vector<int> ability_ids;
vector<Ability> abilities;
@@ -35,4 +35,4 @@ public:
friend ostream& operator<<( ostream&, const Hero&);
};

#endif
#endif
File renamed without changes.
@@ -1,16 +1,19 @@
#ifndef PLAYER_HPP
#define PLAYER_HPP

#include <vector>
#include "hero.hpp"
#include <array>
#include <string>
#include "Hero.hpp"
using namespace std;

class Player
{
private:
vector<Hero> heroes;
string name;
array<Hero, 5> heroes;
public:
Player(vector<Hero> selection);
Player(array<int, 5> selection);
Hero GetHero(int ID);
}

#endif
@@ -3,7 +3,7 @@
#include <algorithm>
#include <string>
#include "include/Game.hpp"
#include "include/mainMenu.hpp"
#include "include/MainMenu.hpp"

using namespace std;

@@ -16,6 +16,6 @@ int main(int argc, char **argv)
}
vector<string> args(argv, argv + argc);
bool cbreak_present = find(args.begin(), args.end(), "cbreak") != args.end();
mainMenu();
MainMenu();
return 0;
}
}
@@ -1,5 +1,5 @@
#include "../include/ability.hpp"
#include "../include/effect.hpp"
#include "../include/Ability.hpp"
#include "../include/Effect.hpp"
#include <iostream>

Ability::Ability(int _id)
@@ -12,7 +12,7 @@ Ability::Ability(int _id)
cur->set_sql("SELECT * FROM Abilities WHERE Ability_ID = ?;");
cur->prepare();
cur->bind(1, _id);

while(cur->step())
{
Ability_Name = cur->get_text(1);
@@ -24,23 +24,23 @@ Ability::Ability(int _id)
Mana_Cost = cur->get_int(7);
Stamina_Cost = cur->get_int(8);
}

cur->reset();
cur->set_sql("SELECT Effect_ID FROM Ability_Effects WHERE Ability_ID = ?;");
cur->prepare();
cur->bind(1, _id);

while(cur->step())
{
effect_ids.emplace_back(cur->get_int(0));
}

}
catch(sqlite::exception e)
{
cerr << e.what() << endl;
}

for(int i=0; i<effect_ids.size(); ++i)
{
Effect ability_effect(effect_ids[i]);
@@ -68,4 +68,4 @@ ostream& operator<<( ostream& os, const Ability& ability )
<< "Costs " << ability.Mana_Cost << " mana and " << ability.Stamina_Cost << " stamina\n"
<< "Have the following effects:\n";
return os;
}
}
@@ -1,5 +1,5 @@
add_library(game Game.cpp)
add_library(window GameWindow.cpp)
add_library(menu mainMenu.cpp)
add_library(ability ability.cpp)
add_library(effect effect.cpp)
add_library(menu MainMenu.cpp)
add_library(ability Ability.cpp)
add_library(effect Effect.cpp)
@@ -1,4 +1,4 @@
#include "../include/effect.hpp"
#include "../include/Effect.hpp"
#include <iostream>

Effect::Effect(int _id)
@@ -11,7 +11,7 @@ Effect::Effect(int _id)
cur->set_sql("SELECT * FROM Effects WHERE Effect_ID = ?;");
cur->prepare();
cur->bind(1, _id);

while(cur->step())
{
Effect_Name = cur->get_text(1);
@@ -24,12 +24,12 @@ Effect::Effect(int _id)
{
cerr << e.what() << endl;
}

};

ostream& operator<<( ostream& os, const Effect& effect )
{
os << effect.Effect_Name << "affects the " << effect.Target_Stat << " of the targeted hero for "
os << effect.Effect_Name << "affects the " << effect.Target_Stat << " of the targeted hero for "
<< effect.Duration << " turns and have an impact of " << effect.Impact << "." << endl;
return os;
}
}
@@ -6,7 +6,7 @@

using namespace std;

void mainGame()
void MainGame()
{
/* Setting up windows using GameWindow class */
initscr();
@@ -33,15 +33,15 @@ void mainGame()
{"Ultimate", "Your ultimate move!"},
{"Transform", "Become different!"}
};

bool game_over = false;
int current_player = 1;
int choice = -1;
string to_print = "Player " + to_string(current_player) + "'s turn!";
text_box.Clear();
text_box.Print(to_print);
getch();

while(!game_over)
{
//text_box.Clear();
@@ -75,4 +75,4 @@ void mainGame()
text_box.Clear(false);
menu_desc.Clear(false);
endwin();
}
}
@@ -1,5 +1,5 @@
#include "../include/hero.hpp"
#include "../include/ability.hpp"
#include "../include/Hero.hpp"
#include "../include/Ability.hpp"
#include <iostream>

using namespace std;
@@ -14,7 +14,7 @@ Hero::Hero(int _id)
cur->set_sql("SELECT * FROM Heroes WHERE Hero_ID = ?;");
cur->prepare();
cur->bind(1, _id);

while(cur->step())
{
Hero_Name = cur->get_text(1);
@@ -25,12 +25,12 @@ Hero::Hero(int _id)
SPD = cur->get_int(6);
DEF = cur->get_int(7);
}

cur->reset();
cur->set_sql("SELECT Ability_ID FROM Hero_Abilities WHERE Hero_ID = ?;");
cur->prepare();
cur->bind(1, _id);

while(cur->step())
{
ability_ids.emplace_back(cur->get_int(0));
@@ -40,7 +40,7 @@ Hero::Hero(int _id)
{
cerr << e.what() << endl;
}

for(int i=0; i<ability_ids.size(); ++i)
{
Ability hero_ability(ability_ids[i]);
@@ -51,7 +51,7 @@ Hero::Hero(int _id)
{
cout << get<i>(Hero_details) << endl;
}**/

}

int Hero::GetHP() {return HP;}
@@ -61,12 +61,12 @@ int Hero::GetSPD() {return SPD;}
int Hero::GetDEF() {return DEF;}

void Hero::DealDMG(int dmg) {HP = dmg * ((100-DEF)/100);}
void Hero::TakeSP(int amount)
void Hero::TakeSP(int amount)
{
SP -= amount;
if(SP < 0) SP = 0;
}
void Hero::TakeMP(int amount)
void Hero::TakeMP(int amount)
{
MP -= amount;
if(MP < 0) MP = 0;
@@ -76,7 +76,7 @@ void Hero::SetDEF(int defence) {DEF = defence;}

ostream& operator<<( ostream& os, const Hero& hero )
{
os << "Details of " << hero.Hero_Name << ":\n"
os << "Details of " << hero.Hero_Name << ":\n"
<< "HP: " << hero.HP << "\n"
<< "SP: " << hero.SP << "\n"
<< "MP: " << hero.MP << "\n"
@@ -100,7 +100,7 @@ ostream& operator<<( ostream& os, const Ability& ability )
ostream& operator<<( ostream& os, const Effect& effect )
{
os << effect.Effect_Name << "affects the " << effect.Target_Stat << " of the targeted hero for "
os << effect.Effect_Name << "affects the " << effect.Target_Stat << " of the targeted hero for "
<< effect.Duration << " turns and have an impact of " << effect.Impact << "." << endl;
return os;
}
@@ -1,4 +1,4 @@
#include "../include/mainMenu.hpp"
#include "../include/MainMenu.hpp"
#include "../include/Game.hpp"
#include <ncurses.h>
#include <locale.h>
@@ -7,18 +7,18 @@
#include "../include/GameWindow.hpp"
using namespace std;

void mainMenu()
void MainMenu()
{
setlocale(LC_ALL, "");
initscr();
cbreak();
noecho();
curs_set(0);

vector<string> choices ={"Start Battle","Help","Exit"};
bool gameOver=false;
while(gameOver!=true)
{
{
GameWindow titleWin(9, 52, 0, COLS/2 - 26);
GameWindow menuWin(5,52,10,COLS/2 - 26);
const char *c="______ _ _ ___ \n | ___ (_) | | / _ \\ \n | |_/ /___ _____| | / /_\\ \\_ __ ___ _ __ __ _ \n | __/| \\ \\/ / _ \\ | | _ | '__/ _ \\ '_ \\ / _` | \n | | | |> < __/ | | | | | | | __/ | | | (_| | \n \\_| |_/_/\\_\\___|_| \\_| |_/_| \\___|_| |_|\\__,_|";
@@ -41,16 +41,16 @@ void mainMenu()
{
titleWin.Clear(false);
menuWin.Clear(false);
bool helpOver=false;
bool helpOver=false;
while(helpOver!=true)
{

GameWindow helpWin(9,120,0,COLS/2-60);
GameWindow helpDescr(5,120,9,COLS/2-60);
int helpChoice;
helpChoice=helpWin.Menu(help,helpDescr);
if (helpChoice==6) {helpWin.Clear(false);helpDescr.Clear(false);helpOver=true;}
else if (helpChoice==1)
if (helpChoice==6) {helpWin.Clear(false);helpDescr.Clear(false);helpOver=true;}
else if (helpChoice==1)
{
helpWin.Clear(false);
helpDescr.Clear(false);
@@ -120,7 +120,7 @@ void mainMenu()
dmgDescr.Clear(false);
damageOver=true;
}

}
}
else if(helpChoice==3)
@@ -180,7 +180,7 @@ void mainMenu()
}
else if (choice==0)
{
mainGame();
mainGame();
}
}
endwin();
File renamed without changes.

0 comments on commit 12d06b3

Please sign in to comment.