Files
Foundry-VTT-Docker/resources/app/dist/database/documents/fog.mjs

1 line
1.0 KiB
JavaScript
Raw Normal View History

2025-01-04 00:34:03 +01:00
import BaseFogExploration from"../../../common/documents/fog-exploration.mjs";import ServerDocumentMixin from"../backend/server-document.mjs";export default class FogExploration extends(ServerDocumentMixin(BaseFogExploration)){_onCreate(e,o,t){return o.broadcast=!1,super._onCreate(e,o,t)}_onUpdate(e,o,t){return o.broadcast=!1,super._onUpdate(e,o,t)}_onDelete(e,o){return e.broadcast=!1,super._onDelete(e,o)}static async find(e={},o={}){const t=await super.find(e,o);if(!0===o.expireOthers){const e=t.length?t.pop():null;return t.length&&await this.sublevel.delMany(t.map((e=>e._id))),e}return t}static socketListeners(e){e.on("resetFog",this.#e.bind(e))}static async#e(e){if(!this.user.isGM)throw new Error("You do not have permission to reset Fog of War for this scene");const o=(await FogExploration.find({scene:e})).map((e=>e.id));await FogExploration.sublevel.delMany(o),global.logger.info(`Reset ${o.length} FogExploration documents for Scene ${e}`),global.express.io.emit("resetFog",{sceneId:e}),db.DatabaseBackend.emit(FogExploration.documentName,"delete",o)}}