'UPDATE Gamestatus SET ActiveExplainer = 1, ActiveWatchdog=1 WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")',
(error,results)=>{
if(error){
console.log(error);
res.status(500).json({status:'false'});
}else{
res.status(200).json({status:'true'});
}
}
);
}else{
res.status(500).json({status:'false'});
}
});
//End a Round and unlock the game positions and invert RedTurn
router.post('/endRound',(req,res)=>{
constspielname=req.body.spielname;
if(spielname.match(/^[0-9a-zA-Z]+$/)!=null){
db.query(
'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+'\")',
(error,results)=>{
if(error){
console.log(error);
res.status(500).json({status:'false'});
}else{
res.status(200).json({status:'true'});
}
}
);
}else{
res.status(500).json({status:'false'});
}
});
//Starts a new Game and resets red and blue and chooses a random value for RedTurn
router.post('/newGame',(req,res)=>{
constspielname=req.body.spielname;
if(spielname.match(/^[0-9a-zA-Z]+$/)!=null){
db.query(
'UPDATE Gamestatus SET Red = 0, Blue = 0, RedTurn = '+Math.round(Math.random())+' WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")',