Merge branch 'stats-in-generic-check-roll-dialog' into 'master'

feat: show stats in generic check roll dialog

See merge request dungeonslayers/ds4!147
This commit is contained in:
Johannes Loher 2021-10-02 01:34:32 +00:00
commit be46ae47e3

View file

@ -317,7 +317,11 @@ export class DS4Actor extends Actor {
* @param options - Additional options to customize the roll
*/
async rollGenericCheck(options: { speaker?: { token?: TokenDocument; alias?: string } } = {}): Promise<void> {
const { attribute, trait } = await this.selectAttributeAndTrait();
const attributeAndTrait = await this.selectAttributeAndTrait();
if (!attributeAndTrait) {
return;
}
const { attribute, trait } = attributeAndTrait;
const checkTargetNumber = this.data.data.attributes[attribute].total + this.data.data.traits[trait].total;
const speaker = ChatMessage.getSpeaker({ actor: this, ...options.speaker });
await createCheckRoll(checkTargetNumber, {
@ -337,7 +341,7 @@ export class DS4Actor extends Actor {
protected async selectAttributeAndTrait(): Promise<{
attribute: keyof typeof DS4.i18n.attributes;
trait: keyof typeof DS4.i18n.traits;
}> {
} | null> {
const attributeIdentifier = "attribute-trait-selection-attribute";
const traitIdentifier = "attribute-trait-selection-trait";
return Dialog.prompt({
@ -347,12 +351,26 @@ export class DS4Actor extends Actor {
{
label: getGame().i18n.localize("DS4.Attribute"),
identifier: attributeIdentifier,
options: DS4.i18n.attributes,
options: Object.fromEntries(
(Object.entries(DS4.i18n.attributes) as [keyof typeof DS4.i18n.attributes, string][]).map(
([attribute, translation]) => [
attribute,
`${translation} (${this.data.data.attributes[attribute].total})`,
],
),
),
},
{
label: getGame().i18n.localize("DS4.Trait"),
identifier: traitIdentifier,
options: DS4.i18n.traits,
options: Object.fromEntries(
(Object.entries(DS4.i18n.traits) as [keyof typeof DS4.i18n.traits, string][]).map(
([trait, translation]) => [
trait,
`${translation} (${this.data.data.traits[trait].total})`,
],
),
),
},
],
}),
@ -385,6 +403,7 @@ export class DS4Actor extends Actor {
trait: selectedTrait,
};
},
rejectClose: false,
});
}
}