Skip to content
Snippets Groups Projects
Commit d0ab5ea3 authored by ivarnm's avatar ivarnm
Browse files

#88 Add game explanation

parent be5e49cf
No related branches found
No related tags found
1 merge request!87Resolve "Game Explanation"
......@@ -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 (!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();
});
}
);
}
);
});
......
......@@ -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() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment