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 {sortByString} from '@theme/util/filterHelpers'
|
||||||
|
import { getResourceIndexInLibrary } from '@theme/util'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
|
|
@ -51,30 +52,28 @@ export default {
|
||||||
state.magicItems.sort((a, b) => { return sortByString(a.title, b.title) })
|
state.magicItems.sort((a, b) => { return sortByString(a.title, b.title) })
|
||||||
},
|
},
|
||||||
updateMagicItem: (state, payload) => {
|
updateMagicItem: (state, payload) => {
|
||||||
state.magicItems.forEach((magicItem, idx) => {
|
let magicItemIndex = getResourceIndexInLibrary(payload, state.magicItems)
|
||||||
if (magicItem.key == payload.key) {
|
if (magicItemIndex >= 0) {
|
||||||
state.magicItems[idx] = payload
|
state.magicItems[magicItemIndex] = payload
|
||||||
}
|
}
|
||||||
})
|
|
||||||
},
|
},
|
||||||
removeMagicItem: (state, payload) => {
|
removeMagicItem: (state, payload) => {
|
||||||
state.magicItems.forEach((magicItem, idx) => {
|
let magicItemIndex = getResourceIndexInLibrary(payload, state.magicItems)
|
||||||
if (magicItem.key == payload.key) {
|
if (magicItemIndex >= 0) {
|
||||||
state.magicItems.splice(idx, 1)
|
state.magicItems.splice(magicItemIndex, 1)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
},
|
},
|
||||||
setNotPrintedMagicItems: (state, payload) => {
|
setNotPrintedMagicItems: (state, payload) => {
|
||||||
state.notPrintedMagicItems = payload
|
state.notPrintedMagicItems = payload
|
||||||
},
|
},
|
||||||
addNotPrintedMagicItem: (state, payload) => {
|
addNotPrintedMagicItem: (state, payload) => {
|
||||||
let magicItemIndex = state.notPrintedMagicItems.findIndex(magicItem => magicItem.key == payload.key)
|
let magicItemIndex = getResourceIndexInLibrary(payload, state.notPrintedMagicItems)
|
||||||
if (!magicItemIndex >= 0) {
|
if (!magicItemIndex >= 0) {
|
||||||
state.notPrintedMagicItems.push(payload)
|
state.notPrintedMagicItems.push(payload)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeNotPrintedMagicItem: (state, payload) => {
|
removeNotPrintedMagicItem: (state, payload) => {
|
||||||
let magicItemIndex = state.notPrintedMagicItems.findIndex(magicItem => magicItem.key == payload.key)
|
let magicItemIndex = getResourceIndexInLibrary(payload, state.notPrintedMagicItems)
|
||||||
if (magicItemIndex >= 0) {
|
if (magicItemIndex >= 0) {
|
||||||
state.notPrintedMagicItems.splice(magicItemIndex, 1)
|
state.notPrintedMagicItems.splice(magicItemIndex, 1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {sortByString} from '@theme/util/filterHelpers'
|
import {sortByString} from '@theme/util/filterHelpers'
|
||||||
|
import { getResourceIndexInLibrary } from '@theme/util'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
|
|
@ -51,30 +52,28 @@ export default {
|
||||||
state.monsters.sort((a, b) => { return sortByString(a.title, b.title) })
|
state.monsters.sort((a, b) => { return sortByString(a.title, b.title) })
|
||||||
},
|
},
|
||||||
updateMonster: (state, payload) => {
|
updateMonster: (state, payload) => {
|
||||||
state.monsters.forEach((monster, idx) => {
|
let monsterIndex = getResourceIndexInLibrary(payload, state.monsters)
|
||||||
if (monster.key == payload.key) {
|
if (monsterIndex >= 0) {
|
||||||
state.monsters[idx] = payload
|
state.monsters[monsterIndex] = payload
|
||||||
}
|
}
|
||||||
})
|
|
||||||
},
|
},
|
||||||
removeMonster: (state, payload) => {
|
removeMonster: (state, payload) => {
|
||||||
state.monsters.forEach((monster, idx) => {
|
let monsterIndex = getResourceIndexInLibrary(payload, state.monsters)
|
||||||
if (monster.key == payload.key) {
|
if (monsterIndex >= 0) {
|
||||||
state.monsters.splice(idx, 1)
|
state.monsters.splice(monsterIndex, 1)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
},
|
},
|
||||||
setNotPrintedMonsters: (state, payload) => {
|
setNotPrintedMonsters: (state, payload) => {
|
||||||
state.notPrintedMonsters = payload
|
state.notPrintedMonsters = payload
|
||||||
},
|
},
|
||||||
addNotPrintedMonster: (state, payload) => {
|
addNotPrintedMonster: (state, payload) => {
|
||||||
let monsterIndex = state.notPrintedMonsters.findIndex(monster => monster.key == payload.key)
|
let monsterIndex = getResourceIndexInLibrary(payload, state.notPrintedMonsters)
|
||||||
if (!monsterIndex >= 0) {
|
if (!monsterIndex >= 0) {
|
||||||
state.notPrintedMonsters.push(payload)
|
state.notPrintedMonsters.push(payload)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeNotPrintedMonster: (state, payload) => {
|
removeNotPrintedMonster: (state, payload) => {
|
||||||
let monsterIndex = state.notPrintedMonsters.findIndex(monster => monster.key == payload.key)
|
let monsterIndex = getResourceIndexInLibrary(payload, state.notPrintedMonsters)
|
||||||
if (monsterIndex >= 0) {
|
if (monsterIndex >= 0) {
|
||||||
state.notPrintedMonsters.splice(monsterIndex, 1)
|
state.notPrintedMonsters.splice(monsterIndex, 1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {sortByString} from '@theme/util/filterHelpers'
|
import {sortByString} from '@theme/util/filterHelpers'
|
||||||
|
import { getResourceIndexInLibrary } from '@theme/util'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
|
|
@ -55,18 +56,16 @@ export default {
|
||||||
state.spells.sort((a, b) => { return sortByString(a.title, b.title) })
|
state.spells.sort((a, b) => { return sortByString(a.title, b.title) })
|
||||||
},
|
},
|
||||||
updateSpell: (state, payload) => {
|
updateSpell: (state, payload) => {
|
||||||
state.spells.forEach((spell, idx) => {
|
let spellIndex = getResourceIndexInLibrary(payload, state.spells)
|
||||||
if (spell.key == payload.key) {
|
if (spellIndex >= 0) {
|
||||||
state.spells[idx] = payload
|
state.spells[spellIndex] = payload
|
||||||
}
|
}
|
||||||
})
|
|
||||||
},
|
},
|
||||||
removeSpell: (state, payload) => {
|
removeSpell: (state, payload) => {
|
||||||
state.spells.forEach((spell, idx) => {
|
let spellIndex = getResourceIndexInLibrary(payload, state.spells)
|
||||||
if (spell.key == payload.key) {
|
if (spellIndex >= 0) {
|
||||||
state.spells.splice(idx, 1)
|
state.spells.splice(spellIndex, 1)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
},
|
},
|
||||||
setSpellSlots: (state, payload) => {
|
setSpellSlots: (state, payload) => {
|
||||||
state.spellSlots = payload
|
state.spellSlots = payload
|
||||||
|
|
@ -75,13 +74,13 @@ export default {
|
||||||
state.notPrintedSpells = payload
|
state.notPrintedSpells = payload
|
||||||
},
|
},
|
||||||
addNotPrintedSpell: (state, payload) => {
|
addNotPrintedSpell: (state, payload) => {
|
||||||
let spellIndex = state.notPrintedSpells.findIndex(spell => spell.key == payload.key)
|
let spellIndex = getResourceIndexInLibrary(payload, state.notPrintedSpells)
|
||||||
if (!spellIndex >= 0) {
|
if (!spellIndex >= 0) {
|
||||||
state.notPrintedSpells.push(payload)
|
state.notPrintedSpells.push(payload)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeNotPrintedSpell: (state, payload) => {
|
removeNotPrintedSpell: (state, payload) => {
|
||||||
let spellIndex = state.notPrintedSpells.findIndex(spell => spell.key == payload.key)
|
let spellIndex = getResourceIndexInLibrary(payload, state.notPrintedSpells)
|
||||||
if (spellIndex >= 0) {
|
if (spellIndex >= 0) {
|
||||||
state.notPrintedSpells.splice(spellIndex, 1)
|
state.notPrintedSpells.splice(spellIndex, 1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
<v-icon v-if="isHiddenPrint(item)">mdi-printer-off</v-icon>
|
<v-icon v-if="isHiddenPrint(item)">mdi-printer-off</v-icon>
|
||||||
<v-icon v-else>mdi-printer</v-icon>
|
<v-icon v-else>mdi-printer</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn class="d-print-none mr-2" small depressed link icon :to="{ path: '/creation-de-monstre-pnj/', query: { key: item.key } }"><v-icon>mdi-pencil</v-icon></v-btn>
|
<v-btn v-if="item.custom" class="d-print-none mr-2" small depressed link icon :to="{ path: '/creation-de-monstre-pnj/', query: { key: item.key } }"><v-icon>mdi-pencil</v-icon></v-btn>
|
||||||
<v-btn color="error" class="d-print-none" small depressed icon @click="removeMonster(item)"><v-icon>mdi-delete</v-icon></v-btn>
|
<v-btn color="error" class="d-print-none" small depressed icon @click="removeMonster(item)"><v-icon>mdi-delete</v-icon></v-btn>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -222,6 +222,7 @@ import { CONDITIONS } from '../../data/conditions'
|
||||||
import { DAMAGETYPES } from '../../data/damageTypes'
|
import { DAMAGETYPES } from '../../data/damageTypes'
|
||||||
import { LANGUAGES } from '../../data/languages'
|
import { LANGUAGES } from '../../data/languages'
|
||||||
import { getUrlParameter } from '@theme/util/filterHelpers'
|
import { getUrlParameter } from '@theme/util/filterHelpers'
|
||||||
|
import { isResourceInLibrary } from '@theme/util'
|
||||||
import { getProficiencyBonus, displayBonus } from '@theme/util/monsterHelpers'
|
import { getProficiencyBonus, displayBonus } from '@theme/util/monsterHelpers'
|
||||||
import slugify from 'slugify'
|
import slugify from 'slugify'
|
||||||
slugify.extend({"'": '-'})
|
slugify.extend({"'": '-'})
|
||||||
|
|
@ -236,13 +237,7 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
isMonsterInBestiary () {
|
isMonsterInBestiary () {
|
||||||
let isInBestiary = false
|
return isResourceInLibrary(this.monster, this.$store.state.myMonsters.monsters)
|
||||||
for (let s of this.$store.state.myMonsters.monsters) {
|
|
||||||
if (s.key == this.monster.key) {
|
|
||||||
isInBestiary = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isInBestiary
|
|
||||||
},
|
},
|
||||||
|
|
||||||
displayToggleMonsterButton () {
|
displayToggleMonsterButton () {
|
||||||
|
|
@ -514,9 +509,65 @@ export default {
|
||||||
for (let monster of this.$store.state.myMonsters.monsters) {
|
for (let monster of this.$store.state.myMonsters.monsters) {
|
||||||
if (monster.key == monsterKey) {
|
if (monster.key == monsterKey) {
|
||||||
this.monster = monster
|
this.monster = monster
|
||||||
|
// this.monster = {
|
||||||
|
// custom: monster.custom,
|
||||||
|
// pid: 'monster',
|
||||||
|
// key: monster.key,
|
||||||
|
// title: monster.title,
|
||||||
|
// content: '',
|
||||||
|
// frontmatter: {
|
||||||
|
// type: monster.frontmatter.type ? monster.frontmatter.type : '',
|
||||||
|
// subtype: monster.frontmatter.subtype ? monster.frontmatter.subtype : '',
|
||||||
|
// size: monster.frontmatter.size ? monster.frontmatter.size : '',
|
||||||
|
// challenge: monster.frontmatter.challenge ? monster.frontmatter.challenge : '0',
|
||||||
|
// alignment: monster.frontmatter.alignment ? monster.frontmatter.alignment : '',
|
||||||
|
// isSwarm: monster.frontmatter.isSwarm,
|
||||||
|
// swarmSize: monster.frontmatter.swarmSize ? monster.frontmatter.swarmSize : '',
|
||||||
|
// hitDiceCount: monster.frontmatter.hitDiceCount,
|
||||||
|
// hitDieSize: monster.frontmatter.hitDieSize,
|
||||||
|
// abilityScores: {
|
||||||
|
// for: monster.frontmatter.abilityScores.for,
|
||||||
|
// dex: monster.frontmatter.abilityScores.dex,
|
||||||
|
// con: monster.frontmatter.abilityScores.con,
|
||||||
|
// int: monster.frontmatter.abilityScores.int,
|
||||||
|
// sag: monster.frontmatter.abilityScores.sag,
|
||||||
|
// cha: monster.frontmatter.abilityScores.cha,
|
||||||
|
// },
|
||||||
|
// ac: {
|
||||||
|
// armorType: monster.frontmatter.ac ? monster.frontmatter.ac.armorType : null,
|
||||||
|
// value: monster.frontmatter.ac ? monster.frontmatter.ac.value : null,
|
||||||
|
// hasShield: monster.frontmatter.ac ? monster.frontmatter.ac.hasShield : false,
|
||||||
|
// },
|
||||||
|
// savingThrow: monster.frontmatter.savingThrow ? monster.frontmatter.savingThrow : null,
|
||||||
|
// skills: monster.frontmatter.skills ? monster.frontmatter.skills : null,
|
||||||
|
// movement: {
|
||||||
|
// walk: monster.frontmatter.movement ? monster.frontmatter.movement.walk : null,
|
||||||
|
// climb: monster.frontmatter.movement ? monster.frontmatter.movement.climb : null,
|
||||||
|
// burrow: monster.frontmatter.movement ? monster.frontmatter.movement.burrow : null,
|
||||||
|
// swim: monster.frontmatter.movement ? monster.frontmatter.movement.swim : null,
|
||||||
|
// fly: monster.frontmatter.movement ? monster.frontmatter.movement.fly : null,
|
||||||
|
// hover: monster.frontmatter.movement ? monster.frontmatter.movement.hover : null,
|
||||||
|
// },
|
||||||
|
// senses: {
|
||||||
|
// tremorsense: monster.frontmatter.senses ? monster.frontmatter.senses.tremorsense : null,
|
||||||
|
// blindsight: monster.frontmatter.senses ? monster.frontmatter.senses.blindsight : null,
|
||||||
|
// darkvision: monster.frontmatter.senses ? monster.frontmatter.senses.darkvision : null,
|
||||||
|
// truesight: monster.frontmatter.senses ? monster.frontmatter.senses.truesight : null,
|
||||||
|
// },
|
||||||
|
// conditionImmunities: monster.frontmatter.conditionImmunities,
|
||||||
|
// damageTypeVulnerabilities: monster.frontmatter.damageTypeVulnerabilities,
|
||||||
|
// damageTypeResistances: monster.frontmatter.damageTypeResistances,
|
||||||
|
// damageTypeImmunities: monster.frontmatter.damageTypeImmunities,
|
||||||
|
// languages: monster.frontmatter.languages,
|
||||||
|
// customLanguage: monster.frontmatter.customLanguage,
|
||||||
|
// telepathy: monster.frontmatter.telepathy
|
||||||
|
// }
|
||||||
|
// }
|
||||||
if (!this.monster.custom) {
|
if (!this.monster.custom) {
|
||||||
this.monster.content = monster.rawContent
|
this.monster.content = monster.rawContent
|
||||||
this.monster.custom = true
|
this.monster.custom = true
|
||||||
|
} else {
|
||||||
|
this.monster.content = monster.content
|
||||||
}
|
}
|
||||||
if (this.monster.frontmatter.skills) {
|
if (this.monster.frontmatter.skills) {
|
||||||
this.monster.frontmatter.skills.forEach((mskill, idx) => {
|
this.monster.frontmatter.skills.forEach((mskill, idx) => {
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ import { saveAs } from 'file-saver'
|
||||||
import { CLASSES } from '../../data/classes'
|
import { CLASSES } from '../../data/classes'
|
||||||
import { SPELLSCHOOLS, SPELLLEVELS } from '../../data/spells'
|
import { SPELLSCHOOLS, SPELLLEVELS } from '../../data/spells'
|
||||||
import { getUrlParameter } from '@theme/util/filterHelpers'
|
import { getUrlParameter } from '@theme/util/filterHelpers'
|
||||||
|
import { isResourceInLibrary } from '@theme/util'
|
||||||
import slugify from 'slugify'
|
import slugify from 'slugify'
|
||||||
slugify.extend({"'": '-'})
|
slugify.extend({"'": '-'})
|
||||||
|
|
||||||
|
|
@ -123,13 +124,7 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
isSpellInSpellBook () {
|
isSpellInSpellBook () {
|
||||||
let isInSpellBook = false
|
return isResourceInLibrary(this.spell, this.$store.state.mySpells.spells)
|
||||||
for (let s of this.$store.state.mySpells.spells) {
|
|
||||||
if (s.key == this.spell.key) {
|
|
||||||
isInSpellBook = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isInSpellBook
|
|
||||||
},
|
},
|
||||||
|
|
||||||
displayToggleSpellButton () {
|
displayToggleSpellButton () {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import Breadcrumb from '@theme/components/Breadcrumb'
|
||||||
import MagicItem from '@theme/components/MagicItem'
|
import MagicItem from '@theme/components/MagicItem'
|
||||||
import MyMagicItemsButton from '@theme/global-components/MyMagicItemsButton'
|
import MyMagicItemsButton from '@theme/global-components/MyMagicItemsButton'
|
||||||
import Edit from '@theme/components/Edit'
|
import Edit from '@theme/components/Edit'
|
||||||
|
import { isResourceInLibrary } from '@theme/util'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'MagicItemLayout',
|
name: 'MagicItemLayout',
|
||||||
|
|
@ -31,13 +32,7 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
isMagicItemInTreasureChest () {
|
isMagicItemInTreasureChest () {
|
||||||
let isInTreasureChest = false
|
return isResourceInLibrary(this.$page, this.$store.state.myMagicItems.magicItems)
|
||||||
for (let s of this.$store.state.myMagicItems.magicItems) {
|
|
||||||
if (s.key == this.$page.key) {
|
|
||||||
isInTreasureChest = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isInTreasureChest
|
|
||||||
},
|
},
|
||||||
|
|
||||||
displayToggleMagicItemButton () {
|
displayToggleMagicItemButton () {
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import Breadcrumb from '@theme/components/Breadcrumb'
|
import Breadcrumb from '@theme/components/Breadcrumb'
|
||||||
import { setUrlParams, getUrlParameter } from '@theme/util/filterHelpers'
|
import { setUrlParams, getUrlParameter } from '@theme/util/filterHelpers'
|
||||||
|
import { isResourceInLibrary } from '@theme/util'
|
||||||
import MagicItem from '@theme/components/MagicItem'
|
import MagicItem from '@theme/components/MagicItem'
|
||||||
import MyMagicItemsButton from '@theme/global-components/MyMagicItemsButton'
|
import MyMagicItemsButton from '@theme/global-components/MyMagicItemsButton'
|
||||||
|
|
||||||
|
|
@ -182,13 +183,7 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
isItemInTreasureChest (magicItem) {
|
isItemInTreasureChest (magicItem) {
|
||||||
let isInTreasureChest = false
|
return isResourceInLibrary(magicItem, this.$store.state.myMagicItems.magicItems)
|
||||||
for (let mi of this.$store.state.myMagicItems.magicItems) {
|
|
||||||
if (mi.key == magicItem.key) {
|
|
||||||
isInTreasureChest = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isInTreasureChest
|
|
||||||
},
|
},
|
||||||
toggleItemInTreasureChest (magicItem) {
|
toggleItemInTreasureChest (magicItem) {
|
||||||
if (this.isItemInTreasureChest(magicItem)) {
|
if (this.isItemInTreasureChest(magicItem)) {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import Breadcrumb from '@theme/components/Breadcrumb'
|
||||||
import Monster from '@theme/components/Monster'
|
import Monster from '@theme/components/Monster'
|
||||||
import MyMonstersButton from '@theme/global-components/MyMonstersButton'
|
import MyMonstersButton from '@theme/global-components/MyMonstersButton'
|
||||||
import Edit from '@theme/components/Edit'
|
import Edit from '@theme/components/Edit'
|
||||||
|
import { isResourceInLibrary } from '@theme/util'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'MonsterLayout',
|
name: 'MonsterLayout',
|
||||||
|
|
@ -31,13 +32,7 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
isMonsterInBestiary () {
|
isMonsterInBestiary () {
|
||||||
let isInBestiary = false
|
return isResourceInLibrary(this.$page, this.$store.state.myMonsters.monsters)
|
||||||
for (let s of this.$store.state.myMonsters.monsters) {
|
|
||||||
if (s.key == this.$page.key) {
|
|
||||||
isInBestiary = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isInBestiary
|
|
||||||
},
|
},
|
||||||
|
|
||||||
displayToggleMonsterButton () {
|
displayToggleMonsterButton () {
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ import { mapState } from 'vuex'
|
||||||
import Breadcrumb from '@theme/components/Breadcrumb'
|
import Breadcrumb from '@theme/components/Breadcrumb'
|
||||||
import { displayChallenge } from '@theme/util/monsterHelpers'
|
import { displayChallenge } from '@theme/util/monsterHelpers'
|
||||||
import { setUrlParams, getUrlParameter } from '@theme/util/filterHelpers'
|
import { setUrlParams, getUrlParameter } from '@theme/util/filterHelpers'
|
||||||
|
import { isResourceInLibrary } from '@theme/util'
|
||||||
import Monster from '@theme/components/Monster'
|
import Monster from '@theme/components/Monster'
|
||||||
import MyMonstersButton from '@theme/global-components/MyMonstersButton'
|
import MyMonstersButton from '@theme/global-components/MyMonstersButton'
|
||||||
import { CHALLENGES } from '../../data/monsters'
|
import { CHALLENGES } from '../../data/monsters'
|
||||||
|
|
@ -268,13 +269,7 @@ export default {
|
||||||
displayList (list) { return list.join(', ') },
|
displayList (list) { return list.join(', ') },
|
||||||
displayChallenge (challenge) { return displayChallenge(challenge) },
|
displayChallenge (challenge) { return displayChallenge(challenge) },
|
||||||
isMonsterInBestiary (monster) {
|
isMonsterInBestiary (monster) {
|
||||||
let isInBestiary = false
|
return isResourceInLibrary(monster, this.$store.state.myMonsters.monsters)
|
||||||
for (let m of this.$store.state.myMonsters.monsters) {
|
|
||||||
if (m.key == monster.key) {
|
|
||||||
isInBestiary = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isInBestiary
|
|
||||||
},
|
},
|
||||||
toggleMonsterInBestiary (monster) {
|
toggleMonsterInBestiary (monster) {
|
||||||
if (this.isMonsterInBestiary(monster)) {
|
if (this.isMonsterInBestiary(monster)) {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import Breadcrumb from '@theme/components/Breadcrumb'
|
||||||
import Spell from '@theme/components/Spell'
|
import Spell from '@theme/components/Spell'
|
||||||
import MySpellsButton from '@theme/global-components/MySpellsButton'
|
import MySpellsButton from '@theme/global-components/MySpellsButton'
|
||||||
import Edit from '@theme/components/Edit'
|
import Edit from '@theme/components/Edit'
|
||||||
|
import { isResourceInLibrary } from '@theme/util'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'SpellLayout',
|
name: 'SpellLayout',
|
||||||
|
|
@ -31,13 +32,7 @@ export default {
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
isSpellInSpellBook () {
|
isSpellInSpellBook () {
|
||||||
let isInSpellBook = false
|
return isResourceInLibrary(this.$page, this.$store.state.mySpells.spells)
|
||||||
for (let s of this.$store.state.mySpells.spells) {
|
|
||||||
if (s.key == this.$page.key) {
|
|
||||||
isInSpellBook = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isInSpellBook
|
|
||||||
},
|
},
|
||||||
|
|
||||||
displayToggleSpellButton () {
|
displayToggleSpellButton () {
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,7 @@
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import Breadcrumb from '@theme/components/Breadcrumb'
|
import Breadcrumb from '@theme/components/Breadcrumb'
|
||||||
import { setUrlParams, getUrlParameter } from '@theme/util/filterHelpers'
|
import { setUrlParams, getUrlParameter } from '@theme/util/filterHelpers'
|
||||||
|
import { isResourceInLibrary } from '@theme/util'
|
||||||
import Spell from '@theme/components/Spell'
|
import Spell from '@theme/components/Spell'
|
||||||
import MySpellsButton from '@theme/global-components/MySpellsButton'
|
import MySpellsButton from '@theme/global-components/MySpellsButton'
|
||||||
|
|
||||||
|
|
@ -281,13 +282,7 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
isSpellInSpellBook (spell) {
|
isSpellInSpellBook (spell) {
|
||||||
let isInSpellBook = false
|
return isResourceInLibrary(spell, this.$store.state.mySpells.spells)
|
||||||
for (let s of this.$store.state.mySpells.spells) {
|
|
||||||
if (s.key == spell.key) {
|
|
||||||
isInSpellBook = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isInSpellBook
|
|
||||||
},
|
},
|
||||||
toggleSpellInSpellBook (spell) {
|
toggleSpellInSpellBook (spell) {
|
||||||
if (this.isSpellInSpellBook(spell)) {
|
if (this.isSpellInSpellBook(spell)) {
|
||||||
|
|
|
||||||
|
|
@ -238,3 +238,27 @@ function resolveItem (item, pages, base, groupDepth = 1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Returns index of resource in library
|
||||||
|
*/
|
||||||
|
export function getResourceIndexInLibrary (resource, library) {
|
||||||
|
let idx = -1
|
||||||
|
if (resource.custom) {
|
||||||
|
idx = library.findIndex(item => item.key == resource.key)
|
||||||
|
} else {
|
||||||
|
idx = library.findIndex(item => item.path == resource.path)
|
||||||
|
}
|
||||||
|
return idx
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Returns presence of resource in library
|
||||||
|
*/
|
||||||
|
export function isResourceInLibrary (resource, library) {
|
||||||
|
let idx = getResourceIndexInLibrary(resource, library)
|
||||||
|
if (idx >= 0) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ skills:
|
||||||
- name: "religion"
|
- name: "religion"
|
||||||
movement:
|
movement:
|
||||||
walk: 9
|
walk: 9
|
||||||
senses:
|
|
||||||
languages:
|
languages:
|
||||||
- "une langue au choix (commun le plus souvent)"
|
- "une langue au choix (commun le plus souvent)"
|
||||||
source: "Créatures & Oppositions"
|
source: "Créatures & Oppositions"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue