1
0
Fork 0
mirror of https://github.com/em-squared/5e-drs.git synced 2025-10-30 21:24:18 +00:00

modification de l'identification des resources plus robuste

This commit is contained in:
Maxime Moraine 2020-05-24 13:32:31 +02:00
parent 0494298159
commit 96d028dfa6
14 changed files with 130 additions and 94 deletions

View file

@ -1,4 +1,5 @@
import {sortByString} from '@theme/util/filterHelpers'
import { getResourceIndexInLibrary } from '@theme/util'
export default {
namespaced: true,
@ -55,18 +56,16 @@ export default {
state.spells.sort((a, b) => { return sortByString(a.title, b.title) })
},
updateSpell: (state, payload) => {
state.spells.forEach((spell, idx) => {
if (spell.key == payload.key) {
state.spells[idx] = payload
}
})
let spellIndex = getResourceIndexInLibrary(payload, state.spells)
if (spellIndex >= 0) {
state.spells[spellIndex] = payload
}
},
removeSpell: (state, payload) => {
state.spells.forEach((spell, idx) => {
if (spell.key == payload.key) {
state.spells.splice(idx, 1)
}
})
let spellIndex = getResourceIndexInLibrary(payload, state.spells)
if (spellIndex >= 0) {
state.spells.splice(spellIndex, 1)
}
},
setSpellSlots: (state, payload) => {
state.spellSlots = payload
@ -75,13 +74,13 @@ export default {
state.notPrintedSpells = payload
},
addNotPrintedSpell: (state, payload) => {
let spellIndex = state.notPrintedSpells.findIndex(spell => spell.key == payload.key)
let spellIndex = getResourceIndexInLibrary(payload, state.notPrintedSpells)
if (!spellIndex >= 0) {
state.notPrintedSpells.push(payload)
}
},
removeNotPrintedSpell: (state, payload) => {
let spellIndex = state.notPrintedSpells.findIndex(spell => spell.key == payload.key)
let spellIndex = getResourceIndexInLibrary(payload, state.notPrintedSpells)
if (spellIndex >= 0) {
state.notPrintedSpells.splice(spellIndex, 1)
}