Skip to content
Permalink
master
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
//new quest log.cpp
#include <iostream>
#include <string>
#include <ncurses.h>
#include <vector>
#include "sql.h"
#include "terminalSize.h"
void active_quests(int y, int x);
void completed_quests (int y, int x);
void questLog();
void active_quests(int y , int x) {
clear();
mvprintw(y,x, "\n Your active quests: \n\n");
//display quests
std::vector<string> results;
std::string query;
query = query = "SELECT * FROM Quests WHERE Status = 1";
results = sql_call(query);
int y_coord = 3;
for (std::string x : results) {
mvprintw(y_coord,0,x.c_str());
y_coord += 1;
clrtoeol();
}
mvprintw(y,x,"Press anything the return to quest log");
getch();
}
void completed_quests(int y, int x) {
clear();
mvprintw(y,x, "\n Your completed quests: \n\n");
//display quests
std::vector<string> results;
std::string query;
query = query = "SELECT * FROM Quests WHERE Status = 2";
results = sql_call(query);
int y_coord = 3;
for (std::string x : results) {
mvprintw(y_coord,0,x.c_str());
y_coord += 1;
}
mvprintw(y,x,"Press anything the return to quest log");
getch();
}
void questLog() {
initscr();
noecho();
char input;
int x = 0;
int y = 0;
int ymax, xmax;
std::string query;
std::vector<string> results;
getxy(ymax, xmax);
const std::string navigateString = "Press [1] to view active quests\nPress [2] to view completed quests\nPress [3] to exit the quest log\n";
std::cout << "Your quest Log:\n";
while (input != '3') {
clear();
mvprintw(y,x, navigateString.c_str() );
input = getch();
if (input == '1') {
active_quests(y,x);
}
else if (input == '2'){
completed_quests(y,x);
}
else {
clear();
mvprintw(y,x, "Invalid input\nPress any button to return");
getch();
}
}
endwin();
}