Skip to content

Commit

Permalink
Added Settings to allow Alt settigns for Bad Rolls
Browse files Browse the repository at this point in the history
  • Loading branch information
ChasarooniZ committed Feb 29, 2024
1 parent 7d7a029 commit e6e10af
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 6 deletions.
13 changes: 12 additions & 1 deletion languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
"name": "Enable Module",
"hint": "Enables functionality of module"
},
"harmful-options": {
"name": "Harmful +1s Mattering",
"hint": "How to handle when a +1 matters in a bad way (IE helps an enemy or neutral party)",
"choices": {
"normal": "Treat Normally",
"none": "Don't Show",
"alt-sound": "Use alt. Sound",
"alt-image": "Use alt. Pop Up",
"alt-sound-image": "use alt. Sound & Pop Up"
}
},
"position": {
"name": "Enable Module",
"hint": "Enables functionality of module",
Expand Down Expand Up @@ -49,7 +60,7 @@
},
"delay": {
"name": "Delay",
"hint": "How long to delay after the chat message appears before showing the effect"
"hint": "How long to delay after the chat message appears before showing the effect in seconds"
},
"scale": {
"name": "Scale",
Expand Down
Binary file added resources/+1matters-evil.webm
Binary file not shown.
Binary file added resources/evil-rules-lawyer-sfx-reverb.ogg
Binary file not shown.
41 changes: 37 additions & 4 deletions scripts/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,35 @@ Hooks.once('ready', function () {
Hooks.on('modifiersMatter', (data) => {
//console.log({ modifiers: data })
if (!game.settings.get("pf2e-rules-lawyer", "enabled")) return;
debugLog(data)
const harmHelp = isHelpfulOrHarmful(data);
debugLog({ data, harmHelp })
let vidFile = 'modules/pf2e-rules-lawyer/resources/+1matters.webm';
let sfxFile = 'modules/pf2e-rules-lawyer/resources/rules-lawyer-sfx.ogg';
if (harmHelp === "HARMFUL") {
const harmful_option = game.settings.get("pf2e-rules-lawyer", "harmful-option");
switch (harmful_option) {
case 'none':
return;
case 'normal':
break;
case 'alt-sound':
sfxFile = 'modules/pf2e-rules-lawyer/resources/evil-rules-lawyer-sfx-reverb.ogg'
break;
case 'alt-image':
vidFile = 'modules/pf2e-rules-lawyer/resources/+1matters-evil.webm';
break;
case 'alt-sound-image':
vidFile = 'modules/pf2e-rules-lawyer/resources/+1matters-evil.webm';
sfxFile = 'modules/pf2e-rules-lawyer/resources/evil-rules-lawyer-sfx-reverb.ogg'
break;
default:
return;
}
}
const position = game.settings.get("pf2e-rules-lawyer", "position");
const anchor = getAnchor(position);
const uiOffset = getUIOffset(position)
const offset = getBaseOffset(position);
const vidFile = 'modules/pf2e-rules-lawyer/resources/+1matters.webm';
const sfxFile = 'modules/pf2e-rules-lawyer/resources/rules-lawyer-sfx.ogg';
const volume = game.settings.get("pf2e-rules-lawyer", "volume") / 100;
const worldXOffset = game.settings.get("pf2e-rules-lawyer", "offset.x");
const worldYOffset = game.settings.get("pf2e-rules-lawyer", "offset.y");
Expand Down Expand Up @@ -92,7 +114,18 @@ function getBaseOffset(position) {
}
}

function isHelpfulOrHarmful(data) {
const relevantSignificance = [];
const isRollerGood = data.rollingActor.alliance === "party";
const isDCGood = data.actorWithDc.alliance === "party";
if (isRollerGood)
relevantSignificance.push("ESSENTIAL")
if (isDCGood)
relevantSignificance.push("HARMFUL")
return data.significantModifiers.some(mod => relevantSignificance.includes(mod.significance)) ? "HELPFUL" : "HARMFUL"
}

export function debugLog(data, context = "") {
if (game.settings.get("pf2e-rules-lawyer", 'debug'))
console.log(`PF2E-Rules-Lawyer${context || "[" + context + "]"}:`, data);
console.log(`PF2E-Rules-Lawyer${context ? "[" + context + "]" : ""}:`, data);
}
29 changes: 28 additions & 1 deletion scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ Hooks.on("init", () => {
type: Boolean,
});


game.settings.register("pf2e-rules-lawyer", "harmful-options", {
name: game.i18n.localize("pf2e-rules-lawyer.module-settings.harmful-options.name"),
hint: game.i18n.localize("pf2e-rules-lawyer.module-settings.harmful-options.hint"),
scope: "world",
config: true,
default: "bot-right",
type: String,
choices: {
["normal"]: game.i18n.localize("pf2e-rules-lawyer.module-settings.harmful-options.choices.normal"),
["none"]: game.i18n.localize("pf2e-rules-lawyer.module-settings.harmful-options.choices.none"),
["alt-sound"]: game.i18n.localize("pf2e-rules-lawyer.module-settings.harmful-options.choices.alt-sound"),
["alt-image"]: game.i18n.localize("pf2e-rules-lawyer.module-settings.harmful-options.choices.alt-image"),
["alt-sound-image"]: game.i18n.localize("pf2e-rules-lawyer.module-settings.harmful-options.choices.alt-sound-image"),
}
});

game.settings.register("pf2e-rules-lawyer", "offset.x", {
name: game.i18n.localize("pf2e-rules-lawyer.module-settings.offset.x.name"),
hint: game.i18n.localize("pf2e-rules-lawyer.module-settings.offset.x.hint"),
Expand Down Expand Up @@ -84,7 +101,12 @@ Hooks.on("init", () => {
hint: game.i18n.localize("pf2e-rules-lawyer.module-settings.delay.hint"),
scope: "world",
config: true,
default: 2,
default: 1,
range: {
min: 0,
max: 10,
step: 0.1
},
type: Number,
});

Expand All @@ -94,6 +116,11 @@ Hooks.on("init", () => {
scope: "world",
config: true,
default: 5,
range: {
min: 0,
max: 10,
step: 0.1
},
type: Number,
});

Expand Down

0 comments on commit e6e10af

Please sign in to comment.