get username from local storage
This commit is contained in:
parent
ec8e9e16de
commit
ab6bd9af93
@ -109,6 +109,7 @@ def join_room(sid, room):
|
|||||||
sio.enter_room(sid, room_name)
|
sio.enter_room(sid, room_name)
|
||||||
while len([p for p in games[i].players if p.name == sio.get_session(sid).name]):
|
while len([p for p in games[i].players if p.name == sio.get_session(sid).name]):
|
||||||
sio.get_session(sid).name += f'_{random.randint(0,100)}'
|
sio.get_session(sid).name += f'_{random.randint(0,100)}'
|
||||||
|
sio.emit('me', data=sio.get_session(sid).name, room=sid)
|
||||||
games[i].add_player(sio.get_session(sid))
|
games[i].add_player(sio.get_session(sid))
|
||||||
advertise_lobbies()
|
advertise_lobbies()
|
||||||
|
|
||||||
|
@ -13,10 +13,9 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'FullScreenInput',
|
name: 'FullScreenInput',
|
||||||
components: {
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
cancel: Function,
|
cancel: Function,
|
||||||
|
defaultValue: String,
|
||||||
cancelText: {
|
cancelText: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
@ -47,6 +46,7 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.realCancelText = this.cancelText
|
this.realCancelText = this.cancelText
|
||||||
|
this.val = this.defaultValue
|
||||||
if (this.realCancelText == '') {
|
if (this.realCancelText == '') {
|
||||||
this.realCancelText = this.$t('cancel')
|
this.realCancelText = this.$t('cancel')
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
<Chooser v-if="selectedInfo" :text="$t('details')" :cards="selectedInfo" :cancelText="$t('ok')" :cancel="()=>{selectedInfo = null}" :select="()=>{selectedInfo = null}"/>
|
<Chooser v-if="selectedInfo" :text="$t('details')" :cards="selectedInfo" :cancelText="$t('ok')" :cancel="()=>{selectedInfo = null}" :select="()=>{selectedInfo = null}"/>
|
||||||
<transition name="bounce">
|
<transition name="bounce">
|
||||||
<Chooser v-if="hasToChoose" :text="`${$t('choose_card')}${target_p?$t('choose_card_from') + target_p:''}`" :cards="chooseCards" :select="chooseCard"/>
|
<Chooser v-if="hasToChoose" :text="`${$t('choose_card')}${target_p?$t('choose_card_from') + target_p:''}`" :cards="chooseCards" :select="chooseCard"/>
|
||||||
<full-screen-input v-if="hasToSetUsername" :text="$t('choose_username')" :val="username" :cancel="setUsername" :cancelText="$t('ok')"/>
|
<full-screen-input v-if="!started && hasToSetUsername" :defaultValue="storedUsername" :text="$t('choose_username')" :val="username" :cancel="setUsername" :cancelText="$t('ok')"/>
|
||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -118,6 +118,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
storedUsername() {
|
||||||
|
if (localStorage.getItem('username'))
|
||||||
|
return localStorage.getItem('username')
|
||||||
|
return ''
|
||||||
|
},
|
||||||
isRoomOwner() {
|
isRoomOwner() {
|
||||||
return this.players.length > 0 && this.players[0].name == this.username
|
return this.players.length > 0 && this.players[0].name == this.username
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user