Skip to content

Commit a239872

Browse files
authored
fix: Additional v1.7.x fixes (#289)
* fix: Character generator now properly sets scores * fix: Items should once again properly display their descriptions. * fix: Treasure items should be created under the Treasure inventory heading * fix: Item and armor descriptions should target the correct fields
1 parent fe92b96 commit a239872

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed

src/module/actor/actor-sheet.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export class OseActorSheet extends ActorSheet {
373373
_createItem(event) {
374374
event.preventDefault();
375375
const header = event.currentTarget;
376-
const type = header.dataset.type;
376+
const { treasure, type } = header.dataset;
377377
const createItem = (type, name) => ({
378378
name: name ? name : `New ${type.capitalize()}`,
379379
type: type,
@@ -386,8 +386,11 @@ export class OseActorSheet extends ActorSheet {
386386
const itemData = createItem(dialogInput.type, dialogInput.name);
387387
this.actor.createEmbeddedDocuments("Item", [itemData], {});
388388
});
389-
} else
390-
return this.actor.createEmbeddedDocuments("Item", [createItem(type)], {});
389+
} else {
390+
const itemData = createItem(type);
391+
if (treasure) itemData.system = { treasure: true }
392+
return this.actor.createEmbeddedDocuments("Item", [itemData], {});
393+
}
391394
}
392395

393396
async _updateItemQuantity(event) {

src/module/dialog/character-creation.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class OseCharacterCreator extends FormApplication {
2828
* @return {Object}
2929
*/
3030
getData() {
31-
let data = foundry.utils.deepClone(this.object.data);
31+
let data = foundry.utils.deepClone(this.object);
3232
data.user = game.user;
3333
data.config = CONFIG.OSE;
3434
this.counters = {
@@ -178,7 +178,7 @@ export class OseCharacterCreator extends FormApplication {
178178
event,
179179
{ updateData = null, preventClose = false, preventRender = false } = {}
180180
) {
181-
updateData = { ...updateData, data: { scores: this.scores } };
181+
updateData = { ...updateData, system: { scores: this.scores } };
182182
super._onSubmit(event, {
183183
updateData: updateData,
184184
preventClose: preventClose,

src/module/item/data-model-item.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ export default class OseDataModelItem extends foundry.abstract.DataModel {
33
const { SchemaField, StringField, NumberField, BooleanField, ArrayField, ObjectField } = foundry.data.fields;
44
return {
55
treasure: new BooleanField(),
6-
details: new ObjectField({
7-
description: new StringField(),
8-
}),
6+
description: new StringField(),
97
tags: new ArrayField(new ObjectField()),
108
cost: new NumberField({ min: 0, initial: 0 }),
119
containerId: new StringField(),
@@ -17,6 +15,11 @@ export default class OseDataModelItem extends foundry.abstract.DataModel {
1715
};
1816
}
1917

18+
static migrateData(source) {
19+
if (source.details?.description && !source.description)
20+
source.description = source.details.description;
21+
return source;
22+
}
2023
get manualTags() {
2124
if (!this.tags) return null;
2225

src/module/item/item-sheet.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class OseItemSheet extends ItemSheet {
5252
data.config = CONFIG.OSE;
5353
data.enriched = {
5454
description: await TextEditor.enrichHTML(
55-
this.item.system?.description || this.item.system?.details?.description || "",
55+
this.item.system?.description || "",
5656
{async: true}
5757
)
5858
}

src/templates/items/armor-sheet.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ <h1 class="charname">
8787
</div>
8888
</div>
8989
<div class="description">
90-
{{editor system.enrichedDescription target="system.description"
90+
{{editor enriched.description target="system.description"
9191
button=true owner=owner editable=editable async=true}}
9292
</div>
9393
</div>

src/templates/items/item-sheet.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ <h1 class="charname">
8282
</div>
8383
<div class="description weapon-editor">
8484
{{editor enriched.description
85-
target="system.details.description"
85+
target="system.description"
8686
button=true
8787
owner=owner
8888
editable=editable

0 commit comments

Comments
 (0)