Petits fixes suite à tests #552

Merged
uberwald merged 4 commits from VincentVk/foundryvtt-reve-de-dragon:v10-fixes into v10 2022-09-16 08:34:19 +02:00
33 changed files with 659 additions and 863 deletions

View File

@ -200,7 +200,6 @@ export class RdDActor extends Actor {
async checkMonnaiePresence() { // Ajout opportuniste si les pièces n'existent pas.
if (!this.items) return; // Sanity check during import
let manquantes = Monnaie.monnaiesManquantes(this.itemTypes['monnaie']);
//console.log("Manque : ", manquantes);
if (manquantes.length > 0) {
await this.createEmbeddedDocuments('Item', manquantes, { renderSheet: false });
}
@ -929,26 +928,27 @@ export class RdDActor extends Actor {
if (!competence) {
return;
}
const stress = this.system.compteurs.experience.value;
const niveau = Number(competence.system.niveau);
const stressTransforme = this.system.compteurs.experience.value;
const xpRequis = RdDItemCompetence.getCompetenceNextXp(niveau) - competence.system.xp;
if (stressTransforme <= 0 || niveau >= competence.system.niveau_archetype || xpRequis <= 0) {
const xpSuivant = RdDItemCompetence.getCompetenceNextXp(niveau);
const xpRequis = xpSuivant - competence.system.xp;
if (stress <= 0 || niveau >= competence.system.niveau_archetype) {
ui.notifications.info(`La compétence ne peut pas augmenter!
stress disponible: ${stressTransforme}
stress disponible: ${stress}
expérience requise: ${xpRequis}
niveau : ${niveau}
archétype : ${competence.system.niveau_archetype}`);
return;
}
const xpUtilise = Math.min(stressTransforme, xpRequis);
const gainNiveau = xpUtilise >= xpRequis ? 1 : 0;
const xpUtilise = Math.max(0, Math.min(stress, xpRequis));
const gainNiveau = (xpUtilise >= xpRequis || xpRequis <=0) ? 1 : 0;
const nouveauNiveau = niveau + gainNiveau;
const nouveauXp = gainNiveau > 0 ? Math.max(competence.system.xp - xpRequis, 0) : (competence.system.xp + xpUtilise);
const nouveauXp = gainNiveau > 0 ? Math.max(competence.system.xp - xpSuivant, 0) : (competence.system.xp + xpUtilise);
await competence.update({
"system.xp": nouveauXp,
"system.niveau": nouveauNiveau,
});
const stressTransformeRestant = Math.max(0, stressTransforme - xpUtilise);
const stressTransformeRestant = Math.max(0, stress - xpUtilise);
await this.update({ "system.compteurs.experience.value": stressTransformeRestant });
this.updateExperienceLog('Dépense stress', xpUtilise, `Stress en ${competence.name} ${gainNiveau ? "pour passer à " + nouveauNiveau : ""}`);
}

View File

@ -22,12 +22,19 @@ const MONNAIES_STANDARD = [
system: { quantite: 0, valeur_deniers: 1000, encombrement: 0.004, description: "" }
}
]
const VALEURS_STANDARDS = MONNAIES_STANDARD.map(it =>it.system.valeur_deniers);
export class Monnaie {
static isSystemMonnaie(item) {
let present = MONNAIES_STANDARD.find(monnaie => monnaie.system.valeur_deniers == item?.system?.valeur_deniers);
return present;
static isSystemMonnaie(item, items) {
if (item.type == 'monnaie') {
const valeur = item.system.valeur_deniers;
if (VALEURS_STANDARDS.includes(valeur)) {
const monnaiesDeValeur = items.filter(it => it.type == 'monnaie' && it.system.valeur_deniers == valeur)
return monnaiesDeValeur.length<=1;
}
}
return false;
}
static monnaiesData() {
@ -40,10 +47,10 @@ export class Monnaie {
static monnaiesManquantes(disponibles) {
const manquantes = MONNAIES_STANDARD.filter(standard => !disponibles.find(disponible => Monnaie.deValeur(disponible, standard.system?.valeur_deniers)));
if (manquantes.length>0) {
if (manquantes.length > 0) {
console.error('monnaiesManquantes', manquantes, ' avec monnaies', disponibles, MONNAIES_STANDARD);
}
return []; //manquantes;
return manquantes;
}
static deValeur(monnaie, valeur) {

View File

@ -26,7 +26,7 @@ export class RdDSheetUtility {
destId: destItemId,
targetActorId: actorId,
itemId: item.id,
sourceActorId: item.actor.id,
sourceActorId: item.actor?.id,
srcId: objetVersConteneur[item.id],
onEnleverConteneur: () => { delete objetVersConteneur[item.id]; },
onAjouterDansConteneur: (itemId, conteneurId) => { objetVersConteneur[itemId] = conteneurId; }

View File

@ -130,6 +130,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-liens-vehicules.html',
'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-editor-notes-mj.html',
//Items
'systems/foundryvtt-reve-de-dragon/templates/header-item.html',
'systems/foundryvtt-reve-de-dragon/templates/item-competence-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-competencecreature-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-arme-sheet.html',
@ -860,7 +861,7 @@ export class RdDUtility {
let itemId = li.data("item-id");
let objet = actorSheet.actor.getObjet(itemId);
if (objet.type == 'monnaie' && Monnaie.isSystemMonnaie(objet)) {
if (Monnaie.isSystemMonnaie(objet, actorSheet.actor.items)) {
ui.notifications.warn("Suppression des monnaies de base impossible");
return;
}

View File

@ -0,0 +1,6 @@
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>

View File

@ -1,10 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">

View File

@ -1,10 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
@ -31,5 +26,4 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -23,5 +17,4 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -18,7 +12,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -46,7 +40,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -41,7 +35,5 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -35,7 +29,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -50,7 +44,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,10 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
@ -48,7 +43,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,10 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
@ -33,7 +28,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -78,7 +72,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -26,7 +20,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -26,7 +20,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -18,7 +12,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -26,5 +20,4 @@
</div>
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}" />
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -55,7 +49,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -30,7 +24,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -14,7 +8,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -20,10 +14,6 @@
<label for="xp">Compteur </label>
<input class="attribute-value" type="text" name="system.compteur" value="{{system.compteur}}" data-dtype="Number"/>
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -14,7 +8,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -38,7 +32,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -36,7 +30,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,16 +1,7 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -76,7 +70,5 @@
{{/if}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,16 +1,8 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
@ -74,7 +68,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,11 +1,5 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="flexcol">
@ -23,7 +17,5 @@
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>

View File

@ -1,16 +1,8 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.html"}}
{{!-- Sheet Body --}}
<section class="sheet-body">
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>