constsql='SELECT SessionName FROM Session WHERE SessionName = \''+spielname+'\';';
constsql='SELECT SessionName FROM Session WHERE SessionName = \''+spielname+'\';';
...
@@ -32,7 +34,7 @@ function createRouter(db) {
...
@@ -32,7 +34,7 @@ function createRouter(db) {
}
}
};
};
vargetGamestatus=function(req,res,next){
constgetGamestatus=function(req,res){
constspielname=req.body.spielname;
constspielname=req.body.spielname;
if(spielname.match(/^[0-9a-zA-Z]+$/)!=null){
if(spielname.match(/^[0-9a-zA-Z]+$/)!=null){
constsql='SELECT SessionID, Red, Blue, RedTurn, ActiveExplainer, ActiveWatchdog FROM Gamestatus WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
constsql='SELECT SessionID, Red, Blue, RedTurn, ActiveExplainer, ActiveWatchdog FROM Gamestatus WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
...
@@ -63,7 +65,7 @@ function createRouter(db) {
...
@@ -63,7 +65,7 @@ function createRouter(db) {
}
}
};
};
varaddSession=functionaddSession(req,res){
constaddSession=functionaddSession(req,res){
constspielname=req.body.spielname;
constspielname=req.body.spielname;
if(spielname.match(/^[0-9a-zA-Z]+$/)!=null){
if(spielname.match(/^[0-9a-zA-Z]+$/)!=null){
constsql='INSERT INTO Session (SessionName) VALUES (\"'+spielname+'\");';
constsql='INSERT INTO Session (SessionName) VALUES (\"'+spielname+'\");';
constsql='UPDATE Gamestatus SET ActiveExplainer = 1, ActiveWatchdog=1 WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
constsql='UPDATE Gamestatus SET ActiveExplainer = 1, ActiveWatchdog=1 WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
...
@@ -193,7 +196,7 @@ function createRouter(db) {
...
@@ -193,7 +196,7 @@ function createRouter(db) {
}
}
};
};
varendRound=functionendRound(req,res){
constendRound=functionendRound(req,res){
constspielname=req.body.spielname;
constspielname=req.body.spielname;
if(spielname.match(/^[0-9a-zA-Z]+$/)!=null){
if(spielname.match(/^[0-9a-zA-Z]+$/)!=null){
constsql='UPDATE Gamestatus SET RedTurn = (SELECT 1-Gamestatus.RedTurn FROM Gamestatus INNER JOIN Session ON Session.SessionID=Gamestatus.SessionID WHERE Session.SessionName = \"'+spielname+'\"), ActiveExplainer = 0, ActiveWatchdog=0 WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
constsql='UPDATE Gamestatus SET RedTurn = (SELECT 1-Gamestatus.RedTurn FROM Gamestatus INNER JOIN Session ON Session.SessionID=Gamestatus.SessionID WHERE Session.SessionName = \"'+spielname+'\"), ActiveExplainer = 0, ActiveWatchdog=0 WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
...
@@ -214,7 +217,7 @@ function createRouter(db) {
...
@@ -214,7 +217,7 @@ function createRouter(db) {
}
}
};
};
varnewGame=functionnewGame(req,res){
constnewGame=functionnewGame(req,res){
constspielname=req.body.spielname;
constspielname=req.body.spielname;
if(spielname.match(/^[0-9a-zA-Z]+$/)!=null){
if(spielname.match(/^[0-9a-zA-Z]+$/)!=null){
constsql='UPDATE Gamestatus SET Red = 0, Blue = 0, RedTurn = '+Math.round(Math.random())+' WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
constsql='UPDATE Gamestatus SET Red = 0, Blue = 0, RedTurn = '+Math.round(Math.random())+' WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
...
@@ -235,7 +238,7 @@ function createRouter(db) {
...
@@ -235,7 +238,7 @@ function createRouter(db) {
}
}
};
};
varaddPoint=functionaddPoint(req,res){
constaddPoint=functionaddPoint(req,res){
console.log(req.body);
console.log(req.body);
constspielname=req.body.spielname;
constspielname=req.body.spielname;
constteam=req.body.team;
constteam=req.body.team;
...
@@ -286,7 +289,7 @@ function createRouter(db) {
...
@@ -286,7 +289,7 @@ function createRouter(db) {
}
}
};
};
varremovePoint=functionremovePoint(req,res){
constremovePoint=functionremovePoint(req,res){
console.log(req.body);
console.log(req.body);
constspielname=req.body.spielname;
constspielname=req.body.spielname;
constteam=req.body.team;
constteam=req.body.team;
...
@@ -337,6 +340,37 @@ function createRouter(db) {
...
@@ -337,6 +340,37 @@ function createRouter(db) {
}
}
};
};
constgetCard=functiongetCard(req,res){
constcardID=req.body.cardID;
if(Number.isInteger(cardID)){
constsql='SELECT CardID, Solution, Tabu1, Tabu2, Tabu3, Tabu4, Tabu5 FROM Card WHERE CardID = \"'+cardID+'\"';