From 50e67978872921a79767dd5075ec6aea38e7dd98 Mon Sep 17 00:00:00 2001 From: Zithith Date: Thu, 29 Aug 2024 00:29:58 +0100 Subject: [PATCH] feat(ancestry items): added base item sheets, included rough data model for ancestry advancement, first pass at ancestry sheet --- src/index.ts | 5 ++++ src/system/applications/index.ts | 1 + .../applications/item/ancestry-sheet.ts | 24 +++++++++++++++++++ src/system/applications/item/base-sheet.ts | 21 ++++++++++++++++ src/system/applications/item/index.ts | 1 + src/system/data/item/ancestry.ts | 17 ++++++++++++- src/templates/item/ancestry-sheet.hbs | 9 +++++++ 7 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 src/system/applications/item/ancestry-sheet.ts create mode 100644 src/system/applications/item/base-sheet.ts create mode 100644 src/system/applications/item/index.ts create mode 100644 src/templates/item/ancestry-sheet.hbs diff --git a/src/index.ts b/src/index.ts index 16d5a231..d436df6d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -39,6 +39,11 @@ Hooks.once('init', async () => { label: `${game.i18n?.localize('COSMERE.Actor.Adversary.Adversary')}`, }); + Items.registerSheet('cosmere-rpg', applications.item.AncestrySheet, { + types: ['ancestry'], + label: `${game.i18n?.localize('COSMERE.Item.Type.Ancestry.label')}`, + }); + CONFIG.Dice.types.push(dice.PlotDie); CONFIG.Dice.terms.p = dice.PlotDie; CONFIG.Dice.termTypes[dice.PlotDie.name] = dice.PlotDie; diff --git a/src/system/applications/index.ts b/src/system/applications/index.ts index 68e5df89..f0a3e806 100644 --- a/src/system/applications/index.ts +++ b/src/system/applications/index.ts @@ -1 +1,2 @@ export * as actor from './actor'; +export * as item from './item'; diff --git a/src/system/applications/item/ancestry-sheet.ts b/src/system/applications/item/ancestry-sheet.ts new file mode 100644 index 00000000..ae0adb9e --- /dev/null +++ b/src/system/applications/item/ancestry-sheet.ts @@ -0,0 +1,24 @@ +import { CosmereItem } from '@src/system/documents'; +import { BaseSheet } from './base-sheet'; +import { AncestryItemDataModel } from '@src/system/data/item'; + +export class AncestrySheet extends BaseSheet { + static get defaultOptions() { + return foundry.utils.mergeObject(super.defaultOptions, { + classes: ['cosmere-rpg', 'sheet', 'item', 'ancestry'], + width: 520, + height: 250, + resizeable: true, + }); + } + + get item() { + return super.item as CosmereItem; + } + + getData() { + return { + ...super.getData(), + }; + } +} diff --git a/src/system/applications/item/base-sheet.ts b/src/system/applications/item/base-sheet.ts new file mode 100644 index 00000000..ff5ac486 --- /dev/null +++ b/src/system/applications/item/base-sheet.ts @@ -0,0 +1,21 @@ +import { CosmereItem } from '@system/documents/item'; + +export class BaseSheet extends ItemSheet { + get template() { + return `systems/cosmere-rpg/templates/item/${this.item.type}-sheet.hbs`; + } + + get item(): CosmereItem { + return super.item; + } + + getData() { + return { + ...(super.getData() as ItemSheet.ItemSheetData), + desc: this.item.hasDescription() + ? this.item.system.description + : undefined, + // effects: prepareActiveEffectCategories(this.item.effects) + }; + } +} diff --git a/src/system/applications/item/index.ts b/src/system/applications/item/index.ts new file mode 100644 index 00000000..e8e9cb39 --- /dev/null +++ b/src/system/applications/item/index.ts @@ -0,0 +1 @@ +export * from './ancestry-sheet'; diff --git a/src/system/data/item/ancestry.ts b/src/system/data/item/ancestry.ts index 120e6533..63bacc7d 100644 --- a/src/system/data/item/ancestry.ts +++ b/src/system/data/item/ancestry.ts @@ -14,7 +14,22 @@ export class AncestryItemDataModel extends DataModelMixin( ) { static defineSchema() { return foundry.utils.mergeObject(super.defineSchema(), { - // TODO: Advancements + advancement: new foundry.data.fields.SchemaField({ + extraTalentPicks: new foundry.data.fields.SchemaField({ + levels: new foundry.data.fields.ArrayField( + new foundry.data.fields.NumberField(), + ), + restrictions: new foundry.data.fields.ObjectField(), + // ^ how to define a rule object?... e.g. "only attaches to owned talent in singer tree" + }), + extraTalentTrees: new foundry.data.fields.StringField(), + extraTalents: new foundry.data.fields.ArrayField( + new foundry.data.fields.SchemaField({ + name: new foundry.data.fields.StringField(), + level: new foundry.data.fields.NumberField(), + }), + ), + }), }); } } diff --git a/src/templates/item/ancestry-sheet.hbs b/src/templates/item/ancestry-sheet.hbs new file mode 100644 index 00000000..a17a0cfe --- /dev/null +++ b/src/templates/item/ancestry-sheet.hbs @@ -0,0 +1,9 @@ +
+
+ +

{{item.name}}

+
+
+ {{desc.value}} +
+
\ No newline at end of file