diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js
index 0687df0..f18410b 100644
--- a/module/actor/actor-sheet.js
+++ b/module/actor/actor-sheet.js
@@ -304,31 +304,23 @@ export class MothershipActorSheet extends ActorSheet {
weapon.sheet.render(true);
});
-
+ // Rollable Attribute
html.find('.stat-roll').click(ev => {
const div = $(ev.currentTarget);
const statName = div.data("key");
- const attribute = this.actor.system.stats[statName];
- var shifted = false;
- if (ev.shiftKey) shifted = true;
- this.actor.rollStat(attribute, shifted);
+ this.actor.rollCheck(null,'low',statName,null,null);
});
// Rollable Skill
html.find('.skill-roll').click(ev => {
const li = event.currentTarget.closest(".item");
- this.actor.rollSkill(li.dataset.itemId, {
- event: event
- });
+ this.actor.rollCheck(null,null,null,li.dataset.itemId,null);
});
// Rollable Weapon
html.find('.weapon-roll').click(ev => {
const li = ev.currentTarget.closest(".item");
-
- this.actor.rollWeapon(li.dataset.itemId, {
- event: ev
- });
+ this.actor.rollCheck(null,'low','combat',null,li.dataset.itemId);
});
// Rollable Item/Anything with a description that we want to click on.
@@ -339,11 +331,11 @@ export class MothershipActorSheet extends ActorSheet {
});
});
+ //increase ammo
html.on('mousedown', '.weapon-ammo', ev => {
const li = ev.currentTarget.closest(".item");
const item = duplicate(this.actor.getEmbeddedDocument("Item", li.dataset.itemId))
let amount = item.system.ammo;
-
if (event.button == 0) {
if (amount >= 0) {
item.system.ammo = Number(amount) + 1;
@@ -353,35 +345,13 @@ export class MothershipActorSheet extends ActorSheet {
item.system.ammo = Number(amount) - 1;
}
}
-
this.actor.updateEmbeddedDocuments('Item', [item]);
});
//Reload Shots
html.on('mousedown', '.weapon-reload', ev => {
const li = ev.currentTarget.closest(".item");
- const item = duplicate(this.actor.getEmbeddedDocument("Item", li.dataset.itemId))
-
- if (!item.system.useAmmo) {
- item.system.curShots = item.system.shots;
- } else {
- item.system.ammo += item.system.curShots;
- let reloadAmount = Math.min(item.system.ammo, item.system.shots);
- item.system.curShots = reloadAmount;
-
- item.system.ammo -= reloadAmount;
- }
-
- this.actor.updateEmbeddedDocuments('Item', [item]);
-
- let actor = this.actor;
- let speaker = ChatMessage.getSpeaker({ actor });
- ChatMessage.create({
- speaker,
- content: `Reloading ` + item.name + "..."
- },
- { chatBubble: true });
-
+ this.actor.reloadWeapon(li.dataset.itemId);
});
// Rollable Item/Anything with a description that we want to click on.
@@ -390,6 +360,7 @@ export class MothershipActorSheet extends ActorSheet {
attribute.label = "Calm";
this.actor.rollStress(attribute);
});
+
// Rollable Item/Anything with a description that we want to click on.
html.find('.stress-roll').click(ev => {
//roll hotbar macro for stress
diff --git a/module/actor/actor.js b/module/actor/actor.js
index 8e256b2..9d82bb2 100644
--- a/module/actor/actor.js
+++ b/module/actor/actor.js
@@ -240,7 +240,6 @@ export class MothershipActor extends Actor {
}
//central roll parsing function | TAKES rollResult: [Foundry roll object], zeroBased: true, checkCrit: true, rollTarget: 41 | RETURNS enriched Foundry roll object
- //IN PROGRESS, still translating from macro
parseRollResult(rollString,rollResult,zeroBased,checkCrit,rollTarget,comparison) {
//init vars
let doubles = new Set([0, 11, 22, 33, 44, 55, 66, 77, 88, 99]);
@@ -541,223 +540,328 @@ export class MothershipActor extends Actor {
await game.dice3d.waitFor3DAnimationByMessageID(chatId);
}
-
-
-/* rollStatSelect(statList) { //REMOVEME? candidate for removal
-
- let selectList = "";
-
- statList.forEach(stat => selectList += "")
- statList.forEach(stat => console.log(stat[0]));
-
- console.log(statList);
-
- let d = new Dialog({
- title: "Select Roll Type",
- content: "
Stat
",
+ //central adding addribute function | TAKES skill | RETURNS player selected attribute
+ chooseAttribute(rollString,aimFor,attribute,skill,weapon) {
+ //open dialog asking player to choose a core stat
+ new Dialog({
+ title: `Choose a Stat`,
+ content: `
+
+
+
Select a Stat
Choose the Stat that best suits the nature of this Skill Check. You will add your skill bonus to the Stat value for this roll (giving you a higher number to roll under).
",
- buttons: {
- cancel: {
- icon: '',
- label: "Cancel",
- callback: () => { }
- }
- },
- default: "roll",
- close: () => { }
- });
- t.render(true);
- }
-
- // let actor = this;
- // let speaker = ChatMessage.getSpeaker({ actor });
- // ChatMessage.create({
- // speaker,
- // content: item.system.ammo > 0 ? `I need to reload my ` + item.name + "!" : "I'm out of ammo!",
- // type: CHAT_MESSAGE_TYPES.EMOTE
- // },
- // { chatBubble: true });
- return;
+ button3: {
+ label: `Disadvantage`,
+ callback: (html) => this.rollCheck(`1d100 [-]`,`low`,html.find("input[name='stat']:checked").attr("value"),skill,weapon),
+ icon: ``
}
}
- }
+ },{width: 600,height: 475}).render(true);
+ }
+ //central adding skill function | TAKES nothing | RETURNS player selected skill
+ chooseSkill(rollString,aimFor,attribute,skill,weapon) {
+ //get list of player skills
+ let playerItems = this.items;
+ //create header for skill list
+ let skillHeader = `
+
+
+
Add a Skill?
If you have a Skill that is relevant to the task at hand, you can add the Skill’s bonus to your Stat or Save before making your roll (giving you a higher number to roll under).
+
`;
+ //create footer for skill list
+ const skillFooter = `
Select your roll type:
`;
+ //create template for skill row
+ const skillRow = `
+ `;
+ //create skillList string
+ let skillList = ``;
+ //create skill counter
+ let skillCount = 0;
+ //create dialog pixel counter
+ let dialogHeight = 192;
+ //loop through and create skill rows
+ for (let item of playerItems) {
+ //check if this is a skill
+ if (item.type === "skill") {
+ //set temprow as template
+ let tempRow = skillRow;
+ //replace ID
+ tempRow = tempRow.replaceAll("[RADIO_ID]",item.name);
+ //replace value
+ tempRow = tempRow.replace("[RADIO_VALUE]",item.system.bonus);
+ //replace img
+ tempRow = tempRow.replace("[RADIO_IMG]",item.img);
+ //replace name
+ tempRow = tempRow.replace("[RADIO_NAME]",item.name);
+ //replace desc
+ tempRow = tempRow.replace("[RADIO_DESC]",item.system.description.replace("
","
: "));
+ //add to skillList
+ skillList = skillList + tempRow;
+ //increment skill count
+ skillCount++;
+ //increment pixel counter
+ dialogHeight = dialogHeight + 77;
+ }
+ }
+ //check if there are no skills, and adjust prompt accordingly
+ if (skillCount === 0) {
+ //set window height
+ dialogHeight = 105;
+ //make skill header blank
+ skillHeader = ``;
+ }
+ //make content string
+ let skillHtml = skillHeader + skillList + skillFooter;
+ //make window setting
+ let dlgTitle = '';
+ if (attribute === 'sanity' || attribute === 'fear' || attribute === 'body') {
+ dlgTitle = `Save`;
+ } else if (weapon) {
+ dlgTitle = `Attack`;
+ } else {
+ dlgTitle = `Stat Check`;
+ }
//Select the stat of the roll.
- let t = new Dialog({
- title: "Select Stat",
- content: "