From e02f35540547679646eccfd772b45384836adbdf Mon Sep 17 00:00:00 2001
From: Vincent Vandemeulebrouck
Date: Fri, 10 Dec 2021 01:16:45 +0100
Subject: [PATCH 1/5] Correction stress sans monter de niveau
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
l'expérience n'était pas augmenté si insuffisante pour monter de niveau
---
module/actor.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/module/actor.js b/module/actor.js
index 1aaebd46..a3b8b0ec 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -936,15 +936,15 @@ export class RdDActor extends Actor {
return;
}
const xpUtilise = Math.min(stressTransforme, xpRequis);
- const stressTransformeRestant = Math.max(0, stressTransforme - xpUtilise);
const gainNiveau = xpUtilise >= xpRequis ? 1 : 0;
-
- await this.update({ "data.compteurs.experience.value": stressTransformeRestant });
const nouveauNiveau = niveau + gainNiveau;
+ const nouveauXp = gainNiveau > 0 ? Math.max(compData.data.xp - xpRequis, 0) : (compData.data.xp + xpUtilise);
await competence.update({
- "data.xp": Math.max(compData.data.xp - xpRequis, 0),
+ "data.xp": nouveauXp,
"data.niveau": nouveauNiveau,
});
+ const stressTransformeRestant = Math.max(0, stressTransforme - xpUtilise);
+ await this.update({ "data.compteurs.experience.value": stressTransformeRestant });
this.updateExperienceLog('Dépense stress', xpUtilise, `Stress en ${competence.name} ${gainNiveau ? "pour passer à " + nouveauNiveau : ""}`);
}
From 508d352b0b6059d014fbb22b39b84115710a7c2e Mon Sep 17 00:00:00 2001
From: Vincent Vandemeulebrouck
Date: Fri, 10 Dec 2021 01:18:59 +0100
Subject: [PATCH 2/5] Fix vente/don de conteneur
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Pour passer par le tchat, le conteneur doit être vide.
Correction du calcul de quantité pour les conteneurs.
---
module/actor.js | 2 +-
module/dialog-item-vente.js | 7 ++++---
module/item-sheet.js | 3 +--
module/item.js | 18 +++++++++++++++---
4 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/module/actor.js b/module/actor.js
index a3b8b0ec..e786e985 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -3711,7 +3711,7 @@ export class RdDActor extends Actor {
}
const itemVendu = Misc.data(vendeur?.getObjet(itemId));
if (itemVendu) {
- if (isItemEmpilable ? itemVendu.data.quantite < achat.quantiteTotal : achat.choix.nombreLots != 1) {
+ if (isItemEmpilable ? (itemVendu.data.quantite < achat.quantiteTotal) : (achat.choix.nombreLots != 1)) {
await acheteur?.ajouterDeniers(coutDeniers);
ChatUtility.notifyUser(achat.userId, 'warn', `Le vendeur n'a plus assez de ${vente.item.name} !`);
return;
diff --git a/module/dialog-item-vente.js b/module/dialog-item-vente.js
index a0a5dcf4..b0802171 100644
--- a/module/dialog-item-vente.js
+++ b/module/dialog-item-vente.js
@@ -5,6 +5,7 @@ export class DialogItemVente extends Dialog {
static async create(item, callback) {
const itemData = Misc.data(item);
+ const quantite = item.isConteneur() ? 1 : itemData.data.quantite;
const venteData = {
item: itemData,
alias: item.actor?.name ?? game.user.name,
@@ -13,9 +14,9 @@ export class DialogItemVente extends Dialog {
prixUnitaire: itemData.data.cout,
prixLot: itemData.data.cout,
tailleLot: 1,
- quantiteNbLots: itemData.data.quantite,
- quantiteMaxLots: itemData.data.quantite,
- quantiteMax: itemData.data.quantite,
+ quantiteNbLots: quantite,
+ quantiteMaxLots: quantite,
+ quantiteMax: quantite ,
quantiteIllimite: !item.isOwned,
isOwned: item.isOwned,
};
diff --git a/module/item-sheet.js b/module/item-sheet.js
index 2863e30c..d46a8a83 100644
--- a/module/item-sheet.js
+++ b/module/item-sheet.js
@@ -30,10 +30,9 @@ export class RdDItemSheet extends ItemSheet {
/* -------------------------------------------- */
_getHeaderButtons() {
let buttons = super._getHeaderButtons();
- const videSiConteneur = this.object.isConteneur() ? this.object.isVide() : true;
// Add "Post to chat" button
// We previously restricted this to GM and editable items only. If you ever find this comment because it broke something: eh, sorry!
- if ("cout" in Misc.templateData(this.object) && videSiConteneur) {
+ if ("cout" in Misc.templateData(this.object) && this.object.isVideOuNonConteneur()) {
buttons.unshift({
class: "post",
icon: "fas fa-comments-dollar",
diff --git a/module/item.js b/module/item.js
index 679f21b6..f6fc38d9 100644
--- a/module/item.js
+++ b/module/item.js
@@ -63,8 +63,16 @@ export class RdDItem extends Item {
return Misc.data(this).type == 'conteneur';
}
- isVide() {
- return this.isConteneur() && (Misc.templateData(this).contenu ?? []).length == 0;
+ isConteneurNonVide() {
+ return this.isConteneur() && (Misc.templateData(this).contenu?.length ?? 0) > 0;
+ }
+
+ isConteneurVide() {
+ return this.isConteneur() && (Misc.templateData(this).contenu?.length ?? 0) == 0;
+ }
+
+ isVideOuNonConteneur() {
+ return !this.isConteneur() || (Misc.templateData(this).contenu?.length ?? 0) == 0;
}
isAlcool() {
@@ -143,7 +151,7 @@ export class RdDItem extends Item {
getActionPrincipale(options = { warnIfNot: true }) {
const itemData = Misc.data(this);
- if (itemData.type != 'conteneur' && (itemData.data.quantite ?? 0) <= 0) {
+ if (!this.isConteneur() && (itemData.data.quantite ?? 0) <= 0) {
if (options.warnIfNot) {
ui.notifications.warn(`Vous n'avez plus de ${itemData.name}.`);
}
@@ -217,6 +225,10 @@ export class RdDItem extends Item {
async proposerVente() {
console.log(this);
+ if (this.isConteneurNonVide()) {
+ ui.notifications.warn(`Votre ${this.name} n'est pas vide, pas possible de le donner ou le vendre`);
+ return;
+ }
const dialog = await DialogItemVente.create(this, (vente) => this._onProposerVente(vente))
dialog.render(true);
}
From 4aef9c05716b03883e0962bb9a18eb0b260d7a47 Mon Sep 17 00:00:00 2001
From: Vincent Vandemeulebrouck
Date: Fri, 10 Dec 2021 01:21:01 +0100
Subject: [PATCH 3/5] =?UTF-8?q?Montrer=20son=20=C3=A9quipement?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
On peut aussi le montrer sans le vendre
---
module/actor-sheet.js | 5 ++
module/item-sheet.js | 18 +++---
module/item.js | 64 -------------------
.../actor-sheet-inventaire-conteneur.html | 1 +
templates/post-item.html | 22 -------
5 files changed, 16 insertions(+), 94 deletions(-)
diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index e5ac0586..808b1c70 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -188,6 +188,11 @@ export class RdDActorSheet extends ActorSheet {
const item = RdDSheetUtility.getItem(event, this.actor);
item?.proposerVente();
});
+ html.find('.item-montrer').click(async event => {
+ const item = RdDSheetUtility.getItem(event, this.actor);
+ item?.postItem();
+ });
+
html.find('.item-action').click(async event => {
const item = RdDSheetUtility.getItem(event, this.actor);
this.actor.actionItem(item);
diff --git a/module/item-sheet.js b/module/item-sheet.js
index d46a8a83..204fa00b 100644
--- a/module/item-sheet.js
+++ b/module/item-sheet.js
@@ -34,18 +34,16 @@ export class RdDItemSheet extends ItemSheet {
// We previously restricted this to GM and editable items only. If you ever find this comment because it broke something: eh, sorry!
if ("cout" in Misc.templateData(this.object) && this.object.isVideOuNonConteneur()) {
buttons.unshift({
- class: "post",
+ class: "vendre",
icon: "fas fa-comments-dollar",
onclick: ev => this.item.proposerVente()
});
}
- else {
- buttons.unshift({
- class: "post",
- icon: "fas fa-comment",
- onclick: ev => this.item.postItem()
- });
- }
+ buttons.unshift({
+ class: "montrer",
+ icon: "fas fa-comment",
+ onclick: ev => this.item.postItem()
+ });
return buttons
}
@@ -202,6 +200,10 @@ export class RdDItemSheet extends ItemSheet {
const item = RdDSheetUtility.getItem(event, this.actor);
item?.proposerVente();
});
+ html.find('.item-montrer').click(async event => {
+ const item = RdDSheetUtility.getItem(event, this.actor);
+ item?.postItem();
+ });
html.find('.item-action').click(async event => {
const item = RdDSheetUtility.getItem(event, this.actor);
this.actor.actionItem(item, async () => itemSheetDialog.render(true));
diff --git a/module/item.js b/module/item.js
index f6fc38d9..23bfb441 100644
--- a/module/item.js
+++ b/module/item.js
@@ -262,70 +262,6 @@ export class RdDItem extends Item {
if (this.actor) {
chatData.actor = { id: this.actor.id };
}
- //Check if the posted item should have availability/pay buttons
- chatData.hasPrice = "cout" in chatData.data;
- chatData.data.cout_deniers = 0;
-
- let dialogResult = [-1, -1]; // dialogResult[0] = quantité, dialogResult[1] = prix
- if (chatData.hasPrice) {
- chatData.data.cout_deniers = Math.floor(chatData.data.cout * 100);
- dialogResult = await new Promise((resolve, reject) => {
- new Dialog({
- content:
- `Modifier la quantité?
-
-
-
-
- Modifier la prix?
-
-
-
-
- `,
- title: "Quantité & Prix",
- buttons: {
- post: {
- label: "Soumettre",
- callback: (dlg) => {
- resolve([Number(dlg.find('[name="quantity"]').val()), Number(dlg.find('[name="price"]').val())])
- }
- },
- }
- }).render(true)
- })
- }
-
- let quantiteEnvoi = this.isOwned ? Math.min(dialogResult[0], chatData.data.quantite) : dialogResult[0];
- const prixTotal = dialogResult[1];
- if (quantiteEnvoi > 0) {
- if (this.isOwned) {
- if (chatData.data.quantite == 0) {
- quantiteEnvoi = -1
- }
- else if (quantiteEnvoi > chatData.data.quantite) {
- quantiteEnvoi = chatData.data.quantite;
- ui.notifications.notify(`Impossible de poster plus que ce que vous avez. La quantité à été réduite à ${quantiteEnvoi}.`)
- }
- if (quantiteEnvoi > 0) {
- this.diminuerQuantite(quantiteEnvoi);
- }
- }
- }
-
- if (chatData.hasPrice) {
- if (quantiteEnvoi > 0)
- chatData.postQuantity = Number(quantiteEnvoi);
- if (prixTotal >= 0) {
- chatData.postPrice = prixTotal;
- chatData.data.cout_deniers = Math.floor(prixTotal * 100); // Mise à jour cout en deniers
- }
- chatData.finalPrice = Number(chatData.postPrice) * Number(chatData.postQuantity);
- chatData.data.cout_deniers_total = chatData.data.cout_deniers * Number(chatData.postQuantity);
- chatData.data.quantite = chatData.postQuantity;
- console.log("POST : ", chatData.finalPrice, chatData.data.cout_deniers_total, chatData.postQuantity);
- }
-
// JSON object for easy creation
chatData.jsondata = JSON.stringify(
{
diff --git a/templates/actor-sheet-inventaire-conteneur.html b/templates/actor-sheet-inventaire-conteneur.html
index b206db08..92d90dde 100644
--- a/templates/actor-sheet-inventaire-conteneur.html
+++ b/templates/actor-sheet-inventaire-conteneur.html
@@ -24,6 +24,7 @@
{{/if}}
+
{{#if item.data.actionPrincipale}}
{{item.data.actionPrincipale}}
{{/if}}
diff --git a/templates/post-item.html b/templates/post-item.html
index 36347ccf..57ef44aa 100644
--- a/templates/post-item.html
+++ b/templates/post-item.html
@@ -9,28 +9,6 @@
{{#each properties as |property p|}}
{{{property}}}
{{/each}}
- {{#if (or postQuantity postPrice)}}
-
- {{#if postQuantity}}
- Quantité: {{postQuantity}}
- {{/if}}
- {{#if postPrice}}
- Prix: {{postPrice}} Sols
- {{/if}}
-
- {{/if}}
-
- Prix Total: {{finalPrice}} Sols
-
- {{#if hasPrice}}
-
- Payer
-
- {{/if}}
-
From 76741579cc3503dfdae5aba86d40a0b69ced07dd Mon Sep 17 00:00:00 2001
From: Vincent Vandemeulebrouck
Date: Fri, 10 Dec 2021 01:21:39 +0100
Subject: [PATCH 4/5] typo: rencontrer, pas recontrer
---
module/rdd-tmr-rencontre-dialog.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/module/rdd-tmr-rencontre-dialog.js b/module/rdd-tmr-rencontre-dialog.js
index 75c43fce..50b03df2 100644
--- a/module/rdd-tmr-rencontre-dialog.js
+++ b/module/rdd-tmr-rencontre-dialog.js
@@ -5,7 +5,7 @@ export class RdDTMRRencontreDialog extends Dialog {
constructor(html, tmrApp, rencontre, postRencontre) {
const dialogConf = {
title: "Rencontre en TMR!",
- content: "Vous recontrez un " + rencontre.name + " de force " + rencontre.force + "
",
+ content: "Vous rencontrez un " + rencontre.name + " de force " + rencontre.force + "
",
buttons: {
derober: { icon: '', label: "Se dérober", callback: () => { this.onButtonFuir(() => tmrApp.derober()); } },
refouler: { icon: '', label: "Refouler", callback: () => this.onButtonAction(() => tmrApp.refouler()) },
From e6aebbe8c360ea90f285dd2ff034792217bf607b Mon Sep 17 00:00:00 2001
From: Vincent Vandemeulebrouck
Date: Sat, 11 Dec 2021 02:20:20 +0100
Subject: [PATCH 5/5] =?UTF-8?q?Fix=20edit=20objets=20d'un=20v=C3=A9hicule?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Nommage des events homogène
---
module/actor-creature-sheet.js | 6 +++---
module/actor-entite-sheet.js | 26 +++++++++++++-------------
module/actor-vehicule-sheet.js | 4 ++--
3 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/module/actor-creature-sheet.js b/module/actor-creature-sheet.js
index 218ba08f..215731aa 100644
--- a/module/actor-creature-sheet.js
+++ b/module/actor-creature-sheet.js
@@ -56,15 +56,15 @@ export class RdDActorCreatureSheet extends RdDActorSheet {
if (!this.options.editable) return;
// On competence change
- html.find('.creature-carac').change((event) => {
+ html.find('.creature-carac').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "carac_value", parseInt(event.target.value));
});
- html.find('.creature-niveau').change((event) => {
+ html.find('.creature-niveau').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "niveau", parseInt(event.target.value));
});
- html.find('.creature-dommages').change((event) => {
+ html.find('.creature-dommages').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value));
});
diff --git a/module/actor-entite-sheet.js b/module/actor-entite-sheet.js
index aa836cbf..eabaf828 100644
--- a/module/actor-entite-sheet.js
+++ b/module/actor-entite-sheet.js
@@ -69,59 +69,59 @@ export class RdDActorEntiteSheet extends ActorSheet {
if (!this.options.editable) return;
// Update Inventory Item
- html.find('.item-edit').click(ev => {
- const li = $(ev.currentTarget).parents(".item");
+ html.find('.item-edit').click(event => {
+ const li = $(event.currentTarget).parents(".item");
const item = this.actor.getEmbeddedDocument('Item', li.data("itemId"));
item.sheet.render(true);
});
// Delete Inventory Item
- html.find('.item-delete').click(ev => {
- const li = $(ev.currentTarget).parents(".item");
+ html.find('.item-delete').click(event => {
+ const li = $(event.currentTarget).parents(".item");
this.actor.deleteEmbeddedDocuments('Item', [li.data("itemId")]);
li.slideUp(200, () => this.render(false));
});
// Roll Carac
- html.find('.carac-label a').click((event) => {
+ html.find('.carac-label a').click(async event => {
let caracName = event.currentTarget.attributes.name.value;
this.actor.rollCarac( caracName.toLowerCase() );
});
// On competence change
- html.find('.creature-carac').change((event) => {
+ html.find('.creature-carac').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "carac_value", parseInt(event.target.value) );
} );
- html.find('.creature-niveau').change((event) => {
+ html.find('.creature-niveau').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "niveau", parseInt(event.target.value) );
} );
- html.find('.creature-dommages').change((event) => {
+ html.find('.creature-dommages').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "dommages", parseInt(event.target.value) );
} );
// Roll Skill
- html.find('.competence-label a').click((event) => {
+ html.find('.competence-label a').click(async event => {
let compName = event.currentTarget.text;
this.actor.rollCompetence( compName );
});
- html.find('.endurance-plus').click((event) => {
+ html.find('.endurance-plus').click(event => {
this.actor.santeIncDec("endurance", 1);
this.render(true);
});
- html.find('.endurance-moins').click((event) => {
+ html.find('.endurance-moins').click(event => {
this.actor.santeIncDec("endurance", -1);
this.render(true);
});
- html.find('.encaisser-direct').click(ev => {
+ html.find('.encaisser-direct').click(event => {
this.actor.encaisser();
});
- html.find('.remise-a-neuf').click(ev => {
+ html.find('.remise-a-neuf').click(event => {
if (game.user.isGM) {
this.actor.remiseANeuf();
}
diff --git a/module/actor-vehicule-sheet.js b/module/actor-vehicule-sheet.js
index 8b2f6096..4ae2356c 100644
--- a/module/actor-vehicule-sheet.js
+++ b/module/actor-vehicule-sheet.js
@@ -103,12 +103,12 @@ export class RdDActorVehiculeSheet extends ActorSheet {
if (!this.options.editable) return;
// Update Inventory Item
- html.find('.item-edit').click(ev => {
+ html.find('.item-edit').click(async event => {
const item = RdDSheetUtility.getItem(event, this.actor);
item.sheet.render(true);
});
// Delete Inventory Item
- html.find('.item-delete').click(ev => {
+ html.find('.item-delete').click(async event => {
const li = RdDSheetUtility.getEventElement(event);
RdDUtility.confirmerSuppression(this, li);
});