Remove .windows-mcp gitlink and gate ledger writes

This commit is contained in:
centron\schwoerer
2026-01-12 13:27:13 +01:00
parent 6f1c8b7c88
commit 767969c201
2 changed files with 19 additions and 2 deletions

Submodule .windows-mcp deleted from a1a56eab56

View File

@@ -1,6 +1,6 @@
const MODULE_ID = "gowlers-tracking-ledger"; const MODULE_ID = "gowlers-tracking-ledger";
const MODULE_VERSION = "1.3.2"; const MODULE_VERSION = "1.3.3";
const TRACK_SETTING = "actorSettings"; const TRACK_SETTING = "actorSettings";
const FLAG_SCOPE = "world"; const FLAG_SCOPE = "world";
const MAX_HISTORY_ROWS = 100; const MAX_HISTORY_ROWS = 100;
@@ -113,6 +113,7 @@ const ledgerState = {
damageOverlay: null, damageOverlay: null,
damageMeterIncludeNPCs: true, damageMeterIncludeNPCs: true,
damageMeterMode: "encounter", // "encounter" or "all" damageMeterMode: "encounter", // "encounter" or "all"
lastNoGmWarningTime: 0,
}; };
function getHistoryPageState(actorId, tabId) { function getHistoryPageState(actorId, tabId) {
@@ -1228,9 +1229,24 @@ function renderHistoryTable(entries, columns, id, rowsPerPage = 10, currentPage
</table>`; </table>`;
} }
function canWriteActor(actor) {
if (!actor) return false;
if (game.user?.isGM) return true;
const hasActiveGm = (game.users ?? []).some((u) => u.isGM && u.active);
if (!hasActiveGm) {
const now = Date.now();
if (now - (ledgerState.lastNoGmWarningTime || 0) > 10000) {
ledgerState.lastNoGmWarningTime = now;
ui.notifications?.error?.("Gowler's Tracking Ledger requires an active GM to record updates.");
}
}
return false;
}
async function recordHistoryEntry(actor, statId, previous, nextValue, userId, options = {}, change = {}) { async function recordHistoryEntry(actor, statId, previous, nextValue, userId, options = {}, change = {}) {
const config = STAT_CONFIGS[statId]; const config = STAT_CONFIGS[statId];
if (!config) return; if (!config) return;
if (!canWriteActor(actor)) return;
const diffValue = config.diff(previous, nextValue); const diffValue = config.diff(previous, nextValue);
@@ -1738,6 +1754,7 @@ function resolveActorFromMetadataSafe(metadata = {}) {
async function recordDamageDealt(attacker, entry) { async function recordDamageDealt(attacker, entry) {
if (!attacker?.id) return; if (!attacker?.id) return;
if (!canWriteActor(attacker)) return;
try { try {
const existing = (await attacker.getFlag(FLAG_SCOPE, DAMAGE_DEALT_FLAG)) ?? []; const existing = (await attacker.getFlag(FLAG_SCOPE, DAMAGE_DEALT_FLAG)) ?? [];
existing.unshift(entry); existing.unshift(entry);
@@ -2597,6 +2614,7 @@ async function onCombatEnd(combat) {
*/ */
async function updateEncounterSummary(actor, combat, status = "ongoing") { async function updateEncounterSummary(actor, combat, status = "ongoing") {
if (!actor || !combat) return; if (!actor || !combat) return;
if (!canWriteActor(actor)) return;
console.log(`[GowlersTracking] updateEncounterSummary for ${actor.name}, combat ${combat.id}, status: ${status}`); console.log(`[GowlersTracking] updateEncounterSummary for ${actor.name}, combat ${combat.id}, status: ${status}`);