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.7 #18

Merged
merged 8 commits into from
Aug 1, 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
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,14 @@ Jul 30, 2022
## v0.0.6
Jul 30, 2022
* Fix attack/strike roll fudges for PF2e
* Add concept of "Total Roll" (including modifiers) vs "Raw Die Roll" (only the die)
* Add concept of "Total Roll" (including modifiers) vs "Raw Die Roll" (only the die)

## v0.0.7
Aug 1, 2022
* Remove 'Times' functionality from fudge
* Fix for raw die fudge still happening when global disabled
* Issue where disabled fudge before enabled would prevent selection of enabled
* Change fudge icon behavior for global disabled
* Fudge icon adjustments #14
* Fudge config adjustments #15
* Fix fudge whispers going to more than GM #16
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "Die Hard",
"description": "Adjustments for DND5e & PF2e die rolls like fudging...",
"author": "Jeremy (UranusBytes)",
"version": "0.0.6",
"version": "0.0.7",
"minimumCoreVersion": "9",
"compatibleCoreVersion": "9",
"esmodules": [
Expand Down
3 changes: 2 additions & 1 deletion scripts/classes/DieHard.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default class DieHard {
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.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.innerHTML = '<span title="Fudge Paused"><i id="die-hard-pause-fudge-icon" class="fas fa-pause-circle die-hard-icon-hidden"></i></span><span title="Fudge"><i id="die-hard-fudge-icon" class="fas fa-poop"></i></span>';

fudgeButton.addEventListener("click", async (ev) => {
new DieHardFudgeDialog().render(true);
Expand Down
8 changes: 4 additions & 4 deletions scripts/classes/DieHardDnd5e.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ export default class DieHardDnd5e extends DieHardSystem{
actorFudges = []
}
dieHardLog(false, functionLogName + ' - actorFudges', actorFudges);
let fudgeIndex = actorFudges.findIndex(element => { return element.whatId === rollType;});
if (fudgeIndex !== -1 && actorFudges[fudgeIndex].statusActive) {
let fudgeIndex = actorFudges.findIndex(element => { return ((element.whatId === rollType) && (element.statusActive));});
if (fudgeIndex !== -1) {
dieHardLog(false, functionLogName + ' - active actor fudge', actorFudges[fudgeIndex]);
foundry.utils.mergeObject(options, {data: {fudge: true, fudgeOperator: actorFudges[fudgeIndex].operator, fudgeOperatorValue: actorFudges[fudgeIndex].operatorValue, fudgeHow: actorFudges[fudgeIndex].howFormula }});
if (actorFudges[fudgeIndex].statusEndless) {
Expand All @@ -205,8 +205,8 @@ export default class DieHardDnd5e extends DieHardSystem{
userFudges = []
}
dieHardLog(false, functionLogName + ' - userFudges', userFudges);
fudgeIndex = userFudges.findIndex(element => { return element.whatId === rollType;});
if (fudgeIndex !== -1 && userFudges[fudgeIndex].statusActive) {
fudgeIndex = userFudges.findIndex(element => { return ((element.whatId === rollType) && (element.statusActive));});
if (fudgeIndex !== -1) {
dieHardLog(false, functionLogName + ' - active user fudge', userFudges[fudgeIndex]);
foundry.utils.mergeObject(options, {data: {fudge: true, fudgeOperator: userFudges[fudgeIndex].operator, fudgeOperatorValue: userFudges[fudgeIndex].operatorValue, fudgeHow: userFudges[fudgeIndex].howFormula }});
if (userFudges[fudgeIndex].statusEndless) {
Expand Down
2 changes: 2 additions & 0 deletions scripts/classes/DieHardFudgeDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ export default class DieHardFudgeDialog extends FormApplication {
}

let fudgeTimes = 1;
/*
if (Number.isInteger(Number.parseInt(formData.fudgeTimes))) {
fudgeTimes = Number.parseInt(formData.fudgeTimes);
}
*/

try {
for (let loopIndex = 0; loopIndex < fudgeTimes; loopIndex++) {
Expand Down
4 changes: 4 additions & 0 deletions scripts/classes/DieHardPf2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ export default class DieHardPf2e extends DieHardSystem {
/**
* Generic wrapper for all PF2e Check rolls
*/

// Currently not used, since can't find way to intercept lower level roll
/*
wrappedCheckRoll(wrapped, check, context, event, callback) {
dieHardLog(true, 'DieHardPf2e.wrappedCheckRoll - this', this);
dieHardLog(true, 'DieHardPf2e.wrappedCheckRoll - arguments.length', arguments.length);
Expand Down Expand Up @@ -251,6 +254,7 @@ export default class DieHardPf2e extends DieHardSystem {
let result = wrapped(check, context, event, callback);
dieHardLog(false, 'DieHardPf2e.wrappedCheckRoll - result', result);
}
*/

/*
actorRollSave(wrapped, skillId, options = {}) {
Expand Down
52 changes: 42 additions & 10 deletions scripts/classes/DieHardSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,19 @@ export default class DieHardSystem{
dieHardLog(false, functionLogName + ' - this', this);
dieHardLog(false, functionLogName + ' - eval_options', eval_options);

if (game.settings.get('foundry-die-hard', 'dieHardSettings').fudgeConfig.globalDisable) {
dieHardLog(true, functionLogName + ' - Globally disabled', game.settings.get('foundry-die-hard', 'dieHardSettings').fudgeConfig.globalDisable);
// Globally disabled
return wrapped(eval_options)
}

// Check if user has an active raw fudge
let userFudges = game.users.current.getFlag('foundry-die-hard', 'fudges');
if (! Array.isArray(userFudges)) {
userFudges = []
}
let fudgeIndex = userFudges.findIndex(element => { return element.whatId === ('rawd' + this.faces);});
if (fudgeIndex !== -1 && userFudges[fudgeIndex].statusActive) {
let fudgeIndex = userFudges.findIndex(element => { return ((element.whatId === ('rawd' + this.faces)) && (element.statusActive));});
if (fudgeIndex !== -1) {
dieHardLog(false, functionLogName + ' - active user raw fudge', userFudges[fudgeIndex]);

// Time to make the fudge
Expand Down Expand Up @@ -202,18 +208,38 @@ export default class DieHardSystem{
continue;
}

dieHardLog(false, functionLogName + ' - DEBUG POINT');
// Check if actor has an active total fudge
// ToDo: something goes here... #6
/*
// Check if actor has an active fudge
let actorFudges = game.actors.get(actorId).getFlag('foundry-die-hard', 'fudges');
if (! Array.isArray(actorFudges)) {
actorFudges = []
}
//dieHardLog(false, 'DieHardDnd5e.wrappedRoll - actorFudges', actorFudges);
let fudgeIndex = actorFudges.findIndex(element => { return element.whatId === rollType;});
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();
}

*/

// Check if user has an active total fudge
let userFudges = game.users.current.getFlag('foundry-die-hard', 'fudges');
if (! Array.isArray(userFudges)) {
userFudges = []
}

let fudgeIndex = userFudges.findIndex(element => { return element.whatId === ('totald' + this.dice[die].faces);});
let fudgeIndex = userFudges.findIndex(element => { return ((element.whatId === ('totald' + this.dice[die].faces)) && (element.statusActive));});
dieHardLog(false, functionLogName + ' - dice faces', this.dice[die].faces);
if (fudgeIndex !== -1 && userFudges[fudgeIndex].statusActive) {
if (fudgeIndex !== -1) {
dieHardLog(false, functionLogName + ' - active user total fudge', userFudges[fudgeIndex]);
foundry.utils.mergeObject(this, {data: {fudge: true, fudgeOperator: userFudges[fudgeIndex].operator, fudgeOperatorValue: userFudges[fudgeIndex].operatorValue, fudgeHow: userFudges[fudgeIndex].howFormula }});

Expand Down Expand Up @@ -314,13 +340,18 @@ export default class DieHardSystem{

dmToGm(message) {
var dm_ids = [];
for (let indexA = 0; indexA < game.users.length; indexA++) {
if (game.users[indexA].value.isGM) {
dm_ids.push(game.users[indexA].key)
// dieHardLog(false, 'DieHardSystem.dmToGm - game.users.values()', game.users.values());
for (let user of game.users.values()) {
// dieHardLog(false, 'DieHardSystem.dmToGm - user', user);
if (user.isGM) {
dm_ids.push(user.id)
// dieHardLog(false, 'DieHardSystem.dmToGm - Added', user);
}
}
// dieHardLog(false, 'DieHardSystem.dmToGm - dm_ids', dm_ids);
let whisper_to_dm = ChatMessage.create({
user: game.user.id,
type: CONST.CHAT_MESSAGE_TYPES.WHISPER,
whisper: dm_ids,
blind: true,
content: message
Expand Down Expand Up @@ -431,11 +462,12 @@ export default class DieHardSystem{

async refreshActiveFudgesIcon() {
if (game.settings.get('foundry-die-hard', 'dieHardSettings').fudgeConfig.globalDisable) {
document.getElementById('die-hard-pause-fudge-icon').classList.remove("die-hard-fudge-pause-icon-hidden");
document.getElementById('die-hard-fudge-icon').classList.remove("die-hard-fudge-icon-active");
document.getElementById('die-hard-pause-fudge-icon').classList.remove("die-hard-icon-hidden");
document.getElementById('die-hard-fudge-icon').classList.add("die-hard-icon-hidden");
return;
} else {
document.getElementById('die-hard-pause-fudge-icon').classList.add("die-hard-fudge-pause-icon-hidden");
document.getElementById('die-hard-pause-fudge-icon').classList.add("die-hard-icon-hidden");
document.getElementById('die-hard-fudge-icon').classList.remove("die-hard-icon-hidden");
}
if (this.hasActiveFudges()) {
document.getElementById('die-hard-fudge-icon').classList.add("die-hard-fudge-icon-active");
Expand Down
18 changes: 13 additions & 5 deletions styles/die-hard.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,26 @@ Inspiration/plagarism from https://gitlab.com/asacolips-projects/foundry-mods/fo
z-index: 99999999;
position: absolute;
}
#chat-controls .die-hard-fudge-pause-icon-hidden {
visibility: hidden;
#chat-controls .die-hard-icon-hidden {
display: none;
}
#chat-controls #die-hard-pause-fudge-icon {
flex: 0 0 0;
padding-left: 2px;
padding-left: 0px;
color: #FFA500;
}
.die-hard-status-button {
margin-right: 5px;
margin-left: 5px;
}
#chat-controls .die-hard-fudge-icon-active {
color: #FFA500;
/*
animation-name: fudge-icon-color;
animation-duration: 2s;
animation-iteration-count: infinite;

*/
}


Expand Down Expand Up @@ -125,7 +133,7 @@ div.die-hard-form-group {
cursor: pointer;
text-align:center;
}

/*
@keyframes fudge-icon-color {
0% {
color: #FFFFFF;
Expand All @@ -137,7 +145,7 @@ div.die-hard-form-group {
color: #FFFFFF;
}
}

*/
.die-hard-form-error {
animation-name: die-hard-form-error-color;
animation-duration: 1s;
Expand Down
17 changes: 8 additions & 9 deletions templates/die-hard-fudge-config.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ <h3 class="form-header" id="fudgeHowHeader"><span style="font-weight: bold;">RUL
<label for="fudge-formula">Formula:</label>
<input type="text" class="form-control die-hard-column-input-formula" name="fudgeFormula" id="fudgeFormula" value="> 15">
<i class="fas fa-question-circle fudge-help-formula" style="margin-left:5px"></i>
<!--
<label for="fudge-formula">Times:</label>
<input type="text" class="form-control die-hard-column-input-times" name="fudgeTimes" id="fudgeTimes">
<i class="fas fa-question-circle fudge-help-times" style="margin-left:5px"></i>
-->
</div>

<div style="height:15px"></div>
Expand All @@ -89,9 +91,7 @@ <h3 class="form-header">Active Fudges</h3>
<th>|</th>
<th>Rule</th>
<th>|</th>
<th>Status</th>
<th>|</th>
<th colspan="2">Actions</th>
<th colspan="3">Status</th>
</tr>
</thead>
<tbody id="activeFudges">
Expand All @@ -105,17 +105,16 @@ <h3 class="form-header">Active Fudges</h3>
<th>|</th>
<td class="toggle-fudge" data-who="{{ whoId }}" data-fudge="{{ id }}">
{{#if statusActive}}
<i class="fas fa-toggle-on" title="Enabled" style="color:green"></i>
<i class="fas fa-toggle-on die-hard-status-button" title="Enabled" style="color:green"></i>
{{else}}
<i class="fas fa-toggle-off" title="Disabled" style="color:red"></i>
<i class="fas fa-toggle-off die-hard-status-button" title="Disabled" style="color:red"></i>
{{/if}}
</td>
<th>|</th>
<td class="endless-fudge" data-who="{{ whoId }}" data-fudge="{{ id }}">
{{#if statusEndless}}
<i class="fas fa-retweet endless-fudge-enabled" title="Persistent Mode On"></i>
<i class="fas fa-retweet endless-fudge-enabled die-hard-status-button" title="Persistent Mode On"></i>
{{else}}
<i class="fas fa-retweet" title="Persistent Mode Off"></i>
<i class="fas fa-retweet die-hard-status-button" title="Persistent Mode Off"></i>
{{/if}}
<!--
fas fa-recycle
Expand All @@ -130,7 +129,7 @@ <h3 class="form-header">Active Fudges</h3>
<i class="fas fa-pause-circle"></i>
<i class="fas fa-play-circle"></i>
-->
<i class="fas fa-trash-alt" title="Delete"></i>
<i class="fas fa-trash-alt die-hard-status-button" title="Delete"></i>
<!--
<i class="fas fa-trash-alt" title="Delete"></i>
-->
Expand Down