mirror of
https://github.com/em-squared/5e-drs.git
synced 2025-10-30 13:14:20 +00:00
modification de l'identification des resources plus robuste
This commit is contained in:
parent
0494298159
commit
96d028dfa6
14 changed files with 130 additions and 94 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import {sortByString} from '@theme/util/filterHelpers'
|
||||
import { getResourceIndexInLibrary } from '@theme/util'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
|
@ -51,30 +52,28 @@ export default {
|
|||
state.magicItems.sort((a, b) => { return sortByString(a.title, b.title) })
|
||||
},
|
||||
updateMagicItem: (state, payload) => {
|
||||
state.magicItems.forEach((magicItem, idx) => {
|
||||
if (magicItem.key == payload.key) {
|
||||
state.magicItems[idx] = payload
|
||||
}
|
||||
})
|
||||
let magicItemIndex = getResourceIndexInLibrary(payload, state.magicItems)
|
||||
if (magicItemIndex >= 0) {
|
||||
state.magicItems[magicItemIndex] = payload
|
||||
}
|
||||
},
|
||||
removeMagicItem: (state, payload) => {
|
||||
state.magicItems.forEach((magicItem, idx) => {
|
||||
if (magicItem.key == payload.key) {
|
||||
state.magicItems.splice(idx, 1)
|
||||
}
|
||||
})
|
||||
let magicItemIndex = getResourceIndexInLibrary(payload, state.magicItems)
|
||||
if (magicItemIndex >= 0) {
|
||||
state.magicItems.splice(magicItemIndex, 1)
|
||||
}
|
||||
},
|
||||
setNotPrintedMagicItems: (state, payload) => {
|
||||
state.notPrintedMagicItems = payload
|
||||
},
|
||||
addNotPrintedMagicItem: (state, payload) => {
|
||||
let magicItemIndex = state.notPrintedMagicItems.findIndex(magicItem => magicItem.key == payload.key)
|
||||
let magicItemIndex = getResourceIndexInLibrary(payload, state.notPrintedMagicItems)
|
||||
if (!magicItemIndex >= 0) {
|
||||
state.notPrintedMagicItems.push(payload)
|
||||
}
|
||||
},
|
||||
removeNotPrintedMagicItem: (state, payload) => {
|
||||
let magicItemIndex = state.notPrintedMagicItems.findIndex(magicItem => magicItem.key == payload.key)
|
||||
let magicItemIndex = getResourceIndexInLibrary(payload, state.notPrintedMagicItems)
|
||||
if (magicItemIndex >= 0) {
|
||||
state.notPrintedMagicItems.splice(magicItemIndex, 1)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import {sortByString} from '@theme/util/filterHelpers'
|
||||
import { getResourceIndexInLibrary } from '@theme/util'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
|
@ -51,30 +52,28 @@ export default {
|
|||
state.monsters.sort((a, b) => { return sortByString(a.title, b.title) })
|
||||
},
|
||||
updateMonster: (state, payload) => {
|
||||
state.monsters.forEach((monster, idx) => {
|
||||
if (monster.key == payload.key) {
|
||||
state.monsters[idx] = payload
|
||||
}
|
||||
})
|
||||
let monsterIndex = getResourceIndexInLibrary(payload, state.monsters)
|
||||
if (monsterIndex >= 0) {
|
||||
state.monsters[monsterIndex] = payload
|
||||
}
|
||||
},
|
||||
removeMonster: (state, payload) => {
|
||||
state.monsters.forEach((monster, idx) => {
|
||||
if (monster.key == payload.key) {
|
||||
state.monsters.splice(idx, 1)
|
||||
}
|
||||
})
|
||||
let monsterIndex = getResourceIndexInLibrary(payload, state.monsters)
|
||||
if (monsterIndex >= 0) {
|
||||
state.monsters.splice(monsterIndex, 1)
|
||||
}
|
||||
},
|
||||
setNotPrintedMonsters: (state, payload) => {
|
||||
state.notPrintedMonsters = payload
|
||||
},
|
||||
addNotPrintedMonster: (state, payload) => {
|
||||
let monsterIndex = state.notPrintedMonsters.findIndex(monster => monster.key == payload.key)
|
||||
let monsterIndex = getResourceIndexInLibrary(payload, state.notPrintedMonsters)
|
||||
if (!monsterIndex >= 0) {
|
||||
state.notPrintedMonsters.push(payload)
|
||||
}
|
||||
},
|
||||
removeNotPrintedMonster: (state, payload) => {
|
||||
let monsterIndex = state.notPrintedMonsters.findIndex(monster => monster.key == payload.key)
|
||||
let monsterIndex = getResourceIndexInLibrary(payload, state.notPrintedMonsters)
|
||||
if (monsterIndex >= 0) {
|
||||
state.notPrintedMonsters.splice(monsterIndex, 1)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue