X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=blobdiff_plain;f=tictactoe%2Ftictactoe.jsx;h=f0e9e88d6a83f6a9262cbb47a467f293a431b3a7;hp=6a27a220453ab06e38a3abda72cbc372476dafd6;hb=d3a035c38d6deff85f63e313430ac7e45955e2a9;hpb=40244a4fca54b3cea49fd43c63fa86a2efe06333;ds=sidebyside diff --git a/tictactoe/tictactoe.jsx b/tictactoe/tictactoe.jsx index 6a27a22..f0e9e88 100644 --- a/tictactoe/tictactoe.jsx +++ b/tictactoe/tictactoe.jsx @@ -44,11 +44,19 @@ events.addEventListener("player-info", event => { window.game.set_player_info(info); }); +events.addEventListener("player-enter", event => { + const info = JSON.parse(event.data); + + window.game.set_opponent_info(info); +}); + events.addEventListener("player-update", event => { const info = JSON.parse(event.data); if (info.id === window.game.state.player_info.id) window.game.set_player_info(info); + else + window.game.set_opponent_info(info); }); events.addEventListener("move", event => { @@ -84,14 +92,17 @@ function GameInfo(props) { } function PlayerInfo(props) { - if (! props.id) + if (! props.player.id) return null; return (