From 273b64d07bea5ccace50b28855554362b8361875 Mon Sep 17 00:00:00 2001 From: Paul Maskelyne Date: Sat, 23 Sep 2023 11:03:44 +0100 Subject: [PATCH] Background items and migration --- .../creeg_greythorn__PTFsYZ8ni3MbSdw8.json | 2 +- .../elbin_grizzlegut__RfFy5Nq3izy5oVD6.json | 2 +- .../iraga_draguul__CVFznZtBMmHG2w4a.json | 2 +- .../jorbin_ironhelm__wnjtoBC4k5dIiG8X.json | 2 +- .../martin_rast__uXk56wpEwdiTfAQN.json | 2 +- .../ralina_biggins__x3L0onniGSB97CU7.json | 2 +- .../yriel_lirandar__4gxXdPgUd0ofz89A.json | 2 +- .../zaldini_the_red__Jnb0sFKKKrAfowY0.json | 2 +- i18n/de.yaml | 2 +- i18n/en.yaml | 5 +- i18n/es.yaml | 2 +- i18n/fi.yaml | 2 +- i18n/fr.yaml | 2 +- i18n/ko.yaml | 2 +- i18n/sv.yaml | 2 +- scss/sheets/actors/_player.scss | 10 +++- scss/ui/_compendium-item-selector.scss | 15 ++++++ .../BackgroundSelector.mjs | 34 +++++++++++++ .../apps/CompendiumItemSelectors/_module.mjs | 1 + system/src/config.mjs | 1 + system/src/documents/ActorSD.mjs | 27 ++++++----- system/src/documents/CompendiumsSD.mjs | 4 ++ .../migrations/updates/Update_230920_1.mjs | 2 +- .../migrations/updates/Update_230922_1.mjs | 11 +++++ .../migrations/updates/Update_230923_1.mjs | 48 +++++++++++++++++++ system/src/migrations/updates/_module.mjs | 2 + system/src/sheets/ActorSheetSD.mjs | 3 ++ system/src/sheets/ItemSheetSD.mjs | 11 ++++- system/src/sheets/PlayerSheetSD.mjs | 11 +++++ system/system.json | 12 ++++- system/template.json | 9 +++- system/templates/actors/player/background.hbs | 41 +++++++++------- system/templates/items/item.hbs | 42 ++++++++++------ 33 files changed, 252 insertions(+), 65 deletions(-) create mode 100644 system/src/apps/CompendiumItemSelectors/BackgroundSelector.mjs create mode 100644 system/src/migrations/updates/Update_230922_1.mjs create mode 100644 system/src/migrations/updates/Update_230923_1.mjs diff --git a/data/packs/quickstart-pregens.db/creeg_greythorn__PTFsYZ8ni3MbSdw8.json b/data/packs/quickstart-pregens.db/creeg_greythorn__PTFsYZ8ni3MbSdw8.json index 6205dae2..e6980b7d 100644 --- a/data/packs/quickstart-pregens.db/creeg_greythorn__PTFsYZ8ni3MbSdw8.json +++ b/data/packs/quickstart-pregens.db/creeg_greythorn__PTFsYZ8ni3MbSdw8.json @@ -137,7 +137,7 @@ "value": 3 } }, - "background": "Sailor", + "background": "Compendium.shadowdark.backgrounds.Item.4QQNmFHKVIY6aOpW", "bonuses": { "acBonus": 0, "advantage": [ diff --git a/data/packs/quickstart-pregens.db/elbin_grizzlegut__RfFy5Nq3izy5oVD6.json b/data/packs/quickstart-pregens.db/elbin_grizzlegut__RfFy5Nq3izy5oVD6.json index 142498d1..4fe639a9 100644 --- a/data/packs/quickstart-pregens.db/elbin_grizzlegut__RfFy5Nq3izy5oVD6.json +++ b/data/packs/quickstart-pregens.db/elbin_grizzlegut__RfFy5Nq3izy5oVD6.json @@ -137,7 +137,7 @@ "value": 7 } }, - "background": "Jeweler", + "background": "Compendium.shadowdark.backgrounds.Item.2bf6cUSTzdI7CMHE", "bonuses": { "acBonus": 0, "advantage": [ diff --git a/data/packs/quickstart-pregens.db/iraga_draguul__CVFznZtBMmHG2w4a.json b/data/packs/quickstart-pregens.db/iraga_draguul__CVFznZtBMmHG2w4a.json index e4b30369..473ba46d 100644 --- a/data/packs/quickstart-pregens.db/iraga_draguul__CVFznZtBMmHG2w4a.json +++ b/data/packs/quickstart-pregens.db/iraga_draguul__CVFznZtBMmHG2w4a.json @@ -138,7 +138,7 @@ "value": 5 } }, - "background": "Urchin", + "background": "Compendium.shadowdark.backgrounds.Item.jkZbwzeer9YNCf29", "bonuses": { "acBonus": 0, "advantage": [ diff --git a/data/packs/quickstart-pregens.db/jorbin_ironhelm__wnjtoBC4k5dIiG8X.json b/data/packs/quickstart-pregens.db/jorbin_ironhelm__wnjtoBC4k5dIiG8X.json index b50ed5b2..5152df9e 100644 --- a/data/packs/quickstart-pregens.db/jorbin_ironhelm__wnjtoBC4k5dIiG8X.json +++ b/data/packs/quickstart-pregens.db/jorbin_ironhelm__wnjtoBC4k5dIiG8X.json @@ -140,7 +140,7 @@ "value": 10 } }, - "background": "Soldier", + "background": "Compendium.shadowdark.backgrounds.Item.UlC61DRdwHpl8dpt", "bonuses": { "acBonus": 0, "advantage": [ diff --git a/data/packs/quickstart-pregens.db/martin_rast__uXk56wpEwdiTfAQN.json b/data/packs/quickstart-pregens.db/martin_rast__uXk56wpEwdiTfAQN.json index f6149abf..7dbfb7d5 100644 --- a/data/packs/quickstart-pregens.db/martin_rast__uXk56wpEwdiTfAQN.json +++ b/data/packs/quickstart-pregens.db/martin_rast__uXk56wpEwdiTfAQN.json @@ -134,7 +134,7 @@ "value": 3 } }, - "background": "Noble", + "background": "Compendium.shadowdark.backgrounds.Item.sBbHjpCaF0iIoDNM", "bonuses": { "acBonus": 0, "advantage": [ diff --git a/data/packs/quickstart-pregens.db/ralina_biggins__x3L0onniGSB97CU7.json b/data/packs/quickstart-pregens.db/ralina_biggins__x3L0onniGSB97CU7.json index d63bcff3..df2dc84e 100644 --- a/data/packs/quickstart-pregens.db/ralina_biggins__x3L0onniGSB97CU7.json +++ b/data/packs/quickstart-pregens.db/ralina_biggins__x3L0onniGSB97CU7.json @@ -133,7 +133,7 @@ "value": 3 } }, - "background": "Scout", + "background": "Compendium.shadowdark.backgrounds.Item.FRz7qiokf1r9BcjJ", "bonuses": { "acBonus": 0, "advantage": [ diff --git a/data/packs/quickstart-pregens.db/yriel_lirandar__4gxXdPgUd0ofz89A.json b/data/packs/quickstart-pregens.db/yriel_lirandar__4gxXdPgUd0ofz89A.json index 98943d24..8c9201de 100644 --- a/data/packs/quickstart-pregens.db/yriel_lirandar__4gxXdPgUd0ofz89A.json +++ b/data/packs/quickstart-pregens.db/yriel_lirandar__4gxXdPgUd0ofz89A.json @@ -139,7 +139,7 @@ "value": 8 } }, - "background": "Ranger", + "background": "Compendium.shadowdark.backgrounds.Item.lFoVSBNURSvYTb4U", "bonuses": { "acBonus": 0, "advantage": [ diff --git a/data/packs/quickstart-pregens.db/zaldini_the_red__Jnb0sFKKKrAfowY0.json b/data/packs/quickstart-pregens.db/zaldini_the_red__Jnb0sFKKKrAfowY0.json index c3ea24be..16f59fb6 100644 --- a/data/packs/quickstart-pregens.db/zaldini_the_red__Jnb0sFKKKrAfowY0.json +++ b/data/packs/quickstart-pregens.db/zaldini_the_red__Jnb0sFKKKrAfowY0.json @@ -135,7 +135,7 @@ "value": 3 } }, - "background": "Wanted", + "background": "Compendium.shadowdark.backgrounds.Item.eRi9oX0cqwQwV7tk", "bonuses": { "acBonus": 0, "advantage": [ diff --git a/i18n/de.yaml b/i18n/de.yaml index f4cc0a2d..602e0b89 100644 --- a/i18n/de.yaml +++ b/i18n/de.yaml @@ -449,7 +449,7 @@ SHADOWDARK.sheet.npc.tab.description: Beschreibung SHADOWDARK.sheet.player.active_effect_override: This value is being modified by an Active Effect and cannot be edited. Disable the effect to edit it. SHADOWDARK.sheet.player.ancestry.label: Abstammung SHADOWDARK.sheet.player.available_spells: Verfügbare Zauber -SHADOWDARK.sheet.player.background: Hintergrund +SHADOWDARK.sheet.player.background.label: Hintergrund SHADOWDARK.sheet.player.class: Klasse SHADOWDARK.sheet.player.deity: Gottheit SHADOWDARK.sheet.player.languages: Sprachen diff --git a/i18n/en.yaml b/i18n/en.yaml index 9dd7228f..e7f32e35 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -180,6 +180,8 @@ SHADOWDARK.dialog.select_ancestry.prompt: Select Ancestry... SHADOWDARK.dialog.select_ancestry.title: Choose Ancestry SHADOWDARK.dialog.select_armor_property.prompt: Select Armor Property... SHADOWDARK.dialog.select_armor_property.title: Choose Armor Properties +SHADOWDARK.dialog.select_background.prompt: Select Background... +SHADOWDARK.dialog.select_background.title: Choose Background SHADOWDARK.dialog.select_class.prompt: Select Class... SHADOWDARK.dialog.select_class.title: Choose Class SHADOWDARK.dialog.select_languages.prompt: Select Language... @@ -504,7 +506,8 @@ SHADOWDARK.sheet.player.active_effect_override: This value is being modified by SHADOWDARK.sheet.player.ancestry.label: Ancestry SHADOWDARK.sheet.player.ancestry.tooltip: Your character's job SHADOWDARK.sheet.player.available_spells: Available Spells -SHADOWDARK.sheet.player.background: Background +SHADOWDARK.sheet.player.background.label: Background +SHADOWDARK.sheet.player.background.tooltip: Your history and past experience. You are adept at tasks related to your background. SHADOWDARK.sheet.player.class.label: Class SHADOWDARK.sheet.player.class.tooltip: Your character's cultural and ancestral heritage SHADOWDARK.sheet.player.deity: Deity diff --git a/i18n/es.yaml b/i18n/es.yaml index 32734404..b0dfd75d 100644 --- a/i18n/es.yaml +++ b/i18n/es.yaml @@ -449,7 +449,7 @@ SHADOWDARK.sheet.npc.tab.description: Descripción SHADOWDARK.sheet.player.active_effect_override: Este valor está siendo modificado por un efecto activo y no puede ser editado. Deshabilita el efecto para editarlo. SHADOWDARK.sheet.player.ancestry.label: Ancestría SHADOWDARK.sheet.player.available_spells: Hechizos disponibles -SHADOWDARK.sheet.player.background: Trasfondo +SHADOWDARK.sheet.player.background.label: Trasfondo SHADOWDARK.sheet.player.class: Clase SHADOWDARK.sheet.player.deity: Deidad SHADOWDARK.sheet.player.languages: Idiomas diff --git a/i18n/fi.yaml b/i18n/fi.yaml index 3c91f880..14da5ce2 100644 --- a/i18n/fi.yaml +++ b/i18n/fi.yaml @@ -449,7 +449,7 @@ SHADOWDARK.sheet.npc.tab.description: Kuvaus SHADOWDARK.sheet.player.active_effect_override: Tähän arvoon vaikuttaa aktiivinen efekti, eikä sitä pystytä juuri nyt muokkamaan. Disabloi kyseinen efekti muokataksesi arvoa. SHADOWDARK.sheet.player.ancestry.label: Laji SHADOWDARK.sheet.player.available_spells: Saatavilla olevat loitsut -SHADOWDARK.sheet.player.background: Tausta +SHADOWDARK.sheet.player.background.label: Tausta SHADOWDARK.sheet.player.class: Hahmoluokka SHADOWDARK.sheet.player.deity: Jumala SHADOWDARK.sheet.player.languages: Kielet diff --git a/i18n/fr.yaml b/i18n/fr.yaml index fed7a099..916ab6fb 100644 --- a/i18n/fr.yaml +++ b/i18n/fr.yaml @@ -449,7 +449,7 @@ SHADOWDARK.sheet.npc.tab.description: Description SHADOWDARK.sheet.player.active_effect_override: This value is being modified by an Active Effect and cannot be edited. Disable the effect to edit it. SHADOWDARK.sheet.player.ancestry.label: Ascendance SHADOWDARK.sheet.player.available_spells: Available Spells -SHADOWDARK.sheet.player.background: Historique +SHADOWDARK.sheet.player.background.label: Historique SHADOWDARK.sheet.player.class: Classe SHADOWDARK.sheet.player.deity: Croyance SHADOWDARK.sheet.player.languages: Langues diff --git a/i18n/ko.yaml b/i18n/ko.yaml index efcbae75..5c516e13 100644 --- a/i18n/ko.yaml +++ b/i18n/ko.yaml @@ -449,7 +449,7 @@ SHADOWDARK.sheet.npc.tab.description: 설명 SHADOWDARK.sheet.player.active_effect_override: 이것은 현재 활성화된 효과에 의해 변경된 것이며 수정할 수 없습니다. 수정하려면 해당 효과를 비활성화하세요. SHADOWDARK.sheet.player.ancestry.label: 선조 SHADOWDARK.sheet.player.available_spells: 시전 가능한 주문 -SHADOWDARK.sheet.player.background: 배경 +SHADOWDARK.sheet.player.background.label: 배경 SHADOWDARK.sheet.player.class: 클래스 SHADOWDARK.sheet.player.deity: 신 SHADOWDARK.sheet.player.languages: 언어 diff --git a/i18n/sv.yaml b/i18n/sv.yaml index 91062795..d23b9809 100644 --- a/i18n/sv.yaml +++ b/i18n/sv.yaml @@ -449,7 +449,7 @@ SHADOWDARK.sheet.npc.tab.description: Beskrivning SHADOWDARK.sheet.player.active_effect_override: Detta värde ändras av en aktiv effekt och kan inte redigeras. Inaktivera effekten för att redigera den. SHADOWDARK.sheet.player.ancestry.label: Ursprung SHADOWDARK.sheet.player.available_spells: Tillgängliga besvärjelser -SHADOWDARK.sheet.player.background: Bakgrund +SHADOWDARK.sheet.player.background.label: Bakgrund SHADOWDARK.sheet.player.class: Klass SHADOWDARK.sheet.player.deity: Gud SHADOWDARK.sheet.player.languages: Språk diff --git a/scss/sheets/actors/_player.scss b/scss/sheets/actors/_player.scss index abbc661d..df4f45ea 100644 --- a/scss/sheets/actors/_player.scss +++ b/scss/sheets/actors/_player.scss @@ -238,12 +238,18 @@ } .pc_ancestry, + .pc_background, .pc_class, - .pc_languages { + .pc_languages{ grid-template-columns: min-content min-content 1fr; align-items: center; } + .pc_title { + grid-template-columns: min-content 1fr; + align-items: center; + } + .detail-value { text-align: left; } @@ -708,7 +714,7 @@ .uuid-link { margin: 4px; - text-align: center; + // text-align: center; } .xp-score { diff --git a/scss/ui/_compendium-item-selector.scss b/scss/ui/_compendium-item-selector.scss index a3c4e7f1..135b6196 100644 --- a/scss/ui/_compendium-item-selector.scss +++ b/scss/ui/_compendium-item-selector.scss @@ -39,3 +39,18 @@ } } + +.fake-uuid-link { + background: #DDD; + padding: 1px 4px; + border: 1px solid var(--color-border-dark-tertiary); + margin: 4px; + border-radius: 2px; + white-space: nowrap; + word-break: break-all; + + &:hover { + cursor: auto; + text-shadow: none; + } +} diff --git a/system/src/apps/CompendiumItemSelectors/BackgroundSelector.mjs b/system/src/apps/CompendiumItemSelectors/BackgroundSelector.mjs new file mode 100644 index 00000000..04a78254 --- /dev/null +++ b/system/src/apps/CompendiumItemSelectors/BackgroundSelector.mjs @@ -0,0 +1,34 @@ +import CompendiumItemSelector from "../CompendiumItemSelector"; + +export default class BackgroundSelector extends CompendiumItemSelector { + + closeOnSelection = true; + + maxChoices = 1; + + get prompt() { + return game.i18n.localize("SHADOWDARK.dialog.select_background.prompt"); + } + + get title() { + return game.i18n.localize("SHADOWDARK.dialog.select_background.title"); + } + + async getAvailableItems() { + return await shadowdark.compendiums.backgrounds(); + } + + async getUuids() { + const uuid = this.object?.system?.background; + + return uuid !== "" ? [uuid] : []; + } + + async saveUuids(uuids) { + const uuid = uuids[0] ?? ""; + + return this.object.update({ + "system.background": uuid, + }); + } +} diff --git a/system/src/apps/CompendiumItemSelectors/_module.mjs b/system/src/apps/CompendiumItemSelectors/_module.mjs index 75540077..2b802295 100644 --- a/system/src/apps/CompendiumItemSelectors/_module.mjs +++ b/system/src/apps/CompendiumItemSelectors/_module.mjs @@ -1,5 +1,6 @@ export {default as AncestrySelector} from "./AncestrySelector.mjs"; export {default as ArmorPropertySelector} from "./ArmorPropertySelector.mjs"; +export {default as BackgroundSelector} from "./BackgroundSelector.mjs"; export {default as ClassSelector} from "./ClassSelector.mjs"; export {default as LanguageSelector} from "./LanguageSelector.mjs"; export {default as WeaponPropertySelector} from "./WeaponPropertySelector.mjs"; diff --git a/system/src/config.mjs b/system/src/config.mjs index bce7f017..f8c89659 100644 --- a/system/src/config.mjs +++ b/system/src/config.mjs @@ -72,6 +72,7 @@ SHADOWDARK.DEFAULTS = { ITEM_IMAGES: { Ancestry: "icons/environment/people/group.webp", Armor: "icons/equipment/chest/breastplate-banded-steel-gold.webp", + Background: "icons/environment/people/commoner.webp", Basic: "icons/containers/bags/pouch-simple-brown.webp", Class: "icons/sundries/documents/document-sealed-brown-red.webp", Effect: "icons/commodities/tech/cog-brass.webp", diff --git a/system/src/documents/ActorSD.mjs b/system/src/documents/ActorSD.mjs index b4a250a1..9bd515b9 100644 --- a/system/src/documents/ActorSD.mjs +++ b/system/src/documents/ActorSD.mjs @@ -27,6 +27,10 @@ export default class ActorSD extends Actor { this.update({"system.ancestry": item.uuid}); } + async addClass(item) { + this.update({"system.class": item.uuid}); + } + async addLanguage(item) { let languageFound = false; for (const language of await this.languageItems()) { @@ -495,16 +499,6 @@ export default class ActorSD extends Actor { return characterClass && spellcastingAbility !== "" ? true : false; } - /** @inheritDoc */ - // prepareBaseData() { - // switch (this.type) { - // case "Player": - // return this._preparePlayerData(); - // case "NPC": - // return this._prepareNPCData(); - // } - // } - /** @inheritDoc */ prepareData() { super.prepareData(); @@ -976,7 +970,18 @@ export default class ActorSD extends Actor { } } - console.log("done"); + this.backgroundItems.title = ""; + if (this.backgroundItems.class && this.system.alignment !== "") { + const titles = this.backgroundItems.class.system.titles ?? []; + const level = this.system.level?.value ?? 0; + + for (const title of titles) { + if (level >= title.from && level <= title.to) { + this.backgroundItems.title = title[this.system.alignment]; + break; + } + } + } } _preparePlayerData() { diff --git a/system/src/documents/CompendiumsSD.mjs b/system/src/documents/CompendiumsSD.mjs index 5ac4db36..c972866d 100644 --- a/system/src/documents/CompendiumsSD.mjs +++ b/system/src/documents/CompendiumsSD.mjs @@ -78,6 +78,10 @@ export default class CompendiumsSD { return CompendiumsSD.properties("armor", sources); } + static async backgrounds(sources=[]) { + return CompendiumsSD._documents("Item", "Background", sources); + } + static async baseArmor(sources=[]) { const documents = await CompendiumsSD._documents("Item", "Armor", sources); diff --git a/system/src/migrations/updates/Update_230920_1.mjs b/system/src/migrations/updates/Update_230920_1.mjs index 81797861..762d6352 100644 --- a/system/src/migrations/updates/Update_230920_1.mjs +++ b/system/src/migrations/updates/Update_230920_1.mjs @@ -14,7 +14,7 @@ export default class Update_230920_1 extends UpdateBaseSD { const updateData = { "system.class": "", - "system.=-spellcastingAbility": null, + "system.-=spellcastingAbility": null, }; const currentValue = actorData.system?.class ?? ""; diff --git a/system/src/migrations/updates/Update_230922_1.mjs b/system/src/migrations/updates/Update_230922_1.mjs new file mode 100644 index 00000000..666db4f8 --- /dev/null +++ b/system/src/migrations/updates/Update_230922_1.mjs @@ -0,0 +1,11 @@ +import { UpdateBaseSD } from "../UpdateBaseSD.mjs"; + +export default class Update_230922_1 extends UpdateBaseSD { + static version = 230922.1; + + async updateActor(actorData) { + if (actorData.type !== "Player") return; + + return {"system.-=title": null}; + } +} diff --git a/system/src/migrations/updates/Update_230923_1.mjs b/system/src/migrations/updates/Update_230923_1.mjs new file mode 100644 index 00000000..56169ddd --- /dev/null +++ b/system/src/migrations/updates/Update_230923_1.mjs @@ -0,0 +1,48 @@ +import { UpdateBaseSD } from "../UpdateBaseSD.mjs"; + +// Migrates a character actor's Ancesty from a free text field to a uuid +// compendium link +// +// Attempts to match any current value to a uuid compendium link if there is +// a match on the slugified names + +export default class Update_230923_1 extends UpdateBaseSD { + static version = 230923.1; + + async updateActor(actorData) { + if (actorData.type !== "Player") return; + + const updateData = { + "system.background": "", + }; + + const currentValue = actorData.system?.background ?? ""; + + if (currentValue !== "") { + const itemLut = {}; + (await shadowdark.compendiums.backgrounds()).forEach( + item => itemLut[item.name.slugify()] = item.uuid + ); + + const matchingItem = itemLut[currentValue.slugify()]; + + if (matchingItem) { + updateData["system.background"] = matchingItem; + } + else { + ui.notifications.warn( + game.i18n.format( + "Background '{itemName}' for Character '{name}' does not exist in a compendium; you will need to create this Item and update the Character manually.", + { + itemName: currentValue, + name: actorData.name, + } + ), + {permanent: true} + ); + } + } + + return updateData; + } +} diff --git a/system/src/migrations/updates/_module.mjs b/system/src/migrations/updates/_module.mjs index 660bb0a1..a05a3ba2 100644 --- a/system/src/migrations/updates/_module.mjs +++ b/system/src/migrations/updates/_module.mjs @@ -13,3 +13,5 @@ export {default as Update_230915_1} from "./Update_230915_1.mjs"; export {default as Update_230915_2} from "./Update_230915_2.mjs"; export {default as Update_230916_1} from "./Update_230916_1.mjs"; export {default as Update_230920_1} from "./Update_230920_1.mjs"; +export {default as Update_230922_1} from "./Update_230922_1.mjs"; +export {default as Update_230923_1} from "./Update_230923_1.mjs"; diff --git a/system/src/sheets/ActorSheetSD.mjs b/system/src/sheets/ActorSheetSD.mjs index c71b25e1..8fa15e1a 100644 --- a/system/src/sheets/ActorSheetSD.mjs +++ b/system/src/sheets/ActorSheetSD.mjs @@ -249,6 +249,9 @@ export default class ActorSheetSD extends ActorSheet { case "ancestry": new select.AncestrySelector(this.actor).render(true); break; + case "background": + new select.BackgroundSelector(this.actor).render(true); + break; case "class": new select.ClassSelector(this.actor).render(true); break; diff --git a/system/src/sheets/ItemSheetSD.mjs b/system/src/sheets/ItemSheetSD.mjs index 8cab74bc..3aad8d33 100644 --- a/system/src/sheets/ItemSheetSD.mjs +++ b/system/src/sheets/ItemSheetSD.mjs @@ -266,9 +266,14 @@ export default class ItemSheetSD extends ItemSheet { effects: ( ["Effect", "Talent"].includes(item.type) || item.system.magicItem - ), + ) ? true : false, light: item.system.light?.isSource ?? false, description: true, + descriptionOnly: [ + "Background", + "NPC Feature", + ].includes(item.type), + titles: item.type === "Class", }; foundry.utils.mergeObject(context, { @@ -468,7 +473,7 @@ export default class ItemSheetSD extends ItemSheet { currentChoices = choiceObject[splitKey[1]] ?? []; } else { - // TODO throw error + // TODO throw error? } if (currentChoices.includes(uuid)) return; // No duplicates @@ -654,6 +659,8 @@ export default class ItemSheetSD extends ItemSheet { /** @inheritdoc */ _onSubmit(event) { + if (!this.isEditable) return; + switch (this.item.type) { case "Ancestry": { const updateData = this._getSubmitData(); diff --git a/system/src/sheets/PlayerSheetSD.mjs b/system/src/sheets/PlayerSheetSD.mjs index 8854a93b..636ef97e 100644 --- a/system/src/sheets/PlayerSheetSD.mjs +++ b/system/src/sheets/PlayerSheetSD.mjs @@ -89,6 +89,12 @@ export default class PlayerSheetSD extends ActorSheetSD { tooltip: game.i18n.localize("SHADOWDARK.sheet.player.ancestry.tooltip"), item: await fromUuid(system.ancestry) ?? null, }, + background: { + name: "background", + label: game.i18n.localize("SHADOWDARK.sheet.player.background.label"), + tooltip: game.i18n.localize("SHADOWDARK.sheet.player.background.tooltip"), + item: await fromUuid(system.background) ?? null, + }, class: { name: "class", label: game.i18n.localize("SHADOWDARK.sheet.player.class.label"), @@ -137,6 +143,8 @@ export default class PlayerSheetSD extends ActorSheetSD { ) ); + context.classTitle = this.actor.backgroundItems.title; + return context; } @@ -144,6 +152,8 @@ export default class PlayerSheetSD extends ActorSheetSD { switch (item.type) { case "Ancestry": return this.actor.addAncestry(item); + case "Class": + return this.actor.addClass(item); case "Language": return this.actor.addLanguage(item); } @@ -178,6 +188,7 @@ export default class PlayerSheetSD extends ActorSheetSD { const backgroundItems = [ "Ancestry", + "Class", "Language", ]; diff --git a/system/system.json b/system/system.json index e2c49863..f3d450a2 100644 --- a/system/system.json +++ b/system/system.json @@ -8,7 +8,7 @@ "verified": "11" }, "flags": { - "schemaVersion": "230920.1" + "schemaVersion": "230923.1" }, "url": "https://github.com/Muttley/foundryvtt-shadowdark", "manifest": "https://raw.githubusercontent.com/Muttley/foundryvtt-shadowdark/master/system/system.json", @@ -75,6 +75,15 @@ "private": false, "flags": {} }, + { + "name": "backgrounds", + "label": "Backgrounds", + "system": "shadowdark", + "path": "packs/backgrounds", + "type": "Item", + "private": false, + "flags": {} + }, { "name": "classes", "label": "Classes", @@ -234,6 +243,7 @@ "color": "#262626", "packs": [ "ancestries", + "backgrounds", "classes", "languages", "talents" diff --git a/system/template.json b/system/template.json index 2d157609..45db2521 100644 --- a/system/template.json +++ b/system/template.json @@ -127,14 +127,14 @@ "xp": 0 }, "luck": false, - "slots": 10, - "title": "" + "slots": 10 } }, "Item": { "types": [ "Ancestry", "Armor", + "Background", "Basic", "Class", "Gem", @@ -226,6 +226,11 @@ "canBeEquipped": true, "properties": [] }, + "Background": { + "templates": [ + "common" + ] + }, "Basic": { "templates": [ "common", diff --git a/system/templates/actors/player/background.hbs b/system/templates/actors/player/background.hbs index 89bd7469..8776da4b 100644 --- a/system/templates/actors/player/background.hbs +++ b/system/templates/actors/player/background.hbs @@ -31,33 +31,40 @@
-
+
- + {{#if classTitle}} + + {{else}} + + {{/if}}
-
- - -
+ {{> + actors/partials/background-selector + config=backgroundSelectors.background + }}
{{#if showTab.details}} - + {{localize "SHADOWDARK.sheet.item.tab.details"}} {{/if}} - {{#ifEq item.type "Class"}} - + {{#if showTab.titles}} + {{localize "SHADOWDARK.sheet.item.tab.titles"}} - {{/ifEq}} + {{/if}} {{#if showTab.effects}} - + {{localize "SHADOWDARK.sheet.item.tab.effects"}} {{/if}} {{#if showTab.light}} - + {{localize "SHADOWDARK.sheet.item.tab.light"}} {{/if}} {{#if showTab.description}} @@ -62,11 +62,25 @@
- {{> items/tabs/details }} - {{> items/tabs/titles }} - {{> items/tabs/light }} - {{> items/tabs/effects }} - {{> items/tabs/description }} + {{#if showTab.details}} + {{> items/tabs/details }} + {{/if}} + + {{#if showTab.titles}} + {{> items/tabs/titles }} + {{/if}} + + {{#if showTab.light}} + {{> items/tabs/light }} + {{/if}} + + {{#if showTab.effects}} + {{> items/tabs/effects }} + {{/if}} + + {{#if showTab.description}} + {{> items/tabs/description }} + {{/if}}