fix sync checkbox

This commit is contained in:
Alberto Xamin 2020-12-19 18:39:57 +01:00
parent 8d6f94fd01
commit 374e7828cc
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
2 changed files with 12 additions and 6 deletions

View File

@ -341,7 +341,6 @@ class FucileDaCaccia(Card):
def get_starting_deck() -> List[Card]: def get_starting_deck() -> List[Card]:
return [ return [
#TODO: aggiungere anche le carte normalmente presenti https://bang.dvgiochi.com/cardslist.php?id=3
Barile(Suit.CLUBS, 'A'), Barile(Suit.CLUBS, 'A'),
Binocolo(Suit.DIAMONDS, 10), Binocolo(Suit.DIAMONDS, 10),
Dinamite(Suit.CLUBS, 10), Dinamite(Suit.CLUBS, 10),

View File

@ -34,8 +34,8 @@
</div> </div>
<div v-if="!started"> <div v-if="!started">
<h3>{{$t("expansions")}}</h3> <h3>{{$t("expansions")}}</h3>
<div v-for="ex in togglable_expansions" v-bind:key="ex"> <div v-for="ex in expansionsStatus" v-bind:key="ex.id">
<PrettyCheck @click.native="toggleExpansions(ex)" :disabled="!isRoomOwner" :value="is_toggled_expansion(ex)" class="p-switch p-fill" style="margin-top:5px; margin-bottom:3px;">{{get_expansion_name(ex)}}</PrettyCheck> <PrettyCheck @click.native="toggleExpansions(ex.id)" :disabled="!isRoomOwner" :checked="ex.enabled" class="p-switch p-fill" style="margin-top:5px; margin-bottom:3px;">{{ex.name}}</PrettyCheck>
<br> <br>
</div> </div>
<h3>{{$t('mods')}}</h3> <h3>{{$t('mods')}}</h3>
@ -139,6 +139,15 @@ export default {
inviteLink() { inviteLink() {
return `${window.location.origin}/game?code=${this.lobbyName}&pwd=${this.password}` return `${window.location.origin}/game?code=${this.lobbyName}&pwd=${this.password}`
}, },
expansionsStatus() {
return this.togglable_expansions.map(x=>{
return {
id: x,
name: x.replace(/(^|_)([a-z])/g, function($0,$1,$2) {return ' ' + $2.toUpperCase()}),
enabled: this.expansions.indexOf(x) !== -1
}
})
},
storedUsername() { storedUsername() {
if (localStorage.getItem('username')) if (localStorage.getItem('username'))
return localStorage.getItem('username') return localStorage.getItem('username')
@ -174,11 +183,9 @@ export default {
}, },
methods: { methods: {
is_toggled_expansion(ex) { is_toggled_expansion(ex) {
console.log(ex+' '+ this.expansions+ (this.expansions.indexOf(ex) !== -1))
return this.expansions.indexOf(ex) !== -1 return this.expansions.indexOf(ex) !== -1
}, },
get_expansion_name(ex) {
return ex.replace('_', ' ').replace(/\w\S*/g, m => m.charAt(0).toUpperCase()+m.substr(1).toLowerCase())
},
leaveRoom() { leaveRoom() {
window.location.replace(window.location.origin) window.location.replace(window.location.origin)
}, },