|
|
|
@ -55,27 +55,21 @@ export class RdDActor extends Actor {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 remoteActorCall(options) {
|
|
|
|
|
console.log("remoteActorCall ", options)
|
|
|
|
|
options.userId = options.userId ?? Misc.connectedGMOrUser();
|
|
|
|
|
game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_remote_actor_call", data: options });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 (game.user.id == data.userId) { // Seul le joueur choisi effectue l'appel
|
|
|
|
|
const actor = game.actors.get(data?.actorId);
|
|
|
|
|
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, ')');
|
|
|
|
|
console.info(`RdDActor.onRemoteActorCall: pour l'Actor ${data.actorId}, appel de RdDActor.${data.method}(`, ...args, ')');
|
|
|
|
|
actor[data.method](...args);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -3185,7 +3179,7 @@ export class RdDActor extends Actor {
|
|
|
|
|
|
|
|
|
|
async ajouterDeniers(gain, fromActorId = undefined) {
|
|
|
|
|
if (fromActorId && !game.user.isGM) {
|
|
|
|
|
RdDActor.remoteActorCall(this.id, 'ajouterDeniers', gain, fromActorId);
|
|
|
|
|
RdDActor.remoteActorCall({ userId: Misc.connectedGMOrUser(), actorId: this.id, method: 'ajouterDeniers', args: [gain, fromActorId] });
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
const fromActor = game.actors.get(fromActorId)
|
|
|
|
@ -3616,6 +3610,14 @@ export class RdDActor extends Actor {
|
|
|
|
|
await this.createEmbeddedDocuments('ActiveEffect', [effet]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async onPreUpdateItem(item, change, options, id) {
|
|
|
|
|
const itemData = Misc.data(item);
|
|
|
|
|
if (itemData.type == 'competence' && itemData.data.defaut_carac && itemData.data.xp) {
|
|
|
|
|
await this.checkCompetenceXP(itemData.name, itemData.data.xp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
async onCreateItem(item, options, id) {
|
|
|
|
|
switch (item.type) {
|
|
|
|
@ -3628,13 +3630,6 @@ export class RdDActor extends Actor {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async onPreUpdateItem(item, change, options, id) {
|
|
|
|
|
const itemData = Misc.data(item);
|
|
|
|
|
if (itemData.type == 'competence' && itemData.data.defaut_carac && itemData.data.xp) {
|
|
|
|
|
await this.checkCompetenceXP(itemData.name, itemData.data.xp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async onDeleteItem(item, options, id) {
|
|
|
|
|
switch (item.type) {
|
|
|
|
|
case 'tete':
|
|
|
|
@ -3650,29 +3645,32 @@ export class RdDActor extends Actor {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async onCreateOwnedDraconique(item, options, id) {
|
|
|
|
|
|
|
|
|
|
if (game.user.id == Misc.connectedGMOrUser()) {
|
|
|
|
|
let draconique = Draconique.all().find(it => it.match(item));
|
|
|
|
|
if (draconique) {
|
|
|
|
|
draconique.onActorCreateOwned(this, item)
|
|
|
|
|
|
|
|
|
|
this.notifyGestionTeteSouffleQueue(item, draconique.manualMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async onDeleteOwnedDraconique(item, options, id) {
|
|
|
|
|
|
|
|
|
|
if (game.user.id != Misc.connectedGMOrUser()) {
|
|
|
|
|
let draconique = Draconique.all().find(it => it.match(item));
|
|
|
|
|
if (draconique) {
|
|
|
|
|
draconique.onActorDeleteOwned(this, item)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async onDeleteOwnedCaseTmr(item, options, id) {
|
|
|
|
|
if (game.user.id != Misc.connectedGMOrUser()) {
|
|
|
|
|
let draconique = Draconique.all().find(it => it.isCase(item));
|
|
|
|
|
if (draconique) {
|
|
|
|
|
draconique.onActorDeleteCaseTmr(this, item)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
notifyGestionTeteSouffleQueue(item, manualMessage = true) {
|
|
|
|
|
ChatMessage.create({
|
|
|
|
|