@vttforge/cli 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +21 -23
- package/dist/bin.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-CWhUNM__.mjs → src-BrNh991M.mjs} +90 -4
- package/dist/src-BrNh991M.mjs.map +1 -0
- package/package.json +3 -3
- package/templates/module-js/README.md +46 -22
- package/templates/module-js/lang/en.json +19 -1
- package/templates/module-js/module.json +7 -2
- package/templates/module-js/scripts/constants.mjs +12 -0
- package/templates/module-js/scripts/data/note-data.mjs +18 -0
- package/templates/module-js/scripts/enricher.mjs +56 -0
- package/templates/module-js/scripts/main.mjs +75 -53
- package/templates/module-js/scripts/sheets/note-sheet.mjs +69 -0
- package/templates/module-js/styles/main.css +70 -9
- package/templates/module-js/templates/item/note-sheet.hbs +34 -0
- package/templates/module-ts/README.md +51 -22
- package/templates/module-ts/lang/en.json +19 -1
- package/templates/module-ts/module.json +7 -2
- package/templates/module-ts/scripts/constants.ts +12 -0
- package/templates/module-ts/scripts/data/note-data.ts +19 -0
- package/templates/module-ts/scripts/enricher.ts +52 -0
- package/templates/module-ts/scripts/main.ts +73 -55
- package/templates/module-ts/scripts/sheets/note-sheet.ts +76 -0
- package/templates/module-ts/styles/main.css +70 -9
- package/templates/module-ts/templates/item/note-sheet.hbs +34 -0
- package/templates/module-ts/tsconfig.json +8 -2
- package/templates/system-js/README.md +45 -27
- package/templates/system-js/scripts/data/character-data.mjs +65 -59
- package/templates/system-js/scripts/data/gear-data.mjs +31 -31
- package/templates/system-js/scripts/main.mjs +38 -21
- package/templates/system-js/scripts/sheets/character-sheet.mjs +49 -50
- package/templates/system-js/scripts/sheets/gear-sheet.mjs +14 -12
- package/templates/system-js/templates/actor/character-sheet.hbs +1 -1
- package/templates/system-ts/README.md +45 -27
- package/templates/system-ts/scripts/data/character-data.ts +80 -64
- package/templates/system-ts/scripts/data/gear-data.ts +35 -31
- package/templates/system-ts/scripts/main.ts +38 -21
- package/templates/system-ts/scripts/sheets/character-sheet.ts +99 -98
- package/templates/system-ts/scripts/sheets/gear-sheet.ts +26 -20
- package/templates/system-ts/templates/actor/character-sheet.hbs +1 -1
- package/templates/system-ts/tsconfig.json +1 -0
- package/dist/src-CWhUNM__.mjs.map +0 -1
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* GearData —
|
|
2
|
+
* GearData — the `gear` Item type.
|
|
3
3
|
*
|
|
4
|
-
* `kind`
|
|
5
|
-
* `
|
|
6
|
-
* muted.
|
|
4
|
+
* `kind` drives the inventory pill on the character sheet: `equipped` and
|
|
5
|
+
* `valued` render with the accent pill, `stowed` renders muted.
|
|
7
6
|
*/
|
|
8
7
|
import { BaseTypeDataModel, fields } from '@vttforge/core';
|
|
9
8
|
|
|
10
|
-
const GEAR_KINDS = ['equipped', 'valued', 'stowed'] as const;
|
|
9
|
+
export const GEAR_KINDS = ['equipped', 'valued', 'stowed'] as const;
|
|
10
|
+
export type GearKind = (typeof GEAR_KINDS)[number];
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
12
|
+
const defineGearSchema = () => {
|
|
13
|
+
const f = fields();
|
|
14
|
+
return {
|
|
15
|
+
quantity: new f.NumberField({
|
|
16
|
+
required: true,
|
|
17
|
+
nullable: false,
|
|
18
|
+
integer: true,
|
|
19
|
+
min: 0,
|
|
20
|
+
initial: 1,
|
|
21
|
+
}),
|
|
22
|
+
weight: new f.NumberField({
|
|
23
|
+
required: true,
|
|
24
|
+
nullable: false,
|
|
25
|
+
min: 0,
|
|
26
|
+
initial: 0,
|
|
27
|
+
}),
|
|
28
|
+
kind: new f.StringField({
|
|
29
|
+
required: true,
|
|
30
|
+
nullable: false,
|
|
31
|
+
choices: GEAR_KINDS,
|
|
32
|
+
initial: 'stowed',
|
|
33
|
+
}),
|
|
34
|
+
description: new f.HTMLField(),
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export class GearData extends BaseTypeDataModel(defineGearSchema) {}
|
|
39
|
+
|
|
40
|
+
/** The shape of `item.system` for gear, derived from the schema. */
|
|
41
|
+
export type GearSystem = GearData['$inferData'];
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* {{TITLE}} — entry point.
|
|
3
3
|
*
|
|
4
|
-
* `registerSystem`
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* registration, settings, and the `Hooks.once("ready", ...)` migration
|
|
8
|
-
* gate are all wired by one call.
|
|
4
|
+
* One `registerSystem` call replaces the `Hooks.once("init", ...)` block most
|
|
5
|
+
* systems copy from each other: data models, initiative, sheets, settings,
|
|
6
|
+
* and the `ready`-time migration gate.
|
|
9
7
|
*/
|
|
10
8
|
import './foundry-globals.js';
|
|
11
9
|
import { registerSystem, SystemConfig, VttfError } from '@vttforge/core';
|
|
@@ -27,6 +25,39 @@ try {
|
|
|
27
25
|
combat: {
|
|
28
26
|
initiative: { formula: '1d20 + @abilities.dex.mod', decimals: 2 },
|
|
29
27
|
},
|
|
28
|
+
|
|
29
|
+
// The core sheets have to go before ours can be the default. This runs
|
|
30
|
+
// before the `sheets` below are registered.
|
|
31
|
+
onBeforeInit: () => {
|
|
32
|
+
const { Actors, Items } = foundry.documents.collections;
|
|
33
|
+
Actors.unregisterSheet('core', foundry.applications.sheets.ActorSheetV2);
|
|
34
|
+
Items.unregisterSheet('core', foundry.applications.sheets.ItemSheetV2);
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
// Declared here rather than with `Actors.registerSheet`. Foundry keys a
|
|
38
|
+
// sheet by `${scope}.${class name}` and saves that key on every document
|
|
39
|
+
// using it; a bundler renames classes between builds, and the saved key
|
|
40
|
+
// then names a sheet that no longer exists. The `id` is written down, so
|
|
41
|
+
// the key does not move. Pick it once and keep it.
|
|
42
|
+
sheets: [
|
|
43
|
+
{
|
|
44
|
+
id: 'character',
|
|
45
|
+
document: 'Actor',
|
|
46
|
+
sheet: CharacterSheet,
|
|
47
|
+
types: ['character'],
|
|
48
|
+
makeDefault: true,
|
|
49
|
+
label: '{{LOCALE_PREFIX}}.Sheet.Character.title',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'gear',
|
|
53
|
+
document: 'Item',
|
|
54
|
+
sheet: GearSheet,
|
|
55
|
+
types: ['gear'],
|
|
56
|
+
makeDefault: true,
|
|
57
|
+
label: '{{LOCALE_PREFIX}}.Sheet.Gear.title',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
|
|
30
61
|
onAfterInit: () => {
|
|
31
62
|
settings.register('showTutorial', {
|
|
32
63
|
name: '{{LOCALE_PREFIX}}.Settings.showTutorial.name',
|
|
@@ -37,24 +68,10 @@ try {
|
|
|
37
68
|
default: true,
|
|
38
69
|
});
|
|
39
70
|
|
|
40
|
-
//
|
|
41
|
-
// to read and write the version flag.
|
|
71
|
+
// The schemaVersion setting `migrations.run()` reads and writes.
|
|
42
72
|
migrations.register();
|
|
43
|
-
|
|
44
|
-
const { Actors, Items } = foundry.documents.collections;
|
|
45
|
-
Actors.unregisterSheet('core', foundry.applications.sheets.ActorSheetV2);
|
|
46
|
-
Actors.registerSheet(SYSTEM_ID, CharacterSheet, {
|
|
47
|
-
types: ['character'],
|
|
48
|
-
makeDefault: true,
|
|
49
|
-
label: '{{LOCALE_PREFIX}}.Sheet.Character.title',
|
|
50
|
-
});
|
|
51
|
-
Items.unregisterSheet('core', foundry.applications.sheets.ItemSheetV2);
|
|
52
|
-
Items.registerSheet(SYSTEM_ID, GearSheet, {
|
|
53
|
-
types: ['gear'],
|
|
54
|
-
makeDefault: true,
|
|
55
|
-
label: '{{LOCALE_PREFIX}}.Sheet.Gear.title',
|
|
56
|
-
});
|
|
57
73
|
},
|
|
74
|
+
|
|
58
75
|
onReady: async () => {
|
|
59
76
|
if (!game.user?.isGM) return;
|
|
60
77
|
try {
|
|
@@ -1,19 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CharacterSheet — tabbed character sheet
|
|
3
|
-
* `@vttforge/core`. Demonstrates the full boilerplate-elimination surface:
|
|
2
|
+
* CharacterSheet — tabbed character sheet on `BaseActorSheet()`.
|
|
4
3
|
*
|
|
5
|
-
* - `static TABS` — `context.tabs.<group>`
|
|
6
|
-
*
|
|
7
|
-
* - `
|
|
8
|
-
*
|
|
9
|
-
* - Typed `onDropItem(item, event)` — pre-resolves UUIDs, rejects
|
|
10
|
-
* non-`gear` items with a notification, lets `gear` flow through to
|
|
11
|
-
* Foundry's default `_onDropItem` by returning `undefined`.
|
|
4
|
+
* - `static TABS` — `context.tabs.<group>` is filled in for you.
|
|
5
|
+
* - `static DRAG_DROP` — drag-drop wired on render, gated on `isEditable`.
|
|
6
|
+
* - `onDropItem(item, event)` — the item arrives resolved, not as a UUID.
|
|
7
|
+
* Return `false` to refuse, `undefined` to hand the drop back to Foundry.
|
|
12
8
|
*/
|
|
13
9
|
import { BaseActorSheet } from '@vttforge/core';
|
|
10
|
+
import type { CharacterData } from '../data/character-data.js';
|
|
11
|
+
import type { GearData } from '../data/gear-data.js';
|
|
14
12
|
|
|
15
13
|
const SYSTEM_ID = '{{ID}}';
|
|
16
14
|
|
|
15
|
+
/**
|
|
16
|
+
* What this sheet reads off its actor.
|
|
17
|
+
*
|
|
18
|
+
* Foundry's own `Actor` type is not wired in — see `foundry-globals.ts` — so
|
|
19
|
+
* the sheet says what it needs. Grow this as the sheet grows; it is the one
|
|
20
|
+
* place to change when a real type package lands.
|
|
21
|
+
*/
|
|
22
|
+
interface CharacterActor {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly img: string;
|
|
25
|
+
readonly isOwner: boolean;
|
|
26
|
+
readonly system: CharacterData;
|
|
27
|
+
readonly items: {
|
|
28
|
+
filter(fn: (item: GearItem) => boolean): GearItem[];
|
|
29
|
+
get(id: string): GearItem | undefined;
|
|
30
|
+
};
|
|
31
|
+
getRollData(): Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface GearItem {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly img: string;
|
|
38
|
+
readonly type: string;
|
|
39
|
+
readonly system: GearData;
|
|
40
|
+
delete(): Promise<unknown>;
|
|
41
|
+
}
|
|
42
|
+
|
|
17
43
|
interface AbilityViewModel {
|
|
18
44
|
key: string;
|
|
19
45
|
label: string;
|
|
@@ -21,22 +47,18 @@ interface AbilityViewModel {
|
|
|
21
47
|
mod: number;
|
|
22
48
|
}
|
|
23
49
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// biome-ignore lint/suspicious/noExplicitAny: typed sheet bases ship in a later @vttforge/types release
|
|
35
|
-
const Base = BaseActorSheet() as any;
|
|
50
|
+
const ABILITY_LABELS: Record<string, string> = {
|
|
51
|
+
str: '{{LOCALE_PREFIX}}.Ability.str',
|
|
52
|
+
dex: '{{LOCALE_PREFIX}}.Ability.dex',
|
|
53
|
+
con: '{{LOCALE_PREFIX}}.Ability.con',
|
|
54
|
+
int: '{{LOCALE_PREFIX}}.Ability.int',
|
|
55
|
+
wis: '{{LOCALE_PREFIX}}.Ability.wis',
|
|
56
|
+
cha: '{{LOCALE_PREFIX}}.Ability.cha',
|
|
57
|
+
};
|
|
36
58
|
|
|
37
|
-
export class CharacterSheet extends
|
|
38
|
-
static DEFAULT_OPTIONS = foundry.utils.mergeObject(
|
|
39
|
-
|
|
59
|
+
export class CharacterSheet extends BaseActorSheet() {
|
|
60
|
+
static override DEFAULT_OPTIONS = foundry.utils.mergeObject(
|
|
61
|
+
super.DEFAULT_OPTIONS,
|
|
40
62
|
{
|
|
41
63
|
id: '{{ID}}-character',
|
|
42
64
|
classes: ['{{ID}}', 'sheet', 'actor', 'character'],
|
|
@@ -55,9 +77,7 @@ export class CharacterSheet extends Base {
|
|
|
55
77
|
);
|
|
56
78
|
|
|
57
79
|
static PARTS = {
|
|
58
|
-
sheet: {
|
|
59
|
-
template: `systems/${SYSTEM_ID}/templates/actor/character-sheet.hbs`,
|
|
60
|
-
},
|
|
80
|
+
sheet: { template: `systems/${SYSTEM_ID}/templates/actor/character-sheet.hbs` },
|
|
61
81
|
};
|
|
62
82
|
|
|
63
83
|
static TABS = {
|
|
@@ -92,85 +112,72 @@ export class CharacterSheet extends Base {
|
|
|
92
112
|
},
|
|
93
113
|
};
|
|
94
114
|
|
|
95
|
-
static DRAG_DROP = [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
115
|
+
static override DRAG_DROP = [{ dragSelector: '.sh-item[draggable=true]', dropSelector: '.sh-body' }];
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The actor this sheet is for.
|
|
119
|
+
*
|
|
120
|
+
* `this.document` is `unknown` on the base — which document a sheet is for
|
|
121
|
+
* is the system's to know. One cast, here, and everything below is typed.
|
|
122
|
+
*/
|
|
123
|
+
get actor(): CharacterActor {
|
|
124
|
+
return this.document as CharacterActor;
|
|
125
|
+
}
|
|
101
126
|
|
|
102
|
-
|
|
103
|
-
async _prepareContext(options: any) {
|
|
127
|
+
override async _prepareContext(options: unknown): Promise<Record<string, unknown>> {
|
|
104
128
|
const context = await super._prepareContext(options);
|
|
105
|
-
const actor =
|
|
106
|
-
const system = actor
|
|
107
|
-
|
|
108
|
-
str: '{{LOCALE_PREFIX}}.Ability.str',
|
|
109
|
-
dex: '{{LOCALE_PREFIX}}.Ability.dex',
|
|
110
|
-
con: '{{LOCALE_PREFIX}}.Ability.con',
|
|
111
|
-
int: '{{LOCALE_PREFIX}}.Ability.int',
|
|
112
|
-
wis: '{{LOCALE_PREFIX}}.Ability.wis',
|
|
113
|
-
cha: '{{LOCALE_PREFIX}}.Ability.cha',
|
|
114
|
-
};
|
|
129
|
+
const { actor } = this;
|
|
130
|
+
const { system } = actor;
|
|
131
|
+
|
|
115
132
|
context.actor = actor;
|
|
116
133
|
context.system = system;
|
|
117
|
-
context.isEditable =
|
|
118
|
-
context.abilities = Object.entries(system.abilities
|
|
119
|
-
([key,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
label: game.i18n.localize(abilityLabels[key] ?? key),
|
|
126
|
-
value,
|
|
127
|
-
mod,
|
|
128
|
-
};
|
|
129
|
-
},
|
|
134
|
+
context.isEditable = this.isEditable;
|
|
135
|
+
context.abilities = Object.entries(system.abilities).map(
|
|
136
|
+
([key, ability]): AbilityViewModel => ({
|
|
137
|
+
key,
|
|
138
|
+
label: game.i18n.localize(ABILITY_LABELS[key] ?? key),
|
|
139
|
+
value: ability.value,
|
|
140
|
+
mod: ability.mod,
|
|
141
|
+
}),
|
|
130
142
|
);
|
|
131
143
|
context.gear = actor.items
|
|
132
|
-
.filter((item
|
|
133
|
-
.map(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
img: item.img,
|
|
143
|
-
kind: item.system?.kind ?? 'stowed',
|
|
144
|
-
quantity: item.system?.quantity ?? 1,
|
|
145
|
-
weight: item.system?.weight ?? 0,
|
|
146
|
-
description: item.system?.description ?? '',
|
|
147
|
-
}),
|
|
148
|
-
);
|
|
144
|
+
.filter((item) => item.type === 'gear')
|
|
145
|
+
.map((item) => ({
|
|
146
|
+
id: item.id,
|
|
147
|
+
name: item.name,
|
|
148
|
+
img: item.img,
|
|
149
|
+
kind: item.system.kind,
|
|
150
|
+
quantity: item.system.quantity,
|
|
151
|
+
weight: item.system.weight,
|
|
152
|
+
description: item.system.description,
|
|
153
|
+
}));
|
|
149
154
|
context.enrichedBiography = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
|
150
|
-
system.biography
|
|
155
|
+
system.biography,
|
|
151
156
|
{ relativeTo: actor, secrets: actor.isOwner },
|
|
152
157
|
);
|
|
153
158
|
return context;
|
|
154
159
|
}
|
|
155
160
|
|
|
156
|
-
/**
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (
|
|
161
|
+
/** Only gear belongs in this inventory. Anything else is refused with a reason. */
|
|
162
|
+
override async onDropItem(item: unknown, _event: DragEvent): Promise<false | undefined> {
|
|
163
|
+
const type = (item as { type?: string } | null)?.type;
|
|
164
|
+
if (type !== 'gear') {
|
|
160
165
|
ui.notifications?.warn(
|
|
161
|
-
game.i18n.format('{{LOCALE_PREFIX}}.Sheet.Drop.rejected', { type:
|
|
166
|
+
game.i18n.format('{{LOCALE_PREFIX}}.Sheet.Drop.rejected', { type: type ?? 'unknown' }),
|
|
162
167
|
);
|
|
163
168
|
return false;
|
|
164
169
|
}
|
|
165
170
|
return undefined;
|
|
166
171
|
}
|
|
167
172
|
|
|
168
|
-
//
|
|
169
|
-
|
|
170
|
-
|
|
173
|
+
// ApplicationV2 declares action handlers static and calls them with `this`
|
|
174
|
+
// bound to the sheet instance. `this: CharacterSheet` says so to TypeScript.
|
|
175
|
+
|
|
176
|
+
static async _onRollAbility(this: CharacterSheet, _event: Event, target: HTMLElement): Promise<void> {
|
|
177
|
+
const key = target.dataset.ability;
|
|
171
178
|
if (!key) return;
|
|
172
|
-
const actor = this
|
|
173
|
-
const mod = actor.system.abilities
|
|
179
|
+
const { actor } = this;
|
|
180
|
+
const mod = actor.system.abilities[key as keyof CharacterData['abilities']]?.mod ?? 0;
|
|
174
181
|
const roll = new Roll(`1d20 + ${mod}`, actor.getRollData());
|
|
175
182
|
await roll.evaluate();
|
|
176
183
|
await roll.toMessage({
|
|
@@ -181,22 +188,16 @@ export class CharacterSheet extends Base {
|
|
|
181
188
|
});
|
|
182
189
|
}
|
|
183
190
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const cls = CONFIG.Item.documentClass;
|
|
187
|
-
const parent = this.document;
|
|
188
|
-
await cls.create(
|
|
191
|
+
static async _onCreateGear(this: CharacterSheet): Promise<void> {
|
|
192
|
+
await CONFIG.Item.documentClass.create(
|
|
189
193
|
{ name: game.i18n.localize('{{LOCALE_PREFIX}}.Sheet.NewGearName'), type: 'gear' },
|
|
190
|
-
{ parent, renderSheet: true },
|
|
194
|
+
{ parent: this.actor, renderSheet: true },
|
|
191
195
|
);
|
|
192
196
|
}
|
|
193
197
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const row = target?.closest('[data-item-id]') as HTMLElement | null;
|
|
197
|
-
const id = row?.dataset?.itemId;
|
|
198
|
+
static async _onDeleteItem(this: CharacterSheet, _event: Event, target: HTMLElement): Promise<void> {
|
|
199
|
+
const id = target.closest<HTMLElement>('[data-item-id]')?.dataset.itemId;
|
|
198
200
|
if (!id) return;
|
|
199
|
-
|
|
200
|
-
await item?.delete();
|
|
201
|
+
await this.actor.items.get(id)?.delete();
|
|
201
202
|
}
|
|
202
203
|
}
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* GearSheet —
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* GearSheet — the `gear` Item sheet on `BaseItemSheet()`.
|
|
3
|
+
*
|
|
4
|
+
* Single part, one tab group, no drag-drop: the smallest useful sheet.
|
|
5
5
|
*/
|
|
6
6
|
import { BaseItemSheet } from '@vttforge/core';
|
|
7
|
+
import type { GearData } from '../data/gear-data.js';
|
|
7
8
|
|
|
8
9
|
const SYSTEM_ID = '{{ID}}';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
/** What this sheet reads off its item. See `CharacterSheet` for the pattern. */
|
|
12
|
+
interface GearItem {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly img: string;
|
|
15
|
+
readonly isOwner: boolean;
|
|
16
|
+
readonly system: GearData;
|
|
17
|
+
}
|
|
12
18
|
|
|
13
|
-
export class GearSheet extends
|
|
14
|
-
static DEFAULT_OPTIONS = foundry.utils.mergeObject(
|
|
15
|
-
|
|
19
|
+
export class GearSheet extends BaseItemSheet() {
|
|
20
|
+
static override DEFAULT_OPTIONS = foundry.utils.mergeObject(
|
|
21
|
+
super.DEFAULT_OPTIONS,
|
|
16
22
|
{
|
|
17
23
|
id: '{{ID}}-gear',
|
|
18
24
|
classes: ['{{ID}}', 'sheet', 'item', 'gear'],
|
|
@@ -26,9 +32,7 @@ export class GearSheet extends Base {
|
|
|
26
32
|
);
|
|
27
33
|
|
|
28
34
|
static PARTS = {
|
|
29
|
-
sheet: {
|
|
30
|
-
template: `systems/${SYSTEM_ID}/templates/item/gear-sheet.hbs`,
|
|
31
|
-
},
|
|
35
|
+
sheet: { template: `systems/${SYSTEM_ID}/templates/item/gear-sheet.hbs` },
|
|
32
36
|
};
|
|
33
37
|
|
|
34
38
|
static TABS = {
|
|
@@ -51,18 +55,20 @@ export class GearSheet extends Base {
|
|
|
51
55
|
},
|
|
52
56
|
};
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
get item(): GearItem {
|
|
59
|
+
return this.document as GearItem;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
override async _prepareContext(options: unknown): Promise<Record<string, unknown>> {
|
|
56
63
|
const context = await super._prepareContext(options);
|
|
57
|
-
const item =
|
|
64
|
+
const { item } = this;
|
|
58
65
|
context.item = item;
|
|
59
66
|
context.system = item.system;
|
|
60
|
-
context.isEditable =
|
|
61
|
-
context.enrichedDescription =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
);
|
|
67
|
+
context.isEditable = this.isEditable;
|
|
68
|
+
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
|
69
|
+
item.system.description,
|
|
70
|
+
{ relativeTo: item, secrets: item.isOwner },
|
|
71
|
+
);
|
|
66
72
|
return context;
|
|
67
73
|
}
|
|
68
74
|
}
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
<div class="sh-abil">
|
|
77
77
|
<div class="lbl" title="{{ability.label}}">{{ability.key}}</div>
|
|
78
78
|
<input class="val" type="number"
|
|
79
|
-
name="system.abilities.{{ability.key}}"
|
|
79
|
+
name="system.abilities.{{ability.key}}.value"
|
|
80
80
|
value="{{ability.value}}" min="1" max="30" />
|
|
81
81
|
<button type="button" class="mod sh-abil-roll"
|
|
82
82
|
data-action="rollAbility" data-ability="{{ability.key}}"
|