juk3n/fluffypublic Fork
⑂ 3e8aa86
Commits
⬇ Clone ▾
git clone https://git.rickub.com/juk3n/fluffy.git
git clone ssh://git@rickub.com/juk3n/fluffy.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

added game class

Adrian Duraj committed 2024-06-20T16:54:18+02:00 Browse files
3e8aa86 parent: 1664d3e
added include/game.hpp +18 -0
new file mode 100644
@@ -0,0 +1,18 @@
1+#pragma once
2+
3+#include <string>
4+
5+class Game
6+{
7+private:
8+ int id;
9+ std::string name;
10+ std::string path;
11+public:
12+ Game(int id, std::string name, std::string path) : id{id}, name{name}, path{path} { }
13+ ~Game() { }
14+
15+ int getId() { return id; }
16+ std::string getName() { return name; }
17+ std::string getPath() { return path; }
18+};
new file mode 100644
@@ -0,0 +1,18 @@
1+#pragma once
2+
3+#include <string>
4+
5+class Game
6+{
7+private:
8+ int id;
9+ std::string name;
10+ std::string path;
11+public:
12+ Game(int id, std::string name, std::string path) : id{id}, name{name}, path{path} { }
13+ ~Game() { }
14+
15+ int getId() { return id; }
16+ std::string getName() { return name; }
17+ std::string getPath() { return path; }
18+};
modified src/main.cpp +10 -1
@@ -12,6 +12,7 @@
1212 #include <sqlite3.h>
1313 #include <map>
1414
15+#include <game.hpp>
1516
1617 using namespace ftxui;
1718
@@ -43,8 +44,16 @@ void execute_sql_command(sqlite3* database, std::string command) {
4344 }
4445 }
4546
47+int calculateFirstGameIdAvailable() {
48+ int availableId{};
49+
50+ availableId = games.size() + 1;
51+
52+ return availableId;
53+}
54+
4655 void addGame(sqlite3* database, std::string name, std::string path) {
47- int id = games.size() + 1; // calculateId();
56+ int id = calculateFirstGameIdAvailable();
4857 addGameToDatabase(database, id, name, path);
4958 }
5059
@@ -12,6 +12,7 @@
12 #include <sqlite3.h>12 #include <sqlite3.h>
13 #include <map>13 #include <map>
14 14
15+#include <game.hpp>
15 16
16 using namespace ftxui;17 using namespace ftxui;
17 18
@@ -43,8 +44,16 @@ void execute_sql_command(sqlite3* database, std::string command) {
43 }44 }
44 }45 }
45 46
47+int calculateFirstGameIdAvailable() {
48+ int availableId{};
49+
50+ availableId = games.size() + 1;
51+
52+ return availableId;
53+}
54+
46 void addGame(sqlite3* database, std::string name, std::string path) {55 void addGame(sqlite3* database, std::string name, std::string path) {
47- int id = games.size() + 1; // calculateId();56+ int id = calculateFirstGameIdAvailable();
48 addGameToDatabase(database, id, name, path);57 addGameToDatabase(database, id, name, path);
49 }58 }
50 59