Loading events.js +41 −3 Original line number Diff line number Diff line Loading @@ -148,6 +148,40 @@ function createRouter(db) { ); }; const cardsExist = function cardExist(req, res, next) { const spielname = req.body.spielname; if (spielname.match(/^[0-9a-z]+$/) != null) { const sql = 'SELECT Card.CardID, Solution, Tabu1, Tabu2, Tabu3, Tabu4, Tabu5 \n' + 'FROM Card \n' + 'WHERE Card.CardID NOT IN \n' + '(\n' + ' SELECT S2C.CardID\n' + ' FROM S2C\n' + ' WHERE S2C.CardID IS NOT NULL AND S2C.SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")\n' + ');'; console.log('getS2C1: ', sql); db.query( sql, (error, results) => { if (error) { console.log(error); res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'false'}); } else { if (results.length > 0) { next(); } else { res.header('Access-Control-Allow-Origin', "*").status(502).json({ status: 'false', reason: 'Alle Karten sind durchgespielt' }); } } }); } else { res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error'}); } }; const getS2C = async function getS2C(req, res) { const spielname = req.body.spielname; if (spielname.match(/^[0-9a-z]+$/) != null) { Loading Loading @@ -195,7 +229,7 @@ function createRouter(db) { (error, results) => { if (error) { console.log(error); res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'false'}); res.header('Access-Control-Allow-Origin', "*").status(502).json({status: 'false', reason: 'Alle Karten sind durchgespielt'}); } else { const checkUpdate = results[0].affectedRows; console.log('CheckUpdate: ', results[0].affectedRows); Loading Loading @@ -227,7 +261,11 @@ function createRouter(db) { } }); } else { res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error alle Karten durch'}); socket.emit('newCard', { 'sessionName': spielname, 'cardID': -1 }); res.header('Access-Control-Allow-Origin', "*").status(502).json({status: 'error alle Karten durch'}); } } }); Loading Loading @@ -678,7 +716,7 @@ function createRouter(db) { router.post('/getS2C', [getS2C]); //Start a new Round and lock the game positions router.post('/newRound', [isSession, isActiveExplainer, newRound]); router.post('/newRound', [cardsExist, isSession, isActiveExplainer, newRound]); //End a Round and unlock the game positions and invert RedTurn router.post('/endRound', [endRound]); Loading Loading
events.js +41 −3 Original line number Diff line number Diff line Loading @@ -148,6 +148,40 @@ function createRouter(db) { ); }; const cardsExist = function cardExist(req, res, next) { const spielname = req.body.spielname; if (spielname.match(/^[0-9a-z]+$/) != null) { const sql = 'SELECT Card.CardID, Solution, Tabu1, Tabu2, Tabu3, Tabu4, Tabu5 \n' + 'FROM Card \n' + 'WHERE Card.CardID NOT IN \n' + '(\n' + ' SELECT S2C.CardID\n' + ' FROM S2C\n' + ' WHERE S2C.CardID IS NOT NULL AND S2C.SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\")\n' + ');'; console.log('getS2C1: ', sql); db.query( sql, (error, results) => { if (error) { console.log(error); res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'false'}); } else { if (results.length > 0) { next(); } else { res.header('Access-Control-Allow-Origin', "*").status(502).json({ status: 'false', reason: 'Alle Karten sind durchgespielt' }); } } }); } else { res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error'}); } }; const getS2C = async function getS2C(req, res) { const spielname = req.body.spielname; if (spielname.match(/^[0-9a-z]+$/) != null) { Loading Loading @@ -195,7 +229,7 @@ function createRouter(db) { (error, results) => { if (error) { console.log(error); res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'false'}); res.header('Access-Control-Allow-Origin', "*").status(502).json({status: 'false', reason: 'Alle Karten sind durchgespielt'}); } else { const checkUpdate = results[0].affectedRows; console.log('CheckUpdate: ', results[0].affectedRows); Loading Loading @@ -227,7 +261,11 @@ function createRouter(db) { } }); } else { res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'error alle Karten durch'}); socket.emit('newCard', { 'sessionName': spielname, 'cardID': -1 }); res.header('Access-Control-Allow-Origin', "*").status(502).json({status: 'error alle Karten durch'}); } } }); Loading Loading @@ -678,7 +716,7 @@ function createRouter(db) { router.post('/getS2C', [getS2C]); //Start a new Round and lock the game positions router.post('/newRound', [isSession, isActiveExplainer, newRound]); router.post('/newRound', [cardsExist, isSession, isActiveExplainer, newRound]); //End a Round and unlock the game positions and invert RedTurn router.post('/endRound', [endRound]); Loading