2021-12-02 07:38:59 +01:00
|
|
|
/**
|
|
|
|
* Extend the basic ActorSheet with some very simple modifications
|
|
|
|
* @extends {ActorSheet}
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { PegasusUtility } from "./pegasus-utility.js";
|
|
|
|
import { PegasusItemSheet } from "./pegasus-item-sheet.js";
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
export class PegasusActorSheet extends ActorSheet {
|
|
|
|
|
|
|
|
/** @override */
|
|
|
|
static get defaultOptions() {
|
|
|
|
|
|
|
|
return mergeObject(super.defaultOptions, {
|
|
|
|
classes: ["fvtt-pegasus-rpg", "sheet", "actor"],
|
|
|
|
template: "systems/fvtt-pegasus-rpg/templates/actor-sheet.html",
|
|
|
|
width: 640,
|
|
|
|
height: 720,
|
|
|
|
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }],
|
|
|
|
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
|
|
|
|
editScore: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async getData() {
|
|
|
|
const objectData = PegasusUtility.data(this.object);
|
|
|
|
|
|
|
|
let actorData = duplicate(PegasusUtility.templateData(this.object));
|
|
|
|
|
|
|
|
let formData = {
|
|
|
|
title: this.title,
|
|
|
|
id: objectData.id,
|
|
|
|
type: objectData.type,
|
|
|
|
img: objectData.img,
|
|
|
|
name: objectData.name,
|
|
|
|
editable: this.isEditable,
|
|
|
|
cssClass: this.isEditable ? "editable" : "locked",
|
|
|
|
data: actorData,
|
|
|
|
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
|
|
|
|
limited: this.object.limited,
|
|
|
|
specs: this.actor.getSpecs( ),
|
2021-12-02 20:18:21 +01:00
|
|
|
optionsDiceList: PegasusUtility.getOptionsDiceList(),
|
|
|
|
optionsLevel: PegasusUtility.getOptionsLevel(),
|
2021-12-02 07:38:59 +01:00
|
|
|
weapons: this.actor.checkAndPrepareWeapons( duplicate(this.actor.getWeapons()) ),
|
|
|
|
armors: duplicate(this.actor.getArmors()),
|
|
|
|
shields: duplicate(this.actor.getShields()),
|
|
|
|
equipments: duplicate(this.actor.getEquipments()),
|
|
|
|
perks: duplicate(this.actor.getPerks()),
|
2022-01-06 18:22:05 +01:00
|
|
|
abilities: duplicate(this.actor.getAbilities()),
|
2021-12-03 18:31:43 +01:00
|
|
|
activePerks: duplicate(this.actor.getActivePerks()),
|
2021-12-02 07:38:59 +01:00
|
|
|
powers: duplicate(this.actor.getPowers()),
|
|
|
|
subActors: duplicate(this.actor.getSubActors()),
|
2022-01-08 18:28:01 +01:00
|
|
|
race: duplicate(this.actor.getRace()),
|
|
|
|
role: duplicate(this.actor.getRole()),
|
2021-12-02 07:38:59 +01:00
|
|
|
options: this.options,
|
|
|
|
owner: this.document.isOwner,
|
|
|
|
editScore: this.options.editScore,
|
|
|
|
isGM: game.user.isGM
|
|
|
|
}
|
|
|
|
this.formData = formData;
|
|
|
|
|
|
|
|
console.log("PC : ", formData, this.object);
|
|
|
|
return formData;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
|
|
|
activateListeners(html) {
|
|
|
|
super.activateListeners(html);
|
|
|
|
|
|
|
|
// Everything below here is only needed if the sheet is editable
|
|
|
|
if (!this.options.editable) return;
|
|
|
|
|
|
|
|
// Update Inventory Item
|
|
|
|
html.find('.item-edit').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
let itemId = li.data("item-id");
|
|
|
|
const item = this.actor.items.get( itemId );
|
|
|
|
item.sheet.render(true);
|
|
|
|
});
|
|
|
|
// Delete Inventory Item
|
|
|
|
html.find('.item-delete').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
PegasusUtility.confirmDelete(this, li);
|
|
|
|
});
|
|
|
|
|
|
|
|
html.find('.subactor-edit').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
let actorId = li.data("actor-id");
|
|
|
|
let actor = game.actors.get( actorId );
|
|
|
|
actor.sheet.render(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
html.find('.subactor-delete').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
let actorId = li.data("actor-id");
|
|
|
|
this.actor.delSubActor(actorId);
|
|
|
|
});
|
|
|
|
|
|
|
|
html.find('.equipement-moins').click(event => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
this.actor.decrementeQuantite( li.data("item-id") );
|
|
|
|
} );
|
|
|
|
html.find('.equipement-plus').click(event => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
this.actor.incrementeQuantite( li.data("item-id") );
|
|
|
|
} );
|
|
|
|
|
2021-12-02 20:18:21 +01:00
|
|
|
html.find('.roll-stat').click((event) => {
|
|
|
|
const statId = $(event.currentTarget).data("stat-key");
|
|
|
|
this.actor.rollStat(statId);
|
|
|
|
});
|
|
|
|
html.find('.roll-spec').click((event) => {
|
2021-12-02 07:38:59 +01:00
|
|
|
const li = $(event.currentTarget).parents(".item");
|
2021-12-02 20:18:21 +01:00
|
|
|
const specId = li.data("item-id");
|
|
|
|
this.actor.rollSpec(specId);
|
2021-12-02 07:38:59 +01:00
|
|
|
});
|
|
|
|
html.find('.technique-roll').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
const techId = li.data("item-id");
|
|
|
|
this.actor.rollTechnique(techId);
|
|
|
|
});
|
|
|
|
html.find('.weapon-roll').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
const weaponId = li.data("item-id");
|
|
|
|
this.actor.rollWeapon(weaponId);
|
|
|
|
});
|
|
|
|
html.find('.river-flush').click((event) => {
|
|
|
|
const diceIndex = $(event.currentTarget).data("dice-index");
|
|
|
|
this.actor.flushDice(diceIndex);
|
|
|
|
});
|
|
|
|
html.find('.river-use').click((event) => {
|
|
|
|
const diceIndex = $(event.currentTarget).data("dice-index");
|
|
|
|
this.actor.addDice(diceIndex);
|
|
|
|
});
|
|
|
|
|
|
|
|
html.find('.weapon-label a').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
const armeId = li.data("item-id");
|
|
|
|
const statId = li.data("stat-id");
|
|
|
|
this.actor.rollWeapon(armeId, statId);
|
|
|
|
});
|
|
|
|
html.find('.weapon-damage').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
const weapon = this.actor.getOwnedItem(li.data("item-id"));
|
|
|
|
this.actor.rollDamage(weapon, 'damage');
|
|
|
|
});
|
|
|
|
html.find('.weapon-damage-critical').click((event) => {
|
|
|
|
const li = $(event.currentTarget).parents(".item");
|
|
|
|
const weapon = this.actor.getOwnedItem(li.data("item-id"));
|
|
|
|
this.actor.rollDamage(weapon, 'criticaldamage');
|
|
|
|
});
|
|
|
|
|
|
|
|
html.find('.lock-unlock-sheet').click((event) => {
|
|
|
|
this.options.editScore = !this.options.editScore;
|
|
|
|
this.render(true);
|
|
|
|
});
|
|
|
|
html.find('.item-link a').click((event) => {
|
|
|
|
const itemId = $(event.currentTarget).data("item-id");
|
|
|
|
const item = this.actor.getOwnedItem(itemId);
|
|
|
|
item.sheet.render(true);
|
|
|
|
});
|
|
|
|
html.find('.item-equip').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
this.actor.equipItem( li.data("item-id") );
|
2021-12-08 13:53:22 +01:00
|
|
|
this.render(true);
|
2021-12-03 18:31:43 +01:00
|
|
|
});
|
|
|
|
html.find('.perk-active').click(ev => {
|
|
|
|
const li = $(ev.currentTarget).parents(".item");
|
|
|
|
this.actor.activatePerk( li.data("item-id") );
|
|
|
|
this.render(true);
|
|
|
|
|
2021-12-02 07:38:59 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
|
|
|
setPosition(options = {}) {
|
|
|
|
const position = super.setPosition(options);
|
|
|
|
const sheetBody = this.element.find(".sheet-body");
|
|
|
|
const bodyHeight = position.height - 192;
|
|
|
|
sheetBody.css("height", bodyHeight);
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
async _onDrop(event) {
|
|
|
|
let data = event.dataTransfer.getData('text/plain');
|
|
|
|
if (data) {
|
|
|
|
let dataItem = JSON.parse( data);
|
|
|
|
let npc = game.actors.get( dataItem.id);
|
|
|
|
if ( npc ) {
|
|
|
|
this.actor.addSubActor( dataItem.id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
super._onDrop(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @override */
|
|
|
|
_updateObject(event, formData) {
|
|
|
|
// Update the Actor
|
|
|
|
return this.object.update(formData);
|
|
|
|
}
|
|
|
|
}
|