Various fixes

This commit is contained in:
LeRatierBretonnien 2023-03-14 09:14:28 +01:00
parent a63ec19362
commit fef42b7093
8 changed files with 98 additions and 36 deletions

View File

@ -53,6 +53,7 @@ export class MournbladeActorSheet extends ActorSheet {
metier: duplicate(this.actor.getMetier() || {}),
combat: this.actor.getCombatValues(),
equipements: duplicate(this.actor.getEquipments()),
monnaies: duplicate(this.actor.getMonnaies()),
description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}),
options: this.options,
owner: this.document.isOwner,
@ -95,7 +96,7 @@ export class MournbladeActorSheet extends ActorSheet {
let value = ev.currentTarget.value
this.actor.editItemField(itemId, itemType, itemField, dataType, value)
})
html.find('.quantity-minus').click(event => {
const li = $(event.currentTarget).parents(".item");
this.actor.incDecQuantity( li.data("item-id"), -1 );
@ -131,7 +132,16 @@ export class MournbladeActorSheet extends ActorSheet {
let armeId = li.data("item-id")
this.actor.rollArmeDegats(armeId)
})
html.find('.quantity-modify').click(event => {
const li = $(event.currentTarget).parents(".item")
const value = Number($(event.currentTarget).data("quantite-value"))
this.actor.incDecQuantity( li.data("item-id"), value );
})
html.find('.item-add').click((event) => {
const itemType = $(event.currentTarget).data("type")
this.actor.createEmbeddedDocuments('Item', [{ name: `Nouveau ${itemType}`, type: itemType }], { renderSheet: true })
})
html.find('.lock-unlock-sheet').click((event) => {
this.options.editScore = !this.options.editScore;

View File

@ -96,27 +96,33 @@ export class MournbladeActor extends Actor {
armes.push(this.prepareBouclier(arme))
}
}
MournbladeUtility.sortArrayObjectsByName(armes)
return armes
}
/* -------------------------------------------- */
getDons() {
return this.items.filter(item => item.type == "don")
getItemSorted( types) {
let items = this.items.filter(item => types.includes(item.type )) || []
MournbladeUtility.sortArrayObjectsByName(items)
return items
}
getDons() {
return this.getItemSorted(["don"])
}
/* -------------------------------------------- */
getTendances() {
return this.items.filter(item => item.type == "tendance")
return this.getItemSorted(["tendance"])
}
getRunes() {
return this.items.filter(item => item.type == "rune")
return this.getItemSorted(["rune"])
}
/* -------------------------------------------- */
getEquipments() {
return this.items.filter(item => item.type == "equipement")
return this.getItemSorted(["monnaie"])
}
getMonnaies() {
return this.getItemSorted(["monnaie"])
}
/* -------------------------------------------- */
getArmors() {
return this.items.filter(item => item.type == "protection")
return this.getItemSorted(["protection"])
}
getOrigine() {
return this.items.find(item => item.type == "origine")
@ -147,17 +153,8 @@ export class MournbladeActor extends Actor {
comp.push(item)
}
}
return comp.sort(function (a, b) {
let fa = a.name.toLowerCase(),
fb = b.name.toLowerCase();
if (fa < fb) {
return -1;
}
if (fa > fb) {
return 1;
}
return 0;
})
MournbladeUtility.sortArrayObjectsByName(comp)
return comp
}
/* -------------------------------------------- */
@ -359,11 +356,10 @@ export class MournbladeActor extends Actor {
async incDecQuantity(objetId, incDec = 0) {
let objetQ = this.items.get(objetId)
if (objetQ) {
let newQ = objetQ.system.quantity + incDec;
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantity': newQ }]); // pdates one EmbeddedEntity
let newQ = objetQ.system.quantite + incDec;
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantite': newQ }]); // pdates one EmbeddedEntity
}
}
/* -------------------------------------------- */
getCompetence(compId) {
return this.items.get(compId)

View File

@ -68,7 +68,8 @@ function welcomeMessage() {
content: `<div id="welcome-message-Mournblade"><span class="rdd-roll-part">
<strong>Bienvenue dans les Jeunes Royaumes de Mournblade !</strong>
<p>Les livres de Mournblade sont nécessaires pour jouer : https://www.titam-france.fr</p>
<p>Mournblade est jeude rôle publié par Titam France/Sombres projets, tout les droits leur appartiennent.<p>
<p>Mournblade est jeu de rôle publié par Titam France/Sombres projets, tout les droits leur appartiennent.</p>
<p>Système développé par LeRatierBretonnien, support sur le <a href="https://discord.gg/pPSDNJk">Discord FR de Foundry</a>.</p>
` });
}

View File

@ -67,6 +67,13 @@ export class MournbladeUtility {
return opt.concat("\n")
}
/* -------------------------------------------- */
static sortArrayObjectsByName(myArray) {
myArray.sort((a, b) => {
return a.name.localeCompare(b.name);
})
}
/* -------------------------------------------- */
static getPointAmeOptions() {
let opt = []

View File

@ -1,7 +1,7 @@
{
"id": "fvtt-mournblade",
"description": "Mournblade RPG for FoundryVTT",
"version": "10.0.12",
"version": "10.0.13",
"authors": [
{
"name": "Uberwald/LeRatierBretonnien",
@ -15,7 +15,7 @@
"gridUnits": "m",
"license": "LICENSE.txt",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-mournblade/raw/branch/v10/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-mournblade/archive/fvtt-mournblade-10.0.12.zip",
"download": "https://www.uberwald.me/gitea/public/fvtt-mournblade/archive/fvtt-mournblade-10.0.13.zip",
"packs": [
{
"type": "Item",
@ -137,7 +137,6 @@
"background": "systems/fvtt-mournblade/assets/ui/fond_mournblade.webp",
"compatibility": {
"minimum": "10",
"verified": "10.286",
"maximum": "10"
"verified": "10.288"
}
}

View File

@ -233,6 +233,8 @@
]
},
"monnaie": {
"quantite": 0,
"unite": "",
"templates": [
"base"
]

View File

@ -277,7 +277,7 @@
<span class="item-name-label-header">
<h3><label class="items-title-text">Runes</label></h3>
</span>
<span class="item-field-label-short">
<span class="item-field-label-long">
<label class="short-label">Haut parler</label>
</span>
<span class="item-field-label-short">
@ -291,7 +291,7 @@
<li class="item flexrow " data-item-id="{{rune._id}}" data-item-type="rune">
<img class="item-name-img" src="{{rune.img}}" />
<span class="item-name-label competence-name"><a class="roll-rune">{{rune.name}}</a></span>
<span class="item-field-label-short">{{rune.system.formule}}</span>
<span class="item-field-label-long">{{rune.system.formule}}</span>
<span class="item-field-label-short">{{rune.system.seuil}}</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
@ -342,6 +342,43 @@
<div class="flexcol">
<div class="sheet-box color-bg-archetype">
<ul class="item-list alternate-list">
<li class="item flexrow list-item items-title-bg">
<span class="item-name-label-header">
<h3><label class="items-title-text">Richesses et Argent</label></h3>
</span>
<span class="item-field-label-medium">
<label class="short-label">Quantité</label>
</span>
<span class="item-field-label-medium">
<label class="short-label">Unité</label>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-add" data-type="monnaie" title="Ajouter une monnaie"><i
class="fas fa-plus"></i></a>
</div>
</li>
{{#each monnaies as |monnaie key|}}
<li class="item flexrow " data-item-id="{{monnaie._id}}" data-item-type="monnaie">
<img class="item-name-img" src="{{monnaie.img}}" />
<span class="item-name-label competence-name">{{monnaie.name}}</span>
<span class="item-name-label competence-name item-field-label-medium">{{monnaie.system.quantite}}
<a class="quantity-modify plus-minus-button" data-quantite-value="-1">-</a>
<a class="quantity-modify plus-minus-button" data-quantite-value="+1">+</a>
</span>
<span class="item-name-label competence-name item-field-label-medium">{{monnaie.system.unite}}</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</div>
<div class="sheet-box color-bg-archetype">
<ul class="item-list alternate-list">
<li class="item flexrow list-item items-title-bg">
@ -413,7 +450,7 @@
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-add" data-type="arme" title="Ajouter une arme"><i
<a class="item-control item-add" data-type="protection" title="Ajouter une protection"><i
class="fas fa-plus"></i></a>
</div>
</li>
@ -442,7 +479,7 @@
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control item-add" data-type="arme" title="Ajouter une arme"><i
<a class="item-control item-add" data-type="equipement" title="Ajouter un équipement"><i
class="fas fa-plus"></i></a>
</div>
</li>

View File

@ -10,8 +10,18 @@
<section class="sheet-body">
<div class="flexcol">
{{> systems/fvtt-mournblade/templates/partial-item-description.html}}
<div class="flexcol">
<span class="flexrow">
<label class="generic-label">Quantité : </label>
<input type="text" class="padd-right status-small-label color-class-common" name="system.quantite" value="{{data.quantite}}" data-dtype="Number" />
</span>
<span class="flexrow">
<label class="generic-label">Unité/Monnaie : </label>
<input type="text" class="padd-right color-class-common" name="system.unite" value="{{data.unite}}" data-dtype="String" />
</span>
{{> systems/fvtt-mournblade/templates/partial-item-description.html}}
</div>