From 9246d281f514040114ff883fd67f9e43f0df18ad Mon Sep 17 00:00:00 2001
From: Draconas
Date: Sat, 19 Mar 2022 11:16:48 +0000
Subject: [PATCH] #176 : Action Point Riders
A chunk of this was already done (guessing as 5e holdover?), just needed a dialog to enter the extra riders and the code to output them was pre-written.
No automation on this as there are so many different types of AP benny you can get from classes (warlords) and Paragon Paths, that trying to integrate them all would be a mugs game.
---
lang/en.json | 3 ++-
module/actor/actor-sheet.js | 9 +++++++++
module/apps/action-point-extra.js | 28 ++++++++++++++++++++++++++
module/apps/action-point.js | 9 ++++-----
templates/actor-sheet.html | 3 +++
templates/apps/action-point-extra.html | 7 +++++++
templates/apps/action-point.html | 5 -----
7 files changed, 53 insertions(+), 11 deletions(-)
create mode 100644 module/apps/action-point-extra.js
create mode 100644 templates/apps/action-point-extra.html
diff --git a/lang/en.json b/lang/en.json
index bdc35399..ccc11578 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -51,7 +51,8 @@
"DND4EBETA.ActionOpportunityShort": "OP-A",
"DND4EBETA.ActionOther": "Other",
"DND4EBETA.ActionPoints": "Action Points",
-"DND4EBETA.ActionPointUse": "Action Point",
+"DND4EBETA.ActionPointUse": "Spend Action Point",
+"DND4EBETA.ActionPointRiders": "Action Point Riders",
"DND4EBETA.ActionPointsRemain": "Action Points Remaining",
"DND4EBETA.ActionPointUsed": "Action Point used in encounter?",
"DND4EBETA.ActionPl": "Actions",
diff --git a/module/actor/actor-sheet.js b/module/actor/actor-sheet.js
index f05e716b..9b73e362 100644
--- a/module/actor/actor-sheet.js
+++ b/module/actor/actor-sheet.js
@@ -17,6 +17,7 @@ import TraitSelectorSave from "../apps/trait-selector-save.js";
import {onManageActiveEffect, prepareActiveEffectCategories} from "../effects.js";
import HPOptions from "../apps/hp-options.js";
import { Helper } from "../helper.js";
+import {ActionPointExtraDialog} from "../apps/action-point-extra.js";
/**
* Extend the basic ActorSheet with some very simple modifications
@@ -702,6 +703,9 @@ ${parseInt(data.data.movement.shift.value)} ${game.i18n.localize("DND4EBETA.Move
//action point
html.find('.action-point').click(this._onActionPointDialog.bind(this));
+ html.find('.action-point-extra').click(this._onActionPointExtraDialog.bind(this));
+
+
//short rest
html.find('.short-rest').click(this._onShortRest.bind(this));
@@ -1121,6 +1125,11 @@ ${parseInt(data.data.movement.shift.value)} ${game.i18n.localize("DND4EBETA.Move
new ActionPointDialog(this.actor).render(true);
}
+ _onActionPointExtraDialog(event) {
+ event.preventDefault();
+ new ActionPointExtraDialog(this.actor).render(true);
+ }
+
/**
*Opens dialog window to short rest.
*Spend n number of healin surges,
diff --git a/module/apps/action-point-extra.js b/module/apps/action-point-extra.js
new file mode 100644
index 00000000..63d155d0
--- /dev/null
+++ b/module/apps/action-point-extra.js
@@ -0,0 +1,28 @@
+export class ActionPointExtraDialog extends DocumentSheet {
+
+ static get defaultOptions() {
+ const options = super.defaultOptions;
+ return mergeObject(options, {
+ id: "action-point",
+ classes: ["dnd4eBeta", "action-point"],
+ template: "systems/dnd4e/templates/apps/action-point-extra.html",
+ width: 500,
+ closeOnSubmit: true
+ });
+ }
+
+ get title() {
+ return `${this.object.name} - Action Point Riders`;
+ }
+
+ /** @override */
+ getData() {
+ return {data: this.object.data.data}
+ }
+
+ async _updateObject(event, formData) {
+ const updateData = {};
+ for(let data in formData) { updateData[`${data}`] = formData[`${data}`];}
+ return this.object.update(updateData);
+ }
+}
diff --git a/module/apps/action-point.js b/module/apps/action-point.js
index ceaecc55..474d6f44 100644
--- a/module/apps/action-point.js
+++ b/module/apps/action-point.js
@@ -17,15 +17,15 @@ export class ActionPointDialog extends DocumentSheet {
/** @override */
getData() {
- const extra = this.object.data.data.actionpoints.custom.split(";");
+ const extra = this.object.data.data.actionpoints.custom !== "" ? this.object.data.data.actionpoints.custom.split("\n") : "";
return { data: this.object.data.data, extra: extra };
}
async _updateObject(event, formData) {
let extra = "";
- if (this.object.data.data.actionpoints.custom) {
+ if (this.object.data.data.actionpoints.custom !== "") {
extra = this.object.data.data.actionpoints.custom;
- extra = extra.replace(/;/g,'');
+ extra = extra.replace(/\n/g,'');
extra = "" + extra + "";
}
@@ -34,12 +34,11 @@ export class ActionPointDialog extends DocumentSheet {
user: game.user.id,
speaker: {actor: this.object, alias: this.object.data.name},
// flavor: restFlavor,
- content: `${this.object.data.name} uses an actionpoint gaining the following benifits:
+ content: `${this.object.data.name} uses an actionpoint gaining the following benefits:
- Gaining an addtional Standard Action
${extra}
`
- //game.i18n.format("DND4EBETA.ShortRestResult", {name: this.name, dice: -dhd, health: dhp})
});
const updateData = {};
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html
index ab4501fb..325ffa8b 100644
--- a/templates/actor-sheet.html
+++ b/templates/actor-sheet.html
@@ -120,6 +120,9 @@ {{localize 'DND4EBETA.ActionPoints'}}
+
diff --git a/templates/apps/action-point-extra.html b/templates/apps/action-point-extra.html
new file mode 100644
index 00000000..5b8c37ad
--- /dev/null
+++ b/templates/apps/action-point-extra.html
@@ -0,0 +1,7 @@
+
diff --git a/templates/apps/action-point.html b/templates/apps/action-point.html
index 30d8e9c1..2935f114 100644
--- a/templates/apps/action-point.html
+++ b/templates/apps/action-point.html
@@ -9,11 +9,6 @@
{{/each}}
{{/if}}
-
-