Extract constants for SYSTEM / SOCKET
This commit is contained in:
parent
3ae3003be3
commit
3abaf4e944
@ -33,7 +33,7 @@ import { RollDataAjustements } from "./rolldata-ajustements.js";
|
|||||||
import { DialogItemAchat } from "./dialog-item-achat.js";
|
import { DialogItemAchat } from "./dialog-item-achat.js";
|
||||||
import { RdDItem } from "./item.js";
|
import { RdDItem } from "./item.js";
|
||||||
import { RdDPossession } from "./rdd-possession.js";
|
import { RdDPossession } from "./rdd-possession.js";
|
||||||
import { SYSTEM_RDD } from "./constants.js";
|
import { SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/**
|
/**
|
||||||
@ -68,7 +68,7 @@ export class RdDActor extends Actor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_remote_actor_call", data: data });
|
game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_remote_actor_call", data: data });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -494,11 +494,11 @@ export class RdDActor extends Actor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _recupereChance() {
|
async _recupereChance() {
|
||||||
// On ne récupère un point de chance que si aucun appel à la chance dans la journée
|
// On ne récupère un point de chance que si aucun appel à la chance dans la journée
|
||||||
if (this.getChanceActuel() < this.getChance() && !this.getFlag('foundryvtt-reve-de-dragon', 'utilisationChance')) {
|
if (this.getChanceActuel() < this.getChance() && !this.getFlag(SYSTEM_RDD, 'utilisationChance')) {
|
||||||
await this.chanceActuelleIncDec(1);
|
await this.chanceActuelleIncDec(1);
|
||||||
}
|
}
|
||||||
// Nouveau jour, suppression du flag
|
// Nouveau jour, suppression du flag
|
||||||
await this.unsetFlag('foundryvtt-reve-de-dragon', 'utilisationChance');
|
await this.unsetFlag(SYSTEM_RDD, 'utilisationChance');
|
||||||
}
|
}
|
||||||
|
|
||||||
async _jetDeMoralChateauDormant(message) {
|
async _jetDeMoralChateauDormant(message) {
|
||||||
@ -1469,7 +1469,7 @@ export class RdDActor extends Actor {
|
|||||||
async cacheTMRetMessage() {
|
async cacheTMRetMessage() {
|
||||||
await this.reinsertionAleatoire("Action MJ");
|
await this.reinsertionAleatoire("Action MJ");
|
||||||
await this.cacheTMR();
|
await this.cacheTMR();
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||||
msg: "msg_tmr_move", data: {
|
msg: "msg_tmr_move", data: {
|
||||||
actorId: this.data._id,
|
actorId: this.data._id,
|
||||||
tmrPos: this.data.data.reve.tmrpos
|
tmrPos: this.data.data.reve.tmrpos
|
||||||
@ -1480,7 +1480,7 @@ export class RdDActor extends Actor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async afficheTMRetMessage() {
|
async afficheTMRetMessage() {
|
||||||
await this.montreTMR();
|
await this.montreTMR();
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||||
msg: "msg_tmr_move", data: {
|
msg: "msg_tmr_move", data: {
|
||||||
actorId: this.data._id,
|
actorId: this.data._id,
|
||||||
tmrPos: this.data.data.reve.tmrpos
|
tmrPos: this.data.data.reve.tmrpos
|
||||||
@ -2940,7 +2940,7 @@ export class RdDActor extends Actor {
|
|||||||
async _appelChanceResult(rollData, onSuccess = () => { }, onEchec = () => { }) {
|
async _appelChanceResult(rollData, onSuccess = () => { }, onEchec = () => { }) {
|
||||||
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
|
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
|
||||||
if (rollData.rolled.isSuccess) {
|
if (rollData.rolled.isSuccess) {
|
||||||
await this.setFlag('foundryvtt-reve-de-dragon', 'utilisationChance', true);
|
await this.setFlag(SYSTEM_RDD, 'utilisationChance', true);
|
||||||
await this.chanceActuelleIncDec(-1);
|
await this.chanceActuelleIncDec(-1);
|
||||||
onSuccess();
|
onSuccess();
|
||||||
}
|
}
|
||||||
@ -3493,21 +3493,21 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async resetItemUse() {
|
async resetItemUse() {
|
||||||
await this.unsetFlag('foundryvtt-reve-de-dragon', 'itemUse');
|
await this.unsetFlag(SYSTEM_RDD, 'itemUse');
|
||||||
await this.setFlag('foundryvtt-reve-de-dragon', 'itemUse', {});
|
await this.setFlag(SYSTEM_RDD, 'itemUse', {});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async incDecItemUse(itemId, inc = 1) {
|
async incDecItemUse(itemId, inc = 1) {
|
||||||
let itemUse = duplicate(this.getFlag('foundryvtt-reve-de-dragon', 'itemUse') ?? {});
|
let itemUse = duplicate(this.getFlag(SYSTEM_RDD, 'itemUse') ?? {});
|
||||||
itemUse[itemId] = (itemUse[itemId] ?? 0) + inc;
|
itemUse[itemId] = (itemUse[itemId] ?? 0) + inc;
|
||||||
await this.setFlag('foundryvtt-reve-de-dragon', 'itemUse', itemUse);
|
await this.setFlag(SYSTEM_RDD, 'itemUse', itemUse);
|
||||||
console.log("ITEM USE INC", inc, itemUse);
|
console.log("ITEM USE INC", inc, itemUse);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getItemUse(itemId) {
|
getItemUse(itemId) {
|
||||||
let itemUse = this.getFlag('foundryvtt-reve-de-dragon', 'itemUse') ?? {};
|
let itemUse = this.getFlag(SYSTEM_RDD, 'itemUse') ?? {};
|
||||||
console.log("ITEM USE GET", itemUse);
|
console.log("ITEM USE GET", itemUse);
|
||||||
return itemUse[itemId] ?? 0;
|
return itemUse[itemId] ?? 0;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Misc } from "./misc.js";
|
import { Misc } from "./misc.js";
|
||||||
|
import { SYSTEM_SOCKET_ID } from "./constants.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class providing helper methods to get the list of users, and
|
* Class providing helper methods to get the list of users, and
|
||||||
@ -23,7 +24,7 @@ export class ChatUtility {
|
|||||||
ChatUtility.onNotifyUser(data);
|
ChatUtility.onNotifyUser(data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||||
msg: "msg_user_ui_notifications", data: data
|
msg: "msg_user_ui_notifications", data: data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -70,7 +71,7 @@ export class ChatUtility {
|
|||||||
ChatUtility.onRemoveMessages(data);
|
ChatUtility.onRemoveMessages(data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_delete_chat_message", data: data });
|
game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_delete_chat_message", data: data });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +148,7 @@ export class ChatUtility {
|
|||||||
chatGM.whisper = ChatUtility.getUsers(user => user.isGM);
|
chatGM.whisper = ChatUtility.getUsers(user => user.isGM);
|
||||||
chatGM.content = "Message aveugle de " + game.user.name + "<br>" + chatOptions.content;
|
chatGM.content = "Message aveugle de " + game.user.name + "<br>" + chatOptions.content;
|
||||||
console.log("blindMessageToGM", chatGM);
|
console.log("blindMessageToGM", chatGM);
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_gm_chat_message", data: chatGM });
|
game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_gm_chat_message", data: chatGM });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
export const SYSTEM_RDD = "foundryvtt-reve-de-dragon";
|
export const SYSTEM_RDD = 'foundryvtt-reve-de-dragon';
|
||||||
|
export const SYSTEM_SOCKET_ID = 'system.foundryvtt-reve-de-dragon';
|
||||||
|
|
||||||
export const HIDE_DICE = 'hide';
|
export const HIDE_DICE = 'hide';
|
||||||
export const SHOW_DICE = 'show';
|
export const SHOW_DICE = 'show';
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { RdDItemCompetence } from "./item-competence.js";
|
import { RdDItemCompetence } from "./item-competence.js";
|
||||||
import { Misc } from "./misc.js";
|
import { Misc } from "./misc.js";
|
||||||
|
import { SYSTEM_SOCKET_ID } from "./constants.js";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +75,7 @@ export class RdDAstrologieJoueur extends Dialog {
|
|||||||
if (Misc.isUniqueConnectedGM()) {
|
if (Misc.isUniqueConnectedGM()) {
|
||||||
game.system.rdd.calendrier.requestNombreAstral(data);
|
game.system.rdd.calendrier.requestNombreAstral(data);
|
||||||
} else {
|
} else {
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||||
msg: "msg_request_nombre_astral",
|
msg: "msg_request_nombre_astral",
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,7 @@ import { RdDUtility } from "./rdd-utility.js";
|
|||||||
import { Grammar } from "./grammar.js";
|
import { Grammar } from "./grammar.js";
|
||||||
import { RdDDice } from "./rdd-dice.js";
|
import { RdDDice } from "./rdd-dice.js";
|
||||||
import { Misc } from "./misc.js";
|
import { Misc } from "./misc.js";
|
||||||
import { HIDE_DICE, SHOW_DICE, SYSTEM_RDD } from "./constants.js";
|
import { HIDE_DICE, SHOW_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/'
|
const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/'
|
||||||
@ -172,7 +172,7 @@ export class RdDCalendrier extends Application {
|
|||||||
this.listeNombreAstral = [];
|
this.listeNombreAstral = [];
|
||||||
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral);
|
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral);
|
||||||
|
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||||
msg: "msg_reset_nombre_astral",
|
msg: "msg_reset_nombre_astral",
|
||||||
data: {}
|
data: {}
|
||||||
});
|
});
|
||||||
@ -254,8 +254,8 @@ export class RdDCalendrier extends Application {
|
|||||||
this.checkMaladie("jour");
|
this.checkMaladie("jour");
|
||||||
}
|
}
|
||||||
game.settings.set(SYSTEM_RDD, "calendrier", duplicate(this.calendrier));
|
game.settings.set(SYSTEM_RDD, "calendrier", duplicate(this.calendrier));
|
||||||
// Notification aux joueurs
|
// Notification aux joueurs // TODO: replace with Hook on game settings update
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||||
msg: "msg_sync_time",
|
msg: "msg_sync_time",
|
||||||
data: duplicate(this.calendrier)
|
data: duplicate(this.calendrier)
|
||||||
});
|
});
|
||||||
@ -343,7 +343,7 @@ export class RdDCalendrier extends Application {
|
|||||||
if (Misc.getActiveUser(request.userId)?.isGM) {
|
if (Misc.getActiveUser(request.userId)?.isGM) {
|
||||||
RdDUtility.responseNombreAstral(request);
|
RdDUtility.responseNombreAstral(request);
|
||||||
} else {
|
} else {
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||||
msg: "msg_response_nombre_astral",
|
msg: "msg_response_nombre_astral",
|
||||||
data: request
|
data: request
|
||||||
});
|
});
|
||||||
@ -474,7 +474,7 @@ export class RdDCalendrier extends Application {
|
|||||||
|
|
||||||
await this.rebuildListeNombreAstral();
|
await this.rebuildListeNombreAstral();
|
||||||
|
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||||
msg: "msg_sync_time",
|
msg: "msg_sync_time",
|
||||||
data: duplicate(this.calendrier)
|
data: duplicate(this.calendrier)
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { ChatUtility } from "./chat-utility.js";
|
import { ChatUtility } from "./chat-utility.js";
|
||||||
import { HIDE_DICE, SYSTEM_RDD } from "./constants.js";
|
import { HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
|
||||||
import { RdDItemArme } from "./item-arme.js";
|
import { RdDItemArme } from "./item-arme.js";
|
||||||
import { RdDItemCompetence } from "./item-competence.js";
|
import { RdDItemCompetence } from "./item-competence.js";
|
||||||
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
|
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
|
||||||
@ -473,7 +473,8 @@ export class RdDCombat {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static messagePasseArme(data) {
|
static messagePasseArme(data) {
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_combat_passearme", data: data });
|
// TODO: store required info for combat in the chat message presenting choices?
|
||||||
|
game.socket.emit(SYSTEM_SOCKET_ID, { msg: "msg_combat_passearme", data: data });
|
||||||
RdDCombat.onMsgPasseArme(data);
|
RdDCombat.onMsgPasseArme(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,7 +939,7 @@ export class RdDCombat {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
_socketSendMessageDefense(paramChatDefense, defenderRoll) {
|
_socketSendMessageDefense(paramChatDefense, defenderRoll) {
|
||||||
// envoyer le message au destinataire
|
// envoyer le message au destinataire
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||||
msg: "msg_defense", data: {
|
msg: "msg_defense", data: {
|
||||||
attackerId: this.attacker?.data._id,
|
attackerId: this.attacker?.data._id,
|
||||||
defenderId: this.defender?.data._id,
|
defenderId: this.defender?.data._id,
|
||||||
@ -1302,7 +1303,7 @@ export class RdDCombat {
|
|||||||
this.defender.encaisserDommages(attackerRoll, this.attacker, defenderRoll);
|
this.defender.encaisserDommages(attackerRoll, this.attacker, defenderRoll);
|
||||||
}
|
}
|
||||||
else { // envoi à un GM: les joueurs n'ont pas le droit de modifier les personnages qu'ils ne possèdent pas
|
else { // envoi à un GM: les joueurs n'ont pas le droit de modifier les personnages qu'ils ne possèdent pas
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||||
msg: "msg_encaisser",
|
msg: "msg_encaisser",
|
||||||
data: {
|
data: {
|
||||||
attackerId: this.attackerId,
|
attackerId: this.attackerId,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { SYSTEM_RDD } from "./constants.js";
|
||||||
import { Misc } from "./misc.js";
|
import { Misc } from "./misc.js";
|
||||||
|
|
||||||
export class RddCompendiumOrganiser {
|
export class RddCompendiumOrganiser {
|
||||||
@ -8,7 +9,7 @@ export class RddCompendiumOrganiser {
|
|||||||
static async onRenderCompendium(compendium, html, data) {
|
static async onRenderCompendium(compendium, html, data) {
|
||||||
console.log('onRenderCompendium', compendium, html, data);
|
console.log('onRenderCompendium', compendium, html, data);
|
||||||
const pack = compendium.collection
|
const pack = compendium.collection
|
||||||
if (pack.metadata.system === 'foundryvtt-reve-de-dragon') {
|
if (pack.metadata.system === SYSTEM_RDD) {
|
||||||
html.find('.directory-item').each((i, element) => {
|
html.find('.directory-item').each((i, element) => {
|
||||||
RddCompendiumOrganiser.setEntityTypeName(pack, element);
|
RddCompendiumOrganiser.setEntityTypeName(pack, element);
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
// Import Modules
|
// Import Modules
|
||||||
import { SYSTEM_RDD } from "./constants.js";
|
import { SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
|
||||||
import { RdDActor } from "./actor.js";
|
import { RdDActor } from "./actor.js";
|
||||||
import { RdDItemSheet } from "./item-sheet.js";
|
import { RdDItemSheet } from "./item-sheet.js";
|
||||||
import { RdDActorSheet } from "./actor-sheet.js";
|
import { RdDActorSheet } from "./actor-sheet.js";
|
||||||
@ -147,7 +147,7 @@ Hooks.once("init", async function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
game.socket.on("system.foundryvtt-reve-de-dragon", sockmsg => {
|
game.socket.on(SYSTEM_SOCKET_ID, sockmsg => {
|
||||||
console.log(">>>>> MSG RECV", sockmsg);
|
console.log(">>>>> MSG RECV", sockmsg);
|
||||||
|
|
||||||
RdDUtility.onSocketMessage(sockmsg);
|
RdDUtility.onSocketMessage(sockmsg);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { SYSTEM_SOCKET_ID } from "./constants.js";
|
||||||
import { RollDataAjustements } from "./rolldata-ajustements.js";
|
import { RollDataAjustements } from "./rolldata-ajustements.js";
|
||||||
import { RdDUtility } from "./rdd-utility.js";
|
import { RdDUtility } from "./rdd-utility.js";
|
||||||
import { TMRUtility } from "./tmr-utility.js";
|
import { TMRUtility } from "./tmr-utility.js";
|
||||||
@ -947,7 +948,7 @@ export class RdDTMRDialog extends Dialog {
|
|||||||
this.cumulFatigue += this.fatigueParCase;
|
this.cumulFatigue += this.fatigueParCase;
|
||||||
}
|
}
|
||||||
this.updateValuesDisplay();
|
this.updateValuesDisplay();
|
||||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||||
msg: "msg_tmr_move", data: {
|
msg: "msg_tmr_move", data: {
|
||||||
actorId: this.actor.data._id,
|
actorId: this.actor.data._id,
|
||||||
tmrPos: Misc.data(this.actor).data.reve.tmrpos
|
tmrPos: Misc.data(this.actor).data.reve.tmrpos
|
||||||
|
Loading…
Reference in New Issue
Block a user