Logic #32
@ -154,8 +154,8 @@ io.on('connection', socket => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('card finished', function (difficulty) {
|
socket.on('card finished', function (difficulty, answerIsCorrect) {
|
||||||
gameState['players'][gameState['whosNext']].move(difficulty); //TODO: stop players from moving when answer is wrong
|
if (answerIsCorrect) gameState['players'][gameState['whosNext']].move(difficulty);
|
||||||
gameState['whosNext'] += 1;
|
gameState['whosNext'] += 1;
|
||||||
if(gameState['whosNext'] === gameState['players'].length) gameState['whosNext'] = 0;
|
if(gameState['whosNext'] === gameState['players'].length) gameState['whosNext'] = 0;
|
||||||
io.in(socket.room).emit('card destroyed');
|
io.in(socket.room).emit('card destroyed');
|
||||||
|
@ -79,16 +79,17 @@ function Card(game_board_size, s, a1, a2, a3, a4, d, your_turn) {
|
|||||||
// OK-Button
|
// 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 () {
|
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 (answer !== null) {
|
||||||
if (_this.right_answer === answer) {
|
if (_this.right_answer === answer) { //TODO: do this in backend instead to prevent cheating
|
||||||
console.log("Richtig");
|
console.log("Richtig");
|
||||||
|
socket.emit('card finished', d, true);
|
||||||
} else {
|
} else {
|
||||||
console.log("Falsch");
|
console.log("Falsch");
|
||||||
|
socket.emit('card finished', d, false);
|
||||||
}
|
}
|
||||||
show_card = false;
|
show_card = false;
|
||||||
answer = null;
|
answer = null;
|
||||||
diced = false;
|
diced = false;
|
||||||
rolled_number = null;
|
rolled_number = null;
|
||||||
socket.emit('card finished', d);
|
|
||||||
} else {
|
} else {
|
||||||
alert("Bitte wähle eine Antwortmöglichkeit aus");
|
alert("Bitte wähle eine Antwortmöglichkeit aus");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user