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

#176 : Action Point Riders #200

Merged
merged 1 commit into from
Mar 21, 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
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions module/actor/actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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,
Expand Down
28 changes: 28 additions & 0 deletions module/apps/action-point-extra.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
9 changes: 4 additions & 5 deletions module/apps/action-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,'</li><li>');
extra = extra.replace(/\n/g,'</li><li>');
extra = "<li>" + extra + "</li>";
}

Expand All @@ -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:
<ul>
<li>Gaining an addtional Standard Action</li>
${extra}
</ul>`
//game.i18n.format("DND4EBETA.ShortRestResult", {name: this.name, dice: -dhd, health: dhp})
});

const updateData = {};
Expand Down
3 changes: 3 additions & 0 deletions templates/actor-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ <h4 class="attribute-name">{{localize 'DND4EBETA.ActionPoints'}}</h4>
<footer class="attribute-footer attribute-footer--surge flexrow">
<span style="font-size: 10px; max-width:48px;">Milestones</span>
<input style="width:18px; border-bottom: 1px solid black; max-width:9%; height:14px;" name="data.magicItemUse.milestone" value="{{data.magicItemUse.milestone}}" title="{{localize 'DND4EBETA.Milestones'}}" placeholder="0" data-dtype="Number" onClick="this.select();">
<a class="rest action-point-extra" title="{{localize 'DND4EBETA.ActionPointUse'}}">{{localize "DND4EBETA.ActionPointRiders"}}</a>
</footer>
<footer class="attribute-footer attribute-footer--surge flexrow">
<a class="rest action-point" title="{{localize 'DND4EBETA.ActionPointUse'}}">{{localize "DND4EBETA.ActionPointUse"}}</a>
</footer>
</div>
Expand Down
7 changes: 7 additions & 0 deletions templates/apps/action-point-extra.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<form id="action-point-hd" class="dialog-content">
<p>Additional effects of spending an action point (from classes / features etc...). One per line</p>
<textarea type="text" name="data.actionpoints.custom" value="{{data.actionpoints.custom}}" data-dtype="String" style="width: 100%; min-height: 10em; resize: vertical; border: none;" placeholder="Extra effects, 1 per line:" contentEditable>{{data.actionpoints.custom}}</textarea>
<div class="dialog-buttons">
<button type="submit" name="submit">Update Action Point Riders</button>
</div>
</form>
5 changes: 0 additions & 5 deletions templates/apps/action-point.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
{{/each}}
{{/if}}
</p>

<!-- <div class="form-group">
<label>Situational bonus to surge?</label>
<input type="text" name="bonus" value="" placeholder="{{ localize 'DND4EBETA.RollExample' }}"/>
</div> -->

<div class="dialog-buttons">
<button type="submit" name="submit">Spend Action Point</button>
Expand Down