other players see played cards now

This commit is contained in:
2021-01-20 22:38:12 +01:00
parent b574014c95
commit f23319b7b8
5 changed files with 42 additions and 2 deletions

View File

@ -101,6 +101,7 @@ function setupGame(names, hand)
//game.play_card(4, 0, "y05");
//game.play_card(5, 0, "g05");
//game.give_trick_to(0);
window.the_game = game;
});
};

View File

@ -71,6 +71,13 @@
setupGame(names, window.hand)
//alert('game is set up')
}
else if (fct == "cardPlayed") {
let player_id = msg.player;
let card_idx = msg.card_idx;
let card = msg.card;
let num_players = msg.num_players;
cardPlayed(player_id, card_idx, card, num_players)
}
else {
alert('unknown command: '+event.data);
}
@ -103,6 +110,12 @@
window.game_socket.send(t);
}
function cardPlayed(player, card_idx, card, num_players) {
let myself = "{{player}}";
let player_idx = ((player + num_players) - myself) % num_players;
window.the_game.play_card(player_idx, card_idx, card)
}
</script>