Merge branch 'v1.5-fixes' into 'v1.5'

Petits fixes mineurs

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!288
This commit is contained in:
Leratier Bretonnien 2021-10-08 15:05:08 +00:00
commit 15c2bc395b
4 changed files with 59 additions and 12 deletions

View File

@ -519,6 +519,7 @@ export class RdDActor extends Actor {
await this.santeIncDec("vie", -1); await this.santeIncDec("vie", -1);
} }
else { else {
blessure.jours++;
message.content += ` -- une blessure ${type} reste stable`; message.content += ` -- une blessure ${type} reste stable`;
} }
} }
@ -2111,7 +2112,8 @@ export class RdDActor extends Actor {
xp: carac.xp xp: carac.xp
} }
if (display) { if (display) {
ChatUtility.createChatWithRollMode(this.name, { ChatMessage.create({
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html`, checkXp) content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html`, checkXp)
}); });
} }
@ -2142,7 +2144,8 @@ export class RdDActor extends Actor {
archetypeWarning: newCompData.data.niveau > compData.data.niveau_archetype archetypeWarning: newCompData.data.niveau > compData.data.niveau_archetype
} }
if (display) { if (display) {
ChatUtility.createChatWithRollMode(this.name, { ChatMessage.create({
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html`, checkXp) content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html`, checkXp)
}); });
} }
@ -2156,11 +2159,10 @@ export class RdDActor extends Actor {
if (!this.isPersonnage()) return; if (!this.isPersonnage()) return;
let xpData = await this._appliquerExperience(rollData.rolled, rollData.selectedCarac.label, rollData.competence); let xpData = await this._appliquerExperience(rollData.rolled, rollData.selectedCarac.label, rollData.competence);
if (xpData && display) { if (xpData && display) {
let message = { ChatMessage.create({
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name), whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-gain-xp.html`, xpData) content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-gain-xp.html`, xpData)
} });
ChatMessage.create(message);
} }
} }
@ -2991,8 +2993,8 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getCaracByName(caracName) { getCaracByName(name) {
switch (Grammar.toLowerCaseNoAccent(caracName)) { switch (Grammar.toLowerCaseNoAccent(name)) {
case 'reve-actuel': case 'reve actuel': case 'reve-actuel': case 'reve actuel':
return { return {
label: 'Rêve actuel', label: 'Rêve actuel',
@ -3006,14 +3008,14 @@ export class RdDActor extends Actor {
type: "number" type: "number"
}; };
} }
return RdDActor._findCaracByName(Misc.templateData(this).carac, caracName); return RdDActor._findCaracByName(Misc.templateData(this).carac, name);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _findCaracByName(carac, name) { static _findCaracByName(carac, name) {
name = Grammar.toLowerCaseNoAccent(name); name = Grammar.toLowerCaseNoAccent(name);
switch (name) { switch (name) {
case 'reve-actuel': case 'rêve actuel': case 'reve-actuel': case 'reve actuel':
return carac.reve; return carac.reve;
case 'chance-actuelle': case 'chance actuelle': case 'chance-actuelle': case 'chance actuelle':
return carac.chance; return carac.chance;
@ -3587,7 +3589,7 @@ export class RdDActor extends Actor {
if (acheteur) { if (acheteur) {
let resteAcheteur = await acheteur.depenser(coutDeniers); let resteAcheteur = await acheteur.depenser(coutDeniers);
if (resteAcheteur < 0) { if (resteAcheteur < 0) {
ui.notifications.warn(`Vous n'avez pas assez d'argent pour payer ${vente.prixTotal} sols !`); ChatUtility.notifyUser(achat.userId, 'warn', `Vous n'avez pas assez d'argent pour payer ${Math.ceil(coutDeniers/100)} sols !`);
return; return;
} }
} }
@ -3596,7 +3598,7 @@ export class RdDActor extends Actor {
let itemVenduData = Misc.data(itemVendu); let itemVenduData = Misc.data(itemVendu);
if ("quantite" in itemVenduData.data ? itemVenduData.data.quantite < achat.quantiteTotal : achat.choix.nombreLots != 1) { if ("quantite" in itemVenduData.data ? itemVenduData.data.quantite < achat.quantiteTotal : achat.choix.nombreLots != 1) {
await acheteur?.ajouterDeniers(coutDeniers); await acheteur?.ajouterDeniers(coutDeniers);
ui.notifications.warn(`Le vendeur n'a plus assez de ${vente.item.name} !`); ChatUtility.notifyUser(achat.userId, 'warn', `Le vendeur n'a plus assez de ${vente.item.name} !`);
return; return;
} }
vendeur.ajouterDeniers(coutDeniers); vendeur.ajouterDeniers(coutDeniers);
@ -3628,6 +3630,7 @@ export class RdDActor extends Actor {
const chatAchatItem = duplicate(vente); const chatAchatItem = duplicate(vente);
chatAchatItem.quantiteTotal = achat.quantiteTotal; chatAchatItem.quantiteTotal = achat.quantiteTotal;
ChatMessage.create({ ChatMessage.create({
speaker: {alias: (acheteur ?? vendeur).name} ,
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name), whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-achat-item.html', chatAchatItem) content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-achat-item.html', chatAchatItem)
}); });

View File

@ -9,6 +9,33 @@ export class ChatUtility {
static onSocketMessage(sockmsg) { static onSocketMessage(sockmsg) {
switch (sockmsg.msg) { switch (sockmsg.msg) {
case "msg_delete_chat_message": return ChatUtility.onRemoveMessages(sockmsg.data); case "msg_delete_chat_message": return ChatUtility.onRemoveMessages(sockmsg.data);
case "msg_user_ui_notifications": return ChatUtility.onNotifyUser(sockmsg.data);
}
}
/* -------------------------------------------- */
static notifyUser(userId, level = 'info', message) {
const data = {
userId: userId, level: level, message: message
};
if (game.user.id == userId) {
ChatUtility.onNotifyUser(data);
}
else {
game.socket.emit("system.foundryvtt-reve-de-dragon", {
msg: "msg_user_ui_notifications", data: data
});
}
}
static onNotifyUser(data) {
if (game.user.id == data.userId) {
switch (data.level) {
case 'warn': ui.notifications.warn(data.message); break;
case 'error': ui.notifications.error(data.message); break;
default: ui.notifications.info(data.message); break;
}
} }
} }
@ -25,6 +52,19 @@ export class ChatUtility {
} }
} }
static onRemoveMessages(data) {
if (Misc.isElectedUser()) {
if (data.part) {
const toDelete = game.messages.filter(it => it.data.content.includes(data.part));
toDelete.forEach(it => it.delete());
}
if (data.messageId) {
game.messages.get(data.messageId)?.delete();
}
}
}
/* -------------------------------------------- */
static removeMessages(data) { static removeMessages(data) {
if (Misc.isElectedUser()){ if (Misc.isElectedUser()){
ChatUtility.onRemoveMessages(data); ChatUtility.onRemoveMessages(data);

View File

@ -79,6 +79,7 @@ export class DialogItemAchat extends Dialog {
async onAchat() { async onAchat() {
await $(".nombreLots").change(); await $(".nombreLots").change();
(this.vendeur ?? this.acheteur).achatVente({ (this.vendeur ?? this.acheteur).achatVente({
userId: game.user.id,
vendeurId: this.vendeur?.id, vendeurId: this.vendeur?.id,
acheteurId: this.acheteur?.id, acheteurId: this.acheteur?.id,
prixTotal: this.venteData.prixTotal, prixTotal: this.venteData.prixTotal,

View File

@ -1134,7 +1134,10 @@ ul, li {
border-image-width: 4px; border-image-width: 4px;
border-image-outset: 0px; border-image-outset: 0px;
} }
#controls .control-tools {
max-height: calc(100vh - 156px);
height: auto;
}
#controls .scene-control.active, #controls .control-tool.active, #controls .scene-control:hover, #controls .control-tool:hover { #controls .scene-control.active, #controls .control-tool.active, #controls .scene-control:hover, #controls .control-tool:hover {
background: rgba(72, 46, 28, 1); background: rgba(72, 46, 28, 1);
background-origin: padding-box; background-origin: padding-box;