Logic #32

Merged
thorsten-rausch merged 9 commits from logic into main 2021-06-16 09:00:52 +00:00
2 changed files with 5 additions and 4 deletions
Showing only changes of commit 4674720cfb - Show all commits

View File

@ -154,8 +154,8 @@ io.on('connection', socket => {
}
});
socket.on('card finished', function (difficulty) {
gameState['players'][gameState['whosNext']].move(difficulty); //TODO: stop players from moving when answer is wrong
socket.on('card finished', function (difficulty, answerIsCorrect) {
if (answerIsCorrect) gameState['players'][gameState['whosNext']].move(difficulty);
gameState['whosNext'] += 1;
if(gameState['whosNext'] === gameState['players'].length) gameState['whosNext'] = 0;
io.in(socket.room).emit('card destroyed');

View File

@ -79,16 +79,17 @@ function Card(game_board_size, s, a1, a2, a3, a4, d, your_turn) {
// OK-Button
this.card.addChild(new Button(0xffffff, 0xcccccc, 0xffffff, this.card_width - 40, 100, this.card_x + 20, this.card_y + this.card_height - 120, "OK", null, function () {
if (answer !== null) {
if (_this.right_answer === answer) {
if (_this.right_answer === answer) { //TODO: do this in backend instead to prevent cheating
console.log("Richtig");
socket.emit('card finished', d, true);
} else {
console.log("Falsch");
socket.emit('card finished', d, false);
}
show_card = false;
answer = null;
diced = false;
rolled_number = null;
socket.emit('card finished', d);
} else {
alert("Bitte wähle eine Antwortmöglichkeit aus");
}