diff --git a/backend/api/games.js b/backend/api/games.js index a83bc05fe5b8cee7c1ecf0cfa6749bdc71f01beb..471e91154a092f4bd281bb168ff2028cc0636723 100644 --- a/backend/api/games.js +++ b/backend/api/games.js @@ -66,7 +66,6 @@ router.get("/gamename/:gameId", (req, res) => { .find({ _id: id }) - .project({ name: 1 }) .toArray((err, result) => { if (err) { res.sendStatus(500); @@ -94,7 +93,8 @@ router.post("/", (req, res) => { const db = client.db("gameWare"); const collection = "games"; - name = req.body.name; + const name = req.body.name; + const explanation = req.body.explanation; if (!name) { // Name not provided in body @@ -102,14 +102,22 @@ router.post("/", (req, res) => { return; } - db.collection(collection).insertOne({ name }, (err, result) => { - if (err) { - res.sendStatus(500); // Internal server error - return; + if (!explanation) { + res.status(400).send("Explanation not provided"); + return; + } + + db.collection(collection).insertOne( + { name, explanation }, + (err, result) => { + if (err) { + res.sendStatus(500); // Internal server error + return; + } + res.json(result.ops[0]); + client.close(); } - res.json(result.ops[0]); - client.close(); - }); + ); } ); }); diff --git a/frontend/core/src/com/gameware/game/models/Game.java b/frontend/core/src/com/gameware/game/models/Game.java index d2d29d7c9d154e31794c2a5a04b4636d0f764091..99bb212bbb624f7e1772928f859f4b38a0e1d52a 100644 --- a/frontend/core/src/com/gameware/game/models/Game.java +++ b/frontend/core/src/com/gameware/game/models/Game.java @@ -5,10 +5,12 @@ import com.badlogic.gdx.utils.Json; public class Game implements ModelInterface { private String _id; private String name; + private String explanation; - public Game(String _id, String name) { + public Game(String _id, String name, String explanation) { this._id = _id; this.name = name; + this.explanation = explanation; } public Game() { @@ -22,9 +24,13 @@ public class Game implements ModelInterface { return name; } + public String getExplanation() { + return explanation; + } + @Override public String toString() { - return this.name; + return report(); } public void reset() {