1
0
Fork 0
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:
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

@ -222,6 +222,7 @@ import { CONDITIONS } from '../../data/conditions'
import { DAMAGETYPES } from '../../data/damageTypes'
import { LANGUAGES } from '../../data/languages'
import { getUrlParameter } from '@theme/util/filterHelpers'
import { isResourceInLibrary } from '@theme/util'
import { getProficiencyBonus, displayBonus } from '@theme/util/monsterHelpers'
import slugify from 'slugify'
slugify.extend({"'": '-'})
@ -236,13 +237,7 @@ export default {
computed: {
isMonsterInBestiary () {
let isInBestiary = false
for (let s of this.$store.state.myMonsters.monsters) {
if (s.key == this.monster.key) {
isInBestiary = true
}
}
return isInBestiary
return isResourceInLibrary(this.monster, this.$store.state.myMonsters.monsters)
},
displayToggleMonsterButton () {
@ -514,9 +509,65 @@ export default {
for (let monster of this.$store.state.myMonsters.monsters) {
if (monster.key == monsterKey) {
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) {
this.monster.content = monster.rawContent
this.monster.custom = true
} else {
this.monster.content = monster.content
}
if (this.monster.frontmatter.skills) {
this.monster.frontmatter.skills.forEach((mskill, idx) => {

View file

@ -110,6 +110,7 @@ import { saveAs } from 'file-saver'
import { CLASSES } from '../../data/classes'
import { SPELLSCHOOLS, SPELLLEVELS } from '../../data/spells'
import { getUrlParameter } from '@theme/util/filterHelpers'
import { isResourceInLibrary } from '@theme/util'
import slugify from 'slugify'
slugify.extend({"'": '-'})
@ -123,13 +124,7 @@ export default {
computed: {
isSpellInSpellBook () {
let isInSpellBook = false
for (let s of this.$store.state.mySpells.spells) {
if (s.key == this.spell.key) {
isInSpellBook = true
}
}
return isInSpellBook
return isResourceInLibrary(this.spell, this.$store.state.mySpells.spells)
},
displayToggleSpellButton () {

View file

@ -18,6 +18,7 @@ import Breadcrumb from '@theme/components/Breadcrumb'
import MagicItem from '@theme/components/MagicItem'
import MyMagicItemsButton from '@theme/global-components/MyMagicItemsButton'
import Edit from '@theme/components/Edit'
import { isResourceInLibrary } from '@theme/util'
export default {
name: 'MagicItemLayout',
@ -31,13 +32,7 @@ export default {
computed: {
isMagicItemInTreasureChest () {
let isInTreasureChest = false
for (let s of this.$store.state.myMagicItems.magicItems) {
if (s.key == this.$page.key) {
isInTreasureChest = true
}
}
return isInTreasureChest
return isResourceInLibrary(this.$page, this.$store.state.myMagicItems.magicItems)
},
displayToggleMagicItemButton () {

View file

@ -77,6 +77,7 @@
import { mapState } from 'vuex'
import Breadcrumb from '@theme/components/Breadcrumb'
import { setUrlParams, getUrlParameter } from '@theme/util/filterHelpers'
import { isResourceInLibrary } from '@theme/util'
import MagicItem from '@theme/components/MagicItem'
import MyMagicItemsButton from '@theme/global-components/MyMagicItemsButton'
@ -182,13 +183,7 @@ export default {
methods: {
isItemInTreasureChest (magicItem) {
let isInTreasureChest = false
for (let mi of this.$store.state.myMagicItems.magicItems) {
if (mi.key == magicItem.key) {
isInTreasureChest = true
}
}
return isInTreasureChest
return isResourceInLibrary(magicItem, this.$store.state.myMagicItems.magicItems)
},
toggleItemInTreasureChest (magicItem) {
if (this.isItemInTreasureChest(magicItem)) {

View file

@ -18,6 +18,7 @@ import Breadcrumb from '@theme/components/Breadcrumb'
import Monster from '@theme/components/Monster'
import MyMonstersButton from '@theme/global-components/MyMonstersButton'
import Edit from '@theme/components/Edit'
import { isResourceInLibrary } from '@theme/util'
export default {
name: 'MonsterLayout',
@ -31,13 +32,7 @@ export default {
computed: {
isMonsterInBestiary () {
let isInBestiary = false
for (let s of this.$store.state.myMonsters.monsters) {
if (s.key == this.$page.key) {
isInBestiary = true
}
}
return isInBestiary
return isResourceInLibrary(this.$page, this.$store.state.myMonsters.monsters)
},
displayToggleMonsterButton () {

View file

@ -90,6 +90,7 @@ import { mapState } from 'vuex'
import Breadcrumb from '@theme/components/Breadcrumb'
import { displayChallenge } from '@theme/util/monsterHelpers'
import { setUrlParams, getUrlParameter } from '@theme/util/filterHelpers'
import { isResourceInLibrary } from '@theme/util'
import Monster from '@theme/components/Monster'
import MyMonstersButton from '@theme/global-components/MyMonstersButton'
import { CHALLENGES } from '../../data/monsters'
@ -268,13 +269,7 @@ export default {
displayList (list) { return list.join(', ') },
displayChallenge (challenge) { return displayChallenge(challenge) },
isMonsterInBestiary (monster) {
let isInBestiary = false
for (let m of this.$store.state.myMonsters.monsters) {
if (m.key == monster.key) {
isInBestiary = true
}
}
return isInBestiary
return isResourceInLibrary(monster, this.$store.state.myMonsters.monsters)
},
toggleMonsterInBestiary (monster) {
if (this.isMonsterInBestiary(monster)) {

View file

@ -18,6 +18,7 @@ import Breadcrumb from '@theme/components/Breadcrumb'
import Spell from '@theme/components/Spell'
import MySpellsButton from '@theme/global-components/MySpellsButton'
import Edit from '@theme/components/Edit'
import { isResourceInLibrary } from '@theme/util'
export default {
name: 'SpellLayout',
@ -31,13 +32,7 @@ export default {
computed: {
isSpellInSpellBook () {
let isInSpellBook = false
for (let s of this.$store.state.mySpells.spells) {
if (s.key == this.$page.key) {
isInSpellBook = true
}
}
return isInSpellBook
return isResourceInLibrary(this.$page, this.$store.state.mySpells.spells)
},
displayToggleSpellButton () {

View file

@ -117,6 +117,7 @@
import { mapState } from 'vuex'
import Breadcrumb from '@theme/components/Breadcrumb'
import { setUrlParams, getUrlParameter } from '@theme/util/filterHelpers'
import { isResourceInLibrary } from '@theme/util'
import Spell from '@theme/components/Spell'
import MySpellsButton from '@theme/global-components/MySpellsButton'
@ -281,13 +282,7 @@ export default {
methods: {
isSpellInSpellBook (spell) {
let isInSpellBook = false
for (let s of this.$store.state.mySpells.spells) {
if (s.key == spell.key) {
isInSpellBook = true
}
}
return isInSpellBook
return isResourceInLibrary(spell, this.$store.state.mySpells.spells)
},
toggleSpellInSpellBook (spell) {
if (this.isSpellInSpellBook(spell)) {