forked from public/foundryvtt-reve-de-dragon
Extract constants for SYSTEM / SOCKET
This commit is contained in:
@ -33,7 +33,7 @@ import { RollDataAjustements } from "./rolldata-ajustements.js";
|
||||
import { DialogItemAchat } from "./dialog-item-achat.js";
|
||||
import { RdDItem } from "./item.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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -494,11 +494,11 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async _recupereChance() {
|
||||
// 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);
|
||||
}
|
||||
// Nouveau jour, suppression du flag
|
||||
await this.unsetFlag('foundryvtt-reve-de-dragon', 'utilisationChance');
|
||||
await this.unsetFlag(SYSTEM_RDD, 'utilisationChance');
|
||||
}
|
||||
|
||||
async _jetDeMoralChateauDormant(message) {
|
||||
@ -1469,7 +1469,7 @@ export class RdDActor extends Actor {
|
||||
async cacheTMRetMessage() {
|
||||
await this.reinsertionAleatoire("Action MJ");
|
||||
await this.cacheTMR();
|
||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
||||
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||
msg: "msg_tmr_move", data: {
|
||||
actorId: this.data._id,
|
||||
tmrPos: this.data.data.reve.tmrpos
|
||||
@ -1480,7 +1480,7 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async afficheTMRetMessage() {
|
||||
await this.montreTMR();
|
||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
||||
game.socket.emit(SYSTEM_SOCKET_ID, {
|
||||
msg: "msg_tmr_move", data: {
|
||||
actorId: this.data._id,
|
||||
tmrPos: this.data.data.reve.tmrpos
|
||||
@ -2940,7 +2940,7 @@ export class RdDActor extends Actor {
|
||||
async _appelChanceResult(rollData, onSuccess = () => { }, onEchec = () => { }) {
|
||||
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-appelchance.html')
|
||||
if (rollData.rolled.isSuccess) {
|
||||
await this.setFlag('foundryvtt-reve-de-dragon', 'utilisationChance', true);
|
||||
await this.setFlag(SYSTEM_RDD, 'utilisationChance', true);
|
||||
await this.chanceActuelleIncDec(-1);
|
||||
onSuccess();
|
||||
}
|
||||
@ -3493,21 +3493,21 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async resetItemUse() {
|
||||
await this.unsetFlag('foundryvtt-reve-de-dragon', 'itemUse');
|
||||
await this.setFlag('foundryvtt-reve-de-dragon', 'itemUse', {});
|
||||
await this.unsetFlag(SYSTEM_RDD, 'itemUse');
|
||||
await this.setFlag(SYSTEM_RDD, 'itemUse', {});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
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;
|
||||
await this.setFlag('foundryvtt-reve-de-dragon', 'itemUse', itemUse);
|
||||
await this.setFlag(SYSTEM_RDD, 'itemUse', itemUse);
|
||||
console.log("ITEM USE INC", inc, itemUse);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getItemUse(itemId) {
|
||||
let itemUse = this.getFlag('foundryvtt-reve-de-dragon', 'itemUse') ?? {};
|
||||
let itemUse = this.getFlag(SYSTEM_RDD, 'itemUse') ?? {};
|
||||
console.log("ITEM USE GET", itemUse);
|
||||
return itemUse[itemId] ?? 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user