New slots

This commit is contained in:
LeRatierBretonnien 2023-03-10 18:32:13 +01:00
parent 36c9945886
commit c2a7fbb4b5
12 changed files with 345 additions and 84 deletions

View File

@ -53,6 +53,17 @@
"WH.conf.beltpouch1": "Beltpouch 1",
"WH.conf.beltpouch2": "Beltpouch 2",
"WH.conf.beltpouch3": "Beltpouch 3",
"WH.conf.scrollcase": "Scroll case",
"WH.conf.wandcase": "Wand case",
"WH.conf.potioncase": "Potion case",
"WH.conf.bagholding": "Bag of holding",
"WH.conf.quiverholding": "Quiver of holding",
"WH.conf.backpackholding": "Backpack of holding",
"WH.conf.smallchest": "Small chest",
"WH.conf.mediumchest": "Medium chest",
"WH.conf.largechest": "Large chest",
"WH.conf.hugechest": "Huge chest",
"WH.conf.partystorage": "Party chest/storage",
"WH.conf.unknown": "Unknown",
"WH.conf.yes": "Yes",
@ -192,6 +203,9 @@
"WH.ui.raceSkills": "Race skills",
"WH.ui.identified": "Identified",
"WH.ui.bodyslots": "Body",
"WH.ui.containerslot": "Containers",
"WH.chat.save": "Save",
"WH.chat.mweaponmalus": "Multiple weapons malus ",
"WH.chat.diceresult": "Dice result",

View File

@ -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}),
@ -67,6 +66,12 @@ export class WarheroActorSheet extends ActorSheet {
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
// Race mngt

View File

@ -184,11 +184,36 @@ export class WarheroActor extends Actor {
this.items.forEach(it => { if (it.type == 'money') { nbMoney += it.system.quantity } })
return nbMoney
}
/* -------------------------------------------- */
buildEquipmentsSlot() {
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)
@ -205,6 +230,34 @@ export class WarheroActor extends Actor {
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]
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
}
/* -------------------------------------------- */
@ -695,8 +748,7 @@ 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) {

View File

@ -22,6 +22,10 @@ export const WARHERO_CONFIG = {
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"},
cloak: {nbslots: 1, itemtype:"equipment", label: "WH.conf.cloak"},
@ -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: {

View File

@ -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 });

View 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;
}
}

View File

@ -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);
}

View File

@ -107,7 +107,7 @@
"styles": [
"styles/simple.css"
],
"version": "10.0.38",
"version": "10.0.40",
"compatibility": {
"minimum": "10",
"verified": "10",
@ -115,7 +115,7 @@
},
"title": "Warhero RPG",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-warhero/raw/branch/master/system.json",
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-warhero/archive/fvtt-warhero-10.0.38.zip",
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-warhero/archive/fvtt-warhero-10.0.40.zip",
"url": "https://www.uberwald.me/gitea/public/fvtt-warhero",
"background": "images/ui/warhero_welcome_page.webp",
"id": "fvtt-warhero"

View File

@ -3,7 +3,8 @@
"types": [
"character",
"npc",
"monster"
"monster",
"party"
],
"templates": {
"biodata": {
@ -212,6 +213,11 @@
"description": ""
}
},
"party": {
"templates": [
"biodata"
]
},
"character": {
"templates": [
"biodata",

View File

@ -486,58 +486,19 @@
<label class="">{{localize "WH.ui.totalmoney"}} : {{totalMoney}}</label>
</div>
{{#each slotEquipments as |slot slotKey|}}
<ul class="item-list alternate-list">
<li class="item flexrow list-item items-title-bg {{#if (gt slot.slotUsed slot.nbslots)}}items-title-bg-red{{/if}}">
<span class="item-name-label-header">
<h3><label class="items-title-text">{{localize slot.label}}</label></h3>
</span>
<span class="item-field-label-medium">
<label class="short-label">{{localize "WH.ui.Type"}}</label>
</span>
<span class="item-field-label-long">
<label class="short-label">{{localize "WH.ui.Qty"}}</label>
</span>
<span class="item-field-label-medium">
<label class="short-label">{{localize "WH.ui.maxslots"}}: {{slot.nbslots}}</label>
</span>
<span class="item-field-label-medium">
<label class="short-label">{{localize "WH.ui.slotsused"}}: {{slot.slotUsed}}</label>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-add" data-type="{{itemtype}}" data-slot="{{slotKey}}" title="Create Item"><i class="fas fa-plus"></i></a>
</div>
</li>
{{#each slot.content as |item itemKey|}}
<li class="item flexrow list-item list-item-shadow" data-item-id="{{item._id}}">
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
src="{{item.img}}" /></a>
<span class="item-name-label">{{item.name}}</span>
<hr>
<h3>{{localize "WH.ui.bodyslots"}} : </h3>
<span class="item-field-label-medium">
<label class="short-label">{{upperFirst item.type}}</label>
</span>
<span class="item-field-label-long"><label>
{{item.system.quantity}}
(<a class="quantity-minus plus-minus-button"> -</a>/<a class="quantity-plus plus-minus-button">+</a>)
</label>
</span>
<span class="item-field-label-medium">
<label class="short-label">{{localize (concat "WH.conf." item.system.isidentified)}}</label>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
{{#each bodyContainers as |slot slotKey|}}
{{> systems/fvtt-warhero/templates/partial-container.html slot=slot}}
{{/each}}
<hr>
<h3>{{localize "WH.ui.containerslot"}} : </h3>
{{#each equipmentContainers as |slot slotKey|}}
{{> systems/fvtt-warhero/templates/partial-container.html slot=slot}}
{{/each}}
<hr>

View File

@ -0,0 +1,49 @@
<ul class="item-list alternate-list">
<li class="item flexrow list-item items-title-bg {{#if (gt slot.slotUsed slot.nbslots)}}items-title-bg-red{{/if}}">
<span class="item-name-label-header">
<h3><label class="items-title-text">{{localize slot.label}}</label></h3>
</span>
<span class="item-field-label-medium">
<label class="short-label">{{localize "WH.ui.Type"}}</label>
</span>
<span class="item-field-label-long">
<label class="short-label">{{localize "WH.ui.Qty"}}</label>
</span>
<span class="item-field-label-medium">
<label class="short-label">{{localize "WH.ui.maxslots"}}: {{slot.nbslots}}</label>
</span>
<span class="item-field-label-medium">
<label class="short-label">{{localize "WH.ui.slotsused"}}: {{slot.slotUsed}}</label>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-add" data-type="{{itemtype}}" data-slot="{{slotKey}}" title="Create Item"><i class="fas fa-plus"></i></a>
</div>
</li>
{{#each slot.content as |item itemKey|}}
<li class="item flexrow list-item list-item-shadow" data-item-id="{{item._id}}">
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
src="{{item.img}}" /></a>
<span class="item-name-label">{{item.name}}</span>
<span class="item-field-label-medium">
<label class="short-label">{{upperFirst item.type}}</label>
</span>
<span class="item-field-label-long"><label>
{{item.system.quantity}}
(<a class="quantity-minus plus-minus-button"> -</a>/<a class="quantity-plus plus-minus-button">+</a>)
</label>
</span>
<span class="item-field-label-medium">
<label class="short-label">{{localize (concat "WH.conf." item.system.isidentified)}}</label>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>

100
templates/party-sheet.html Normal file
View File

@ -0,0 +1,100 @@
<form class="{{cssClass}}" autocomplete="off">
{{!-- Sheet Header --}}
<header class="sheet-header">
<div class="header-fields">
<h1 class="charname margin-right"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
<div class="flexrow">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
<div class="flexcol">
</div>
</div>
</div>
</header>
{{!-- Sheet Tab Navigation --}}
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="equipment">{{localize "WH.ui.equipment"}}</a>
<a class="item" data-tab="biodata">{{localize "WH.ui.biography"}}</a>
</nav>
{{!-- Sheet Body --}}
<section class="sheet-body">
{{!-- Equipement Tab --}}
<div class="tab equipment" data-group="primary" data-tab="equipment">
{{#each partySlots as |slot slotKey|}}
<ul class="item-list alternate-list">
<li class="item flexrow list-item items-title-bg {{#if (gt slot.slotUsed slot.nbslots)}}items-title-bg-red{{/if}}">
<span class="item-name-label-header">
<h3><label class="items-title-text">{{localize slot.label}}</label></h3>
</span>
<span class="item-field-label-medium">
<label class="short-label">{{localize "WH.ui.Type"}}</label>
</span>
<span class="item-field-label-long">
<label class="short-label">{{localize "WH.ui.Qty"}}</label>
</span>
<span class="item-field-label-medium">
<label class="short-label">{{localize "WH.ui.maxslots"}}: {{slot.nbslots}}</label>
</span>
<span class="item-field-label-medium">
<label class="short-label">{{localize "WH.ui.slotsused"}}: {{slot.slotUsed}}</label>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-add" data-type="{{itemtype}}" title="Create Item"><i class="fas fa-plus"></i></a>
</div>
</li>
{{#each slot.content as |item itemKey|}}
<li class="item flexrow list-item list-item-shadow" data-item-id="{{item._id}}">
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
src="{{item.img}}" /></a>
<span class="item-name-label">{{item.name}}</span>
<span class="item-field-label-medium">
<label class="short-label">{{upperFirst item.type}}</label>
</span>
<span class="item-field-label-long"><label>
{{item.system.quantity}}
(<a class="quantity-minus plus-minus-button"> -</a>/<a class="quantity-plus plus-minus-button">+</a>)
</label>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
{{/each}}
<hr>
</div>
{{!-- Biography Tab --}}
<div class="tab biodata" data-group="primary" data-tab="biodata">
<hr>
<h3>{{localize "WH.ui.background"}} : </h3>
<div class="form-group editor">
{{editor description target="system.biodata.description" button=true owner=owner
editable=editable}}
</div>
<hr>
<h3>{{localize "WH.ui.notes"}} : </h3>
<div class="form-group editor">
{{editor notes target="system.biodata.notes" button=true owner=owner editable=editable}}
</div>
<hr>
</article>
</div>
</section>
</form>