470 lines
32 KiB
Lua
470 lines
32 KiB
Lua
dofile(arg[1]..'/client_addons/GatewayDiagnostics/TurtleTalentProvider.lua')
|
|
do
|
|
-- The server knows the trained rank4 ability, not the rank1 talent spell.
|
|
local provider=GatewayTurtleTalentProvider.New({tabs={},talents={{id=109,ranks={{id=23881}}}},
|
|
rankSuccessors={[23881]={23892,23893,23894}}})
|
|
provider.state={known={[23894]=true}}
|
|
assert(provider:Rank(109,false)==1 and provider.state.known[23881]==nil)
|
|
assert(provider:KnowsRank(23881,provider.state.known))
|
|
provider.state.known={[99999]=true}
|
|
assert(provider:Rank(109,false)==0)
|
|
end
|
|
do
|
|
local format=GatewayTurtleTalentProvider.FormatDescription
|
|
local refs={[12966]={id=12966,procCharges=3,effects={{basePoints=9,dieSides=1}}}}
|
|
local text,unresolved=format({description='Speed $12966s1% for $12966n swings.'},refs)
|
|
assert(text=='Speed 10% for 3 swings.'and #unresolved==0)
|
|
for _,charges in ipairs({0,1,5,255})do
|
|
text,unresolved=format({description='$n',procCharges=charges})
|
|
assert(text==tostring(charges)and #unresolved==0)
|
|
end
|
|
for _,charges in ipairs({-1,256,1.5,'3',false})do
|
|
text,unresolved=format({description='$n',procCharges=charges})
|
|
assert(text=='$n'and #unresolved==1)
|
|
end
|
|
for _,raw in ipairs({'$99999n','$12966n1','$N'})do
|
|
text,unresolved=format({description=raw},refs);assert(text==raw and #unresolved==1)
|
|
end
|
|
text,unresolved=format({description='$n'});assert(text=='$n'and #unresolved==1)
|
|
refs[12966].id=12967
|
|
text,unresolved=format({description='$12966n'},refs);assert(text=='$12966n'and #unresolved==1)
|
|
end
|
|
do
|
|
local trained={id=23894,rank='Rank 4',description='200 plus 35% AP; $51670s1% for $51670d.'}
|
|
local refs={[51670]={id=51670,effects={{basePoints=9,dieSides=1}},durationMs=6000}}
|
|
local text,unresolved=GatewayTurtleTalentProvider.FormatDescription(trained,refs)
|
|
assert(text=='200 plus 35% AP; 10% for 6 sec.'and #unresolved==0)
|
|
local provider=GatewayTurtleTalentProvider.New({tabs={},talents={{id=109,ranks={{id=23881}}}},
|
|
rankSuccessors={[23881]={23892,23893,23894}},tooltipSpells={
|
|
[23892]={id=23892,rank='Rank 2',description='$s1 plus 35% AP.',effects={{basePoints=129,dieSides=1}}},
|
|
[23894]=trained,[51670]=refs[51670]}})
|
|
provider.state={known={[23894]=true}}
|
|
local info=provider:TooltipInfo(109)
|
|
assert(info.rank==1 and info.committedRank==1 and info.record.id==23894 and info.nextRecord==nil and info.trainedAbilityRank=='Rank 4')
|
|
assert(provider.state.known[23881]==nil and provider.byID[109].ranks[1].id==23881)
|
|
provider.state.known={[23892]=true};info=provider:TooltipInfo(109)
|
|
assert(info.rank==1 and info.record.id==23892 and info.trainedAbilityRank=='Rank 2')
|
|
assert(provider.FormatDescription(info.record,provider.spellRecords)=='130 plus 35% AP.')
|
|
provider.state.known={[23892]=true,[23894]=true};info=provider:TooltipInfo(109)
|
|
assert(info.record.id==23894 and info.trainedAbilityRank=='Rank 4')
|
|
provider.state.known={};info=provider:TooltipInfo(109)
|
|
assert(info.rank==0 and info.record.id==23881 and info.trainedAbilityRank==nil)
|
|
provider.staged[109]=1;info=provider:TooltipInfo(109)
|
|
assert(info.rank==1 and info.committedRank==0 and info.record.id==23881)
|
|
local cases={
|
|
{{description='$s1',effects={{basePoints=9,dieSides=0}}},'9',0},
|
|
{{description='$s1',effects={{basePoints=9,dieSides=3}}},'10 to 12',0},
|
|
{{description='$/10;51670s1 $51670t1'},'1 2',0},
|
|
{{description='$s1',effects={{basePoints=9,dieSides=1,pointsPerLevel=0.5}}},'$s1',1},
|
|
{{description='$s1',effects={{basePoints=9,dieSides=1,dicePerLevel=1}}},'$s1',1},
|
|
{{description='$99999s1 $51670d $S1',effects={{basePoints=9,dieSides=1}}},'$99999s1 6 sec 10',1},
|
|
}
|
|
refs[51670].effects[1].amplitudeMs=2000
|
|
for _,c in ipairs(cases)do
|
|
text,unresolved=GatewayTurtleTalentProvider.FormatDescription(c[1],refs)
|
|
assert(text==c[2]and #unresolved==c[3],text)
|
|
end
|
|
refs[51670].id=123
|
|
text,unresolved=GatewayTurtleTalentProvider.FormatDescription({description='$51670s1'},refs)
|
|
assert(text=='$51670s1'and #unresolved==1)
|
|
end
|
|
do
|
|
-- REA trace of the pinned Classic executable:0x507710 dispatches s/S
|
|
-- together, but0x507b1a and0x507b50 distinguish m(first)and M(second).
|
|
-- Actual source Ravager and Improved Slam records use these forms.
|
|
local format=GatewayTurtleTalentProvider.FormatDescription
|
|
for _,r in ipairs({{base=-1001,rage=-11,seconds='1',cost='1'},
|
|
{base=-1501,rage=-21,seconds='1.5',cost='2'},
|
|
{base=-2001,rage=-31,seconds='2',cost='3'}})do
|
|
local text,unresolved=format({description='Reduces the cooldown of your Whirlwind by $/1000;m1 sec and the Rage cost of your Cleave by $/10;m2.',
|
|
effects={{basePoints=r.base,dieSides=1},{basePoints=r.rage,dieSides=1}}})
|
|
assert(text=='Reduces the cooldown of your Whirlwind by '..r.seconds..' sec and the Rage cost of your Cleave by '..r.cost..'.'and #unresolved==0)
|
|
end
|
|
for _,r in ipairs({{base=-251,seconds='0.25'},{base=-501,seconds='0.5'}})do
|
|
local text,unresolved=format({description='Reduces the cast time and global cooldown of your Slam ability by $/1000;S1 sec.',effects={{basePoints=r.base,dieSides=1}}})
|
|
assert(text=='Reduces the cast time and global cooldown of your Slam ability by '..r.seconds..' sec.'and #unresolved==0)
|
|
end
|
|
local refs={[51670]={id=51670,effects={{basePoints=9,dieSides=3}}}}
|
|
local text,unresolved=format({description='$51670m1 $51670M1 $51670S1 $/10;51670m1 $/10;51670M1 $/10;51670S1'},refs)
|
|
assert(text=='10 12 10 to 12 1 1.2 1 to 1.2'and #unresolved==0)
|
|
for _,raw in ipairs({'$m4','$M01','$S1suffix','$/0;m1','$/2147483648;S1','$/-10;M1','$99999m1','$99999S1'})do
|
|
text,unresolved=format({description=raw,effects={{basePoints=49,dieSides=1}}},refs)
|
|
assert(text==raw and #unresolved==1,raw)
|
|
end
|
|
for _,token in ipairs({'$m1','$M1','$S1'})do
|
|
for _,effect in ipairs({{basePoints=-11,dieSides=3},{basePoints=9,dieSides=1,pointsPerLevel=0.5},
|
|
{basePoints=9,dieSides=1,dicePerLevel=1},{basePoints=1.5,dieSides=1},{basePoints=9,dieSides=-1}})do
|
|
text,unresolved=format({description=token,effects={effect}})
|
|
assert(text==token and #unresolved==1)
|
|
end
|
|
end
|
|
refs[51670].id=123
|
|
text,unresolved=format({description='$51670S1'},refs)
|
|
assert(text=='$51670S1'and #unresolved==1)
|
|
end
|
|
local function ranks(...)local t={}for _,id in ipairs({...})do t[#t+1]={id=id}end;return t end
|
|
-- Actual Turtle IDs/layout: Tactical Mastery is row0; Deflection requires5
|
|
-- points in Arms. Forever's original tree places these differently.
|
|
local data={tabs={{id=161,name='Arms',classMask=1,order=0},{id=163,name='Protection',classMask=1,order=2},{id=81,name='Arcane',classMask=128,order=0}},talents={
|
|
{id=56,tab=161,row=0,prerequisite=0,requiredSpell=0,ranks=ranks(12282,12663,12664)},
|
|
{id=57,tab=161,row=0,prerequisite=0,requiredSpell=0,ranks=ranks(12295,12676,12677,12678,12679)},
|
|
{id=60,tab=161,row=1,prerequisite=0,requiredSpell=0,ranks=ranks(16462,16463,16464,16465,16466)},
|
|
{id=58,tab=161,row=0,prerequisite=0,requiredSpell=0,ranks=ranks(12286,12658)},
|
|
{id=64,tab=161,row=2,prerequisite=58,prerequisiteRank=1,requiredSpell=0,ranks=ranks(12834,12849,12867)},
|
|
{id=66,tab=161,row=3,prerequisite=64,prerequisiteRank=2,requiredSpell=0,ranks=ranks(16493,16494)},
|
|
{id=9999,tab=81,row=0,prerequisite=0,requiredSpell=0,ranks=ranks(11113)}}}
|
|
-- Pinned extracted Turtle Talent59 / Spell12285,12697: actual source tokens
|
|
-- store rage in tenths. Do not use the destination spell's different text.
|
|
local charge={id=59,tab=161,row=1,column=0,prerequisite=0,prerequisiteRank=0,requiredSpell=0,ranks={
|
|
{id=12285,name='Improved Charge',description='Increases the amount of rage generated by your Charge ability by $/10;s1.',effects={{basePoints=49}}},
|
|
{id=12697,name='Improved Charge',description='Increases the amount of rage generated by your Charge ability by $/10;s1.',effects={{basePoints=99}}}}}
|
|
data.talents[#data.talents+1]=charge
|
|
local text,unresolved=GatewayTurtleTalentProvider.FormatDescription(charge.ranks[1])
|
|
assert(text=='Increases the amount of rage generated by your Charge ability by 5.'and #unresolved==0)
|
|
text,unresolved=GatewayTurtleTalentProvider.FormatDescription(charge.ranks[2])
|
|
assert(text=='Increases the amount of rage generated by your Charge ability by 10.'and #unresolved==0)
|
|
-- Genuine Spell16462 uses a simple effect value; Spell12282 uses a negative
|
|
-- basePoints reduction and the same explicit divisor as Charge.
|
|
assert(GatewayTurtleTalentProvider.FormatDescription({id=16462,description='Increases your Parry chance by $s1%.',effects={{basePoints=0}}})=='Increases your Parry chance by 1%.')
|
|
assert(GatewayTurtleTalentProvider.FormatDescription({id=12282,description='Reduces the cost of your Heroic Strike ability by $/10;s1 rage point.',effects={{basePoints=-11}}})=='Reduces the cost of your Heroic Strike ability by 1 rage point.')
|
|
-- Genuine Reprisal ranks51593/51594: ProcChance column25 is50/100;
|
|
-- effect1 basePoints24/49 gives the separate25/50 damage percentages.
|
|
local reprisal='Increases the damage dealt by your Revenge ability by $s1%, and has a $h% chance to refund its rage cost if successful.'
|
|
for _,r in ipairs({{id=51593,base=24,chance=50,damage=25},{id=51594,base=49,chance=100,damage=50}})do
|
|
text,unresolved=GatewayTurtleTalentProvider.FormatDescription({id=r.id,description=reprisal,procChance=r.chance,effects={{basePoints=r.base}}})
|
|
assert(text=='Increases the damage dealt by your Revenge ability by '..r.damage..'%, and has a '..r.chance..'% chance to refund its rage cost if successful.'and #unresolved==0)
|
|
end
|
|
-- A different class uses the same token: Mage Impact11103/12357 has2/4.
|
|
for _,chance in ipairs({0,2,4,100})do
|
|
text,unresolved=GatewayTurtleTalentProvider.FormatDescription({description='Chance: $h%.',procChance=chance})
|
|
assert(text=='Chance: '..chance..'%.'and #unresolved==0)
|
|
end
|
|
for _,value in ipairs({false,'50',-1,101,1.5,0/0,math.huge,-math.huge})do
|
|
text,unresolved=GatewayTurtleTalentProvider.FormatDescription({description='$h%',procChance=value})
|
|
assert(text=='$h%'and #unresolved==1)
|
|
end
|
|
text,unresolved=GatewayTurtleTalentProvider.FormatDescription({description='$h%'})
|
|
assert(text=='$h%'and #unresolved==1) -- Missing data is never defaulted to0.
|
|
for _,raw in ipairs({'$hSuffix','$h1','$h_','${h}','${procChance}','$51593h'})do
|
|
text,unresolved=GatewayTurtleTalentProvider.FormatDescription({description=raw,procChance=50})
|
|
assert(text==raw and #unresolved>0)
|
|
end
|
|
for _,raw in ipairs({'$d','$s4','$s12','$s01','$s1suffix','$/0;s1','$/-10;s1','$/2.5;s1','$/10;s01','$/2147483648;s1','$$s1','$?a1:yes:no;'})do
|
|
text,unresolved=GatewayTurtleTalentProvider.FormatDescription({description=raw,effects={{basePoints=49}}})
|
|
assert(text==raw and #unresolved>0,raw)
|
|
end
|
|
for _,record in ipairs({{description='$s1'},{description='$s1',effects={1}},{description='$s1',effects={{basePoints=1.5}}}})do
|
|
text,unresolved=GatewayTurtleTalentProvider.FormatDescription(record);assert(text=='$s1'and #unresolved==1)
|
|
end
|
|
local long=string.rep('x',8193);assert(GatewayTurtleTalentProvider.FormatDescription({description=long})==long)
|
|
local many=string.rep('$s1 ',257);assert(GatewayTurtleTalentProvider.FormatDescription({description=many,effects={{basePoints=49}}})==many)
|
|
local descriptions=GatewayTurtleTalentProvider.New(data)
|
|
local function descriptionSnapshot(seq,points,known)
|
|
descriptions:Receive('GWTURTLE1 BEGIN '..seq..' 4509 1 60 '..points..' '..#known)
|
|
if #known>0 then descriptions:Receive('GWTURTLE1 SPELLS '..seq..' '..table.concat(known,','))end
|
|
assert(descriptions:Receive('GWTURTLE1 END '..seq))
|
|
end
|
|
descriptionSnapshot(1,51,{})
|
|
local info=descriptions:TooltipInfo(59)
|
|
assert(info.rank==0 and info.record.id==12285 and info.nextRecord==nil) -- Unlearned previews only first rank.
|
|
descriptionSnapshot(2,50,{12285})
|
|
info=descriptions:TooltipInfo(59)
|
|
assert(info.rank==1 and info.record.id==12285 and info.nextRecord.id==12697)
|
|
descriptions.staged[59]=2;info=descriptions:TooltipInfo(59)
|
|
assert(info.rank==2 and info.committedRank==1 and info.record.id==12697 and info.nextRecord==nil)
|
|
local p=GatewayTurtleTalentProvider.New(data)
|
|
assert(not p:CanPurchase(56))
|
|
assert(not p:Receive('GWTURTLE1 BEGIN 1 4509 1 60 48 1'))
|
|
assert(not p:Receive('GWTURTLE1 END 1')) -- Truncated snapshot does not become state.
|
|
assert(p.state==nil)
|
|
p:Receive('GWTURTLE1 BEGIN 2 4509 1 60 48 1');p:Receive('GWTURTLE1 SPELLS 2 12664')
|
|
assert(p:Receive('GWTURTLE1 END 2'));assert(p:Rank(56,false)==3)
|
|
assert(#p:ClassTabs()==2 and p:AvailablePoints()==48)
|
|
assert(not p:CanPurchase(60) and not p:CanPurchase(9999))
|
|
assert(p:Stage(57));assert(p:Stage(57));assert(p:CanPurchase(60))
|
|
assert(p:Rank(57,false)==0 and p:Rank(57,true)==2 and p:AvailablePoints()==46)
|
|
assert(not p:CanPurchase(66));assert(p:Stage(57));assert(p:Stage(57));assert(p:Stage(57))
|
|
assert(not p:CanPurchase(66));assert(not p:CanPurchase(57))
|
|
local queue=p:Purchases();assert(#queue==5 and queue[1].id==57 and queue[1].rank==1 and queue[5].rank==5)
|
|
assert(p:PurchaseExpectation(57,5)==nil) -- Every emitted step buys exactly one rank.
|
|
local expected=p:PurchaseExpectation(57,1)
|
|
assert(expected.priorRank==0 and expected.priorPoints==48 and expected.cost==1 and expected.points==47)
|
|
assert(not p:PurchaseAcknowledged(expected)) -- Staging is never an ACK.
|
|
for _=1,5 do assert(p:Stage(60))end
|
|
for _=1,2 do assert(p:Stage(58))end
|
|
assert(not p:CanPurchase(66));for _=1,3 do assert(p:Stage(64))end
|
|
assert(p:CanPurchase(66))
|
|
p:Undo();assert(p:AvailablePoints()==48 and p:Rank(57,true)==0)
|
|
p:Receive('GWTURTLE1 BEGIN 1 4509 1 60 99 0');assert(not p:Receive('GWTURTLE1 END 1'));assert(p.state.points==48)
|
|
p:Receive('GWTURTLE1 BEGIN 3 4509 1 60 47 2');p:Receive('GWTURTLE1 SPELLS 3 12664,12295')
|
|
assert(p:Receive('GWTURTLE1 END 3'));assert(p:Rank(57,false)==1 and p:AvailablePoints()==47)
|
|
p:Receive('GWTURTLE1 BEGIN 4 4509 1 60 47 2');p:Receive('GWTURTLE1 SPELLS 4 12664,12664')
|
|
assert(not p:Receive('GWTURTLE1 END 4'));assert(p.state.seq==3)
|
|
assert(p:ActiveContext()==p.state)
|
|
p:Clear();assert(p:ActiveContext()==nil and p.receiving==nil and next(p.staged)==nil and p.pending==nil)
|
|
|
|
-- The actual native frame is modelled only at its documented Lua boundary.
|
|
-- No fake engine configuration or C_Traits API is allowed by these tests.
|
|
local function forbidden()error('Unexpected engine trait API')end
|
|
C_Traits=setmetatable({},{__index=forbidden});C_ClassTalents=setmetatable({},{__index=forbidden})
|
|
C_SpecializationInfo=setmetatable({},{__index=forbidden})
|
|
StaticPopupDialogs={};ACCEPT='Accept';CANCEL='Cancel';SlashCmdList={}
|
|
local popup
|
|
GetCoinTextureString=nil -- Actual70334 removed this deprecated global.
|
|
StaticPopup_Show=function(key,cost,_,offer)popup={key=key,cost=cost,offer=offer}end
|
|
local now=0
|
|
InCombatLockdown=function()return false end;GetTime=function()return now end
|
|
ChatFrame_AddMessageEventFilter=function()end
|
|
local sent={}
|
|
SendChatMessage=function()error('Protected SAY is forbidden for provider controls')end
|
|
UnitName=function(unit)assert(unit=='player');return 'Fixture'end
|
|
C_ChatInfo={SendAddonMessage=function(prefix,text,kind,target)
|
|
assert(prefix=='GWTURTLE'and kind=='WHISPER'and target=='Fixture')
|
|
sent[#sent+1]={'.gwtalent '..text,kind,target}
|
|
end}
|
|
TalentFrameBaseMixin={Event={TalentButtonAcquired='TalentButtonAcquired'}}
|
|
Enum={TraitNodeType={Single=1},TraitNodeEntryType={SpendSquare=1},TraitEdgeType={RequiredForAvailability=1},TraitEdgeVisualStyle={Straight=1}}
|
|
GatewayTurtleData=data
|
|
for _,talent in ipairs(data.talents)do talent.column=0 end
|
|
local driver
|
|
CreateFrame=function()
|
|
driver={events={},scripts={}}
|
|
function driver:RegisterEvent(event)self.events[event]=true end
|
|
function driver:SetScript(name,callback)self.scripts[name]=callback end
|
|
return driver
|
|
end
|
|
PlayerSpellsFrame=nil
|
|
local earlierAudit={seq=777,guid=9999,class=1,level=60,points=0,count=1,known={[12679]=true}}
|
|
GatewayDiagnosticsSaved={turtleState=earlierAudit,turtleLastAcknowledgedState=earlierAudit,turtleStateActive=true}
|
|
dofile(arg[1]..'/client_addons/GatewayDiagnostics/TurtleTalents.lua')
|
|
assert(GatewayTurtleTalents:ActiveContext()==nil and GatewayDiagnosticsSaved.turtleState==nil)
|
|
assert(not GatewayDiagnosticsSaved.turtleStateActive and GatewayDiagnosticsSaved.turtleLastAcknowledgedState==earlierAudit)
|
|
local function event(name,message)driver.scripts.OnEvent(driver,name,message)end
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 RESET 17379390977340422605 10000')
|
|
assert(popup==nil and #sent==0)
|
|
-- A trainer offer can open only after a complete self-talent snapshot.
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 BEGIN 1 4509 1 60 51 0')
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 END 1')
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 RESET 17379390977340422605 10000')
|
|
assert(popup.key=='GATEWAY_TURTLE_TALENT_RESET'and popup.cost=='1g 0s 0c')
|
|
assert(popup.offer.guid=='17379390977340422605')
|
|
StaticPopupDialogs.GATEWAY_TURTLE_TALENT_RESET.OnAccept(nil,popup.offer)
|
|
assert(sent[#sent][1]=='.gwtalent reset 17379390977340422605'and GatewayTurtleTalents.resetOffer==nil)
|
|
event('PLAYER_LEAVING_WORLD')
|
|
-- SharedTalentUI can load later: normal ADDON_LOADED retries arm exactly one
|
|
-- secure post-hook. No original PlayerSpells source replacement is involved.
|
|
local secureHooks=0
|
|
hooksecurefunc=function(owner,key,callback)
|
|
secureHooks=secureHooks+1;local original=owner[key]
|
|
owner[key]=function(self,...)original(self,...);callback(self,...)end
|
|
end
|
|
TalentFrameBaseMixin.OnLoad=function(self)self.baseLoaded=(self.baseLoaded or 0)+1 end
|
|
ClassTalentsFrameMixin={RefreshConfigID=function()error('Original nil-config RefreshConfigID must not run')end}
|
|
event('ADDON_LOADED','Blizzard_SharedTalentUI');event('ADDON_LOADED','Blizzard_SharedTalentUI')
|
|
assert(secureHooks==1)
|
|
local unrelated={RefreshConfigID=function()end};local untouched=unrelated.RefreshConfigID
|
|
TalentFrameBaseMixin.OnLoad(unrelated)
|
|
assert(unrelated.RefreshConfigID==untouched and not unrelated.gatewayTurtleRefreshArmed)
|
|
local function control()
|
|
return {shown=true,Hide=function(self)self.shown=false end,SetShown=function(self,value)self.shown=value end,
|
|
SetOnClickHandler=function(self,callback)self.click=callback end,SetupMenu=function(self,callback)self.menu=callback end}
|
|
end
|
|
local frame={shown=true,loaded=0,released=0,callbacks={},configIDs=nil}
|
|
for _,key in ipairs({'TabSystem','ActiveSpec','LoadSystem','GamepadPrimaryTabIcon','GamepadSecondaryTabIcon','InspectCopyButton',
|
|
'ApplyButton','UndoButton','ResetButton','SearchBox','SearchOptionsDropdown'})do frame[key]=control()end
|
|
frame.ClassCurrencyDisplay=control()
|
|
frame.DisabledOverlay={CreateFontString=function()
|
|
local label=control()
|
|
function label:SetPoint()end
|
|
function label:SetWidth()end
|
|
function label:SetText(value)self.text=value end
|
|
return label
|
|
end}
|
|
function frame:ClearInfoCaches()end
|
|
function frame:SetDisabledOverlayShown(value)self.disabled=value end
|
|
function frame:IsInspecting()return false end
|
|
function frame:IsShown()return self.shown end
|
|
function frame:ReleaseAllTalentButtons()self.released=self.released+1 end
|
|
function frame:MarkTreeClean()self.dirty=false end
|
|
function frame:MarkTreeDirty()self.dirty=true end
|
|
function frame:RefreshClassCurrencyDisplay()end
|
|
function frame:UpdateAllButtons()end
|
|
function frame:TriggerEvent()end
|
|
function frame:UpdateConfigButtonsState()self.valid=self:HasValidConfig()end
|
|
function frame:HookScript(name,callback)self.callbacks[name]=callback end
|
|
function frame:RegisterCallback(_,callback)self.talentButtonAcquired=callback end
|
|
function frame:GetTalentButtonByNodeID()return nil end
|
|
function frame:EnumerateAllTalentButtons()return function()end end
|
|
function frame:LoadTalentTreeInternal()self.loaded=self.loaded+1;self.loadedNodes=self:GetTreeNodes();self:MarkTreeClean()end
|
|
function frame:UpdateInspecting()self.LoadSystem:SetShown(true);self:RefreshConfigID()end
|
|
frame.RefreshConfigID=ClassTalentsFrameMixin.RefreshConfigID
|
|
TalentFrameBaseMixin.OnLoad(frame)
|
|
local deferredRefresh=frame.RefreshConfigID
|
|
assert(frame.gatewayTurtleRefreshArmed and deferredRefresh~=ClassTalentsFrameMixin.RefreshConfigID)
|
|
assert(frame.treeHeaderPool==nil and frame.loaded==0 and frame.turtleActiveContext==nil and frame.GetConfigID==nil)
|
|
TalentFrameBaseMixin.OnLoad(frame)
|
|
assert(frame.RefreshConfigID==deferredRefresh and secureHooks==1) -- Duplicate frame/base load is inert.
|
|
frame.treeHeaderPool={ReleaseAll=function()end,Acquire=function()
|
|
return {Setup=function()end,SetPoint=function()end,Show=function()end}
|
|
end}
|
|
-- Original class OnLoad initializes its headers/other controls before its
|
|
-- first RefreshConfigID: only now may the deferred closure install the view.
|
|
assert(frame:RefreshConfigID())
|
|
assert(frame.configIDs==nil and frame:GetConfigID()==nil and frame:GetTalentTreeID()==nil)
|
|
assert(not frame:HasValidConfig() and frame.disabled and frame.loaded==0 and not frame.dirty)
|
|
local function noBuildControls()
|
|
for _,key in ipairs({'TabSystem','ActiveSpec','LoadSystem','GamepadPrimaryTabIcon','GamepadSecondaryTabIcon','InspectCopyButton'})do assert(not frame[key].shown,key)end
|
|
end
|
|
noBuildControls()
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 BEGIN 1 4509 1 60 48 1')
|
|
assert(frame.turtleActiveContext==nil and frame.loaded==0)
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 SPELLS 1 12664')
|
|
assert(frame.turtleActiveContext==nil)
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 END 1')
|
|
assert(frame:HasValidConfig() and not frame.disabled and frame.loaded==1)
|
|
assert(frame.turtleActiveContext==GatewayTurtleTalents:ActiveContext())
|
|
assert(frame.turtleActiveContext.guid==4509 and frame.turtleActiveContext.points==48)
|
|
local audit=GatewayDiagnosticsSaved.turtleLastAcknowledgedState
|
|
assert(audit.guid==4509 and audit.seq==1 and audit.points==48 and audit.count==1 and audit.known[12664])
|
|
assert(audit~=frame.turtleActiveContext and audit.known~=frame.turtleActiveContext.known)
|
|
assert(frame:GetConfigID()==nil and frame:GetTalentTreeID()==nil)
|
|
assert(frame.loadedNodes[1]==56 and frame:GetAndCacheNodeInfo(56).activeRank==3)
|
|
assert(frame:GetAndCacheNodeInfo(57).activeRank==0)
|
|
local edges=frame:GetAndCacheNodeInfo(58).visibleEdges
|
|
assert(#edges==1 and edges[1].targetNode==64 and not edges[1].isActive)
|
|
GatewayTurtleTalents.staged[58]=2
|
|
assert(frame:GetAndCacheNodeInfo(58).visibleEdges[1].isActive)
|
|
GatewayTurtleTalents.staged[58]=nil
|
|
assert(#frame:GetAndCacheNodeInfo(57).visibleEdges==0)
|
|
frame:UpdateInspecting();noBuildControls() -- Original script cannot re-show loadouts.
|
|
frame:SetConfigID(999999);frame:SetTalentTreeID(1117);frame:SetTab(5);frame:RefreshLoadoutOptions()
|
|
assert(frame:GetConfigID()==nil and frame:GetTalentTreeID()==nil and frame.turtleActiveContext.guid==4509)
|
|
noBuildControls() -- Native selection calls cannot turn into invented configs.
|
|
frame:PurchaseRank(57);assert(GatewayTurtleTalents:Rank(57,false)==0 and GatewayTurtleTalents:Rank(57,true)==1)
|
|
frame:ApplyConfig();assert(sent[#sent][1]=='.gwtalent learn 57 1' and sent[#sent][2]=='WHISPER')
|
|
assert(GatewayTurtleTalents:Rank(57,false)==0) -- A request is not an ACK.
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 BEGIN 2 4509 1 60 47 2')
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 SPELLS 2 12664,12295');event('CHAT_MSG_SYSTEM','GWTURTLE1 END 2')
|
|
assert(GatewayTurtleTalents:Rank(57,false)==1 and GatewayTurtleTalents.pending==nil and frame.turtleActiveContext.points==47)
|
|
-- A genuine reset/unallocated build remains a valid active source context.
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 BEGIN 3 4509 1 60 51 0');event('CHAT_MSG_SYSTEM','GWTURTLE1 END 3')
|
|
assert(frame:HasValidConfig() and not frame.disabled and frame:GetAndCacheNodeInfo(56).activeRank==0)
|
|
assert(frame.turtleActiveContext.points==51 and GatewayTurtleTalents:Spent(nil,false)==0)
|
|
local resetAudit=GatewayDiagnosticsSaved.turtleLastAcknowledgedState
|
|
assert(resetAudit.guid==4509 and resetAudit.seq==3 and resetAudit.points==51 and resetAudit.count==0 and next(resetAudit.known)==nil)
|
|
event('PLAYER_LEAVING_WORLD')
|
|
assert(frame.turtleActiveContext==nil and not frame:HasValidConfig() and frame.disabled and not frame.dirty)
|
|
assert(GatewayDiagnosticsSaved.turtleState==nil and not GatewayDiagnosticsSaved.turtleStateActive)
|
|
assert(GatewayDiagnosticsSaved.turtleLastAcknowledgedState==resetAudit)
|
|
local beforeEnteringWorld=#sent
|
|
event('PLAYER_ENTERING_WORLD');assert(#sent==beforeEnteringWorld) -- No unsolicited protected chat during initialization.
|
|
assert(GatewayTurtleTalents:ActiveContext()==nil and GatewayDiagnosticsSaved.turtleLastAcknowledgedState==resetAudit)
|
|
frame.callbacks.OnShow();assert(#sent==beforeEnteringWorld+1 and sent[#sent][1]=='.gwtalent state')
|
|
assert(GatewayTurtleTalents:ActiveContext()==nil) -- Refresh request alone does not restore old saved state.
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 BEGIN 1 4510 8 10 1 0');event('CHAT_MSG_SYSTEM','GWTURTLE1 END 1')
|
|
assert(frame:HasValidConfig() and frame.turtleActiveContext.guid==4510 and frame.loadedNodes[1]==9999)
|
|
assert(#frame.loadedNodes==1 and frame:GetConfigID()==nil);noBuildControls()
|
|
local function snapshot(seq,guid,class,level,points,spells)
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 BEGIN '..seq..' '..guid..' '..class..' '..level..' '..points..' '..#spells)
|
|
if #spells>0 then event('CHAT_MSG_SYSTEM','GWTURTLE1 SPELLS '..seq..' '..table.concat(spells,','))end
|
|
event('CHAT_MSG_SYSTEM','GWTURTLE1 END '..seq)
|
|
end
|
|
snapshot(100,4509,1,60,51,{})
|
|
frame:PurchaseRank(56);frame:PurchaseRank(57);frame:ApplyConfig()
|
|
assert(sent[#sent][1]=='.gwtalent learn 56 1')
|
|
local sentBefore=#sent;local request=GatewayTurtleTalents.pending.expected
|
|
assert(request.priorPoints==51 and request.priorRank==0 and request.cost==1 and request.points==50)
|
|
snapshot(101,4509,1,60,51,{12282}) -- Learned rank arrives first.
|
|
assert(#sent==sentBefore and GatewayTurtleTalents.pending.id==56)
|
|
snapshot(102,4509,1,60,51,{12282,6603}) -- Ordinary trainer spell is not a talent-cost ACK.
|
|
assert(#sent==sentBefore and GatewayTurtleTalents.pending.id==56)
|
|
snapshot(103,4509,1,60,49,{12282,6603}) -- A different decrement is not this request's ACK.
|
|
assert(#sent==sentBefore and GatewayTurtleTalents.pending.id==56)
|
|
snapshot(104,4509,1,60,50,{12282,6603})
|
|
assert(#sent==sentBefore+1 and sent[#sent][1]=='.gwtalent learn 57 1')
|
|
assert(GatewayTurtleTalents.pending.expected.priorPoints==50 and GatewayTurtleTalents.pending.expected.points==49)
|
|
sentBefore=#sent
|
|
snapshot(105,4509,1,60,49,{12282,6603}) -- Points arrive first for the next request.
|
|
assert(#sent==sentBefore and GatewayTurtleTalents.pending.id==57)
|
|
snapshot(106,4509,1,60,49,{12282,12295,6603})
|
|
assert(#sent==sentBefore and GatewayTurtleTalents.pending==nil)
|
|
-- A completely rejected purchase remains pending and then times out without
|
|
-- consuming points locally, inventing a learned rank, or sending the next item.
|
|
frame:PurchaseRank(58);frame:ApplyConfig();sentBefore=#sent
|
|
snapshot(107,4509,1,60,49,{12282,12295,6603})
|
|
assert(GatewayTurtleTalents.pending.id==58 and GatewayTurtleTalents:Rank(58,false)==0)
|
|
assert(frame.turtleActiveContext.points==49 and #sent==sentBefore)
|
|
now=9;driver.scripts.OnUpdate()
|
|
assert(GatewayTurtleTalents.pending==nil and GatewayTurtleTalents.staged[58]==1)
|
|
assert(GatewayTurtleTalents.resyncSeq==107 and #sent==sentBefore+1 and sent[#sent][1]=='.gwtalent state')
|
|
assert(GatewayDiagnosticsSaved.turtleApply.status=='stopped'and GatewayDiagnosticsSaved.turtleApply.accepted==0)
|
|
assert(GatewayTurtleTalents:Rank(58,false)==0 and frame.turtleActiveContext.points==49)
|
|
snapshot(108,4509,1,60,49,{12282,12295,6603})
|
|
assert(GatewayTurtleTalents.resyncSeq==nil)
|
|
GatewayTurtleTalents:Undo()
|
|
frame:PurchaseRank(58);frame:ApplyConfig();sentBefore=#sent
|
|
snapshot(109,4510,8,10,1,{}) -- Changing scope cancels ownership, not an ACK.
|
|
assert(GatewayTurtleTalents.pending==nil and next(GatewayTurtleTalents.staged)==nil and #sent==sentBefore)
|
|
GameTooltip={lines={},SetOwner=function(self,owner)self.owner=owner;self.lines={}end,
|
|
IsOwned=function(self,owner)return self.owner==owner end,Hide=function(self)self.owner=nil end,AddLine=function(self,line)self.lines[#self.lines+1]=line end,Show=function()end}
|
|
local button={GetNodeID=function()return 59 end};frame.talentButtonAcquired(nil,button)
|
|
snapshot(110,4509,1,60,46,{12679})
|
|
button:SetTooltipInternal()
|
|
assert(GameTooltip.lines[2]=='Unlearned (0/2)'and GameTooltip.lines[3]=='First rank (1/2)')
|
|
assert(GameTooltip.lines[4]=='Increases the amount of rage generated by your Charge ability by 5.')
|
|
snapshot(111,4509,1,60,45,{12679,12285})
|
|
button:SetTooltipInternal()
|
|
assert(GameTooltip.lines[2]=='Talent rank 1/2'and GameTooltip.lines[3]=='Increases the amount of rage generated by your Charge ability by 5.')
|
|
assert(GameTooltip.lines[4]=='Next rank (2/2)'and GameTooltip.lines[5]=='Increases the amount of rage generated by your Charge ability by 10.')
|
|
assert(frame:GetAndCacheDefinitionInfo(59).overrideDescription==GameTooltip.lines[3])
|
|
frame:PurchaseRank(59);button:SetTooltipInternal()
|
|
assert(GameTooltip.lines[2]=='Talent rank 2/2'and GameTooltip.lines[3]=='Pending allocation; server rank 1')
|
|
assert(GameTooltip.lines[4]=='Increases the amount of rage generated by your Charge ability by 10.')
|
|
assert(frame:GetAndCacheDefinitionInfo(59).overrideDescription==GameTooltip.lines[4])
|
|
for _,line in ipairs(GameTooltip.lines)do assert(not line:find('Next rank',1,true))end
|
|
-- Multi-rank Apply uses one genuine rank per acknowledged point. Duplicate
|
|
-- clicks/snapshots never replay a request; a partial failure reports acceptance.
|
|
GatewayTurtleTalents:Undo();snapshot(200,4509,1,60,51,{})
|
|
for _=1,3 do frame:PurchaseRank(56)end
|
|
for _=1,2 do frame:PurchaseRank(57)end
|
|
frame:ApplyConfig();local sentStart=#sent
|
|
frame:ApplyConfig();assert(#sent==sentStart)
|
|
assert(sent[#sent][1]=='.gwtalent learn 56 1')
|
|
snapshot(201,4509,1,60,50,{12282})
|
|
assert(sent[#sent][1]=='.gwtalent learn 56 2')
|
|
snapshot(201,4509,1,60,50,{12282});assert(#sent==sentStart+1)
|
|
snapshot(202,4509,1,60,49,{12663})
|
|
assert(sent[#sent][1]=='.gwtalent learn 56 3')
|
|
snapshot(203,4509,1,60,48,{12664})
|
|
assert(sent[#sent][1]=='.gwtalent learn 57 1')
|
|
now=18;driver.scripts.OnUpdate()
|
|
local report=GatewayDiagnosticsSaved.turtleApply
|
|
assert(report.status=='stopped'and report.accepted==3 and report.total==5 and report.remaining==2)
|
|
assert(GatewayTurtleTalents:Rank(56,false)==3 and GatewayTurtleTalents:Rank(57,false)==0)
|
|
assert(GatewayTurtleTalents.staged[56]==nil and GatewayTurtleTalents.staged[57]==2)
|
|
snapshot(204,4509,1,60,48,{12664})
|
|
assert(GatewayTurtleTalents.resyncSeq==nil and GatewayTurtleTalents.pending==nil)
|
|
frame:ApplyConfig();assert(sent[#sent][1]=='.gwtalent learn 57 1')
|
|
snapshot(205,4509,1,60,47,{12664,12295})
|
|
assert(sent[#sent][1]=='.gwtalent learn 57 2')
|
|
snapshot(206,4509,1,60,46,{12664,12676})
|
|
assert(GatewayTurtleTalents.pending==nil and next(GatewayTurtleTalents.staged)==nil)
|
|
assert(GatewayDiagnosticsSaved.turtleApply.status=='complete'and GatewayDiagnosticsSaved.turtleApply.accepted==2)
|
|
-- Rank-only delivery must stay explicitly ambiguous on timeout, not become
|
|
-- an invented refund, a full ACK or a replayable failed batch.
|
|
frame:PurchaseRank(58);frame:ApplyConfig()
|
|
snapshot(207,4509,1,60,46,{12664,12676,12286})
|
|
now=27;driver.scripts.OnUpdate()
|
|
local flight=GatewayDiagnosticsSaved.turtleApply.inFlight
|
|
assert(flight.id==58 and flight.rank==1 and flight.observedRank==1 and flight.expectedPoints==45 and flight.observedPoints==46)
|
|
assert(GatewayDiagnosticsSaved.turtleApply.accepted==0 and GatewayTurtleTalents:Rank(58,false)==1)
|
|
local beforeResync=#sent;snapshot(208,4509,1,60,45,{12664,12676,12286})
|
|
assert(#sent==beforeResync and GatewayTurtleTalents.pending==nil and GatewayTurtleTalents.resyncSeq==nil)
|
|
-- A corrupt/stale staged tier cannot send a speculative first purchase.
|
|
GatewayTurtleTalents.staged={[66]=1}
|
|
local invalid,why=GatewayTurtleTalents:Purchases()
|
|
assert(invalid==nil and why=='invalid-prerequisites-or-points')
|
|
GatewayTurtleTalents.staged={[56]='bad'}
|
|
invalid,why=GatewayTurtleTalents:Purchases();assert(invalid==nil and why=='invalid-staged-rank')
|
|
print('Turtle model/original-frame lifecycle: atomic snapshots, authentic ranks, rank+point ACKs, resets/reconnect and bounded source/current-next tooltips passed; no engine trait calls or real-client claim.')
|