mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-15 07:41:21 +02:00
feat(mods): expose selected save chronology
This commit is contained in:
@@ -13,6 +13,7 @@ local T = require("tests.harness").suite("mod title playthrough context")
|
||||
local Loader = require("src.mods.Loader")
|
||||
local Runtime = require("src.mods.Runtime")
|
||||
local SaveData = require("src.core.SaveData")
|
||||
local SaveSerializer = require("src.core.SaveSerializer")
|
||||
local Version = require("src.core.Version")
|
||||
local GameMethods = require("src.core.Game")
|
||||
local StateStack = require("src.core.StateStack")
|
||||
@@ -227,6 +228,28 @@ if type(storage) == "table" then
|
||||
"failed title reconstruction never writes a normal Pokémon save")
|
||||
end
|
||||
|
||||
-- A title policy may compare its own durable checkpoint chronology with the
|
||||
-- ordinary CONTINUE target, but it must never receive that save's contents,
|
||||
-- slot path, or a way to open another playthrough. This fixture writes the
|
||||
-- canonical normal save directly to model an already-completed vanilla SAVE.
|
||||
active.save.meta.savedAt = 4321
|
||||
fs.write("save.lua", SaveSerializer.encode(active.save))
|
||||
SaveData.resetSlotState()
|
||||
local titleWithNormalSave = {
|
||||
save = SaveData.newGame({ version = "red" }),
|
||||
stack = { states = { { screenId = "TitleState" } } },
|
||||
}
|
||||
local selectedWithNormal, normalCode, normalMessage = storage:selected(titleWithNormalSave)
|
||||
T.check(type(selectedWithNormal) == "table",
|
||||
"legacy-to-slot migration keeps the selected playthrough identity: "
|
||||
.. tostring(normalCode or normalMessage))
|
||||
if type(selectedWithNormal) == "table" then
|
||||
T.eq(selectedWithNormal:context().normalSavedAt, 4321,
|
||||
"title selected context exposes only matching normal-save chronology")
|
||||
end
|
||||
T.check(titleWithNormalSave.save.meta.playthroughId == nil,
|
||||
"normal-save chronology lookup does not bind the fresh title skeleton")
|
||||
|
||||
local explicitNewGame = SaveData.newGame({ version = "red" })
|
||||
local freshContext = storage:context({ save = explicitNewGame })
|
||||
T.check(freshContext and freshContext.playthroughId ~= originalId,
|
||||
|
||||
Reference in New Issue
Block a user