"use strict"; global.window = global; global.TarinaiSnapshot = { version: 40 }; global.TarinaiSaveSchema = { BINARY_SCHEMA_VERSION: 53, FIELD_IDS: ["garden"], itemTypeValue(_index, fallback = "") { return fallback; }, }; require("../js/save_codec.js"); // first_birth + statistician + memento_mori. Current v8 also stores persistent lively-making progress. // Achievements 65-75 remain in the extended mask value at spell[3]. const progress = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 9999, 99]; const spell = [8, 1, 0, 1152, 100, [0, 1, 2], progress]; const snapshot = { v: 40, a: "tj1", m: [1, 0, "garden", 0], w: [0, 0, 0, 0, 0, -9990, 1, 0, "w0000000000000000", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], t: [], i: [], g: { w: [[], [], 0, 0, 0, null, -1, null, 0, -1, -1], t: [], i: [], s: spell, }, }; const bytes = global.TarinaiSaveCodec.encodeBinarySnapshot(snapshot); const decoded = global.TarinaiSaveCodec.decodeBinarySnapshot(bytes); const restored = decoded?.g?.s; if (!Array.isArray(restored) || restored[0] !== 8) throw new Error("achievement spell v8 was not restored"); if (restored[3] !== 1152) throw new Error("extended achievement mask bytes were lost"); if (restored[6]?.[14] !== 29) throw new Error("statistician progress was lost"); if (restored[6]?.[15] !== 9999) throw new Error("memento mori progress was lost"); if (restored[6]?.[16] !== 99) throw new Error("lively making progress was lost"); const oldSchemaBytes = Uint8Array.from(bytes); oldSchemaBytes[0] = (oldSchemaBytes[0] & 0x80) | 52; let rejectedOldSchema = false; try { global.TarinaiSaveCodec.decodeBinarySnapshot(oldSchemaBytes); } catch (_) { rejectedOldSchema = true; } if (!rejectedOldSchema) throw new Error("obsolete binary schema was accepted"); console.log("[OK] current-only schema 53, achievement v8 mask, and persistent progress binary round-trip passed");