Annence/Boheme
This commit is contained in:
@ -52,6 +52,7 @@ export class EcrymeActorSheet extends ActorSheet {
|
||||
hasAmertume: EcrymeUtility.hasAmertume(),
|
||||
cephalySkills: this.actor.getCephalySkills(),
|
||||
subActors: duplicate(this.actor.getSubActors()),
|
||||
annency: this.actor.getAnnency(),
|
||||
description: await TextEditor.enrichHTML(this.object.system.description, { async: true }),
|
||||
notes: await TextEditor.enrichHTML(this.object.system.notes, { async: true }),
|
||||
equipementlibre: await TextEditor.enrichHTML(this.object.system.equipementlibre, { async: true }),
|
||||
@ -79,6 +80,12 @@ export class EcrymeActorSheet extends ActorSheet {
|
||||
if (e.keyCode === 13) return false;
|
||||
});
|
||||
|
||||
html.find('.open-annency').click(ev => {
|
||||
let actorId = $(ev.currentTarget).data("annency-id")
|
||||
const actor = game.actors.get(actorId)
|
||||
actor.sheet.render(true)
|
||||
})
|
||||
|
||||
// Update Inventory Item
|
||||
html.find('.item-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
|
@ -68,6 +68,31 @@ export class EcrymeActor extends Actor {
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
buildAnnencyActorList() {
|
||||
let membersFull = {}
|
||||
for(let id of this.system.base.characters) {
|
||||
let actor = game.actors.get(id)
|
||||
membersFull[id] = { name: actor.name, id: actor.id, img: actor.img }
|
||||
}
|
||||
return membersFull
|
||||
}
|
||||
/* ----------------------- --------------------- */
|
||||
addAnnencyActor(actorId) {
|
||||
let members = duplicate(this.system.base.characters)
|
||||
members.push(actorId)
|
||||
this.update({ 'system.base.characters': members })
|
||||
}
|
||||
async removeAnnencyActor(actorId) {
|
||||
let members = this.system.base.characters.filter(id => id != actorId)
|
||||
this.update({ 'system.base.characters': members })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getAnnency() {
|
||||
return game.actors.find(a => a.type == 'annency' && a.system.base.characters.includes(this.id))
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getConfrontations() {
|
||||
return this.items.filter(it => it.type == "confrontation")
|
||||
|
143
modules/actors/ecryme-annency-sheet.js
Normal file
143
modules/actors/ecryme-annency-sheet.js
Normal file
@ -0,0 +1,143 @@
|
||||
/**
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
* @extends {ActorSheet}
|
||||
*/
|
||||
|
||||
import { EcrymeUtility } from "../common/ecryme-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class EcrymeAnnencySheet extends ActorSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["fvtt-ecryme", "sheet", "actor"],
|
||||
template: "systems/fvtt-ecryme/templates/actors/annency-sheet.hbs",
|
||||
width: 640,
|
||||
height: 600,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "annency" }],
|
||||
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
|
||||
editScore: true
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
|
||||
let formData = {
|
||||
title: this.title,
|
||||
id: this.actor.id,
|
||||
type: this.actor.type,
|
||||
img: this.actor.img,
|
||||
name: this.actor.name,
|
||||
editable: this.isEditable,
|
||||
cssClass: this.isEditable ? "editable" : "locked",
|
||||
system: duplicate(this.object.system),
|
||||
limited: this.object.limited,
|
||||
config: duplicate(game.system.ecryme.config),
|
||||
hasCephaly: EcrymeUtility.hasCephaly(),
|
||||
hasBoheme: EcrymeUtility.hasBoheme(),
|
||||
hasAmertume: EcrymeUtility.hasAmertume(),
|
||||
characters: this.actor.buildAnnencyActorList(),
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
editScore: this.options.editScore,
|
||||
isGM: game.user.isGM
|
||||
}
|
||||
this.formData = formData;
|
||||
|
||||
console.log("Annency : ", 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;
|
||||
|
||||
html.bind("keydown", function (e) { // Ignore Enter in actores sheet
|
||||
if (e.keyCode === 13) return false;
|
||||
});
|
||||
|
||||
html.find('.actor-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
let actorId = li.data("actor-id")
|
||||
const actor = game.actors.get(actorId)
|
||||
actor.sheet.render(true)
|
||||
})
|
||||
html.find('.actor-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
let actorId = li.data("actor-id")
|
||||
this.actor.removeAnnencyActor(actorId)
|
||||
})
|
||||
|
||||
|
||||
// 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")
|
||||
EcrymeUtility.confirmDelete(this, li).catch("Error : No deletion confirmed")
|
||||
})
|
||||
html.find('.item-add').click(ev => {
|
||||
let dataType = $(ev.currentTarget).data("type")
|
||||
this.actor.createEmbeddedDocuments('Item', [{ name: "NewItem", type: dataType }], { renderSheet: true })
|
||||
})
|
||||
|
||||
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('.update-field').change(ev => {
|
||||
const fieldName = $(ev.currentTarget).data("field-name");
|
||||
let value = Number(ev.currentTarget.value);
|
||||
this.actor.update({ [`${fieldName}`]: value });
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onDropActor(event, dragData) {
|
||||
const actor = fromUuidSync(dragData.uuid)
|
||||
if (actor) {
|
||||
this.actor.addAnnencyActor(actor.id)
|
||||
} else {
|
||||
ui.notifications.warn("Actor not found")
|
||||
}
|
||||
super._onDropActor(event)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @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;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
_updateObject(event, formData) {
|
||||
// Update the Actor
|
||||
return this.object.update(formData);
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
import { EcrymeActor } from "./actors/ecryme-actor.js";
|
||||
import { EcrymeItemSheet } from "./items/ecryme-item-sheet.js";
|
||||
import { EcrymeActorSheet } from "./actors/ecryme-actor-sheet.js";
|
||||
import { EcrymeAnnencySheet } from "./actors/ecryme-annency-sheet.js";
|
||||
import { EcrymeUtility } from "./common/ecryme-utility.js";
|
||||
import { EcrymeCombat } from "./app/ecryme-combat.js";
|
||||
import { EcrymeItem } from "./items/ecryme-item.js";
|
||||
@ -58,7 +59,7 @@ Hooks.once("init", async function () {
|
||||
// Register sheet application classes
|
||||
Actors.unregisterSheet("core", ActorSheet);
|
||||
Actors.registerSheet("fvtt-ecryme", EcrymeActorSheet, { types: ["pc"], makeDefault: true });
|
||||
//Actors.registerSheet("fvtt-ecryme", EcrymeNPCSheet, { types: ["pnj"], makeDefault: false });
|
||||
Actors.registerSheet("fvtt-ecryme", EcrymeAnnencySheet, { types: ["annency"], makeDefault: false });
|
||||
|
||||
Items.unregisterSheet("core", ItemSheet);
|
||||
Items.registerSheet("fvtt-ecryme", EcrymeItemSheet, { makeDefault: true });
|
||||
|
Reference in New Issue
Block a user