Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XfR1apt9f3R7SxBKB2FF2D
247 lines
12 KiB
Lua
247 lines
12 KiB
Lua
-- [PFUI=1] texlua fast.lua <addon> <race> <class> 1 casual
|
|
-- xpGuide's own Fast guides: a group of their own after the casual route, a start guide for your race, the experience rate
|
|
-- (2x by default, 1x on the Character page), the professions in a step's condition, class trainers, and every guide parsing.
|
|
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 strip(s) return (L53.gsub(L53.gsub(s or "", "|c%x%x%x%x%x%x%x%x", ""), "|r", "")) end
|
|
local function F(n) return _G["pfQuest_xpGuide" .. n] end
|
|
local function settle() W.Fire("QUEST_LOG_UPDATE"); W.Tick(0.4, 4); W.Tick(3, 1); ER.StepsChanged() end
|
|
W.Tick(3, 3)
|
|
local _, race = UnitRace("player")
|
|
local _, class = UnitClass("player")
|
|
local faction = UnitFactionGroup("player")
|
|
|
|
check(type(pfQuest_xpGuide_Fast) == "table" and table.getn(ER.MissingFiles()) == 0,
|
|
"Data\\Fast.lua loaded (" .. tostring(pfQuest_xpGuide_Fast and pfQuest_xpGuide_Fast.guides) .. " guides)")
|
|
|
|
-- the groups: casual route first, then ours
|
|
local groups = S.Groups()
|
|
local order = {}
|
|
for _, g in ipairs(groups) do table.insert(order, g.guides[1].route and "route" or g.guides[1].fast and "xpfast" or g.guides[1].bethink and "bethink" or g.guides[1].vanilla and "vanilla" or "rxp") end
|
|
P("note order: " .. table.concat(order, ","))
|
|
local firstFast, firstRxp, firstBethink
|
|
for i, o in ipairs(order) do
|
|
if o == "xpfast" and not firstFast then firstFast = i end
|
|
if o == "rxp" and not firstRxp then firstRxp = i end
|
|
if o == "bethink" and not firstBethink then firstBethink = i end
|
|
end
|
|
check(firstFast and firstRxp and firstFast < firstRxp and firstFast < firstBethink, "xpGuide Fast comes before RestedXP's, Bethink's and VanillaGuide's")
|
|
local mine = {}
|
|
for _, g in ipairs(S.Guides()) do if g.fast then table.insert(mine, g) end end
|
|
check(table.getn(mine) == (faction == "Alliance" and 51 or 52), "every visit of your faction is a guide (" .. table.getn(mine) .. ")")
|
|
local lastHi = 0
|
|
for _, g in ipairs(mine) do if g.hi > lastHi then lastHi = g.hi end end
|
|
check(lastHi == 60, "they go up to 60")
|
|
|
|
-- the rate: 1x unless you choose 2x
|
|
ER.db.xpRate = nil
|
|
check(ER.XPRate() == 1, "the rate is 1x by default")
|
|
check(S.Applies("XP1") and not S.Applies("XP2"), "XP1 fits and XP2 does not, on 1x")
|
|
check(not ER.SetXPRate(3, true) and ER.XPRate() == 1, "a rate that is neither 1 nor 2 is refused")
|
|
|
|
-- the guide for your race's start
|
|
local start
|
|
for _, g in ipairs(mine) do if g.lo == 1 and S.Applies(g.defaultFor) then start = g end end
|
|
check(start ~= nil, "a Fast guide for your race's start: " .. tostring(start and start.title))
|
|
if not start then P(fails .. " FAILED") REPORT() return end
|
|
check(ER.StartGuide(S.Key(start), true, true), " ...it starts")
|
|
ER.ShowTracker(); settle()
|
|
|
|
local function count(kinds)
|
|
local n = 0
|
|
for _, it in ipairs(S.All()) do
|
|
for _, e in ipairs(it.step.elements) do
|
|
if kinds[e.kind] then n = n + 1 end
|
|
end
|
|
end
|
|
return n
|
|
end
|
|
-- the steps that are for you at all (Fits), and the quest lines inside the guide, on 2x and on 1x
|
|
local function accepts()
|
|
local n = 0
|
|
for i = 1, S.Count() do
|
|
local st = S.Step(i)
|
|
if st and S.Fits(st) then
|
|
for _, e in ipairs(st.elements) do if e.kind == "A" then n = n + 1 end end
|
|
end
|
|
end
|
|
return n
|
|
end
|
|
ER.SetXPRate(2, true)
|
|
local a2 = accepts()
|
|
ER.SetXPRate(1, true)
|
|
local a1 = accepts()
|
|
check(a1 > a2 and a2 > 0, "1x picks up more quests than 2x (" .. a1 .. " against " .. a2 .. ")")
|
|
check(a2 >= a1 * 0.4 and a2 <= a1 * 0.8, "2x keeps about half to two thirds of them (" .. math.floor(a2 * 100 / a1) .. "%)")
|
|
check(S.Applies("XP1") and not S.Applies("XP2"), "XP1 fits and XP2 does not, on 1x")
|
|
ER.SetXPRate(2, true)
|
|
check(S.Applies("XP2") and not S.Applies("XP1"), "XP2 fits and XP1 does not, on 2x")
|
|
check(accepts() == a2, "back on 2x the same quests")
|
|
-- the guide stays on its step when the rate changes
|
|
local pos = S.Position()
|
|
ER.SetXPRate(1, true)
|
|
check(S.Running() and S.Position() == pos, "changing the rate keeps your place (step " .. pos .. ")")
|
|
ER.SetXPRate(2, true)
|
|
|
|
-- professions in a condition
|
|
ER.db.profs = nil
|
|
ER.SetXPRate(2, true) -- (drops what is remembered for a condition)
|
|
check(S.Applies("FirstAid") and S.Applies("Cooking") and not S.Applies("Fishing") and not S.Applies("Survival"),
|
|
"First Aid and Cooking are on by default, Fishing and Survival off")
|
|
local _, myclass = UnitClass("player")
|
|
local rec = {}
|
|
for _, n in ipairs(ER.PRIMARY) do if ER.Recommended(n) then table.insert(rec, n) end end
|
|
check(table.getn(rec) == 2 and ER.HasProf(rec[1]) and ER.HasProf(rec[2]), "two primary professions are suggested for " .. tostring(myclass) .. ": " .. table.concat(rec, ", "))
|
|
check(ER.ProfDetail("Mining") == "not learned", "a profession you do not have says so")
|
|
ER.SetProf("Mining", true)
|
|
check(S.Applies("Mining") and S.Applies("Mining FirstAid"), "a ticked profession fits, alone or with another")
|
|
ER.SetProf("Cooking", false)
|
|
check(not S.Applies("Cooking") and S.Applies("Mining/Cooking"), "an unticked one does not")
|
|
check(not ER.SetProf("Basket Weaving", true), "a profession that does not exist is refused")
|
|
local list = table.concat(ER.ProfList(), ",")
|
|
check(string.find(list, "Mining", 1, true) and string.find(list, "First Aid", 1, true) and not string.find(list, "Cooking", 1, true), "ProfList: " .. list)
|
|
-- skills in the game's skill list count
|
|
local keep = { GetNumSkillLines = _G.GetNumSkillLines, GetSkillLineInfo = _G.GetSkillLineInfo }
|
|
_G.GetNumSkillLines = function() return 3 end
|
|
_G.GetSkillLineInfo = function(i)
|
|
if i == 1 then return "Professions", true, true end
|
|
if i == 2 then return "Herbalism", false, nil, 61 end
|
|
return "Fishing", false, nil, 12
|
|
end
|
|
ER.db.profs = nil
|
|
H.W.Fire("SKILL_LINES_CHANGED")
|
|
check(ER.KnowsProf("Herbalism") and ER.ProfRank("Herbalism") == 61 and S.Applies("Herbalism") and S.Applies("Fishing"), "professions in the skill list count by themselves")
|
|
check(ER.ProfDetail("Herbalism") == "61/0" or string.find(ER.ProfDetail("Herbalism"), "^61/"), " ...with their skill: " .. ER.ProfDetail("Herbalism"))
|
|
_G.GetNumSkillLines, _G.GetSkillLineInfo = keep.GetNumSkillLines, keep.GetSkillLineInfo
|
|
H.W.Fire("SKILL_LINES_CHANGED")
|
|
ER.db.profs = nil
|
|
|
|
-- the Character page
|
|
local info = ER.SettingsInfo()
|
|
local page
|
|
for _, p in ipairs(info.pages) do if p.title == "Character" then page = p end end
|
|
check(page ~= nil and page.checks[1] == "1x experience" and page.checks[2] == "2x experience", "Settings has a Character page with the rate first")
|
|
if page then
|
|
local all = table.concat(page.checks, ",")
|
|
check(string.find(all, "Mining", 1, true) and string.find(all, "Survival", 1, true) and string.find(all, "First Aid", 1, true), " ...and the professions (" .. table.getn(page.checks) .. " ticks)")
|
|
end
|
|
ER.ShowSettings("Character")
|
|
check(F("Settings") and F("Settings"):IsShown(), " ...it opens")
|
|
local tick1, tick2 = F("SettingsCheck" .. 0), nil
|
|
F("Settings"):Hide()
|
|
|
|
-- class trainers: one for your class at the right capital
|
|
local want = { Human = "Stormwind City", Dwarf = "Ironforge", Gnome = "Ironforge", NightElf = "Darnassus", Orc = "Orgrimmar", Troll = "Orgrimmar",
|
|
Tauren = "Thunder Bluff", Scourge = "Undercity" }
|
|
local seen, generic = 0, 0
|
|
for _, it in ipairs(S.All()) do
|
|
local st = it.step
|
|
for _, e in ipairs(st.elements) do
|
|
if e.kind == "V" and e.what == "trainer" and S.Applies(st.need) then seen = seen + 1 end
|
|
end
|
|
end
|
|
check(seen >= 1, "a class trainer step for you in the first guide (" .. seen .. ")")
|
|
|
|
-- every Fast guide of your faction reads: steps, quests that have titles, no empty steps, places that are on the map
|
|
local bad, total, noTitle, noPlace = 0, 0, 0, 0
|
|
for _, g in ipairs(mine) do
|
|
local ok = ER.StartGuide(S.Key(g), true, true)
|
|
if not ok then bad = bad + 1 else
|
|
for i = 1, S.Count() do
|
|
local st = S.Step(i)
|
|
total = total + 1
|
|
for _, e in ipairs(st.elements) do
|
|
if (e.kind == "A" or e.kind == "C" or e.kind == "T") and e.id and not S.QuestTitle(e.id) then noTitle = noTitle + 1 end
|
|
if e.kind == "G" and (not e.x or not e.y or not e.zone) then noPlace = noPlace + 1 end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
check(bad == 0, "every Fast guide opens (" .. total .. " steps)")
|
|
check(noTitle == 0, "every quest line has a title (" .. noTitle .. " without)")
|
|
check(noPlace == 0, "every place has a zone and a point (" .. noPlace .. " without)")
|
|
|
|
-- a Fast guide plays on into the next one
|
|
local first
|
|
for _, g in ipairs(mine) do if g.lo == 1 and S.Applies(g.defaultFor) then first = g end end
|
|
ER.StartGuide(S.Key(first), true, true); settle()
|
|
local nxt = S.NextGuide()
|
|
check(nxt ~= nil and nxt.fast and nxt.lo >= first.hi - 1, "the next guide is a Fast one: " .. tostring(nxt and nxt.name))
|
|
local follow = S.FollowOn()
|
|
check(follow ~= nil and follow.fast, "FollowOn stays with the Fast guides: " .. tostring(follow and follow.name))
|
|
|
|
-- picking a Fast guide from the list asks for the rate and the professions first
|
|
ER.db.xpRate, ER.db.profs = nil, nil
|
|
ER.Steps.Stop()
|
|
ER.ChooseGuide(first)
|
|
local dlg = F("FastSetup")
|
|
check(dlg and dlg:IsShown() and not S.Running(), "choosing a Fast guide shows the question and does not start it yet")
|
|
check(ER.FastSetupInfo.pickRate == 1 and F("FastSetupRate1"):GetChecked(), " ...1x is ticked by default")
|
|
local ticked = 0
|
|
for _, n in ipairs(ER.PRIMARY) do if F("FastSetupProf" .. _) and F("FastSetupProf" .. _):GetChecked() then ticked = ticked + 1 end end
|
|
check(ticked == 2, " ...the class's two primary professions are ticked (" .. ticked .. ")")
|
|
check(string.find(ER.FastSetupInfo.prof["Cooking"].label:GetText() or "", "not learned", 1, true) ~= nil, " ...each profession shows its skill")
|
|
F("FastSetupRate2"):SetChecked(1); F("FastSetupRate2"):GetScript("OnClick")()
|
|
check(ER.FastSetupInfo.pickRate == 2, " ...2x can be picked")
|
|
F("FastSetupStart"):GetScript("OnClick")()
|
|
check(S.Running() and S.Info().fast and ER.XPRate() == 2 and not dlg:IsShown(), "Start keeps the rate and starts the guide")
|
|
ER.ShowTracker(); settle()
|
|
ER.ChooseGuide(first)
|
|
check(ER.FastSetupInfo.pickRate == 2, "the next time the question starts from your last answer")
|
|
F("FastSetupCancel"):GetScript("OnClick")()
|
|
check(not dlg:IsShown(), "Cancel closes it")
|
|
local other
|
|
for _, g in ipairs(S.Guides()) do if not g.fast and not g.route then other = g break end end
|
|
ER.Steps.Stop(); ER.ChooseGuide(other)
|
|
check(S.Running() and not dlg:IsShown(), "any other guide starts at once")
|
|
|
|
-- the main window says which rate a Fast guide is on
|
|
ER.SetXPRate(1, true)
|
|
ER.StartGuide(S.Key(first), true, true); ER.ShowTracker(); H.W.Tick(0.3, 4)
|
|
local now = F("GuideNow")
|
|
local function plain(t) return (string.gsub(string.gsub(t or "", "|c%x%x%x%x%x%x%x%x", ""), "|r", "")) end
|
|
check(now and string.find(plain(now.detail._text), "1x exp", 1, true) ~= nil, "the heading carries the rate: " .. plain(now and now.detail._text))
|
|
ER.SetXPRate(2, true); H.W.Tick(0.3, 4)
|
|
check(now and string.find(plain(now.detail._text), "2x exp", 1, true) ~= nil, " ...and follows a change of it")
|
|
|
|
-- the same quest is never accepted twice at one stop (a chain's second part comes after the first is handed in)
|
|
local dup = 0
|
|
for _, g in ipairs(mine) do
|
|
ER.StartGuide(S.Key(g), true, true)
|
|
for i = 1, S.Count() do
|
|
local st = S.Step(i)
|
|
local seenId = {}
|
|
for _, e in ipairs(st.elements) do
|
|
if e.kind == "A" and e.id then
|
|
local t = S.QuestTitle(e.id)
|
|
if seenId[t] then dup = dup + 1 end
|
|
seenId[t] = true
|
|
end
|
|
end
|
|
end
|
|
end
|
|
check(dup == 0, "no step accepts two quests of the same name (" .. dup .. ")")
|
|
|
|
-- difficulty: Casual leaves out the elite quests, Hard keeps them
|
|
local function fits(mode)
|
|
ER.SetMode(mode, true)
|
|
local n = 0
|
|
for _, g in ipairs(mine) do
|
|
ER.StartGuide(S.Key(g), true, true)
|
|
for i = 1, S.Count() do
|
|
local st = S.Step(i)
|
|
if S.Fits(st) then for _, e in ipairs(st.elements) do if e.kind == "A" then n = n + 1 end end end
|
|
end
|
|
end
|
|
return n
|
|
end
|
|
local ac, ah = fits("casual"), fits("hard")
|
|
check(ah > ac, "difficulty changes the Fast guides: Hard has more quests than Casual (" .. ah .. " against " .. ac .. ")")
|
|
ER.SetMode("casual", true)
|
|
|
|
P(fails == 0 and "PASSED" or (fails .. " FAILED"))
|
|
REPORT()
|