diff --git a/backend/__init__.py b/backend/__init__.py index 2bb0999..a2e267a 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -173,13 +173,14 @@ def chat_message(sid, msg): elif '/cancelgame' in msg and ses.game.started: ses.game.reset() elif '/gameinfo' in msg: - sio.emit('chat_message', room=sid, data=f'info: {ses.game.__dict__}') + sio.emit('chat_message', room=sid, data={'color': f'#black','text':f'info: {ses.game.__dict__}'}) elif '/meinfo' in msg: - sio.emit('chat_message', room=sid, data=f'info: {ses.__dict__}') + sio.emit('chat_message', room=sid, data={'color': f'#black','text':f'info: {ses.__dict__}'}) else: - sio.emit('chat_message', room=sid, data=f'{msg} COMMAND NOT FOUND') + sio.emit('chat_message', room=sid, data={'color': f'#black','text':f'{msg} COMMAND NOT FOUND'}) else: - sio.emit('chat_message', room=ses.game.name, data=f'[{ses.name}]: {msg}') + color = sid.encode('utf-8').hex()[-3:] + sio.emit('chat_message', room=ses.game.name, data={'color': f'#{color}','text':f'[{ses.name}]: {msg}'}) @sio.event def start_game(sid): diff --git a/frontend/src/components/Chat.vue b/frontend/src/components/Chat.vue index 67c992b..967cb59 100644 --- a/frontend/src/components/Chat.vue +++ b/frontend/src/components/Chat.vue @@ -2,7 +2,7 @@

{{$t("chat.chat")}}

-

{{msg}}

+

{{msg.text}}

.

@@ -21,10 +21,11 @@ export default { }), sockets: { chat_message(msg) { - if (msg.indexOf('_') === 0) { + console.log(msg) + if ((typeof msg === "string") && msg.indexOf('_') === 0) { let params = msg.split('|') let type = params.shift().substring(1) - this.messages.push(this.$t(`chat.${type}`, params)) + this.messages.push({text:this.$t(`chat.${type}`, params)}) }else { this.messages.push(msg) } @@ -45,8 +46,8 @@ export default { \ No newline at end of file diff --git a/frontend/src/components/Player.vue b/frontend/src/components/Player.vue index 10eeeb7..fb2cb50 100644 --- a/frontend/src/components/Player.vue +++ b/frontend/src/components/Player.vue @@ -20,8 +20,8 @@

{{desc}}

-
- {{$t('hand')}} +
+ {{$t('hand')}}