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?
Text-Based-Game/src/_effect.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
51 lines (44 sloc)
1.26 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
#include <iostream> | |
#include "../include/libsqlite.hpp" // provided by Hintea, D. in 4005 CEM https://cumoodle.coventry.ac.uk/pluginfile.php/2606853/mod_resource/content/0/libsqlite.hpp | |
#include <tuple> | |
using namespace std; | |
class Effect | |
{ | |
private: | |
// tuple<int, string, string, int, float> effect; | |
vector<int> effect; | |
public: | |
Effect(int effectID) | |
{ | |
// connecting to SQLite database and setting attributes from each record | |
sqlite::sqlite db("Database/Game_Database.sqlite"); | |
auto cur = db.get_statement(); | |
// cur->set_sql("SELECT * FROM Effects WHERE Effect_ID = ?;"); | |
cur->set_sql("SELECT Effect_ID FROM Ability_Effects WHERE Ability_ID = ?;"); | |
cur->prepare(); | |
cur->bind(1, effectID); | |
while(cur->step()) | |
{ | |
// effect = make_tuple(cur->get_int(0), cur->get_text(1), cur->get_text(2), cur->get_int(3), cur->get_double(4)); | |
effect.emplace_back(cur->get_int(0)); | |
} | |
} | |
vector<int> get_effects() | |
{ | |
return effect; | |
} | |
tuple<int, string, string, int, float> get_effects() | |
{ | |
return effect; | |
} | |
}; | |
int main() | |
{ | |
Effect e(1); | |
vector<int> effects = e.get_effects(); | |
for (int i=0; i<effects.size(); i++) | |
{ | |
cout << effects[i] << endl; | |
} | |
return 0; | |
} |