Skip to content

Commit

Permalink
For issue vttred#445
Browse files Browse the repository at this point in the history
* sets FormApplication option, submitOnClose to false.
* migrated Gather scores to _onSubmit override
* Added default to data.roll.type check in helpers-dice.js, setting isSuccess AND isFailure to false.
* set data object in call to OseDice.Roll to not provide type Object.
  • Loading branch information
Stew-rt committed May 29, 2023
1 parent 31882ad commit e19689f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
46 changes: 22 additions & 24 deletions src/module/dialog/character-creation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class OseCharacterCreator extends FormApplication {
options.id = "character-creator";
options.template = `${OSE.systemPath()}/templates/actors/dialogs/character-creation.html`;
options.width = 235;
options.submitOnClose = false;
return options;
}

Expand Down Expand Up @@ -98,9 +99,7 @@ export default class OseCharacterCreator extends FormApplication {
: game.i18n.localize(`OSE.scores.${score}.long`);
const rollParts = ["3d6"];
const data = {
roll: {
type: "result",
},
roll: {},
};
if (options.skipMessage) {
return new Roll(rollParts[0]).evaluate({ async: false });
Expand All @@ -123,27 +122,6 @@ export default class OseCharacterCreator extends FormApplication {
});
}

async close(options) {
// Gather scores
const speaker = ChatMessage.getSpeaker({ actor: this });
const templateData = {
config: CONFIG.OSE,
scores: this.scores,
title: game.i18n.localize("OSE.dialog.generator"),
stats: this.object.stats,
gold: this.gold,
};
const content = await renderTemplate(
`${OSE.systemPath()}/templates/chat/roll-creation.html`,
templateData
);
ChatMessage.create({
content,
speaker,
});
return super.close(options);
}

/** @override */
activateListeners(html) {
super.activateListeners(html);
Expand Down Expand Up @@ -193,6 +171,26 @@ export default class OseCharacterCreator extends FormApplication {
preventClose,
preventRender,
});

// Gather scores
const speaker = ChatMessage.getSpeaker({ actor: this.object.actor });
const templateData = {
config: CONFIG.OSE,
scores: this.scores,
title: game.i18n.localize("OSE.dialog.generator"),
stats: this.object.stats,
gold: this.gold,
};
const content = await renderTemplate(
`${OSE.systemPath()}/templates/chat/roll-creation.html`,
templateData
);

await ChatMessage.create({
content,
speaker,
});

// Generate gold
const itemData = {
name: game.i18n.localize("OSE.items.gp.short"),
Expand Down
8 changes: 7 additions & 1 deletion src/module/helpers-dice.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,13 @@ const OseDice = {

break;
}
// No default

default : {
result.isSuccess = false;
result.isFailure = false;

break;
}
}
return result;
},
Expand Down

0 comments on commit e19689f

Please sign in to comment.