Gestion des signes draconiques #455
@ -48,6 +48,39 @@ export class RdDActor extends Actor {
|
||||
Hooks.on("updateActor", (actor, change, options, actorId) => actor.onUpdateActor(change, options, actorId));
|
||||
}
|
||||
|
||||
static onSocketMessage(sockmsg) {
|
||||
switch (sockmsg.msg) {
|
||||
case "msg_remote_actor_call":
|
||||
return RdDActor.onRemoteActorCall(sockmsg.data);
|
||||
}
|
||||
}
|
||||
|
||||
static remoteActorCall(actorId, method, ...args) {
|
||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
||||
msg: "msg_remote_actor_call",
|
||||
data: {
|
||||
gmId: Misc.connectedGM(),
|
||||
toActorId: actorId,
|
||||
method: method,
|
||||
args: args
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static onRemoteActorCall(data) {
|
||||
if (game.user.id == data.gmId) { // Seul le GM connecté choisi effectue l'appel
|
||||
const actor = game.actors.get(data?.toActorId);
|
||||
if (!actor) {
|
||||
console.info("RdDActor.onRemoteActorCall: Pas d'Actor disponible ", data);
|
||||
}
|
||||
else {
|
||||
const args = data.args;
|
||||
console.info(`RdDActor.onRemoteActorCall: pour l'Actor ${data.toActorId}, appel de RdDActor.${data.method}(`, ...args, ')');
|
||||
actor[data.method](...args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static getParentActor(document) {
|
||||
return document?.parent instanceof Actor ? document.parent : undefined
|
||||
}
|
||||
|
@ -47,11 +47,13 @@ export class Misc {
|
||||
const parsed = parseInt(value);
|
||||
return isNaN(parsed) ? 0 : parsed;
|
||||
}
|
||||
|
||||
static keepDecimals(num, decimals) {
|
||||
if (decimals<=0 || decimals>6) return num;
|
||||
const decimal = Math.pow(10, parseInt(decimals));
|
||||
return Math.round(num * decimal) / decimal;
|
||||
}
|
||||
|
||||
static getFractionHtml(diviseur) {
|
||||
if (!diviseur || diviseur <= 1) return undefined;
|
||||
switch (diviseur || 1) {
|
||||
@ -111,4 +113,9 @@ export class Misc {
|
||||
static templateData(it) {
|
||||
return Misc.data(it)?.data ?? {}
|
||||
}
|
||||
|
||||
static connectedGM()
|
||||
{
|
||||
return game.users.entities.find(u => u.isGM && u.active)?.id;
|
||||
}
|
||||
}
|
@ -1211,7 +1211,7 @@ export class RdDCombat {
|
||||
attackerId: this.attackerId,
|
||||
defenderTokenId: defenderTokenId,
|
||||
attackerRoll: attackerRoll,
|
||||
gmId: game.users.entities.find(u => u.isGM)?.id,
|
||||
gmId: Misc.connectedGM(),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -140,10 +140,11 @@ Hooks.once("init", async function () {
|
||||
};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
game.socket.on("system.foundryvtt-reve-de-dragon", data => {
|
||||
RdDUtility.onSocketMesssage(data);
|
||||
RdDCombat.onSocketMessage(data);
|
||||
ChatUtility.onSocketMessage(data);
|
||||
game.socket.on("system.foundryvtt-reve-de-dragon", sockmsg => {
|
||||
RdDUtility.onSocketMesssage(sockmsg);
|
||||
RdDCombat.onSocketMessage(sockmsg);
|
||||
ChatUtility.onSocketMessage(sockmsg);
|
||||
RdDActor.onSocketMessage(sockmsg);
|
||||
});
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user