Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.0.5 #8

Merged
merged 2 commits into from
Jul 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ Jun 25, 2022

## v0.0.4-ALPHA.0
Jul 23, 2022
* Refactor of all
* Refactor of all


## v0.0.5-BETA.0
Jul 30, 2022
* Initial release supporting PF2e system
* Right-click of fudge icon to globally pause/disable all fudges
* Config dialog UI improvements
* Notification to DMs when new version installed/upgraded
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/UranusBytes/foundry-die-hard) ![GitHub Releases](https://img.shields.io/github/downloads/UranusBytes/foundry-die-hard/latest/total) ![GitHub Releases](https://img.shields.io/github/downloads/UranusBytes/foundry-die-hard/total)

![Forge Installs](https://img.shields.io/badge/dynamic/json?label=Forge%20Installs&query=package.installs&suffix=%25&url=https%3A%2F%2Fforge-vtt.com%2Fapi%2Fbazaar%2Fpackage%2Ffoundry-die-hard&colorB=4aa94a) ![Foundry Version](https://img.shields.io/endpoint?url=https://foundryshields.com/version?url=https%3A%2F%2Fgithub.jparrowsec.cn%2FUranusBytes%2Ffoundry-die-hard%2Freleases%2Flatest%2Fdownload%2Fmodule.json)

Die Hard
========
This Foundry VTT module is intended to provide functionality that modifies/adjusted die rolls in certain systems.
Expand All @@ -14,20 +18,22 @@ Currently being (quasi) managed here: https://github.com/users/UranusBytes/proje

## Currently Supported Systems
* DND5e (current)

## Future Supported Systems
* PF2e

## Troubleshoot
Extensive logging is used within the module, with debug logging enabled with the package debugging enabled

## Known Issues
* Raw die rolls for actors not working (even if fudge defined on GM/Player)
* Actors throwing raw It's possible to define a fudge that is impossible to achieve (especially when considering modifiers. Or to define a fudge of "> 20" for a d20). The failsafe is attempting to fudge 150 times, at which point the closest possible is provided.
* It's possible to define a fudge that is impossible to achieve (especially when considering modifiers. Or to define a fudge of "> 20" for a d20). The failsafe is attempting to fudge 150 times, at which point the closest possible is provided.
* When the fudge config dialog is open, fudge status/list is not updated if any are changed by other GMs and/or PC/Actor rolls
* Completely incompatible with [Better Rolls for 5e](https://github.com/RedReign/FoundryVTT-BetterRolls5e) #6

## Currently Supported Functionality
### Fudge
# Current module Functionality
## Fudge
Allow the GM to influence die rolls

# Fudge
![die-hard-fudge](docs/die-hard-fudge.jpg)

With the module enabled, a poop icon will be displayed above the message tray.
Expand Down Expand Up @@ -67,6 +73,9 @@ The way Fudge works is that the next die roll of that type (either system specif



## Future Planned Functionality
### Karmic dice
# Future Planned Functionality
## Karmic dice
All for gradual adjustment/influence of player dice over time...

# Thanks
None of this module would be possible without the inspiration, and continued guidance/support/feedback, from @apoapostolov. Thank you!
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "foundry-die-hard",
"title": "Die Hard",
"description": "Adjustments for DND5e die rolls like fudging...",
"description": "Adjustments for DND5e & PF2e die rolls like fudging...",
"author": "Jeremy (UranusBytes)",
"version": "0.0.4",
"version": "0.0.5",
"minimumCoreVersion": "9",
"compatibleCoreVersion": "9",
"esmodules": [
Expand Down
9 changes: 0 additions & 9 deletions scripts/classes/DEPRECATED_DieHardFudge.js

This file was deleted.

45 changes: 45 additions & 0 deletions scripts/classes/DieHard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {dieHardLog, insertAfter} from "../lib/helpers.js";
import DieHardFudgeDialog from "./DieHardFudgeDialog.js";


export default class DieHard {

constructor() {
dieHardLog(true, 'DieHard - constructor');

// Setup default settings;

}

init() {
dieHardLog(true, 'DieHard - init');
}

static renderFudgeIcon() {
if (game.settings.get('foundry-die-hard', 'dieHardSettings').system == null) {
dieHardLog(false, 'Unsupported system for world; not rendering side bar')
return
}
dieHardLog(false, 'Render side bar')
let fudgeButton = document.createElement('label');
//fudgeButton.setAttribute('id', 'die-hard-fudge-icon');
fudgeButton.classList.add('die-hard-fudge-icon');
fudgeButton.innerHTML = '<div class="die-hard-pause-fudge-overlay"><i id="die-hard-pause-fudge-icon" class="fas fa-pause-circle"></i></div><i id="die-hard-fudge-icon" class="fas fa-poop"></i>';

fudgeButton.addEventListener("click", async (ev) => {
new DieHardFudgeDialog().render(true);
});
fudgeButton.addEventListener("contextmenu", async (ev) => {
game.settings.get('foundry-die-hard', 'dieHardSettings').system.disableAllFudges();
});

// ToDo: Fix this ugly hack
// the document object isn't existing sometimes yet, so just ignore. It'll eventually render
try {
//insertAfter(pauseButton, document.querySelector('.chat-control-icon'));
insertAfter(fudgeButton, document.querySelector('.chat-control-icon'));
game.settings.get('foundry-die-hard', 'dieHardSettings').system.refreshActiveFudgesIcon()
}
catch (e) { }
}
}
10 changes: 7 additions & 3 deletions scripts/classes/DieHardConfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {dieHardLog} from "../lib/helpers.js";
import {DieHardDnd5e} from "./DieHardDnd5e.js";
import DieHardDnd5e from "./DieHardDnd5e.js";
import DieHardPf2e from "./DieHardPf2e.js";

export default class DieHardConfig {
// static get defaultOptions() {
Expand Down Expand Up @@ -47,15 +48,18 @@ export default class DieHardConfig {
allActors: true
},
fudgeConfig: {
maxFudgeAttemptsPerRoll: 150
maxFudgeAttemptsPerRoll: 150,
globalDisable: false
},
gmFudges: []
};

if (game.system.id == 'dnd5e') {
dieHardLog(true, 'Configuring for dndn5e system')
dieHardSettings.system = new DieHardDnd5e;

} else if (game.system.id == 'pf2e') {
dieHardLog(true, 'Configuring for pf2e system')
dieHardSettings.system = new DieHardPf2e;
} else {
dieHardLog(true, 'Unsupport game system: ' + game.system.id)
}
Expand Down
45 changes: 32 additions & 13 deletions scripts/classes/DieHardDnd5e.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {dieHardLog} from "../lib/helpers.js";
import {DieHardSystem} from "./DieHardSystem.js";
import {DieHardFudgeD20Roll} from "./DieHardFudgeD20Roll.js";

export class DieHardDnd5e extends DieHardSystem{
import DieHardSystem from "./DieHardSystem.js";
import DieHardFudgeD20Roll from "./DieHardFudgeD20Roll.js";

export default class DieHardDnd5e extends DieHardSystem{
constructor() {
dieHardLog(false, 'DieHardDnd5e - constructor');
super();
Expand All @@ -19,6 +20,7 @@ export class DieHardDnd5e extends DieHardSystem{
// See notes in DieHardFudgeD20Roll
CONFIG.Dice.DieHardFudgeD20Roll = DieHardFudgeD20Roll;

this.rawRollClassName = "Roll"
this.fudgeWhatOptions = [
{
id: 'actorRollSkill',
Expand Down Expand Up @@ -187,11 +189,18 @@ export class DieHardDnd5e extends DieHardSystem{
if (fudgeIndex !== -1 && actorFudges[fudgeIndex].statusActive) {
dieHardLog(false, 'DieHardDnd5e.wrappedRoll - active actor fudge', actorFudges[fudgeIndex]);
foundry.utils.mergeObject(options, {data: {fudge: true, fudgeOperator: actorFudges[fudgeIndex].operator, fudgeOperatorValue: actorFudges[fudgeIndex].operatorValue, fudgeHow: actorFudges[fudgeIndex].howFormula }});
// Delete the fudge from the actor
let deletedFudge = actorFudges.splice(fudgeIndex,1)
game.actors.get(actorId).setFlag('foundry-die-hard', 'fudges', actorFudges);
// Check if still have active fudges;
this.refreshActiveFudgesIcon();
if (actorFudges[fudgeIndex].statusEndless) {
dieHardLog(false, 'DieHardSystem.wrappedRoll - fudge is endless');
} else {
// Disable the fudge
actorFudges[fudgeIndex].statusActive = false

// Delete the fudge from the actor
// let deletedFudge = actorFudges.splice(fudgeIndex, 1)
game.actors.get(actorId).setFlag('foundry-die-hard', 'fudges', actorFudges);
// Check if still have active fudges;
this.refreshActiveFudgesIcon();
}
}

// Check if user has an active fudge
Expand Down Expand Up @@ -220,31 +229,41 @@ export class DieHardDnd5e extends DieHardSystem{

actorRollSkill(wrapped, skillId, options={}) {
dieHardLog(false, 'DieHardDnd5e.actorRollSkill', this);
game.settings.get('foundry-die-hard', 'dieHardSettings').system.wrappedRoll(options, this.id, 'actorRollSkill')
if (!game.settings.get('foundry-die-hard', 'dieHardSettings').fudgeConfig.globalDisable) {
game.settings.get('foundry-die-hard', 'dieHardSettings').system.wrappedRoll(options, this.id, 'actorRollSkill')
}
wrapped(skillId, options);
}

actorRollAbilitySave(wrapped, abilityId, options={}) {
dieHardLog(false, 'DieHardDnd5e.actorRollAbilitySave', this);
game.settings.get('foundry-die-hard', 'dieHardSettings').system.wrappedRoll(options, this.id, 'actorRollAbilitySave')
if (!game.settings.get('foundry-die-hard', 'dieHardSettings').fudgeConfig.globalDisable) {
game.settings.get('foundry-die-hard', 'dieHardSettings').system.wrappedRoll(options, this.id, 'actorRollAbilitySave')
}
wrapped(abilityId, options);
}

actorRollAbilityTest(wrapped, abilityId, options={}) {
dieHardLog(false, 'DieHardDnd5e.actorRollAbilityTest', this);
game.settings.get('foundry-die-hard', 'dieHardSettings').system.wrappedRoll(options, this.id, 'actorRollAbilityTest')
if (!game.settings.get('foundry-die-hard', 'dieHardSettings').fudgeConfig.globalDisable) {
game.settings.get('foundry-die-hard', 'dieHardSettings').system.wrappedRoll(options, this.id, 'actorRollAbilityTest')
}
wrapped(abilityId, options);
}

actorRollDeathSave(wrapped, options={}) {
dieHardLog(false, 'DieHardDnd5e.actorRollDeathSave', this);
game.settings.get('foundry-die-hard', 'dieHardSettings').system.wrappedRoll(options, this.id, 'actorRollDeathSave')
if (!game.settings.get('foundry-die-hard', 'dieHardSettings').fudgeConfig.globalDisable) {
game.settings.get('foundry-die-hard', 'dieHardSettings').system.wrappedRoll(options, this.id, 'actorRollDeathSave')
}
wrapped(options);
}

entityRollAttack(wrapped, options={}) {
dieHardLog(false, 'DieHardDnd5e.entityRollAttack', this);
game.settings.get('foundry-die-hard', 'dieHardSettings').system.wrappedRoll(options, this.actor.id, 'entityRollAttack')
if (!game.settings.get('foundry-die-hard', 'dieHardSettings').fudgeConfig.globalDisable) {
game.settings.get('foundry-die-hard', 'dieHardSettings').system.wrappedRoll(options, this.actor.id, 'entityRollAttack')
}
wrapped(options);
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/classes/DieHardFudgeD20Roll.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Because this extends D20Roll, I could not find a clean way to import. I tried m
import D20Roll from '../../../../systems/dnd5e/module/dice/d20-roll.js'
import {dieHardLog} from "../lib/helpers.js";

export class DieHardFudgeD20Roll extends D20Roll {
export default class DieHardFudgeD20Roll extends D20Roll {
// This is a simple extension
constructor(formula, data, options) {
super(formula, data, options);
Expand Down
2 changes: 1 addition & 1 deletion scripts/classes/DieHardFudgeDialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {dieHardLog} from "../lib/helpers.js";

export class DieHardFudgeDialog extends FormApplication {
export default class DieHardFudgeDialog extends FormApplication {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ['form'],
Expand Down
2 changes: 1 addition & 1 deletion scripts/classes/DieHardFudgeRoll.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class DieHardFudgeRoll extends Roll {
export default class DieHardFudgeRoll extends Roll {
// This is a simple extension
constructor(formula, data, options) {
super(formula, data, options);
Expand Down
Loading