@@ -675,46 +675,35 @@ function TradeQueryClass:ReduceOutput(output)
675675end
676676
677677-- Method to evaluate a result by getting it's output and weight
678- function TradeQueryClass :GetResultEvaluation (row_idx , result_index , calcFunc , baseOutput )
678+ function TradeQueryClass :GetResultEvaluation (row_idx , result_index )
679679 local result = self .resultTbl [row_idx ][result_index ]
680- if not calcFunc then -- Always evaluate when calcFunc is given
681- calcFunc , baseOutput = self .itemsTab .build .calcsTab :GetMiscCalculator ()
682- local onlyWeightedBaseOutput = self :ReduceOutput (baseOutput )
683- if not self .onlyWeightedBaseOutput [row_idx ] then
684- self .onlyWeightedBaseOutput [row_idx ] = { }
685- end
686- if not self .lastComparedWeightList [row_idx ] then
687- self .lastComparedWeightList [row_idx ] = { }
688- end
689- -- If the interesting stats are the same (the build hasn't changed) and result has already been evaluated, then just return that
690- if result .evaluation and tableDeepEquals (onlyWeightedBaseOutput , self .onlyWeightedBaseOutput [row_idx ][result_index ]) and tableDeepEquals (self .statSortSelectionList , self .lastComparedWeightList [row_idx ][result_index ]) then
691- return result .evaluation
692- end
693- self .onlyWeightedBaseOutput [row_idx ][result_index ] = onlyWeightedBaseOutput
694- self .lastComparedWeightList [row_idx ][result_index ] = self .statSortSelectionList
680+ local calcFunc , baseOutput = self .itemsTab .build .calcsTab :GetMiscCalculator ()
681+ local onlyWeightedBaseOutput = self :ReduceOutput (baseOutput )
682+ if not self .onlyWeightedBaseOutput [row_idx ] then
683+ self .onlyWeightedBaseOutput [row_idx ] = { }
684+ end
685+ if not self .lastComparedWeightList [row_idx ] then
686+ self .lastComparedWeightList [row_idx ] = { }
695687 end
688+ -- If the interesting stats are the same (the build hasn't changed) and result has already been evaluated, then just return that
689+ if result .evaluation and tableDeepEquals (onlyWeightedBaseOutput , self .onlyWeightedBaseOutput [row_idx ][result_index ]) and tableDeepEquals (self .statSortSelectionList , self .lastComparedWeightList [row_idx ][result_index ]) then
690+ return result .evaluation
691+ end
692+ self .fullBaseOutput = baseOutput
693+ self .onlyWeightedBaseOutput [row_idx ][result_index ] = onlyWeightedBaseOutput
694+ self .lastComparedWeightList [row_idx ][result_index ] = self .statSortSelectionList
695+
696696 local slotName = self .slotTables [row_idx ].nodeId and " Jewel " .. tostring (self .slotTables [row_idx ].nodeId ) or self .slotTables [row_idx ].slotName
697697 if slotName == " Megalomaniac" then
698698 local addedNodes = {}
699- for nodeName in (result .item_string .. " \r\n " ):gmatch (" 1 Added Passive Skill is (.-)\r ?\n " ) do
700- t_insert (addedNodes , self .itemsTab .build .spec .tree .clusterNodeMap [nodeName ])
699+ for nodeName in (result .item_string .. " \r\n " ):gmatch (" Allocates (.-)\r ?\n " ) do
700+ local node = self .itemsTab .build .spec .tree .notableMap [nodeName :lower ()]
701+ addedNodes [node ] = true
701702 end
702- local output12 = self :ReduceOutput (calcFunc ({ addNodes = { [addedNodes [1 ]] = true , [addedNodes [2 ]] = true } }))
703- local output13 = self :ReduceOutput (calcFunc ({ addNodes = { [addedNodes [1 ]] = true , [addedNodes [3 ]] = true } }))
704- local output23 = self :ReduceOutput (calcFunc ({ addNodes = { [addedNodes [2 ]] = true , [addedNodes [3 ]] = true } }))
705- local output123 = self :ReduceOutput (calcFunc ({ addNodes = { [addedNodes [1 ]] = true , [addedNodes [2 ]] = true , [addedNodes [3 ]] = true } }))
706- -- Sometimes the third node is as powerful as a wet noodle, so use weight per point spent, including the jewel socket
707- local weight12 = self .tradeQueryGenerator .WeightedRatioOutputs (baseOutput , output12 , self .statSortSelectionList ) / 4
708- local weight13 = self .tradeQueryGenerator .WeightedRatioOutputs (baseOutput , output13 , self .statSortSelectionList ) / 4
709- local weight23 = self .tradeQueryGenerator .WeightedRatioOutputs (baseOutput , output23 , self .statSortSelectionList ) / 4
710- local weight123 = self .tradeQueryGenerator .WeightedRatioOutputs (baseOutput , output123 , self .statSortSelectionList ) / 5
711- result .evaluation = {
712- { output = output12 , weight = weight12 , DNs = { addedNodes [1 ].dn , addedNodes [2 ].dn } },
713- { output = output13 , weight = weight13 , DNs = { addedNodes [1 ].dn , addedNodes [3 ].dn } },
714- { output = output23 , weight = weight23 , DNs = { addedNodes [2 ].dn , addedNodes [3 ].dn } },
715- { output = output123 , weight = weight123 , DNs = { addedNodes [1 ].dn , addedNodes [2 ].dn , addedNodes [3 ].dn } },
716- }
717- table.sort (result .evaluation , function (a , b ) return a .weight > b .weight end )
703+
704+ local output = self :ReduceOutput (calcFunc ({ addNodes = addedNodes }))
705+ local weight = self .tradeQueryGenerator .WeightedRatioOutputs (baseOutput , output , self .statSortSelectionList )
706+ result .evaluation = {{ output = output , weight = weight }}
718707 else
719708 local item = new (" Item" , result .item_string )
720709 if not self .enchantInSort then -- Calc item DPS without anoint or enchant as these can generally be added after.
775764
776765-- Method to sort the fetched results
777766function TradeQueryClass :SortFetchResults (row_idx , mode )
778- local calcFunc , baseOutput
779767 local function getResultWeight (result_index )
780- if not calcFunc then
781- calcFunc , baseOutput = self .itemsTab .build .calcsTab :GetMiscCalculator ()
782- end
783768 local sum = 0
784769 for _ , eval in ipairs (self :GetResultEvaluation (row_idx , result_index )) do
785770 sum = sum + eval .weight
@@ -971,27 +956,20 @@ function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, ro
971956 self .itemIndexTbl [row_idx ] = self .sortedResultTbl [row_idx ][index ].index
972957 self :SetFetchResultReturn (row_idx , self .itemIndexTbl [row_idx ])
973958 end )
974- local function addMegalomaniacCompareToTooltipIfApplicable (tooltip , result_index )
975- if slotTbl .slotName ~= " Megalomaniac" then
976- return
977- end
978- for _ , evaluationEntry in ipairs (self :GetResultEvaluation (row_idx , result_index )) do
979- tooltip :AddSeparator (10 )
980- local nodeDNs = evaluationEntry .DNs
981- local nodeCombo = nodeDNs [1 ]
982- for i = 2 , # nodeDNs do
983- nodeCombo = nodeCombo .. " ^8+^7 " .. nodeDNs [i ]
984- end
985- self .itemsTab .build :AddStatComparesToTooltip (tooltip , self .onlyWeightedBaseOutput [row_idx ][result_index ], evaluationEntry .output , " ^8Allocating ^7" .. nodeCombo .. " ^8 will give You:" , # nodeDNs + 2 )
959+ local function addCompareTooltip (tooltip , result_index , dbMode )
960+ local result = self .resultTbl [row_idx ][result_index ]
961+ local item = new (" Item" , result .item_string )
962+ self .itemsTab :AddItemTooltip (tooltip , item , slotTbl , dbMode )
963+ if main .slotOnlyTooltips and slotTbl .slotName == " Megalomaniac" then
964+ local evaluation = self .resultTbl [row_idx ][result_index ].evaluation
965+ self .itemsTab .build :AddStatComparesToTooltip (tooltip , self .onlyWeightedBaseOutput [row_idx ][result_index ], evaluation [1 ].output , " ^7Equipping this item will give you:" )
986966 end
987967 end
988968 controls [" resultDropdown" .. row_idx ].tooltipFunc = function (tooltip , dropdown_mode , dropdown_index , dropdown_display_string )
989- local pb_index = self .sortedResultTbl [row_idx ][dropdown_index ].index
990- local result = self .resultTbl [row_idx ][pb_index ]
991- local item = new (" Item" , result .item_string )
992969 tooltip :Clear ()
993- self .itemsTab :AddItemTooltip (tooltip , item , slotTbl )
994- addMegalomaniacCompareToTooltipIfApplicable (tooltip , pb_index )
970+ local result_index = self .sortedResultTbl [row_idx ][dropdown_index ].index
971+ local result = self .resultTbl [row_idx ][result_index ]
972+ addCompareTooltip (tooltip , result_index )
995973 tooltip :AddSeparator (10 )
996974 tooltip :AddLine (16 , string.format (" ^7Price: %s %s" , result .amount , result .currency ))
997975 end
@@ -1012,14 +990,8 @@ function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, ro
1012990 controls [" importButton" .. row_idx ].tooltipFunc = function (tooltip )
1013991 tooltip :Clear ()
1014992 local selected_result_index = self .itemIndexTbl [row_idx ]
1015- local item_string = self .resultTbl [row_idx ][selected_result_index ].item_string
1016- if selected_result_index and item_string then
1017- -- TODO: item parsing bug caught here.
1018- -- item.baseName is nil and throws error in the following AddItemTooltip func
1019- -- if the item is unidentified
1020- local item = new (" Item" , item_string )
1021- self .itemsTab :AddItemTooltip (tooltip , item , slotTbl , true )
1022- addMegalomaniacCompareToTooltipIfApplicable (tooltip , selected_result_index )
993+ if selected_result_index then
994+ addCompareTooltip (tooltip , selected_result_index , true )
1023995 end
1024996 end
1025997 controls [" importButton" .. row_idx ].enabled = function ()
0 commit comments