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
2fa78730
Commit
2fa78730
authored
Dec 29, 2020
by
Joshua
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://git.willers.digital/Dennis.Willers/tabu-middleware
Conflicts: events.js
parents
942762da
f709d779
Pipeline
#296
passed with stages
in 2 minutes and 31 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
1 deletion
+55
-1
events.js
events.js
+55
-1
No files found.
events.js
View file @
2fa78730
...
...
@@ -19,8 +19,10 @@ function createRouter(db) {
}
);
//Init new Gamestatus
var
redTurn
=
Math
.
random
();
redTurn
=
Math
.
round
(
redTurn
);
db
.
query
(
'
INSERT INTO Gamestatus (SessionID, Red, Blue, RedTurn, ActiveExplainer, ActiveWatchdog) VALUES ((SELECT SessionID FROM Session WHERE SessionName =
\
"
'
+
spielname
+
'
\
"), 0, 0,
1
, 0, 0);
'
,
'
INSERT INTO Gamestatus (SessionID, Red, Blue, RedTurn, ActiveExplainer, ActiveWatchdog) VALUES ((SELECT SessionID FROM Session WHERE SessionName =
\
"
'
+
spielname
+
'
\
"), 0, 0,
'
+
redTurn
+
'
, 0, 0);
'
,
error
=>
{
if
(
error
)
{
console
.
error
(
error
);
...
...
@@ -103,6 +105,58 @@ function createRouter(db) {
}
});
//Return S2C
router
.
post
(
'
/getS2C
'
,
(
req
,
res
)
=>
{
const
spielname
=
req
.
body
.
spielname
;
if
(
spielname
.
match
(
/^
[
0-9a-zA-Z
]
+$/
)
!=
null
)
{
let
card
;
db
.
query
(
'
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
'
+
'
);
'
,
(
error
,
results
)
=>
{
if
(
error
)
{
console
.
log
(
error
);
res
.
status
(
500
).
json
({
status
:
'
false
'
});
}
else
{
console
.
log
(
results
);
let
random
=
Math
.
random
()
*
(
results
.
length
-
1
);
random
=
Math
.
round
(
random
)
card
=
results
[
random
];
console
.
log
(
card
);
db
.
query
(
'
INSERT INTO S2C (SessionID, CardID) VALUES ((SELECT SessionID FROM Session WHERE SessionName =
\
"
'
+
spielname
+
'
\
"),
'
+
card
.
CardID
+
'
);
'
,
(
error
,
results
)
=>
{
if
(
error
)
{
res
.
status
(
500
).
json
({
status
:
'
false
'
});
}
else
{
res
.
status
(
200
).
json
(
{
status
:
'
true
'
,
cardID
:
card
.
CardID
,
solution
:
card
.
Solution
,
tabu1
:
card
.
Tabu1
,
tabu2
:
card
.
Tabu2
,
tabu3
:
card
.
Tabu3
,
tabu4
:
card
.
Tabu4
,
tabu5
:
card
.
Tabu5
,
}
);
}
}
);
}
});
}
else
{
res
.
status
(
500
).
json
({
status
:
'
error
'
});
}
});
//Start a new Round and lock the game positions
router
.
post
(
'
/newRound
'
,
(
req
,
res
)
=>
{
const
spielname
=
req
.
body
.
spielname
;
...
...
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