New slots
This commit is contained in:
@@ -52,13 +52,12 @@ export class WarheroActorSheet extends ActorSheet {
|
||||
armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())),
|
||||
shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields())),
|
||||
powers: this.actor.sortPowers(),
|
||||
equipments: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquipmentsOnly()) ),
|
||||
slotEquipments: this.actor.buildEquipmentsSlot(),
|
||||
subActors: duplicate(this.actor.getSubActors()),
|
||||
competency: this.actor.getCompetency(),
|
||||
race: duplicate(race),
|
||||
classes: duplicate(this.actor.getClasses()),
|
||||
totalMoney: this.actor.computeTotalMoney(),
|
||||
equipments: duplicate(this.actor.getEquipmentsOnly()),
|
||||
//moneys: duplicate(this.actor.getMoneys()),
|
||||
description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}),
|
||||
notes: await TextEditor.enrichHTML(this.object.system.biodata.notes, {async: true}),
|
||||
@@ -66,6 +65,12 @@ export class WarheroActorSheet extends ActorSheet {
|
||||
owner: this.document.isOwner,
|
||||
editScore: this.options.editScore,
|
||||
isGM: game.user.isGM
|
||||
}
|
||||
if (this.actor.type == "party") {
|
||||
formData.partySlots = this.actor.buildPartySlots()
|
||||
} else {
|
||||
formData.equipmentContainers = this.actor.buildEquipmentsSlot()
|
||||
formData.bodyContainers = this.actor.buildBodySlot()
|
||||
}
|
||||
// Dynamic patch
|
||||
formData.system.secondary.counterspell.hasmax = false
|
||||
|
@@ -181,29 +181,82 @@ export class WarheroActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
computeTotalMoney() {
|
||||
let nbMoney = 0
|
||||
this.items.forEach(it => {if (it.type == 'money') { nbMoney += it.system.quantity} } )
|
||||
this.items.forEach(it => { if (it.type == 'money') { nbMoney += it.system.quantity } })
|
||||
return nbMoney
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
buildPartySlots() {
|
||||
let containers = {}
|
||||
for (let slotName in game.system.warhero.config.partySlotNames) {
|
||||
let slotDef = game.system.warhero.config.partySlotNames[slotName]
|
||||
containers[slotName] = duplicate(slotDef)
|
||||
containers[slotName].content = this.items.filter(it => (it.type == 'money' || it.type == 'weapon' || it.type == 'armor' || it.type == 'shield' || it.type == 'equipment') )
|
||||
let slotUsed = 0
|
||||
for (let item of containers[slotName].content) {
|
||||
let q = (item.system.quantity) ? item.system.quantity : 1
|
||||
containers[slotName].nbslots += (item.system.providedslot ?? 0) * q
|
||||
if (item.type == "money") {
|
||||
slotUsed += Math.ceil(item.system.quantity / 1000)
|
||||
} else {
|
||||
slotUsed += item.system.slotused * q
|
||||
}
|
||||
}
|
||||
slotUsed = Math.ceil(slotUsed)
|
||||
containers[slotName].slotUsed = slotUsed
|
||||
}
|
||||
return containers
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
buildBodySlot() {
|
||||
let containers = {}
|
||||
for (let slotName in game.system.warhero.config.slotNames) {
|
||||
let slotDef = game.system.warhero.config.slotNames[slotName]
|
||||
if (!slotDef.container) {
|
||||
containers[slotName] = duplicate(slotDef)
|
||||
containers[slotName].content = this.items.filter(it => (it.type == 'money' || it.type == 'weapon' || it.type == 'armor' || it.type == 'shield' || it.type == 'equipment')
|
||||
&& it.system.slotlocation == slotName)
|
||||
let slotUsed = 0
|
||||
for (let item of containers[slotName].content) {
|
||||
let q = (item.system.quantity) ? item.system.quantity : 1
|
||||
containers[slotName].nbslots += (item.system.providedslot ?? 0) * q
|
||||
if (item.type == "money") {
|
||||
slotUsed += Math.ceil(item.system.quantity / 1000)
|
||||
} else {
|
||||
slotUsed += item.system.slotused * q
|
||||
}
|
||||
}
|
||||
slotUsed = Math.ceil(slotUsed)
|
||||
containers[slotName].slotUsed = slotUsed
|
||||
}
|
||||
}
|
||||
return containers
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
buildEquipmentsSlot() {
|
||||
let containers = {}
|
||||
for (let slotName in game.system.warhero.config.slotNames) {
|
||||
let slotDef = game.system.warhero.config.slotNames[slotName]
|
||||
containers[slotName] = duplicate(slotDef)
|
||||
containers[slotName].content = this.items.filter(it => (it.type == 'money' || it.type == 'weapon' || it.type == 'armor' || it.type == 'shield' || it.type == 'equipment')
|
||||
&& it.system.slotlocation == slotName)
|
||||
let slotUsed = 0
|
||||
for (let item of containers[slotName].content) {
|
||||
let q = (item.system.quantity) ? item.system.quantity : 1
|
||||
containers[slotName].nbslots += (item.system.providedslot?? 0) * q
|
||||
if ( item.type == "money") {
|
||||
slotUsed += Math.ceil(item.system.quantity / 1000)
|
||||
} else {
|
||||
slotUsed += item.system.slotused * q
|
||||
if (slotDef.container) {
|
||||
containers[slotName] = duplicate(slotDef)
|
||||
containers[slotName].content = this.items.filter(it => (it.type == 'money' || it.type == 'weapon' || it.type == 'armor' || it.type == 'shield' || it.type == 'equipment')
|
||||
&& it.system.slotlocation == slotName)
|
||||
let slotUsed = 0
|
||||
for (let item of containers[slotName].content) {
|
||||
let q = (item.system.quantity) ? item.system.quantity : 1
|
||||
containers[slotName].nbslots += (item.system.providedslot ?? 0) * q
|
||||
if (item.type == "money") {
|
||||
slotUsed += Math.ceil(item.system.quantity / 1000)
|
||||
} else {
|
||||
slotUsed += item.system.slotused * q
|
||||
}
|
||||
}
|
||||
slotUsed = Math.ceil(slotUsed)
|
||||
containers[slotName].slotUsed = slotUsed
|
||||
}
|
||||
slotUsed = Math.ceil(slotUsed)
|
||||
containers[slotName].slotUsed = slotUsed
|
||||
}
|
||||
return containers
|
||||
}
|
||||
@@ -322,7 +375,7 @@ export class WarheroActor extends Actor {
|
||||
|
||||
/* ------------------------------------------- */
|
||||
getEquipments() {
|
||||
return this.items.filter(item => item.type == 'shield' || item.type == 'armor' || item.type == "weapon" || item.type == "equipment" || item.type == "potion" || item.type == "poison"|| item.type == "trap" || item.type == "classitem");
|
||||
return this.items.filter(item => item.type == 'shield' || item.type == 'armor' || item.type == "weapon" || item.type == "equipment" || item.type == "potion" || item.type == "poison" || item.type == "trap" || item.type == "classitem");
|
||||
}
|
||||
getCompetencyItems() {
|
||||
return duplicate(this.items.filter(item => item.type == "competency") || [])
|
||||
@@ -485,7 +538,7 @@ export class WarheroActor extends Actor {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async getInitiativeScore(combatId, combatantId) {
|
||||
let roll = new Roll("1d20+"+this.system.attributes.ini.value).roll({async: false})
|
||||
let roll = new Roll("1d20+" + this.system.attributes.ini.value).roll({ async: false })
|
||||
await WarheroUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode"))
|
||||
return roll.total
|
||||
}
|
||||
@@ -578,7 +631,7 @@ export class WarheroActor extends Actor {
|
||||
return
|
||||
}
|
||||
newUse = Math.max(newUse, 0)
|
||||
this.updateEmbeddedDocuments('Item', [{ _id: skill.id, 'system.currentuse': newUse }])
|
||||
this.updateEmbeddedDocuments('Item', [{ _id: skill.id, 'system.currentuse': newUse }])
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
@@ -668,12 +721,12 @@ export class WarheroActor extends Actor {
|
||||
this.update({ 'system.attributes.mana': mana })
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
incrementUse(rollData) {
|
||||
let stat = duplicate(this.system[rollData.mode][rollData.statKey])
|
||||
stat.nbuse++
|
||||
this.update( { [`system.${rollData.mode}.${rollData.statKey}`]: stat })
|
||||
this.update({ [`system.${rollData.mode}.${rollData.statKey}`]: stat })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -695,11 +748,10 @@ export class WarheroActor extends Actor {
|
||||
rollData.mode = rollType
|
||||
rollData.statKey = rollKey
|
||||
rollData.stat = stat
|
||||
if (stat && stat.stat)
|
||||
{
|
||||
if (stat && stat.stat) {
|
||||
rollData.statBonus = duplicate(this.system.statistics[stat.stat])
|
||||
}
|
||||
if ( stat.hasuse && stat.nbuse >= stat.maxuse) {
|
||||
if (stat.hasuse && stat.nbuse >= stat.maxuse) {
|
||||
ui.notifications.warn(game.i18n.localize("WH.notif.toomanyuses"))
|
||||
return
|
||||
}
|
||||
|
@@ -21,6 +21,10 @@ export const WARHERO_CONFIG = {
|
||||
medium: {parry: "3", label: "WH.conf.mediumshield"},
|
||||
tower: {parry: "5", label: "WH.conf.towershield"},
|
||||
},
|
||||
|
||||
partySlotNames : {
|
||||
storage: {nbslots: 2000, itemtype:"equipment", label: "WH.conf.partystorage"}
|
||||
},
|
||||
|
||||
slotNames : {
|
||||
head: {nbslots: 1, itemtype:"armor", label: "WH.conf.head"},
|
||||
@@ -31,14 +35,24 @@ export const WARHERO_CONFIG = {
|
||||
ring: {nbslots: 10, itemtype:"equipment",label: "WH.conf.ring"},
|
||||
dress: {nbslots: 1, itemtype:"equipment",label: "WH.conf.dress"},
|
||||
boots: {nbslots: 1, itemtype:"equipment",label: "WH.conf.boots"},
|
||||
belt: {nbslots: 6, itemtype:"equipment",label: "WH.conf.belt"},
|
||||
quiver: {nbslots: 20, itemtype:"equipment",label: "WH.conf.quiver"},
|
||||
armor: {nbslots: 1, itemtype:"armor",label: "WH.conf.armor"},
|
||||
shield: {nbslots: 1, itemtype:"shield",label: "WH.conf.shield"},
|
||||
backpack: {nbslots: 12, itemtype:"equipment",label: "WH.conf.backpack"},
|
||||
beltpouch1: {nbslots: 4, itemtype:"equipment",label: "WH.conf.beltpouch1"},
|
||||
beltpouch2: {nbslots: 4, itemtype:"equipment", label: "WH.conf.beltpouch2"},
|
||||
beltpouch3: {nbslots: 4, itemtype:"equipment", label: "WH.conf.beltpouch3"},
|
||||
belt: {nbslots: 6, itemtype:"equipment", container: true, available: true, parent: undefined, label: "WH.conf.belt"},
|
||||
quiver: {nbslots: 20, itemtype:"equipment",container: true, available: true, parent: undefined, label: "WH.conf.quiver"},
|
||||
backpack: {nbslots: 12, itemtype:"equipment",container: true, available: true, parent: undefined, label: "WH.conf.backpack"},
|
||||
beltpouch1: {nbslots: 4, itemtype:"equipment",container: true, available: true, parent: undefined, label: "WH.conf.beltpouch1"},
|
||||
beltpouch2: {nbslots: 4, itemtype:"equipment", container: true, available: true, parent: undefined, label: "WH.conf.beltpouch2"},
|
||||
beltpouch3: {nbslots: 4, itemtype:"equipment", container: true, available: true, parent: undefined, label: "WH.conf.beltpouch3"},
|
||||
scrollcase: {nbslots: 17, itemtype:"equipment", container: true, available: false, parent: undefined, label: "WH.conf.scrollcase"},
|
||||
wandcase: {nbslots: 10, itemtype:"equipment", container: true, available: false, parent: undefined, label: "WH.conf.wandcase"},
|
||||
potioncase: {nbslots: 8, itemtype:"equipment", container: true, available: false, parent: undefined, label: "WH.conf.potioncase"},
|
||||
bagholding: {nbslots: 30, itemtype:"equipment", container: true, available: false, parent: undefined, label: "WH.conf.bagholding"},
|
||||
quiverholding: {nbslots: 9999, itemtype:"equipment", container: true, available: false, parent: undefined, label: "WH.conf.quiverholding"},
|
||||
backpackholding: {nbslots: 90, itemtype:"equipment", container: true, available: false, parent: undefined, label: "WH.conf.backpackholding"},
|
||||
smallchest: {nbslots: 6, itemtype:"equipment", container: true, available: false, parent: undefined, label: "WH.conf.smallchest"},
|
||||
mediumchest: {nbslots: 12, itemtype:"equipment", container: true, available: false, parent: undefined, label: "WH.conf.mediumchest"},
|
||||
largechest: {nbslots: 24, itemtype:"equipment", container: true, available: false, parent: undefined, label: "WH.conf.largechest"},
|
||||
hugechest: {nbslots: 24, itemtype:"equipment", container: true, available: false, parent: undefined, label: "WH.conf.hugechest"},
|
||||
},
|
||||
|
||||
progressionList: {
|
||||
|
@@ -11,6 +11,7 @@
|
||||
import { WarheroActor } from "./warhero-actor.js";
|
||||
import { WarheroItemSheet } from "./warhero-item-sheet.js";
|
||||
import { WarheroActorSheet } from "./warhero-actor-sheet.js";
|
||||
import { WarheroPartySheet } from "./warhero-party-sheet.js";
|
||||
import { WarheroNPCSheet } from "./warhero-npc-sheet.js";
|
||||
import { WarheroMonsterSheet } from "./warhero-monster-sheet.js";
|
||||
import { WarheroUtility } from "./warhero-utility.js";
|
||||
@@ -63,6 +64,7 @@ Hooks.once("init", async function () {
|
||||
Actors.registerSheet("fvtt-warhero", WarheroActorSheet, { types: ["character"], makeDefault: true });
|
||||
Actors.registerSheet("fvtt-warhero", WarheroNPCSheet, { types: ["npc"], makeDefault: false });
|
||||
Actors.registerSheet("fvtt-warhero", WarheroMonsterSheet, { types: ["monster"], makeDefault: false });
|
||||
Actors.registerSheet("fvtt-warhero", WarheroPartySheet, { types: ["party"], makeDefault: false });
|
||||
|
||||
Items.unregisterSheet("core", ItemSheet);
|
||||
Items.registerSheet("fvtt-warhero", WarheroItemSheet, { makeDefault: true });
|
||||
|
57
modules/warhero-party-sheet.js
Normal file
57
modules/warhero-party-sheet.js
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
* @extends {ActorSheet}
|
||||
*/
|
||||
import { WarheroActorSheet } from "./warhero-actor-sheet.js";
|
||||
import { WarheroUtility } from "./warhero-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class WarheroPartySheet extends WarheroActorSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["warhero-rpg", "sheet", "actor"],
|
||||
template: "systems/fvtt-warhero/templates/party-sheet.html",
|
||||
width: 640,
|
||||
height: 720,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }],
|
||||
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
|
||||
editScore: true
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
|
||||
const objectData = duplicate(this.object.system)
|
||||
|
||||
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: objectData,
|
||||
limited: this.object.limited,
|
||||
totalMoney: this.actor.computeTotalMoney(),
|
||||
equipments: duplicate(this.actor.getEquipmentsOnly()),
|
||||
//moneys: duplicate(this.actor.getMoneys()),
|
||||
description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}),
|
||||
notes: await TextEditor.enrichHTML(this.object.system.biodata.notes, {async: true}),
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
editScore: this.options.editScore,
|
||||
isGM: game.user.isGM
|
||||
}
|
||||
formData.partySlots = this.actor.buildPartySlots()
|
||||
|
||||
this.formData = formData
|
||||
console.log("PARTY : ", formData, this.object);
|
||||
return formData;
|
||||
}
|
||||
|
||||
}
|
@@ -231,6 +231,7 @@ export class WarheroUtility {
|
||||
'systems/fvtt-warhero/templates/partial-item-description.html',
|
||||
'systems/fvtt-warhero/templates/partial-item-common-equipment.html',
|
||||
'systems/fvtt-warhero/templates/partial-actor-equipment.html',
|
||||
'systems/fvtt-warhero/templates/partial-container.html',
|
||||
]
|
||||
return loadTemplates(templatePaths);
|
||||
}
|
||||
|
Reference in New Issue
Block a user