Remove .windows-mcp gitlink and gate ledger writes
This commit is contained in:
Submodule .windows-mcp deleted from a1a56eab56
@@ -1,6 +1,6 @@
|
||||
|
||||
const MODULE_ID = "gowlers-tracking-ledger";
|
||||
const MODULE_VERSION = "1.3.2";
|
||||
const MODULE_VERSION = "1.3.3";
|
||||
const TRACK_SETTING = "actorSettings";
|
||||
const FLAG_SCOPE = "world";
|
||||
const MAX_HISTORY_ROWS = 100;
|
||||
@@ -113,6 +113,7 @@ const ledgerState = {
|
||||
damageOverlay: null,
|
||||
damageMeterIncludeNPCs: true,
|
||||
damageMeterMode: "encounter", // "encounter" or "all"
|
||||
lastNoGmWarningTime: 0,
|
||||
};
|
||||
|
||||
function getHistoryPageState(actorId, tabId) {
|
||||
@@ -1228,9 +1229,24 @@ function renderHistoryTable(entries, columns, id, rowsPerPage = 10, currentPage
|
||||
</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 = {}) {
|
||||
const config = STAT_CONFIGS[statId];
|
||||
if (!config) return;
|
||||
if (!canWriteActor(actor)) return;
|
||||
|
||||
const diffValue = config.diff(previous, nextValue);
|
||||
|
||||
@@ -1738,6 +1754,7 @@ function resolveActorFromMetadataSafe(metadata = {}) {
|
||||
|
||||
async function recordDamageDealt(attacker, entry) {
|
||||
if (!attacker?.id) return;
|
||||
if (!canWriteActor(attacker)) return;
|
||||
try {
|
||||
const existing = (await attacker.getFlag(FLAG_SCOPE, DAMAGE_DEALT_FLAG)) ?? [];
|
||||
existing.unshift(entry);
|
||||
@@ -2597,6 +2614,7 @@ async function onCombatEnd(combat) {
|
||||
*/
|
||||
async function updateEncounterSummary(actor, combat, status = "ongoing") {
|
||||
if (!actor || !combat) return;
|
||||
if (!canWriteActor(actor)) return;
|
||||
|
||||
console.log(`[GowlersTracking] updateEncounterSummary for ${actor.name}, combat ${combat.id}, status: ${status}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user