Skip to content

Commit

Permalink
feat(ancestry items): added base item sheets, included rough data mod…
Browse files Browse the repository at this point in the history
…el for ancestry advancement, first pass at ancestry sheet
  • Loading branch information
zithith committed Sep 2, 2024
1 parent 2a3ad84 commit 940b3cd
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ Hooks.once('init', async () => {
},
);

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;
Expand Down
1 change: 1 addition & 0 deletions src/system/applications/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * as actor from './actor';
export * as combat from './combat';
export * as item from './item';
24 changes: 24 additions & 0 deletions src/system/applications/item/ancestry-sheet.ts
Original file line number Diff line number Diff line change
@@ -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<AncestryItemDataModel>;
}

getData() {
return {
...super.getData(),
};
}
}
21 changes: 21 additions & 0 deletions src/system/applications/item/base-sheet.ts
Original file line number Diff line number Diff line change
@@ -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)
};
}
}
1 change: 1 addition & 0 deletions src/system/applications/item/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ancestry-sheet';
17 changes: 16 additions & 1 deletion src/system/data/item/ancestry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}),
),
}),
});
}
}
9 changes: 9 additions & 0 deletions src/templates/item/ancestry-sheet.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<form class="sheet" autocomplete="off">
<header class="sheet-header">
<img class="profile" src="{{item.img}}" data-tooltip="{{img.name}}" data-edit="img" />
<h1 class="document-name">{{item.name}}</h1>
</header>
<div>
{{desc.value}}
</div>
</form>

0 comments on commit 940b3cd

Please sign in to comment.