Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Tabu-Middleware
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dennis Willers
Tabu-Middleware
Commits
c72ab85c
Commit
c72ab85c
authored
Apr 16, 2021
by
Dennis Willers
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if Cards still exist for a room. Return -1 as new card if no new card exist
parent
defeee15
Pipeline
#426
passed with stages
in 2 minutes and 19 seconds
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
3 deletions
+41
-3
events.js
events.js
+41
-3
No files found.
events.js
View file @
c72ab85c
...
@@ -148,6 +148,40 @@ function createRouter(db) {
...
@@ -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
getS2C
=
async
function
getS2C
(
req
,
res
)
{
const
spielname
=
req
.
body
.
spielname
;
const
spielname
=
req
.
body
.
spielname
;
if
(
spielname
.
match
(
/^
[
0-9a-z
]
+$/
)
!=
null
)
{
if
(
spielname
.
match
(
/^
[
0-9a-z
]
+$/
)
!=
null
)
{
...
@@ -195,7 +229,7 @@ function createRouter(db) {
...
@@ -195,7 +229,7 @@ function createRouter(db) {
(
error
,
results
)
=>
{
(
error
,
results
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
error
);
console
.
log
(
error
);
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
50
0
).
json
({
status
:
'
false
'
});
res
.
header
(
'
Access-Control-Allow-Origin
'
,
"
*
"
).
status
(
50
2
).
json
({
status
:
'
false
'
,
reason
:
'
Alle Karten sind durchgespielt
'
});
}
else
{
}
else
{
const
checkUpdate
=
results
[
0
].
affectedRows
;
const
checkUpdate
=
results
[
0
].
affectedRows
;
console
.
log
(
'
CheckUpdate:
'
,
results
[
0
].
affectedRows
);
console
.
log
(
'
CheckUpdate:
'
,
results
[
0
].
affectedRows
);
...
@@ -227,7 +261,11 @@ function createRouter(db) {
...
@@ -227,7 +261,11 @@ function createRouter(db) {
}
}
});
});
}
else
{
}
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
'
});
}
}
}
}
});
});
...
@@ -678,7 +716,7 @@ function createRouter(db) {
...
@@ -678,7 +716,7 @@ function createRouter(db) {
router
.
post
(
'
/getS2C
'
,
[
getS2C
]);
router
.
post
(
'
/getS2C
'
,
[
getS2C
]);
//Start a new Round and lock the game positions
//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
//End a Round and unlock the game positions and invert RedTurn
router
.
post
(
'
/endRound
'
,
[
endRound
]);
router
.
post
(
'
/endRound
'
,
[
endRound
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment