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

Confirm delete #179

Merged
merged 7 commits into from
Feb 14, 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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## Version 0.2.62
- Fixed issue with numbers not being strings, again. [merge](https://github.com/EndlesNights/dnd4eBeta/pull/168) from [draconas1](https://github.com/draconas1) authors note, "I hate javascript"
- Update to Steve the Example Character [merge](https://github.com/EndlesNights/dnd4eBeta/pull/164) from [draconas1](https://github.com/draconas1)
Now has a close burst 1 AoE power that uses an implment
has an example ritual that can summon badgers
Feat that adds to fire attack and damage powers
Updated fighter weapon talents to have an effect to boost that attack.
- Added Hooks for Token Action HUD [merge](https://github.com/EndlesNights/dnd4eBeta/pull/163) from [draconas1](https://github.com/draconas1)
- custom movement types will now show up in the tooltip when mouse hovering over movement
- Some more tinkering around with the NPC sheet
added rest buttons
added a field to see temporary HP
custom movement types will now appear directly on the sheet
other minor edits to the CSS styles

## Version 0.2.61
- removed the default miss formula and effects [merge](https://github.com/EndlesNights/dnd4eBeta/pull/162) from [draconas1](https://github.com/draconas1)

## Version 0.2.60
- fix implement groupings [merge](https://github.com/EndlesNights/dnd4eBeta/pull/159) from [draconas1](https://github.com/draconas1)
- fixed issue with NPC initiative calculation check.... again...
Expand Down
Binary file modified dnd4e.zip
Binary file not shown.
15 changes: 13 additions & 2 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"DND4EBETA.AlignmentNE": "Neutral Evil",
"DND4EBETA.AlignmentNG": "Neutral Good",
"DND4EBETA.AlignmentTN": "True Neutral",
"DND4EBETA.AlignmentUN": "Unaligned",
"DND4EBETA.AnyW": "Any Weapon",
"DND4EBETA.Arcane": "Arcane",
"DND4EBETA.AreaOf": "of",
Expand Down Expand Up @@ -280,6 +281,8 @@
"DND4EBETA.DefRef": "Ref",
"DND4EBETA.DefWil": "Will",
"DND4EBETA.Deity": "Deity",
"DND4EBETA.DeleteConfirmTitle": "Confirm Delete of {name}",
"DND4EBETA.DeleteConfirmContent": "Are you sure you want to delete {name}? This cannot be undone.",
"DND4EBETA.description": "A comprehensive game system for running games of Dungeons & Dragons 4th Edition in the Foundry VTT environment.",
"DND4EBETA.Description": "Description",
"DND4EBETA.Details": "Details",
Expand Down Expand Up @@ -451,6 +454,7 @@
"DND4EBETA.HPCurrent": "Current Hit Points",
"DND4EBETA.HPFirst": "Hit Points at 1st Level",
"DND4EBETA.HPPer": "Hit Points per Level Gained",
"DND4EBETA.HPShort": "HP",
"DND4EBETA.HPTotal": "Total Hit Points",
"DND4EBETA.HTwo": "Two Handed",
"DND4EBETA.Identified": "Identified",
Expand Down Expand Up @@ -564,6 +568,12 @@
"DND4EBETA.Mod": "Mod",
"DND4EBETA.MOD": "MOD",
"DND4EBETA.Mount": "Mount",
"DND4EBETA.MovementSpeedCharging": "Charging Speed",
"DND4EBETA.MovementSpeedClimbing": "Climbing Speed",
"DND4EBETA.MovementSpeedShifting": "Shifting Speed",
"DND4EBETA.MovementSpeedRunning": "Running Speed",
"DND4EBETA.MovementSpeedWalking": "Walking Speed",
"DND4EBETA.MovementUnit": "sq.",
"DND4EBETA.Name": "Character Name",
"DND4EBETA.NameNPC": "Non Player Character Name",
"DND4EBETA.Necro": "Necromancy",
Expand Down Expand Up @@ -857,6 +867,7 @@
"DND4EBETA.TargetSquare": "Square",
"DND4EBETA.TargetWall": "Wall",
"DND4EBETA.Teleportation": "Teleportation",
"DND4EBETA.Temp": "Temp",
"DND4EBETA.TempHP": "Temp HP",
"DND4EBETA.TempHPTip": "Temporary Hit Point",
"DND4EBETA.TimeDay": "Days",
Expand Down Expand Up @@ -1014,8 +1025,6 @@
"EFFECT.statusTorch": "Torch",
"EFFECT.statusUnconscious": "Unconscious",
"EFFECT.statusWeakened": "Weakened",
"SETTINGS.4eAllowPolymorphingL": "Allow players to polymorph their own actors.",
"SETTINGS.4eAllowPolymorphingN": "Allow Polymorphing",
"SETTINGS.4eAutoCollapseCardL": "Automatically collapse Item Card descriptions in the Chat Log",
"SETTINGS.4eAutoCollapseCardN": "Collapse Item Cards in Chat",
"SETTINGS.4eAutomationCombatN": "Basic Combat Automation",
Expand All @@ -1037,6 +1046,8 @@
"SETTINGS.4eHalfLevelOptionsL": "Allows the ability to turn off half levels for: Ability, Defense, Skills and Initiative score values.",
"SETTINGS.4eInitTBL": "Append the raw Dexterity ability score to break ties in Initiative.",
"SETTINGS.4eInitTBN": "Initiative Dexterity Tiebreaker",
"SETTINGS.4eItemDeleteConfirmationN": "Confirm Power & Inventory Deletes?",
"SETTINGS.4eItemDeleteConfirmationL": "When enabled, a confirmation dialog will display when trying to delete any power or inventory item",
"SETTINGS.4eNoExpL": "Remove experience bars from character sheets.",
"SETTINGS.4eNoExpN": "Disable Experience Tracking",
"SETTINGS.4eNpcMathOptionsL": "Determins if the Advanced Math Options for NPC's is set during their generation",
Expand Down
37 changes: 36 additions & 1 deletion module/actor/actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,28 @@ export default class ActorSheet4e extends ActorSheet {

this._sortPowers(powers);
this._sortFeatures(features);

// console.log(this)
// console.log(data)

// let moveTypesTitle = "";
// for(const moveType of Object.entries(data.data.movement)){
// moveTypesTitle += `${moveType.value} sq.`
// }

data.moveTitle = `
${parseInt(data.data.movement.walk.value)} ${game.i18n.localize("DND4EBETA.MovementUnit")} ${game.i18n.localize("DND4EBETA.MovementSpeedWalking")}
${parseInt(data.data.movement.run.value)} ${game.i18n.localize("DND4EBETA.MovementUnit")} ${game.i18n.localize("DND4EBETA.MovementSpeedRunning")}
${parseInt(data.data.movement.charge.value)} ${game.i18n.localize("DND4EBETA.MovementUnit")} ${game.i18n.localize("DND4EBETA.MovementSpeedCharging")}
${parseInt(data.data.movement.climb.value)} ${game.i18n.localize("DND4EBETA.MovementUnit")} ${game.i18n.localize("DND4EBETA.MovementSpeedClimbing")}
${parseInt(data.data.movement.shift.value)} ${game.i18n.localize("DND4EBETA.MovementUnit")} ${game.i18n.localize("DND4EBETA.MovementSpeedShifting")}`;

if(data.data.movement.custom){
const moveCustom = [];
data.data.movement.custom.split(";").forEach((c, i) => (c ? moveCustom[i] = c.trim() : null) );
data.data.moveCustom = moveCustom;
moveCustom.forEach((c) => data.moveTitle += `\n${c.trim()}`);
}
}

_compareValues(key, order = 'asc') {
Expand Down Expand Up @@ -914,7 +936,20 @@ export default class ActorSheet4e extends ActorSheet {
event.preventDefault();
const li = event.currentTarget.closest(".item");
const item = this.actor.items.get(li.dataset.itemId);
if ( item ) return item.delete();
if ( item ) {
if (game.settings.get("dnd4e", "itemDeleteConfirmation")) {
return Dialog.confirm({
title: game.i18n.format("DND4EBETA.DeleteConfirmTitle", {name: item.name}),
content: game.i18n.format("DND4EBETA.DeleteConfirmContent", {name: item.name}),
yes: () => { return item.delete() },
no: () => {},
defaultYes: true
});
}
else {
return item.delete();
}
}
}

/* -------------------------------------------- */
Expand Down
2 changes: 1 addition & 1 deletion module/actor/npc-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class ActorSheet4eNPC extends ActorSheet4e {
setPosition(options={}) {
const position = super.setPosition(options);
const sheetBody = this.element.find(".sheet-body");
const bodyHeight = position.height - 312;
const bodyHeight = position.height - 294;
sheetBody.css("height", bodyHeight);
return position;
}
Expand Down
15 changes: 9 additions & 6 deletions module/apps/long-rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ export class LongRestDialog extends DocumentSheet {
};
});
await this.object.updateEmbeddedDocuments("Item", updateItems);
ChatMessage.create({
user: game.user.id,
speaker: {actor: this.object, alias: this.object.data.name},
// flavor: restFlavor,
content: `${this.object.data.name} takes a long rest.`
});

if(this.object.type === "Player Character"){
ChatMessage.create({
user: game.user.id,
speaker: {actor: this.object, alias: this.object.data.name},
// flavor: restFlavor,
content: `${this.object.data.name} takes a long rest.`
});
}

for (let r of Object.entries(this.object.data.data.resources)) {
if((r[1].sr || r[1].lr) && r[1].max) {
Expand Down
21 changes: 12 additions & 9 deletions module/apps/short-rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,18 @@ export class ShortRestDialog extends DocumentSheet {
console.log(updateItems)
await this.object.updateEmbeddedDocuments("Item", updateItems);

ChatMessage.create({
user: game.user.id,
speaker: {actor: this.object, alias: this.object.data.name},
// flavor: restFlavor,
// content: this.object.data.name + " spends a short rest, regaining " + (updateData[`data.attributes.hp.value`] - this.object.data.data.attributes.hp.value) + " HP."
content: formData.surge >= 1 ? `${this.object.data.name} takes a short rest, spending ${formData.surge} healing surge, regaining ${(updateData[`data.attributes.hp.value`] - this.object.data.data.attributes.hp.value)} HP.`
: `${this.object.data.name} takes a short rest.`

});
if(this.object.type === "Player Character"){
ChatMessage.create({
user: game.user.id,
speaker: {actor: this.object, alias: this.object.data.name},
// flavor: restFlavor,
// content: this.object.data.name + " spends a short rest, regaining " + (updateData[`data.attributes.hp.value`] - this.object.data.data.attributes.hp.value) + " HP."
content: formData.surge >= 1 ? `${this.object.data.name} takes a short rest, spending ${formData.surge} healing surge, regaining ${(updateData[`data.attributes.hp.value`] - this.object.data.data.attributes.hp.value)} HP.`
: `${this.object.data.name} takes a short rest.`

});
}


for (let r of Object.entries(this.object.data.data.resources)) {
if(r[1].sr && r[1].max) {
Expand Down
6 changes: 4 additions & 2 deletions module/dnd4eBeta.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { _getInitiativeFormula } from "./combat.js";

import ActorSheet4e from "./actor/actor-sheet.js";
import ActorSheet4eNPC from "./actor/npc-sheet.js";
import {SaveThrowDialog} from "./apps/save-throw.js";
import { preloadHandlebarsTemplates } from "./templates.js";

// Import Entities
Expand All @@ -30,6 +29,7 @@ import * as macros from "./macros.js";
import * as migrations from "./migration.js";
import {MultiAttackRoll} from "./roll/multi-attack-roll.js";
import {RollWithOriginalExpression} from "./roll/roll-with-expression.js";
import {TokenBarHooks} from "./hooks.js";

/* -------------------------------------------- */
/* Foundry VTT Initialization */
Expand Down Expand Up @@ -99,7 +99,9 @@ Hooks.once("init", async function() {
preloadHandlebarsTemplates();

// setup methods that allow for easy integration with token hud
game.dnd4eBeta.quickSave = (actor) => new SaveThrowDialog(actor)._updateObject(null, {save : 0, dc: 10})
game.dnd4eBeta.tokenBarHooks = TokenBarHooks
//legacy, remove after some time when its reasonable for people to have updated token bar
game.dnd4eBeta.quickSave = (actor) => game.dnd4eBeta.tokenBarHooks.quickSave(actor, null)
});

Hooks.once("setup", function() {
Expand Down
32 changes: 32 additions & 0 deletions module/hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {SaveThrowDialog} from "./apps/save-throw.js";

/**
* These methods are all called by https://github.com/Drental/fvtt-tokenactionhud, their method signature should not be changed without a code change there.
*/
export const TokenBarHooks = {}

TokenBarHooks.generatePowerGroups = (actor) => actor.sheet._generatePowerGroups()

TokenBarHooks.updatePowerAvailable = (actor, power) => actor.sheet._checkPowerAvailable(power.data)

TokenBarHooks.isPowerAvailable = (actor, power) => {
actor.sheet._checkPowerAvailable(power.data)
return !power.data.data.notAvailable
}

TokenBarHooks.quickSave = (actor, event) => new SaveThrowDialog(actor)._updateObject(event, {save : 0, dc: 10})

TokenBarHooks.saveDialog = (actor, event) => actor.sheet._onSavingThrow(event)

TokenBarHooks.healDialog = (actor, event) => actor.sheet._onHealMenuDialog(event)

TokenBarHooks.rechargePower = (actor, power, event) => actor.sheet._onItemRecharge(event)

TokenBarHooks.rollPower = (actor, power, event) => actor.usePower(power)

TokenBarHooks.rollSkill = (actor, checkId, event) => actor.rollSkill(checkId, { event: event });

TokenBarHooks.rollAbility = (actor, checkId, event) => actor.rollAbility(checkId, { event: event });

TokenBarHooks.rollItem = (actor, item, event) => item.roll()

1 change: 0 additions & 1 deletion module/item/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ export default class Item4e extends Item {
if(data.attribute){
const attribute = data.attribute.split('.')[1];
if(DND4EBETA.abilities[attribute]){
console.log(data)
labels.attribute = `${game.i18n.localize("DND4EBETA.Ability")}: ${DND4EBETA.abilities[attribute]}`;
}
else if(DND4EBETA.skills[attribute]){
Expand Down
2 changes: 1 addition & 1 deletion module/roll/roll-with-expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class RollWithOriginalExpression extends Roll {

There are probably edge-cases here that I am not covering, but worst that happens is the highlighting looks a little weird / doesn't work.
*/
const trimmedPart = "" + part.trim() // remember part may be a number. Very occasionally not everything is a string!
const trimmedPart = ("" + part).trim() // remember part may be a number. Very occasionally not everything is a string!
if (trimmedPart.indexOf("(") === 0 && trimmedPart.indexOf(']') === trimmedPart.length - 1) {
if (regex.test(trimmedPart)) {
return part
Expand Down
42 changes: 11 additions & 31 deletions module/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,37 +175,17 @@ export const registerSystemSettings = function() {
});


// /**
// * Option to allow GMs to restrict polymorphing to GMs only.
// */
// game.settings.register('dnd4e', 'allowPolymorphing', {
// name: 'SETTINGS.4eAllowPolymorphingN',
// hint: 'SETTINGS.4eAllowPolymorphingL',
// scope: 'world',
// config: true,
// default: false,
// type: Boolean
// });

/**
* Remember last-used polymorph settings.
* delete confirmation
*/
// game.settings.register('dnd4e', 'polymorphSettings', {
// scope: 'client',
// default: {
// keepPhysical: false,
// keepMental: false,
// keepSaves: false,
// keepSkills: false,
// mergeSaves: false,
// mergeSkills: false,
// keepClass: false,
// keepFeats: false,
// keepSpells: false,
// keepItems: false,
// keepBio: false,
// keepVision: true,
// transformTokens: true
// }
// });
game.settings.register("dnd4e", "itemDeleteConfirmation",{
name: "SETTINGS.4eItemDeleteConfirmationN",
hint: "SETTINGS.4eItemDeleteConfirmationL",
scope: "client",
config: true,
default: true,
type: Boolean
});


};
Loading