diff --git a/module/actor/actor.js b/module/actor/actor.js index 729f95b..9f72cdd 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -1169,40 +1169,13 @@ export class MothershipActor extends Actor { //if the weapon has enough ammo remaining to shoot if (weapon.system.ammo + weapon.system.curShots >= weapon.system.shotsPerFire) { //tell player we need to reload and ask what to do - let t = new Dialog({ - title: "Weapon Issue", - content: "

Out of ammo, you need to reload.


", - buttons: { - roll: { - icon: '', - label: "Reload", - callback: (html) => this.reloadWeapon(weapon._id) - }, - cancel: { - icon: '', - label: "Cancel", - callback: () => { } - } - }, - default: "roll", - close: () => { } - }).render(true); + let t = await this.askReload(); + //exit function + return; //if the weapon doesn't have enough ammo remaining to shoot } else { //tell player we are out of ammo - let t = new Dialog({ - title: "Weapon Issue", - content: "

Out of ammo.


", - buttons: { - cancel: { - icon: '', - label: "Ok", - callback: () => { } - } - }, - default: "roll", - close: () => { } - }).render(true); + let t = await this.outOfAmmo(); //exit function return; } @@ -1710,6 +1683,56 @@ export class MothershipActor extends Actor { await game.dice3d.waitFor3DAnimationByMessageID(chatId); } + //central adding skill function | TAKES 'Body Save','1d10' | RETURNS player selected rollString. + async askReload(itemId) { + //wrap the whole thing in a promise, so that it waits for the form to be interacted with + return new Promise(async (resolve) => { + //create final dialog data + const dialogData = { + title: `Weapon Issue`, + content: `

Out of ammo, you need to reload.


`, + buttons: {} + }; + //add buttons + //Advantage + dialogData.buttons.roll = { + label: `Reload`, + callback: () => this.reloadWeapon(itemId), + icon: `` + }; + //Normal + dialogData.buttons.cancel = { + label: `Cancel`, + callback: () => { }, + icon: `` + }; + //render dialog + const dialog = new Dialog(dialogData).render(true); + }); + } + + //central adding skill function | TAKES 'Body Save','1d10' | RETURNS player selected rollString. + async outOfAmmo() { + //wrap the whole thing in a promise, so that it waits for the form to be interacted with + return new Promise(async (resolve) => { + //create final dialog data + const dialogData = { + title: `Weapon Issue`, + content: `

Out of ammo.


`, + buttons: {} + }; + //add buttons + //Ok + dialogData.buttons.cancel = { + label: `Ok`, + callback: () => { }, + icon: '' + }; + //render dialog + const dialog = new Dialog(dialogData).render(true); + }); + } + //reload weapon async reloadWeapon(itemId) { //init vars