From b9839d839fff93c2091130ae5b1d2d38f18815cc Mon Sep 17 00:00:00 2001 From: TheAsel Date: Fri, 31 May 2024 16:18:51 +0200 Subject: [PATCH 01/21] =?UTF-8?q?=E2=9C=A8=20Initial=20item=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/boot/globals.ts | 2 +- src/components/Encounter/CreatureList.vue | 2 +- .../CreaturesTable/EncounterBuilder.vue | 4 +- src/components/Shop/ShopList.vue | 5 + src/components/Shop/ShopTable.vue | 364 ++++++++++++++++++ src/pages/BestiaryPage.vue | 2 +- src/pages/EncounterPage.vue | 2 +- src/pages/IndexPage.vue | 2 +- src/pages/ShopPage.vue | 16 +- src/types/filters.ts | 8 + src/types/item.ts | 33 ++ .../{api-calls.ts => encounter-api-calls.ts} | 6 +- src/utils/shop-api-calls.ts | 53 +++ 13 files changed, 478 insertions(+), 21 deletions(-) create mode 100644 src/components/Shop/ShopList.vue create mode 100644 src/components/Shop/ShopTable.vue create mode 100644 src/types/item.ts rename src/utils/{api-calls.ts => encounter-api-calls.ts} (96%) create mode 100644 src/utils/shop-api-calls.ts diff --git a/src/boot/globals.ts b/src/boot/globals.ts index 63af7f6..c9449cf 100644 --- a/src/boot/globals.ts +++ b/src/boot/globals.ts @@ -3,7 +3,7 @@ import Vue3Tour from 'vue3-tour'; import { createHead } from '@unhead/vue'; const head = createHead(); -const backendUrl = 'https://backbybe.fly.dev'; +const backendUrl = 'https://dev-test-backbybe.fly.dev'; export default boot(({ app }) => { app.use(Vue3Tour); diff --git a/src/components/Encounter/CreatureList.vue b/src/components/Encounter/CreatureList.vue index 1f4425b..8071a88 100644 --- a/src/components/Encounter/CreatureList.vue +++ b/src/components/Encounter/CreatureList.vue @@ -3,7 +3,7 @@ import { ref, watch } from 'vue'; import { biPlus, biDash, biTrash, biPlusLg } from '@quasar/extras/bootstrap-icons'; import { debounce } from 'lodash'; import { partyStore, encounterStore, infoStore } from 'stores/store'; -import { encounterInfo } from 'src/utils/api-calls'; +import { encounterInfo } from 'src/utils/encounter-api-calls'; import type { encounterList } from 'src/types/encounter'; const party = partyStore(); diff --git a/src/components/Encounter/CreaturesTable/EncounterBuilder.vue b/src/components/Encounter/CreaturesTable/EncounterBuilder.vue index 905155a..59a6d23 100644 --- a/src/components/Encounter/CreaturesTable/EncounterBuilder.vue +++ b/src/components/Encounter/CreaturesTable/EncounterBuilder.vue @@ -4,7 +4,7 @@ import { useQuasar } from 'quasar'; import { matPriorityHigh } from '@quasar/extras/material-icons'; import { biXLg } from '@quasar/extras/bootstrap-icons'; import { partyStore, filtersStore, encounterStore, settingsStore } from 'src/stores/store'; -import { encounterGenerator } from 'src/utils/api-calls'; +import { encounterGenerator } from 'src/utils/encounter-api-calls'; import type { alignments, sizes, rarities, challenges, roles } from 'src/types/filters'; import type { creature_encounter } from 'src/types/creature'; import { debounce } from 'lodash'; @@ -82,7 +82,7 @@ const generateEncounter = debounce(async function () { party_levels: partyLevels, creature_roles: creature_roles.value, is_pwl_on: is_pwl_on, - pathfinder_versions: pf_version + pathfinder_version: pf_version }; try { const randomEncounter = await encounterGenerator(post); diff --git a/src/components/Shop/ShopList.vue b/src/components/Shop/ShopList.vue new file mode 100644 index 0000000..67cd8eb --- /dev/null +++ b/src/components/Shop/ShopList.vue @@ -0,0 +1,5 @@ + + + diff --git a/src/components/Shop/ShopTable.vue b/src/components/Shop/ShopTable.vue new file mode 100644 index 0000000..4a3ac6a --- /dev/null +++ b/src/components/Shop/ShopTable.vue @@ -0,0 +1,364 @@ + + + + + + + diff --git a/src/pages/BestiaryPage.vue b/src/pages/BestiaryPage.vue index beff64a..958606a 100644 --- a/src/pages/BestiaryPage.vue +++ b/src/pages/BestiaryPage.vue @@ -5,7 +5,7 @@ import { useRoute, useRouter } from 'vue-router'; import { useQuasar } from 'quasar'; import { matPriorityHigh, matPrint } from '@quasar/extras/material-icons'; import type { creature } from 'src/types/creature'; -import { requestCreatureId } from 'src/utils/api-calls'; +import { requestCreatureId } from 'src/utils/encounter-api-calls'; import _, { isNull } from 'lodash'; import { variants } from 'src/types/filters'; diff --git a/src/pages/EncounterPage.vue b/src/pages/EncounterPage.vue index 5271558..6388343 100644 --- a/src/pages/EncounterPage.vue +++ b/src/pages/EncounterPage.vue @@ -1,7 +1,7 @@ - - diff --git a/src/components/Shop/ShopTable.vue b/src/components/Shop/ShopTable.vue index 4a3ac6a..c9c287e 100644 --- a/src/components/Shop/ShopTable.vue +++ b/src/components/Shop/ShopTable.vue @@ -1,16 +1,29 @@ diff --git a/src/components/Shop/ShopTable/ShopBuilder.vue b/src/components/Shop/ShopTable/ShopBuilder.vue new file mode 100644 index 0000000..d1caffc --- /dev/null +++ b/src/components/Shop/ShopTable/ShopBuilder.vue @@ -0,0 +1,327 @@ + + + + + + + diff --git a/src/pages/BestiaryPage.vue b/src/pages/BestiaryPage.vue index bd154b3..8ada1f5 100644 --- a/src/pages/BestiaryPage.vue +++ b/src/pages/BestiaryPage.vue @@ -6,8 +6,16 @@ import { useQuasar } from 'quasar'; import { matPriorityHigh, matPrint } from '@quasar/extras/material-icons'; import type { creature } from 'src/types/creature'; import { requestCreatureId } from 'src/utils/encounter-api-calls'; -import _, { isNull } from 'lodash'; import { variants } from 'src/types/filters'; +import _, { isNull } from 'lodash'; +import { + cleanEffect, + cleanCompendium, + cleanDamage, + cleanTemplate, + cleanSave, + cleanRoll +} from 'src/utils/clean-regex'; const title = ref('Creature Sheet - BYBE'); @@ -107,116 +115,12 @@ const variantStyle = (value: number | undefined) => { return value; }; -const cleanCompendium = (description: string) => { - const compendiumRegex = - /@UUID\[Compendium\.([\w\-\s]*)\.([\w\-\s]*)\.([\w\-\s]*)\.([\w\-\s'()+]*)\](?:{([\w\s'+]*)})?/g; - - const compendium = description.matchAll(compendiumRegex); - for (const i of compendium) { - if (i) { - if (i[5]) { - description = description.replace(i[0], i[5].toLowerCase()); - } else { - description = description.replace(i[0], i[4].toLowerCase()); - } - } - } - return description; -}; - -const cleanDamage = (description: string) => { - const damageRegex = - /@Damage\[\(?([\w+]*)\)?\[(\w*),?(\w+)?\]?,?(\w+)?\[?(\w+)?\]?(?:[\w|:,[\]-]+)?\](?:\{([\w\s,+]*)\})?/g; - - const damage = description.matchAll(damageRegex); - for (const i of damage) { - if (i) { - if (i[6]) { - description = description.replace(i[0], i[6]); - } else if (i[4]) { - description = description.replace(i[0], i[1] + ' ' + i[2] + ' plus ' + i[4] + ' ' + i[5]); - } else if (i[3]) { - description = description.replace(i[0], i[1] + ' ' + i[2] + ' ' + i[3]); - } else { - description = description.replace(i[0], i[1] + ' ' + i[2]); - } - } - } - return description; -}; - -const cleanTemplate = (description: string) => { - const templateRegex = - /@Template\[type:(\w*)\|distance:(\d*)\|?(?:traits:([\w\-,]*))?\](?:{([\w\s-]*)})?/g; - - const template = description.matchAll(templateRegex); - for (const i of template) { - if (i) { - description = description.replace(i[0], i[2] + '-foot ' + i[1]); - } - } - return description; -}; - -const cleanSave = (description: string) => { - const checkRegex = - /@Check\[type:(\w*)(?:[\w\s\-|]*dc:([\w\s,:+@.()]*))?(?:[\w\s\-,:|()]*basic:(\w*))?[\w\s\-,:|()]*\](?:{([\w\s'+()]*)})?/g; - - const save = description.matchAll(checkRegex); - for (const i of save) { - if (i) { - if (i[2] && Number(i[2])) { - if (i[3] === 'true') { - if (i[4]) { - description = description.replace( - i[0], - 'DC ' + i[2] + ' basic ' + _.upperFirst(i[1]) + ' ' + i[4] - ); - } else { - description = description.replace(i[0], 'DC ' + i[2] + ' basic ' + _.upperFirst(i[1])); - } - } else if (i[4]) { - description = description.replace( - i[0], - 'DC ' + i[2] + ' ' + _.upperFirst(i[1]) + ' ' + i[4] - ); - } else { - description = description.replace(i[0], 'DC ' + i[2] + ' ' + _.upperFirst(i[1])); - } - } else if (i[4]) { - description = description.replace(i[0], _.upperFirst(i[1]) + ' ' + i[4]); - } else { - description = description.replace(i[0], _.upperFirst(i[1])); - } - } - } - return description; -}; - -const cleanRoll = (description: string) => { - const rollRegex = - /\[\[\/b?r \(?{?(\d\*?\d*d?[\d\s\-+]*\d*),?\d*}?\)?[\w\s]*\[?#?[\w\s,]*\]\]\]?(?:{([\w\s\-+;]*)})?/g; - - const roll = description.matchAll(rollRegex); - for (const i of roll) { - if (i) { - if (i[2]) { - description = description.replace(i[0], i[2]); - } else { - description = description.replace(i[0], i[1]); - } - } - } - return description; -}; - const cleanDescription = (description: string) => { const cleanRegex = /<\/?(?:p)?(?:li)?(?:ul)?>|
|@Localize\[.+\]/g; - const effectRegex = - /@UUID\[Compendium\.([\w\-\s]*)\.([\w\-\s]*)\.([\w\-\s]*)\.([\w\-\s]*): ([\w\s\-'()]*)\](?:{([\w\s']*)})?/g; let finalString = description.replace(cleanRegex, ''); - finalString = finalString.replace(effectRegex, ''); + + finalString = cleanEffect(finalString); finalString = cleanCompendium(finalString); @@ -576,9 +480,8 @@ const printPage = () => { style="border: 1px solid #e0e0e0; margin-top: 0; margin-bottom: 8px" />
-
{{ creatureData?.core_data.essential.rarity.toUpperCase() }} diff --git a/src/pages/EncounterPage.vue b/src/pages/EncounterPage.vue index e08e334..e188cfc 100644 --- a/src/pages/EncounterPage.vue +++ b/src/pages/EncounterPage.vue @@ -10,8 +10,8 @@ import { settingsStore } from 'stores/store'; import type { party } from 'src/types/party'; -import type { creature_encounter } from 'src/types/creature'; -import type { encounterList } from 'src/types/encounter'; +import type { min_creature } from 'src/types/creature'; +import type { encounter_list } from 'src/types/encounter'; import CreatureList from 'src/components/Encounter/CreatureList.vue'; import { Step, VTourCallbacks, VTourOptions } from 'vue3-tour'; @@ -82,7 +82,7 @@ if (localEncounters) { return typeof p.name === 'string' && Array.isArray(p.creatures); }); if (isCompatible) { - const encounters: encounterList[] = parsedEncounters; + const encounters: encounter_list[] = parsedEncounters; const encounterNames = encounters.map((p) => p.name); if (new Set(encounterNames).size !== encounterNames.length) { throw new Error('Duplicate saved encounter names'); @@ -286,14 +286,14 @@ const options: VTourOptions = { const startTour = () => { if (!tourActive.value) { tourActive.value = true; - const tmpKoboldMage: creature_encounter = { + const tmpKoboldMage: min_creature = { id: 1721, archive_link: 'https://2e.aonprd.com/NPCs.aspx?ID=3074', name: 'Kobold Cavern Mage', level: 2, variant: 'Base' }; - const tmpKoboldWarrior: creature_encounter = { + const tmpKoboldWarrior: min_creature = { id: 1260, archive_link: 'https://2e.aonprd.com/NPCs.aspx?ID=3072', name: 'Kobold Warrior', diff --git a/src/pages/ItemPage.vue b/src/pages/ItemPage.vue new file mode 100644 index 0000000..dcab8bc --- /dev/null +++ b/src/pages/ItemPage.vue @@ -0,0 +1,77 @@ + + + diff --git a/src/pages/ShopPage.vue b/src/pages/ShopPage.vue index 9511d2d..6ff9088 100644 --- a/src/pages/ShopPage.vue +++ b/src/pages/ShopPage.vue @@ -1,7 +1,10 @@