diff --git a/lang/en.json b/lang/en.json
index 6373ea1..e0b4268 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -129,6 +129,8 @@
"BITD.RollFailurePositionControlled": "You falter. Press on by seizing a risky opportunity, or withdraw and try a different approach.",
"BITD.RollFailurePositionRisky": "Things go badly. You suffer harm a complication occurs, you end up in a desperate position, you lose this opportunity.",
"BITD.RollFailurePositionDesperate": "It’s the worst outcome. You suffer severe harm, a serious complication occurs, you lose this opportunity for action.",
+ "BITD.RollResistance": "You reduce or avoid the effects of the consequence (GM chooses).
Suffer {stress} stress.",
+ "BITD.RollResistanceCritical": "You reduce or avoid the effects of the consequence (GM chooses).
Clear 1 stress.",
"BITD.PositionControlled": "Controlled",
"BITD.PositionRisky": "Risky",
diff --git a/module/blades-actor.js b/module/blades-actor.js
index 0ae5776..ed3bf51 100644
--- a/module/blades-actor.js
+++ b/module/blades-actor.js
@@ -64,9 +64,7 @@ export class BladesActor extends Actor {
// const roll = new Roll("1d20 + @abilities.wis.mod", actor.getRollData());
let attribute_label = BladesHelpers.getAttributeLabel(attribute_name);
- new Dialog({
- title: `${game.i18n.localize('BITD.Roll')} ${game.i18n.localize(attribute_label)}`,
- content: `
+ var content = `
${game.i18n.localize('BITD.Roll')} ${game.i18n.localize(attribute_label)}
- `,
+ `;
+
+ new Dialog({
+ title: `${game.i18n.localize('BITD.Roll')} ${game.i18n.localize(attribute_label)}`,
+ content: content,
buttons: {
yes: {
icon: "",
diff --git a/module/blades-helpers.js b/module/blades-helpers.js
index cd977fb..0b11429 100644
--- a/module/blades-helpers.js
+++ b/module/blades-helpers.js
@@ -186,7 +186,6 @@ export class BladesHelpers {
* @returns {string}
*/
static getAttributeLabel(attribute_name) {
- // Calculate Dice to throw.
let attribute_labels = {};
const attributes = game.system.model.Actor.character.attributes;
@@ -200,6 +199,19 @@ export class BladesHelpers {
return attribute_labels[attribute_name];
}
+
+ /**
+ * Returns true if the attribute is an action
+ *
+ * @param {string} attribute_name
+ * @returns {bool}
+ */
+ static isAttributeAction(attribute_name) {
+ let attribute_labels = {};
+ const attributes = game.system.model.Actor.character.attributes;
+
+ return !(attribute_name in attributes);
+ }
/* -------------------------------------------- */
diff --git a/module/blades-roll.js b/module/blades-roll.js
index 0d24546..c40ac50 100644
--- a/module/blades-roll.js
+++ b/module/blades-roll.js
@@ -46,33 +46,40 @@ async function showChatRollMessage(r, zeromode, attribute_name = "", position =
// Retrieve Roll status.
let roll_status = getBladesRollStatus(rolls, zeromode);
- let position_localize = '';
- switch (position) {
- case 'controlled':
- position_localize = 'BITD.PositionControlled'
- break;
- case 'desperate':
- position_localize = 'BITD.PositionDesperate'
- break;
- case 'risky':
- default:
- position_localize = 'BITD.PositionRisky'
- }
+ let result;
+ if (BladesHelpers.isAttributeAction(attribute_name)) {
+ let position_localize = '';
+ switch (position) {
+ case 'controlled':
+ position_localize = 'BITD.PositionControlled'
+ break;
+ case 'desperate':
+ position_localize = 'BITD.PositionDesperate'
+ break;
+ case 'risky':
+ default:
+ position_localize = 'BITD.PositionRisky'
+ }
- let effect_localize = '';
- switch (effect) {
- case 'limited':
- effect_localize = 'BITD.EffectLimited'
- break;
- case 'great':
- effect_localize = 'BITD.EffectGreat'
- break;
- case 'standard':
- default:
- effect_localize = 'BITD.EffectStandard'
- }
+ let effect_localize = '';
+ switch (effect) {
+ case 'limited':
+ effect_localize = 'BITD.EffectLimited'
+ break;
+ case 'great':
+ effect_localize = 'BITD.EffectGreat'
+ break;
+ case 'standard':
+ default:
+ effect_localize = 'BITD.EffectStandard'
+ }
- let result = await renderTemplate("systems/blades-in-the-dark/templates/blades-roll.html", {rolls: rolls, roll_status: roll_status, attribute_label: attribute_label, position: position, position_localize: position_localize, effect: effect, effect_localize: effect_localize});
+ result = await renderTemplate("systems/blades-in-the-dark/templates/chat/action-roll.html", {rolls: rolls, roll_status: roll_status, attribute_label: attribute_label, position: position, position_localize: position_localize, effect: effect, effect_localize: effect_localize});
+ } else {
+ let stress = getBladesRollStress(rolls, zeromode);
+
+ result = await renderTemplate("systems/blades-in-the-dark/templates/chat/resistance-roll.html", {rolls: rolls, roll_status: roll_status, attribute_label: attribute_label, stress: stress});
+ }
let messageData = {
speaker: speaker,
@@ -151,6 +158,57 @@ export function getBladesRollStatus(rolls, zeromode = false) {
return roll_status;
}
+/**
+ * Get stress of the Roll.
+ * @param {Array} rolls
+ * @param {Boolean} zeromode
+ */
+export function getBladesRollStress(rolls, zeromode = false) {
+
+ var stress = 6;
+
+ // Dice API has changed in 0.7.0 so need to keep that in mind.
+ let isBelow070 = isNewerVersion('0.7.0', game.data.version);
+
+ let sorted_rolls = [];
+ // Sort roll values from lowest to highest.
+ if (isBelow070) {
+ sorted_rolls = rolls.map(i => i.roll).sort();
+ } else {
+ sorted_rolls = rolls.map(i => i.result).sort();
+ }
+
+ let roll_status = "failure"
+
+ if (sorted_rolls[0] === 6 && zeromode) {
+ stress = -1;
+ }
+ else {
+ let use_die;
+ let prev_use_die = false;
+
+ if (zeromode) {
+ use_die = sorted_rolls[0];
+ }
+ else {
+ use_die = sorted_rolls[sorted_rolls.length - 1];
+
+ if (sorted_rolls.length - 2 >= 0) {
+ prev_use_die = sorted_rolls[sorted_rolls.length - 2]
+ }
+ }
+
+ if (use_die === 6 && prev_use_die && prev_use_die === 6) {
+ stress = -1;
+ } else {
+ stress = 6 - use_die;
+ }
+
+ }
+
+ return stress;
+
+}
/**
diff --git a/module/blades.js b/module/blades.js
index 6f8528f..84a1846 100644
--- a/module/blades.js
+++ b/module/blades.js
@@ -29,10 +29,6 @@ Hooks.once("init", async function() {
dice: bladesRoll
}
- // Define Roll template.
- // CONFIG.Dice.template = "systems/blades-in-the-dark/templates/blades-roll.html"
- // CONFIG.Dice.tooltip = "systems/blades-in-the-dark/templates/blades-roll-tooltip.html"
-
CONFIG.Item.entityClass = BladesItem;
CONFIG.Actor.entityClass = BladesActor;
diff --git a/templates/blades-roll.html b/templates/chat/action-roll.html
similarity index 100%
rename from templates/blades-roll.html
rename to templates/chat/action-roll.html
diff --git a/templates/chat/resistance-roll.html b/templates/chat/resistance-roll.html
new file mode 100644
index 0000000..a779552
--- /dev/null
+++ b/templates/chat/resistance-roll.html
@@ -0,0 +1,23 @@
+