Add option for synchronizing the secret door state (resolves #3)

This commit is contained in:
2021-03-14 00:30:40 +01:00
parent 0f1975f9ae
commit 47c5eecd9c
4 changed files with 41 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
import {settingsKey} from "../settings.js"
import {updateSynchronizedDoors} from "./synchronized_doors.js";
// Toggles between normal and secret doors
export function onDoorLeftClick(event) {
@@ -6,7 +7,13 @@ export function onDoorLeftClick(event) {
if (game.settings.get(settingsKey, "toggleSecretDoors") && event.data?.originalEvent?.ctrlKey && game.user.isGM) {
const types = CONST.WALL_DOOR_TYPES
const newtype = this.wall.data.door === types.DOOR ? types.SECRET : types.DOOR
this.wall.update({door: newtype})
const updateData = {door: newtype}
const synchronizationGroup = this.wall.data.flags.smartdoors?.synchronizationGroup
if (game.settings.get(settingsKey, "synchronizedDoors") && synchronizationGroup && this.wall.data.flags.smartdoors?.synchronizeSecretStatus)
updateSynchronizedDoors(updateData, synchronizationGroup)
else
this.wall.update(updateData)
return true
}
return false