constsql='SELECT SessionName FROM Session WHERE SessionName = \''+spielname+'\';';
constsql='SELECT SessionName FROM Session WHERE SessionName = \''+spielname+'\';';
console.log('isSession:',sql);
console.log('isSession:',sql);
db.query(
db.query(
...
@@ -45,7 +45,7 @@ function createRouter(db) {
...
@@ -45,7 +45,7 @@ function createRouter(db) {
constgetGamestatus=function(req,res){
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-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+'\")';
console.log('getGamestatus: ',sql);
console.log('getGamestatus: ',sql);
db.query(
db.query(
...
@@ -76,7 +76,7 @@ function createRouter(db) {
...
@@ -76,7 +76,7 @@ function createRouter(db) {
constaddSession=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-z]+$/)!=null){
constsql='INSERT INTO Session (SessionName) VALUES (\"'+spielname+'\");';
constsql='INSERT INTO Session (SessionName) VALUES (\"'+spielname+'\");';
constsql='SELECT ActiveExplainer FROM Gamestatus WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
constsql='SELECT ActiveExplainer FROM Gamestatus WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
console.log('isActiveExplainer: ',sql)
console.log('isActiveExplainer: ',sql)
db.query(
db.query(
...
@@ -211,7 +211,7 @@ function createRouter(db) {
...
@@ -211,7 +211,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-zA-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, ActiveWatchdog=1 WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
console.log('newRound: ',sql);
console.log('newRound: ',sql);
db.query(
db.query(
...
@@ -237,7 +237,7 @@ function createRouter(db) {
...
@@ -237,7 +237,7 @@ function createRouter(db) {
functionendRound(req){
functionendRound(req){
constspielname=req.body.spielname;
constspielname=req.body.spielname;
if(spielname.match(/^[0-9a-zA-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, ActiveWatchdog=0 WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
console.log('endRound: ',sql);
console.log('endRound: ',sql);
db.query(
db.query(
...
@@ -263,7 +263,7 @@ function createRouter(db) {
...
@@ -263,7 +263,7 @@ function createRouter(db) {
constnewGame=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-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+'\")';
constsql='UPDATE Gamestatus SET Red = 1+(SELECT Red FROM Gamestatus WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")) WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
constsql='UPDATE Gamestatus SET Red = 1+(SELECT Red FROM Gamestatus WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")) WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
constsql='UPDATE Gamestatus SET Red = -1+(SELECT Red FROM Gamestatus WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")) WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';
constsql='UPDATE Gamestatus SET Red = -1+(SELECT Red FROM Gamestatus WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")) WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")';