SotG Update #1

+ Adds compendia for Deployments, Deployment Features, Starship Armor, Starship Equipment, Starship Weapons, and Ventures and associated artwork
+ Adds Starship actor sheet (very, very rough draft, somewhat unpredictable, not fully functional)
+ Adds function to Character sheet to collapse/expand Feature tab rows (major assist from Cyr)
+ Adds function to Character sheet to increment/decrement class levels directly from character sheet (another major assist from Cyr)
This commit is contained in:
Professor Bunbury 2021-04-06 16:03:48 -04:00
parent 3297d9bd8c
commit c793949b37
57 changed files with 1682 additions and 70 deletions

View file

@ -67,6 +67,7 @@ export default class ActorSheet5e extends ActorSheet {
cssClass: isOwner ? "editable" : "locked",
isCharacter: this.entity.data.type === "character",
isNPC: this.entity.data.type === "npc",
isStarship: this.entity.data.type === "starship",
isVehicle: this.entity.data.type === 'vehicle',
config: CONFIG.SW5E,
};
@ -338,6 +339,7 @@ export default class ActorSheet5e extends ActorSheet {
if ( filters.has("prepared") ) {
if ( data.level === 0 || ["innate", "always"].includes(data.preparation.mode) ) return true;
if ( this.actor.data.type === "npc" ) return true;
if ( this.actor.data.type === "starship" ) return true;
return data.preparation.prepared;
}
@ -407,8 +409,11 @@ export default class ActorSheet5e extends ActorSheet {
html.find('.item-create').click(this._onItemCreate.bind(this));
html.find('.item-edit').click(this._onItemEdit.bind(this));
html.find('.item-delete').click(this._onItemDelete.bind(this));
html.find('.item-collapse').click(this._onItemCollapse.bind(this));
html.find('.item-uses input').click(ev => ev.target.select()).change(this._onUsesChange.bind(this));
html.find('.slot-max-override').click(this._onPowerSlotOverride.bind(this));
html.find('.increment-class-level').click(this._onIncrementClassLevel.bind(this));
html.find('.decrement-class-level').click(this._onDecrementClassLevel.bind(this));
// Active Effect management
html.find(".effect-control").click(ev => onManageActiveEffect(ev, this.entity));
@ -757,6 +762,75 @@ export default class ActorSheet5e extends ActorSheet {
this.actor.deleteOwnedItem(li.dataset.itemId);
}
/**
* Handle collapsing a Feature row on the actor sheet
* @param {Event} event The originating click event
* @private
*/
_onItemCollapse(event) {
event.preventDefault();
event.currentTarget.classList.toggle("active");
const li = event.currentTarget.closest("li");
const content = li.querySelector(".content");
if (content.style.display === "none") {
content.style.display = "block";
} else {
content.style.display = "none";
}
}
/**
* Handle incrementing class level on the actor sheet
* @param {Event} event The originating click event
* @private
*/
_onIncrementClassLevel(event) {
event.preventDefault();
const div = event.currentTarget.closest(".character")
const li = event.currentTarget.closest("li");
const actorId = div.id.split("-")[1];
const itemId = li.dataset.itemId;
const actor = game.actors.get(actorId);
const item = actor.getOwnedItem(itemId);
let levels = item.data.data.levels;
const update = {_id: item._id, data: {levels: (levels + 1) }};
actor.updateOwnedItem(update)
}
/**
* Handle decrementing class level on the actor sheet
* @param {Event} event The originating click event
* @private
*/
_onDecrementClassLevel(event) {
event.preventDefault();
const div = event.currentTarget.closest(".character")
const li = event.currentTarget.closest("li");
const actorId = div.id.split("-")[1];
const itemId = li.dataset.itemId;
const actor = game.actors.get(actorId);
const item = actor.getOwnedItem(itemId);
let levels = item.data.data.levels;
const update = {_id: item._id, data: {levels: (levels - 1) }};
actor.updateOwnedItem(update)
}
/* -------------------------------------------- */
/**