Skip to content

Commit

Permalink
created application
Browse files Browse the repository at this point in the history
  • Loading branch information
JFranklin3000 committed Sep 26, 2024
1 parent 0ed7256 commit 583cce0
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 0 deletions.
52 changes: 52 additions & 0 deletions module/apps/essence-manager.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
export class EssenceManager extends FormApplication {
constructor(actor) {
super();
this.actor = actor;
}

static get defaultOptions() {
const defaults = super.defaultOptions

Check failure on line 8 in module/apps/essence-manager.mjs

View workflow job for this annotation

GitHub Actions / Lint

Missing semicolon
const overrides = {
closeOnSubmit: false,
submitOnChange: true,
height: 'auto',
id: 'essence-manager',
template: 'systems/essence20/templates/app/essence-select.hbs',
title: 'Spend Initial 12 Essence Points',
}

Check failure on line 16 in module/apps/essence-manager.mjs

View workflow job for this annotation

GitHub Actions / Lint

Missing semicolon

const mergedOptions = foundry.utils.mergeObject(defaults, overrides);
return mergedOptions;
}

getData() {
console.log(this.actor)

Check failure on line 23 in module/apps/essence-manager.mjs

View workflow job for this annotation

GitHub Actions / Lint

Missing semicolon
const essencePoints = this.actor.system.essencePoints;
return {
essencePoints: essencePoints,
}

Check failure on line 27 in module/apps/essence-manager.mjs

View workflow job for this annotation

GitHub Actions / Lint

Missing semicolon

}

activateListeners(html) {

super.activateListeners(html);

html.find(".essence-change").change(ev => this.render);

Check failure on line 35 in module/apps/essence-manager.mjs

View workflow job for this annotation

GitHub Actions / Lint

'ev' is defined but never used
}

_updateObject(event, formData) {
const expandedData = foundry.utils.expandObject(formData);
const newEssencePoints = 12 - expandedData.system.smarts.max - expandedData.system.social.max - expandedData.system.speed.max - expandedData.system.strength.max

Check failure on line 40 in module/apps/essence-manager.mjs

View workflow job for this annotation

GitHub Actions / Lint

Missing semicolon
this.actor.update({
'system.essences.smarts.max': expandedData.system.smarts.max,
'system.essences.social.max': expandedData.system.social.max,
'system.essences.speed.max': expandedData.system.speed.max,
'system.essences.strength.max': expandedData.system.strength.max,
'system.essencePoints': newEssencePoints,
})

Check failure on line 47 in module/apps/essence-manager.mjs

View workflow job for this annotation

GitHub Actions / Lint

Missing semicolon

}
}

window.EssenceManager = EssenceManager;
1 change: 1 addition & 0 deletions module/data/actor/templates/character.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const character = () => ({
willpower: makeDefensesFields('willpower', 'smarts'),
cleverness: makeDefensesFields('cleverness', 'social'),
}),
essencePoints: makeInt(12),
essences: new fields.SchemaField({
strength: makeEssenceFields(),
speed: makeEssenceFields(),
Expand Down
3 changes: 3 additions & 0 deletions module/helpers/templates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,8 @@ export const preloadHandlebarsTemplates = async function () {
"systems/essence20/templates/item/parts/id-drop.hbs",
"systems/essence20/templates/item/parts/role-perk-drop.hbs",
"systems/essence20/templates/item/parts/sheet-field.hbs",

//Apps partials.
"system/essence20/templates/app/essence-select.hbs",
]);
};
8 changes: 8 additions & 0 deletions module/sheets/actor-sheet.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EssenceManager } from "../apps/essence-manager.mjs";
import { onManageActiveEffect, prepareActiveEffectCategories } from "../helpers/effects.mjs";
import { getNumActions } from "../helpers/actor.mjs";
import { onLevelChange } from "../sheet-handlers/role-handler.mjs";
Expand Down Expand Up @@ -424,6 +425,8 @@ export class Essence20ActorSheet extends ActorSheet {
// Everything below here is only needed if the sheet is editable
if (!this.isEditable) return;

html.find('.essence-manager').click(ev => this.openEssenceApp(ev, this.actor));

// Add Inventory Item
html.find('.item-create').click(ev => onItemCreate(ev, this.actor));

Expand Down Expand Up @@ -538,4 +541,9 @@ export class Essence20ActorSheet extends ActorSheet {
return await onLevelChange(this.actor, this.actor.system.level);
}
}

async openEssenceApp(event, actor) {
new EssenceManager (actor).render(true);
}
}

1 change: 1 addition & 0 deletions templates/actor/parts/misc/pc-skills.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="skillscontainer">
<a class = "essence-manager"><i class="fas fa-gear"></i></a>
{{!-- Strength --}}
<div class="skills-container" style="border-color: {{system.color}};">
<div class="essence-header strength">
Expand Down
22 changes: 22 additions & 0 deletions templates/app/essence-select.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<form>
<div>
<label>Essence Points</label>
<input style="color: white" type="number" name="essencePoints" value="{{essencePoints}}" min="0" step="1" />
</div>
<div class="essence-change">
<label>Strength</label>
<input style="color: white" type="number" name="system.strength.max" value="0" min="0" step="1" />
</div>
<div class="essence-change">
<label>Speed</label>
<input style="color: white" type="number" name="system.speed.max" value="0" min="0" step="1" />
</div>
<div class="essence-change">
<label>Smarts</label>
<input style="color: white" type="number" name="system.smarts.max" value="0" min="0" step="1" />
</div>
<div class="essence-change">
<label>Social</label>
<input style="color: white" type="number" name="system.social.max" value="0" min="0" step="1" />
</div>
</form>

0 comments on commit 583cce0

Please sign in to comment.