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, ActiveCard FROM Gamestatus WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
constsql='INSERT INTO S2C (SessionID, CardID) VALUES ((SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\"), '+card.CardID+');';
constsqlUpdate='UPDATE Gamestatus SET ActiveCard = '+card.CardID+' WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
console.log('getS2C3: ',sql);
db.query(sqlUpdate);
constsqlInsert='INSERT INTO S2C (SessionID, CardID) VALUES ((SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\"), '+card.CardID+');';
res.header('Access-Control-Allow-Origin',"*").status(500).json({status:'error alle Karten durch'});
}
}
}
}
});
});
...
@@ -212,7 +232,7 @@ function createRouter(db) {
...
@@ -212,7 +232,7 @@ function createRouter(db) {
constnewRound=functionnewRound(req,res){
constnewRound=functionnewRound(req,res){
constspielname=req.body.spielname;
constspielname=req.body.spielname;
if(spielname.match(/^[0-9a-z]+$/)!=null){
if(spielname.match(/^[0-9a-z]+$/)!=null){
constsql='UPDATE Gamestatus SET ActiveExplainer = 1, ActiveWatchdog=1 WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
constsql='UPDATE Gamestatus SET ActiveExplainer = 1 WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
console.log('newRound: ',sql);
console.log('newRound: ',sql);
db.query(
db.query(
sql,
sql,
...
@@ -238,7 +258,7 @@ function createRouter(db) {
...
@@ -238,7 +258,7 @@ function createRouter(db) {
functionendRound(req){
functionendRound(req){
constspielname=req.body.spielname;
constspielname=req.body.spielname;
if(spielname.match(/^[0-9a-z]+$/)!=null){
if(spielname.match(/^[0-9a-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, ActiveCard =0 WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
console.log('endRound: ',sql);
console.log('endRound: ',sql);
db.query(
db.query(
sql,
sql,
...
@@ -391,7 +411,7 @@ function createRouter(db) {
...
@@ -391,7 +411,7 @@ function createRouter(db) {
constcardID=req.body.cardID;
constcardID=req.body.cardID;
if(Number.isInteger(cardID)){
if(Number.isInteger(cardID)){
constsql='SELECT CardID, Solution, Tabu1, Tabu2, Tabu3, Tabu4, Tabu5 FROM Card WHERE CardID = \"'+cardID+'\"';
constsql='SELECT CardID, Solution, Tabu1, Tabu2, Tabu3, Tabu4, Tabu5 FROM Card WHERE CardID = \"'+cardID+'\"';