Permalink
Cannot retrieve contributors at this time
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?
asciiGame/quest_log.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
98 lines (73 sloc)
2 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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(); | |
} |