Amélioration des messages de commerce
- Envoyé par l'acheteur plutôt que par le MJ - les erreurs sont affichées au joueur plutôt qu'au MJ
This commit is contained in:
@ -9,6 +9,33 @@ export class ChatUtility {
|
||||
static onSocketMessage(sockmsg) {
|
||||
switch (sockmsg.msg) {
|
||||
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) {
|
||||
if (Misc.isElectedUser()){
|
||||
ChatUtility.onRemoveMessages(data);
|
||||
|
Reference in New Issue
Block a user