mirror of
https://github.com/em-squared/5e-drs.git
synced 2025-11-01 22:14:21 +00:00
correction bug grimoire
This commit is contained in:
parent
417d3edaed
commit
4ee9f0202a
2 changed files with 46 additions and 2 deletions
|
|
@ -7,6 +7,7 @@ export default {
|
||||||
state: {
|
state: {
|
||||||
spells: [],
|
spells: [],
|
||||||
spellSlots: [],
|
spellSlots: [],
|
||||||
|
spellCast: [],
|
||||||
notPrintedSpells: []
|
notPrintedSpells: []
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -39,6 +40,20 @@ export default {
|
||||||
}
|
}
|
||||||
if (localStorageData.spellSlots) {
|
if (localStorageData.spellSlots) {
|
||||||
state.spellSlots = localStorageData.spellSlots
|
state.spellSlots = localStorageData.spellSlots
|
||||||
|
for (let i = 0; i < state.spellSlots.length; i++) {
|
||||||
|
if (state.spellSlots[i] > 0) {
|
||||||
|
if (!state.spellCast[i]) {
|
||||||
|
state.spellCast[i] = new Array(Number(state.spellSlots[i]))
|
||||||
|
}
|
||||||
|
for (let j = 0; j < state.spellSlots[i]; j++) {
|
||||||
|
if (!state.spellCast[i][j]) {
|
||||||
|
state.spellCast[i][j] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
state.spellCast[i] = null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (localStorageData.notPrintedSpells) {
|
if (localStorageData.notPrintedSpells) {
|
||||||
state.notPrintedSpells = localStorageData.notPrintedSpells
|
state.notPrintedSpells = localStorageData.notPrintedSpells
|
||||||
|
|
@ -69,6 +84,23 @@ export default {
|
||||||
},
|
},
|
||||||
setSpellSlots: (state, payload) => {
|
setSpellSlots: (state, payload) => {
|
||||||
state.spellSlots = payload
|
state.spellSlots = payload
|
||||||
|
for (let i = 0; i < state.spellSlots.length; i++) {
|
||||||
|
if (state.spellSlots[i] > 0) {
|
||||||
|
if (!state.spellCast[i]) {
|
||||||
|
state.spellCast[i] = new Array(Number(state.spellSlots[i]))
|
||||||
|
}
|
||||||
|
for (let j = 0; j < state.spellSlots[i]; j++) {
|
||||||
|
if (!state.spellCast[i][j]) {
|
||||||
|
state.spellCast[i][j] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
state.spellCast[i] = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setSpellCast: (state, payload) => {
|
||||||
|
state.spellCast = payload
|
||||||
},
|
},
|
||||||
setNotPrintedSpells: (state, payload) => {
|
setNotPrintedSpells: (state, payload) => {
|
||||||
state.notPrintedSpells = payload
|
state.notPrintedSpells = payload
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
<div class="ml-md-12">
|
<div class="ml-md-12">
|
||||||
<div class="d-flex" v-if="spellSlots[group] > 0">
|
<div class="d-flex" v-if="spellSlots[group] > 0">
|
||||||
<div v-for="(slot, idx) in Number(spellSlots[group])" :key="idx">
|
<div v-for="(slot, idx) in Number(spellSlots[group])" :key="idx">
|
||||||
<v-checkbox dark hide-details class="spell-slot"></v-checkbox>
|
<v-checkbox dark hide-details class="spell-slot" v-model="spellCast[group][idx]"></v-checkbox>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -152,7 +152,15 @@ export default {
|
||||||
return this.$store.state.mySpells.spellSlots
|
return this.$store.state.mySpells.spellSlots
|
||||||
},
|
},
|
||||||
set (value) {
|
set (value) {
|
||||||
this.$store.commit('mySpells/setSpells', value)
|
this.$store.commit('mySpells/setSpellSlots', value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
spellCast: {
|
||||||
|
get () {
|
||||||
|
return this.$store.state.mySpells.spellCast
|
||||||
|
},
|
||||||
|
set (value) {
|
||||||
|
this.$store.commit('mySpells/setSpellCast', value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -168,6 +176,10 @@ export default {
|
||||||
onInputSpellSlots () {
|
onInputSpellSlots () {
|
||||||
this.$store.commit('mySpells/setSpellSlots', this.spellSlots)
|
this.$store.commit('mySpells/setSpellSlots', this.spellSlots)
|
||||||
},
|
},
|
||||||
|
onInputSpellCast (level, idx, value) {
|
||||||
|
this.spellCast[level][idx] = value
|
||||||
|
this.$store.commit('mySpells/setSpellCast', this.spellCast)
|
||||||
|
},
|
||||||
hasSpellOfLevel (level) {
|
hasSpellOfLevel (level) {
|
||||||
for (let spell of this.spells) {
|
for (let spell of this.spells) {
|
||||||
if (spell.frontmatter.level == level && !this.isHiddenPrint(spell)) {
|
if (spell.frontmatter.level == level && !this.isHiddenPrint(spell)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue