-- texlua levelreached.lua 1 casual -- The guide's top level reached: the tips box (under the steps, where the money question is) asks to move on. local here = arg[0]:match("^(.*)/") or "." dofile(here .. "/lib.lua") local W, ER, S, P = H.W, H.ER, H.S, H.P local fails = 0 local function check(ok, what) if not ok then fails = fails + 1; P("FAIL " .. what) else P("ok " .. what) end end local function tip(key) for _, t in ipairs(ER.TipsList()) do if t.key == key then return t end end end local function try(group) local g for _, grp in ipairs(S.Groups()) do if grp.name:find(group, 1, true) then g = grp.guides[1] break end end if not g then P("note no " .. group .. " guide") return end W.level = g.lo ER.StartGuide(S.Key(g), true, true, false); W.Tick(0.3, 3) ER.RemoveTips("levelreached") W.Tick(2.1, 2) check(not tip("levelreached"), group .. ": below the top level, nothing is asked") W.level = g.hi W.Tick(2.1, 2) local t = tip("levelreached") check(t and t.buttons and t.buttons[1].label == "Move on" and t.buttons[2].label == "Stay here", group .. ": at level " .. g.hi .. " the tips box asks: " .. tostring(t and t.text)) if t then t.buttons[1].fn(); W.Tick(0.3, 3) local now = S.Info() check(now and now ~= g and now.lo >= g.lo, " ...Move on starts " .. tostring(now and (now.title or now.name))) ER.RemoveTips("levelreached"); W.Tick(2.1, 2) -- asked once per guide ER.StartGuide(S.Key(g), true, true, false); W.Tick(2.1, 3) check(not tip("levelreached"), " ...asked only once per guide") end end try("VanillaGuide") try("Bethink") try("Alliance") -- the casual route moves on by itself: never asked for _, grp in ipairs(S.Groups()) do local g = grp.guides[1] if g.route then W.level = 10; ER.StartGuide(S.Key(g), true, true, false); ER.RemoveTips("levelreached"); W.Tick(2.1, 3) check(not tip("levelreached"), "the casual route is never asked") break end end P(fails == 0 and "ALL PASSED" or (fails .. " FAILED")) REPORT()