Skip to content

Commit

Permalink
Merge pull request #39 from elizeuangelo/main
Browse files Browse the repository at this point in the history
karma update + css + manifest + totalroll fix
  • Loading branch information
UranusBytes authored Jun 4, 2023
2 parents fad142f + c461fd9 commit 9c054ef
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 117 deletions.
74 changes: 38 additions & 36 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
{
"name": "foundry-die-hard",
"title": "Die Hard",
"description": "Adjustments for DND5e & PF2e die rolls like fudging...",
"author": "Jeremy (UranusBytes)",
"version": "0.1.0",
"minimumCoreVersion": "9",
"compatibleCoreVersion": "10.277",
"esmodules": [
"scripts/die-hard.js"
],
"styles": [
"styles/die-hard.css"
],
"dependencies": [
{
"name": "lib-wrapper",
"type": "module"
}
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "lang/en.json"
}
],
"flags": {
"fvttdevleague": {
"package-jam": 2022
}
},
"url": "https://github.com/UranusBytes/foundry-die-hard",
"manifest": "TBD",
"readme": "https://github.com/UranusBytes/foundry-die-hard/blob/main/README.md",
"changelog": "https://github.com/UranusBytes/foundry-die-hard/blob/main/CHANGELOG.md",
"download": "TBD"
"id": "foundry-die-hard",
"title": "Die Hard",
"description": "Adjustments for DND5e & PF2e die rolls like fudging...",
"author": "Jeremy (UranusBytes)",
"version": "0.1.0",
"esmodules": [
"scripts/die-hard.js"
],
"styles": [
"styles/die-hard.css"
],
"dependencies": [
{
"name": "lib-wrapper",
"type": "module"
}
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "lang/en.json"
}
],
"flags": {
"fvttdevleague": {
"package-jam": 2022
}
},
"compatibility": {
"minimum": 10,
"verified": "10.291"
},
"url": "https://github.com/UranusBytes/foundry-die-hard",
"manifest": "https://github.com/UranusBytes/foundry-die-hard/releases/latest/download/module.json",
"readme": "https://github.com/UranusBytes/foundry-die-hard/blob/main/README.md",
"changelog": "https://github.com/UranusBytes/foundry-die-hard/blob/main/CHANGELOG.md",
"download": "https://github.com/UranusBytes/foundry-die-hard/releases/download/0.1.0/module.zip"
}
56 changes: 31 additions & 25 deletions scripts/classes/DieHard.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ export default class DieHard {
static getDefaultSimpleKarmaSettings() {
return {
enabled: false,
history: 5,
threshold: 5,
floor: 5
history: 2,
threshold: 7,
floor: 13
}
}

static getAvgSimpleKarmaSettings() {
return {
enabled: false,
history: 5,
threshold: 5,
enabled: false,
history: 3,
threshold: 7,
nudge: 5
}
}
Expand Down Expand Up @@ -158,27 +158,33 @@ export default class DieHard {
config: false,
});

// Enables fudge
game.settings.register('foundry-die-hard', 'simpleKarmaSettings', {
name: 'Simple Karma Settings',
hint: 'Simple Karma Settings',
scope: 'world',
config: false,
default: DieHard.getDefaultSimpleKarmaSettings(),
type: Object
});

// Enables karma
game.settings.register('foundry-die-hard', 'avgKarmaSettings', {
name: 'Average Karma Settings',
hint: 'Average Karma Settings',
scope: 'world',
config: false,
default: DieHard.getAvgSimpleKarmaSettings(),
type: Object
});
// Simple Karma
game.settings.register('foundry-die-hard', 'simpleKarmaSettings', {
name: 'Simple Karma Settings',
hint: 'Simple Karma Settings',
scope: 'world',
config: false,
default: DieHard.getDefaultSimpleKarmaSettings(),
type: Object
});

// Average Karma
game.settings.register('foundry-die-hard', 'avgKarmaSettings', {
name: 'Average Karma Settings',
hint: 'Average Karma Settings',
scope: 'world',
config: false,
default: DieHard.getAvgSimpleKarmaSettings(),
type: Object
});

// Karma Who
game.settings.register('foundry-die-hard', 'karmaWho', {
scope: 'world',
config: false,
default: [],
type: Array
});
}

static async refreshDieHardStatus() {
Expand Down
2 changes: 1 addition & 1 deletion scripts/classes/DieHardDnd5e.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class DieHardDnd5e extends DieHardSystem{
this.dmToGm('DieHard-Fudge: Fudge not needed, but still wiped from actor...');
} else {
gen_new_result = true;
let dmMessage = "Fudge (" + result.data.fudgeHow + ") values:" + result.total;
let dmMessage = "Fudge (" + result.data.fudgeHow + ")\nValues:" + result.total;

// This is a safety to prevent endless loops from possibly sneaking in
let SafetyLoopIndex = game.settings.get('foundry-die-hard', 'dieHardSettings').fudgeConfig.maxFudgeAttemptsPerRoll;
Expand Down
16 changes: 11 additions & 5 deletions scripts/classes/DieHardKarmaDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export default class DieHardKarmaDialog extends FormApplication {
simpleKarma: DieHardSetting('simpleKarmaSettings'),
simpleKarmaPlayerStats: this.getkarmaPlayerStats('simpleKarma'),
avgKarma: DieHardSetting('avgKarmaSettings'),
avgKarmaPlayerStats: this.getkarmaPlayerStats('avgKarmaData')
avgKarmaPlayerStats: this.getkarmaPlayerStats('avgKarmaData'),
whoGmOptions: game.dieHardSystem.getFudgeWhoGmOptions(),
whoUserOptions: game.dieHardSystem.getFudgeWhoUserOptions(),
//whoActorOptions: game.dieHardSystem.getFudgeWhoActorOptions(),
};
dieHardLog(false, 'DieHardKarmaDialog.getData', dialogData)
return dialogData;
Expand Down Expand Up @@ -78,7 +81,7 @@ export default class DieHardKarmaDialog extends FormApplication {
}

async _updateObject(event, formData) {
dieHardLog(false, 'DieHardKarmaDialog._updateObject')
dieHardLog(false, 'DieHardKarmaDialog._updateObject');

if (formData.karmaSimpleEnabled && formData.karmaAvgEnabled) {
document.getElementById('karmaWarningHeader').style.display = '';
Expand All @@ -88,14 +91,17 @@ export default class DieHardKarmaDialog extends FormApplication {
document.getElementById('karmaWarningBody').style.display = 'none';
}

let originalKarmaSimpleSettings = game.settings.get('foundry-die-hard', 'simpleKarmaSettings')
const who = formData.karmaWho.filter(Boolean);
await game.settings.set('foundry-die-hard', 'karmaWho', who);

let originalKarmaSimpleSettings = DieHardSetting('simpleKarmaSettings');
let karmaSimpleSettings = {
enabled: formData.karmaSimpleEnabled,
history: formData.karmaSimpleHistory,
threshold: formData.karmaSimpleThreshold,
floor: formData.karmaSimpleFloor
}
await game.settings.set('foundry-die-hard', 'simpleKarmaSettings', karmaSimpleSettings)
await game.settings.set('foundry-die-hard', 'simpleKarmaSettings', karmaSimpleSettings);
if (formData.karmaSimpleEnabled) {
document.getElementById('divKarmaSimpleHistory').style.display = '';
document.getElementById('divKarmaSimpleThreshold').style.display = '';
Expand All @@ -108,7 +114,7 @@ export default class DieHardKarmaDialog extends FormApplication {
document.getElementById('divKarmaSimplePlayerStats').style.display = 'none';
}

let originalKarmaAvgSettings = game.settings.get('foundry-die-hard', 'avgKarmaSettings')
let originalKarmaAvgSettings = DieHardSetting('avgKarmaSettings');
let karmaAvgSettings = {
enabled: formData.karmaAvgEnabled,
history: formData.karmaAvgHistory,
Expand Down
29 changes: 15 additions & 14 deletions scripts/classes/DieHardPf2e.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import {dieHardLog} from "../lib/helpers.js";

import DieHardSystem from "./DieHardSystem.js";
import {DieHardSetting} from "./DieHard.js";
import { dieHardLog } from '../lib/helpers.js';
import DieHardSystem from './DieHardSystem.js';

export default class DieHardPf2e extends DieHardSystem {
constructor() {
dieHardLog(false, 'DieHardPf2e.constructor');
super();
constructor() {
dieHardLog(false, 'DieHardPf2e.constructor');
super();

this.totalRollClassName = ["CheckRoll", "StrikeAttackRoll"]
this.fudgeWhatOptions = []
}
this.totalRollClassName = [
"Roll",
"CheckRoll",
"StrikeAttackRoll",
];
this.fudgeWhatOptions = [];
}

hookReady() {
dieHardLog(false, 'PF2e System Hook - Ready');
}
hookReady() {
dieHardLog(false, 'PF2e System Hook - Ready');
}
}

Loading

0 comments on commit 9c054ef

Please sign in to comment.