From 4ee9f0202ad9d1a250a5bbb1283a9f5a6b344f99 Mon Sep 17 00:00:00 2001 From: Maxime Moraine Date: Thu, 7 Jan 2021 10:10:18 +0100 Subject: [PATCH] correction bug grimoire --- docs/.vuepress/store/modules/mySpells.js | 32 ++++++++++++++++++++ docs/.vuepress/theme/components/MySpells.vue | 16 ++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/docs/.vuepress/store/modules/mySpells.js b/docs/.vuepress/store/modules/mySpells.js index 316c474..f91b66e 100644 --- a/docs/.vuepress/store/modules/mySpells.js +++ b/docs/.vuepress/store/modules/mySpells.js @@ -7,6 +7,7 @@ export default { state: { spells: [], spellSlots: [], + spellCast: [], notPrintedSpells: [] }, @@ -39,6 +40,20 @@ export default { } if (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) { state.notPrintedSpells = localStorageData.notPrintedSpells @@ -69,6 +84,23 @@ export default { }, setSpellSlots: (state, 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) => { state.notPrintedSpells = payload diff --git a/docs/.vuepress/theme/components/MySpells.vue b/docs/.vuepress/theme/components/MySpells.vue index 712785a..95d7aa4 100644 --- a/docs/.vuepress/theme/components/MySpells.vue +++ b/docs/.vuepress/theme/components/MySpells.vue @@ -40,7 +40,7 @@
- +
@@ -152,7 +152,15 @@ export default { return this.$store.state.mySpells.spellSlots }, 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 () { 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) { for (let spell of this.spells) { if (spell.frontmatter.level == level && !this.isHiddenPrint(spell)) {