This commit is contained in:
François-Xavier Guillois
2023-09-06 17:18:58 +02:00
parent c19a351622
commit 55c3d09490
14 changed files with 107 additions and 64 deletions
+18
View File
@@ -11,6 +11,24 @@ export class VermineItem extends Item {
// preparation methods overridden (such as prepareBaseData()).
super.prepareData();
}
prepareBaseData(){
const actorType = (this.actor !== null) ? this.actor.type : 'character';
switch (this.type){
case 'ability':
if (this.system.type == "") {
// console.log('je suis une capacité, avec pour sous-type', this.system.type, actorType);
this.system.type = actorType;
}
if (this.system.totem == "" && this.actor !== null && this.actor.system.identity.totem != "") {
// console.log('je suis une capacité, avec pour sous-type', this.system.type, actorType);
this.system.totem = this.actor.system.identity.totem;
}
break;
default:
break;
}
}
/**
* Prepare a data object which is passed to any Roll formulas which are created related to this Item
+2 -2
View File
@@ -9,12 +9,12 @@ export class VermineActorSheet extends ActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["vermine2047", "sheet", "actor"],
/*classes: ["vermine2047", "sheet", "actor"],
template: "systems/vermine2047/templates/actor/actor-sheet.hbs",
height: 800,
width: 690,
resizable: false,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]*/
});
}
+1 -1
View File
@@ -12,7 +12,7 @@ export class VermineCharacterSheet extends VermineActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["vermine2047", "sheet", "actor"],
classes: ["vermine2047", "sheet", "character", "actor"],
template: "systems/vermine2047/templates/actor/actor-sheet.hbs",
width: 600,
height: 600,
+30 -3
View File
@@ -10,10 +10,10 @@ export class VermineCreatureSheet extends ActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["vermine2047", "sheet", "actor"],
classes: ["vermine2047", "sheet", "actor", "creature"],
template: "systems/vermine2047/templates/actor/actor-sheet.hbs",
width: 600,
height: 600,
width: 300,
height: 300,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]
});
}
@@ -92,6 +92,33 @@ export class VermineCreatureSheet extends ActorSheet {
/** @override */
activateListeners(html) {
super.activateListeners(html);
html.find('.item-create').click(this._onItemCreate.bind(this));
}
async _onItemCreate(event) {
event.preventDefault();
const header = event.currentTarget;
// Get the type of item to create.
const type = header.dataset.type;
// Grab any data associated with this control.
const data = duplicate(header.dataset);
// Initialize a default name.
// const name = `New ${type.capitalize()}`;
const name = game.i18n.localize('ITEMS.new_' + type);
console.log('onItemCreate child', data.type, this.actor.type);
// Prepare the item object.
const itemData = {
name: name,
type: type,
system: data
};
// Remove the type from the dataset since it's in the itemData.type prop.
delete itemData.system["type"];
// Finally, create the item!
return await Item.create(itemData, {parent: this.actor});
}
}
+1
View File
@@ -45,6 +45,7 @@ export class VermineItemSheet extends ItemSheet {
// Add the actor's data to context.data for easier access, as well as flags.
context.system = itemData.system;
context.flags = itemData.flags;
context.config = CONFIG.VERMINE;
return context;
}
+14 -43
View File
@@ -11,10 +11,10 @@ export class VermineGroupSheet extends VermineActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["vermine2047", "sheet", "actor"],
classes: ["vermine2047", "sheet", "actor", "group"],
template: "systems/vermine2047/templates/actor/actor-sheet.hbs",
width: 600,
height: 600,
width: 500,
height: 500,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]
});
}
@@ -88,41 +88,19 @@ export class VermineGroupSheet extends VermineActorSheet {
* @return {undefined}
*/
_prepareItems(context) {
// Initialize containers.
const abilities = [];
const specialties = [];
const backgrounds = [];
const evolutions = [];
const traumas = [];
context.specialties = this.actor.itemTypes['specialty'];
context.backgrounds = this.actor.itemTypes['background'];
context.evolutions = this.actor.itemTypes['evolution'];
context.traumas = this.actor.itemTypes['trauma'];
context.gear = this.actor.itemTypes['item'];
context.weapons = this.actor.itemTypes['weapon'];
context.defenses = this.actor.itemTypes['defense'];
context.vehicles = this.actor.itemTypes['vehicle'];
context.totem_abilities = this.actor.itemTypes['ability'].filter(i=>i.system.type === 'totem');
context.abilities = this.actor.itemTypes['ability'].filter(i=>i.system.type !== 'totem');
// Iterate through items, allocating to containers
for (let i of context.items) {
i.img = i.img || DEFAULT_TOKEN;
if (i.type === 'ability') {
abilities.push(i);
}
else if (i.type === 'specialty') {
specialties.push(i);
}
else if (i.type === 'background') {
backgrounds.push(i);
}
else if (i.type === 'evolution') {
evolutions.push(i);
}
else if (i.type === 'trauma') {
traumas.push(i);
}
}
// Assign and return
context.abilities = abilities;
context.specialties = specialties;
context.backgrounds = backgrounds;
context.evolutions = evolutions;
context.traumas = traumas;
context.members = [];
context.encounters = [];
@@ -134,13 +112,6 @@ export class VermineGroupSheet extends VermineActorSheet {
context.encounters.push(game.actors.get(encounterId));
}
context.gear = this.actor.itemTypes['item'];
context.weapons = this.actor.itemTypes['weapon'];
context.defenses = this.actor.itemTypes['defense'];
context.vehicles = this.actor.itemTypes['vehicle'];
context.totem_abilities = this.actor.itemTypes['ability'].filter(i=>i.type !== 'totem');
context.abilities = this.actor.itemTypes['ability'].filter(i=>i.type === 'totem');
}
+3 -3
View File
@@ -10,10 +10,10 @@ export class VermineNpcSheet extends VermineActorSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["vermine2047", "sheet", "actor"],
classes: ["vermine2047", "sheet", "actor", "npc"],
template: "systems/vermine2047/templates/actor/actor-sheet.hbs",
width: 600,
height: 600,
width: 400,
height: 400,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]
});
}
+1 -6
View File
@@ -8,15 +8,10 @@
// Actor partials.
"systems/vermine2047/templates/actor/parts/actor-id.hbs",
"systems/vermine2047/templates/actor/parts/actor-totem.hbs",
"systems/vermine2047/templates/actor/parts/character-features.hbs",
"systems/vermine2047/templates/actor/parts/character-header.hbs",
"systems/vermine2047/templates/actor/parts/actor-features.hbs",
"systems/vermine2047/templates/actor/parts/actor-items.hbs",
"systems/vermine2047/templates/actor/parts/actor-weapons.hbs",
"systems/vermine2047/templates/actor/parts/actor-defenses.hbs",
"systems/vermine2047/templates/actor/parts/actor-stories.hbs",
"systems/vermine2047/templates/actor/parts/actor-combat.hbs",
// Character partials.
"systems/vermine2047/templates/actor/character/character-id.hbs",