blob: 0cf6a1d2b3f953ab8cbd0b241cd370b0e9a440cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <memory>
#include "backend/Enemy.h"
#include "backend/EnemyFactory.h"
#include "backend/Object.h"
#include "backend/ObjectFactory.h"
#include "GameData.h"
using namespace std;
GameData & GameData::get_instance() {
static GameData instance;
return instance;
}
GameData::GameData() {
this->db = make_unique<DB>("kerkersendraken.db");
}
Enemy * GameData::create_enemy(const string & name) {
Enemy * enemy = EnemyFactory::create_enemy();
return enemy;
}
Object * GameData::create_object(const string & name) {
DBStatement query = this->db->prepare("select type from Objecten where naam = ?");
query.bind(name);
// TODO: uhhhhhhhhh data ophalen
Object * object = ObjectFactory::create_object();
return object;
}
void GameData::leaderbord_add(const string & name, unsigned int gold) {
this->db->prepare("insert into Leaderboard (naam, goudstukken) values (?, ?)")
.bind(name)
.bind(gold)
.execute();
}
|