vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --===========================================================================-- |
2 | ---------------------------- LootTracker by PNB ---------------------------- |
||
3 | --===========================================================================-- |
||
4 | -- LootTrackerSummary.lua |
||
5 | -- |
||
6 | -- Functions to output object summaries. |
||
7 | --===========================================================================-- |
||
8 | |||
9 | |||
10 | ------------------------------------------------------------------------------ |
||
11 | -- GetItemSummary |
||
12 | -- Return a string summary representation of an item. |
||
13 | ------------------------------------------------------------------------------ |
||
14 | |||
15 | function LT_GetItemSummary(item, qualityThreshold, currentPlayer, qualityColor) |
||
16 | |||
17 | --local qualityThreshold = settings.QualityThreshold; |
||
18 | if (qualityThreshold == nil) then |
||
19 | qualityThreshold = LT_MinQuality; |
||
20 | end |
||
21 | |||
22 | if (qualityColor == nil) then |
||
23 | qualityColor = LT_QualityColors[tostring(item.Quality)]; |
||
24 | end |
||
25 | |||
26 | -- Initialize our return values |
||
27 | local contentText = nil; |
||
28 | local count = 0; |
||
29 | local totalValue = 0; |
||
30 | local playerValue = 0; |
||
31 | |||
32 | -- Number of times this item has been looted |
||
33 | count = getn(item.TimesLooted); |
||
34 | |||
35 | -- Process the item value |
||
36 | local valueString = ""; |
||
37 | if ((item.Value ~= nil) and (item.Value > 0)) then |
||
38 | |||
39 | -- The total value is the per-item value multiplied by the count looted |
||
40 | totalValue = (item.Value * count); |
||
41 | |||
42 | -- Create a colored value string |
||
43 | valueString = " (" .. LT_GetValueString(item.Value, true) .. ")"; |
||
44 | |||
45 | -- Determine what the end value is to the current player |
||
46 | if (item.Recipients ~= nil) then |
||
47 | local countReceivedByPlayer = 0; |
||
48 | |||
49 | -- See how many times this loot was received by the current player |
||
50 | if (currentPlayer ~= nil) then |
||
51 | local recipientCount = item.Recipients[currentPlayer]; |
||
52 | if (recipientCount ~= nil) then |
||
53 | countReceivedByPlayer = countReceivedByPlayer + recipientCount; |
||
54 | end |
||
55 | end |
||
56 | |||
57 | -- See how many times this loot was received by everyone |
||
58 | local recipientCount = item.Recipients[LT_EVERYONE]; |
||
59 | if (recipientCount ~= nil) then |
||
60 | countReceivedByPlayer = countReceivedByPlayer + recipientCount; |
||
61 | end |
||
62 | |||
63 | -- The player's received value is the per-item value multiplied by his received count |
||
64 | playerValue = (item.Value * countReceivedByPlayer); |
||
65 | end |
||
66 | end |
||
67 | |||
68 | -- Only create a content string for this item if we're above the threshold |
||
69 | if (item.Quality >= qualityThreshold) then |
||
70 | |||
71 | -- Display a list of who received this item and how many they received |
||
72 | local recipients = LT_GetRecipientsString(item, nil, ", "); |
||
73 | if (recipients ~= nil) then |
||
74 | recipients = ": " .. recipients; |
||
75 | else |
||
76 | recipients = ""; |
||
77 | end |
||
78 | |||
79 | -- Format: |
||
80 | -- Name: Recipient (Count), Recipient (Count) Value |
||
81 | |||
82 | contentText = LT_ColorText(item.Name, qualityColor) .. valueString .. recipients; |
||
83 | end |
||
84 | |||
85 | return contentText, count, totalValue, playerValue; |
||
86 | |||
87 | end |
||
88 | |||
89 | |||
90 | ------------------------------------------------------------------------------ |
||
91 | -- GetKillSummary |
||
92 | -- Get a string representation of a kill. |
||
93 | ------------------------------------------------------------------------------ |
||
94 | |||
95 | function LT_GetKillSummary(kill) |
||
96 | |||
97 | local killCount = getn(kill.TimesKilled); |
||
98 | local killName = LT_ColorText(kill.Name, LT_White); |
||
99 | |||
100 | local killDrops = nil; |
||
101 | local killValue = ""; |
||
102 | |||
103 | local killLevel = ""; |
||
104 | if (kill.Level ~= nil) then |
||
105 | killLevel = ", level " .. kill.Level; |
||
106 | if (kill.Elite) then |
||
107 | killLevel = killLevel .. "+"; |
||
108 | end |
||
109 | end |
||
110 | |||
111 | if (kill.Drops ~= nil) then |
||
112 | |||
113 | local dropsByQuality = {}; |
||
114 | |||
115 | local items = LT_GetItems(); |
||
116 | local totalValue = 0; |
||
117 | |||
118 | -- Calculate the number of drops by quality type |
||
119 | foreach(kill.Drops, function(k,v) |
||
120 | local item = items[k]; |
||
121 | local quality = item.Quality; |
||
122 | |||
123 | if (dropsByQuality[quality] == nil) then |
||
124 | dropsByQuality[quality] = 0; |
||
125 | end |
||
126 | |||
127 | dropsByQuality[quality] = dropsByQuality[quality] + v; |
||
128 | if (item.Value ~= nil) then |
||
129 | totalValue = totalValue + (item.Value * v); |
||
130 | end |
||
131 | end); |
||
132 | |||
133 | for quality = LT_MaxQuality, LT_MinQuality, -1 do |
||
134 | local dropsOfQuality = dropsByQuality[quality]; |
||
135 | if (dropsOfQuality ~= nil) then |
||
136 | local color = LT_QualityColors[tostring(quality)]; |
||
137 | killDrops = LT_StrAppend(killDrops, LT_ColorText(dropsOfQuality, color), ","); |
||
138 | end |
||
139 | end |
||
140 | |||
141 | if (totalValue > 0) then |
||
142 | local averageValue = totalValue / killCount; |
||
143 | local averageValueString = string.format("%.1d", averageValue); |
||
144 | killValue = string.format(" (%s)", LT_GetValueString(averageValueString, true)); |
||
145 | end |
||
146 | end |
||
147 | |||
148 | if (killDrops == nil) then |
||
149 | killDrops = ""; |
||
150 | end |
||
151 | |||
152 | |||
153 | -- Format: |
||
154 | -- Name, level Level (Number)(Value): Drops |
||
155 | |||
156 | return string.format("%s%s (%d)%s %s", killName, killLevel, killCount, killValue, killDrops); |
||
157 | |||
158 | end |
||
159 | |||
160 | |||
161 | ------------------------------------------------------------------------------ |
||
162 | -- GetPlayerSummary |
||
163 | -- Get a string representation of a player. |
||
164 | ------------------------------------------------------------------------------ |
||
165 | |||
166 | function LT_GetPlayerSummary(player, playerCountString) |
||
167 | |||
168 | local playerName = LT_ColorText(player.Name, LT_White); |
||
169 | |||
170 | -- Level |
||
171 | local level = "??"; |
||
172 | if (player.Level ~= nil) then |
||
173 | level = player.Level; |
||
174 | end |
||
175 | |||
176 | -- Class |
||
177 | local class = "Unknown"; |
||
178 | if (player.Class ~= nil) then |
||
179 | class = player.Class; |
||
180 | end |
||
181 | |||
182 | local text = (playerName .. ", level " .. level .. " " .. class); |
||
183 | |||
184 | -- Deaths |
||
185 | if (player.TimesKilled ~= nil) then |
||
186 | local deathCount = getn(player.TimesKilled); |
||
187 | |||
188 | text = text .. " (" .. deathCount .. " deaths)"; |
||
189 | end |
||
190 | |||
191 | -- Loot |
||
192 | if (playerCountString ~= nil) then |
||
193 | text = text .. ": " .. playerCountString; |
||
194 | end |
||
195 | |||
196 | -- Format: |
||
197 | -- Name, level Level Class, (NumberOfDeaths deaths): loot |
||
198 | |||
199 | return text; |
||
200 | |||
201 | end |
||
202 | |||
203 | |||
204 | ------------------------------------------------------------------------------ |
||
205 | -- OutputSummary |
||
206 | -- Outputs a summary of an object or set of objects to the console. |
||
207 | ------------------------------------------------------------------------------ |
||
208 | |||
209 | function LT_OutputSummary(argument, output) |
||
210 | |||
211 | local items = LT_GetItems(); |
||
212 | local kills = LT_GetKills(); |
||
213 | local players = LT_GetPlayers(); |
||
214 | |||
215 | if (output == nil) then |
||
216 | LT_DebugMessage(2, "Redirecting to standard output in LT_OutputSummary"); |
||
217 | output = LT_StdOut; |
||
218 | end |
||
219 | |||
220 | if (argument == LT_QUERY_ITEMS) then |
||
221 | LT_OutputItemsSummary(output); |
||
222 | |||
223 | elseif (argument == LT_QUERY_KILLS) then |
||
224 | LT_OutputKillsSummary(output); |
||
225 | |||
226 | elseif (argument == LT_QUERY_PLAYERS) then |
||
227 | LT_OutputPlayersSummary(output); |
||
228 | |||
229 | elseif (argument == LT_QUERY_LOOT) then |
||
230 | local pendingLoot = LT_GetPendingLoot(); |
||
231 | foreach(pendingLoot, function(k,v) |
||
232 | LT_FormatMessageKeyValue(k, v, output); |
||
233 | end); |
||
234 | |||
235 | elseif (argument == LT_QUERY_TARGETS) then |
||
236 | local pendingTargets = LT_GetPendingTargets(); |
||
237 | foreach(pendingTargets, function(k,v) |
||
238 | LT_FormatMessageKeyValue(k, v, output); |
||
239 | end); |
||
240 | |||
241 | elseif ((argument == nil) or (argument == "")) then |
||
242 | output.Write("Items: {"); |
||
243 | output.Indent(); |
||
244 | LT_OutputItemsSummary(output); |
||
245 | output.Unindent(); |
||
246 | output.Write("}"); |
||
247 | |||
248 | output.Write("Kills: {"); |
||
249 | output.Indent(); |
||
250 | LT_OutputKillsSummary(output); |
||
251 | output.Unindent(); |
||
252 | output.Write("}"); |
||
253 | |||
254 | output.Write("Players: {"); |
||
255 | output.Indent(); |
||
256 | LT_OutputPlayersSummary(output); |
||
257 | output.Unindent(); |
||
258 | output.Write("}"); |
||
259 | |||
260 | else |
||
261 | if (LT_TableHasKey(items, argument)) then |
||
262 | foreach(items[argument], function(k,v) |
||
263 | LT_FormatMessageKeyValue(k, v, output); |
||
264 | end); |
||
265 | |||
266 | elseif (LT_TableHasKey(kills, argument)) then |
||
267 | foreach(kills[argument], function(k,v) |
||
268 | LT_FormatMessageKeyValue(k, v, output); |
||
269 | end); |
||
270 | |||
271 | elseif (LT_TableHasKey(players, argument)) then |
||
272 | foreach(players[argument], function(k,v) |
||
273 | LT_FormatMessageKeyValue(k, v, output); |
||
274 | end); |
||
275 | |||
276 | else |
||
277 | output.Write(string.format(LT_QUERY_ERROR, argument)); |
||
278 | end |
||
279 | end |
||
280 | |||
281 | end |
||
282 | |||
283 | |||
284 | ------------------------------------------------------------------------------ |
||
285 | -- GetToolbarSummary |
||
286 | -- Get the label to display on the toolbar. |
||
287 | ------------------------------------------------------------------------------ |
||
288 | |||
289 | function LT_GetToolbarSummary() |
||
290 | |||
291 | local settings = LT_GetSettings(); |
||
292 | |||
293 | local text = nil; |
||
294 | |||
295 | if (settings.TooltipShowItems) then |
||
296 | -- Get item counts (excluding Money (-1)) |
||
297 | local totalCountString = LT_GetTotalItemCountString(0); |
||
298 | -- Default to 0 |
||
299 | if (totalCountString == nil) then |
||
300 | totalCountString = "0"; |
||
301 | end |
||
302 | |||
303 | local itemText = string.format(LT_TOOLBAR_ITEMS, totalCountString); |
||
304 | |||
305 | if (text == nil) then |
||
306 | text = itemText; |
||
307 | else |
||
308 | text = string.format(LT_TOOLBAR_DIVIDER, text, itemText); |
||
309 | end |
||
310 | end |
||
311 | |||
312 | if (settings.TooltipShowKills) then |
||
313 | -- Total number of kills |
||
314 | local killCount = LT_GetTotalKillCount(kills); |
||
315 | local killText = string.format(LT_TOOLBAR_KILLS, killCount); |
||
316 | |||
317 | if (text == nil) then |
||
318 | text = killText; |
||
319 | else |
||
320 | text = string.format(LT_TOOLBAR_DIVIDER, text, killText); |
||
321 | end |
||
322 | end |
||
323 | |||
324 | if (settings.TooltipShowPlayers) then |
||
325 | -- Total number of players |
||
326 | local players = LT_GetPlayers(); |
||
327 | local playerCount = LT_GetCount(players); |
||
328 | local playerText = string.format(LT_TOOLBAR_PLAYERS, playerCount); |
||
329 | |||
330 | if (text == nil) then |
||
331 | text = playerText; |
||
332 | else |
||
333 | text = string.format(LT_TOOLBAR_DIVIDER, text, playerText); |
||
334 | end |
||
335 | end |
||
336 | |||
337 | |||
338 | -- Format: |
||
339 | -- Items: 26,13,4 | Kills: 51 | Players: 4 |
||
340 | |||
341 | return text; |
||
342 | |||
343 | end |
||
344 | |||
345 | |||
346 | ------------------------------------------------------------------------------ |
||
347 | -- GetTotalItemCountString |
||
348 | -- Put together a string of the count of items looted by quality type. |
||
349 | ------------------------------------------------------------------------------ |
||
350 | |||
351 | function LT_GetTotalItemCountString(qualityThreshold) |
||
352 | |||
353 | local itemsByQuality = LT_GetItemsByQuality(); |
||
354 | local settings = LT_GetSettings(); |
||
355 | |||
356 | if (qualityThreshold == nil) then |
||
357 | qualityThreshold = settings.QualityThreshold; |
||
358 | end |
||
359 | |||
360 | local totalCountString = nil; |
||
361 | local playerCountString = {}; |
||
362 | |||
363 | -- The results come back unsorted. We need to walk through in a specific order |
||
364 | for quality = LT_MaxQuality, LT_MinQuality, -1 do |
||
365 | itemsInBucket = itemsByQuality[quality]; |
||
366 | |||
367 | -- Only process this quality bucket if it meets our threshold |
||
368 | if ((itemsInBucket ~= nil) and (quality >= qualityThreshold)) then |
||
369 | |||
370 | local color = LT_QualityColors[tostring(quality)]; |
||
371 | |||
372 | -- Calculate the total item count, including redundant loots |
||
373 | local itemCount = 0; |
||
374 | local playerCount = {}; |
||
375 | foreach (itemsInBucket, function(k,item) |
||
376 | itemCount = itemCount + getn(item.TimesLooted); |
||
377 | |||
378 | if (item.Recipients ~= nil) then |
||
379 | -- Also keep track of counts by player |
||
380 | foreach(item.Recipients, function(k,v) |
||
381 | if (playerCount[k] == nil) then |
||
382 | playerCount[k] = 0; |
||
383 | end |
||
384 | |||
385 | playerCount[k] = playerCount[k] + v; |
||
386 | end); |
||
387 | end |
||
388 | end); |
||
389 | |||
390 | -- Color the count and add it to the item string. |
||
391 | local countString = LT_ColorText(itemCount, color); |
||
392 | totalCountString = LT_StrAppend(totalCountString, countString, ","); |
||
393 | |||
394 | -- Process all the player count strings. |
||
395 | foreach(playerCount, function(playerName,count) |
||
396 | local countString = LT_ColorText(count, color); |
||
397 | playerCountString[playerName] = LT_StrAppend(playerCountString[playerName], countString, ","); |
||
398 | end); |
||
399 | |||
400 | end |
||
401 | end |
||
402 | |||
403 | return totalCountString, playerCountString; |
||
404 | end |
||
405 | |||
406 | |||
407 | ------------------------------------------------------------------------------ |
||
408 | -- GetTotalKillCount |
||
409 | -- Get the deep number of kills. |
||
410 | ------------------------------------------------------------------------------ |
||
411 | |||
412 | function LT_GetTotalKillCount() |
||
413 | |||
414 | local kills = LT_GetKills(); |
||
415 | |||
416 | local count = 0; |
||
417 | |||
418 | foreach (kills, function(k,v) |
||
419 | |||
420 | count = count + getn(v.TimesKilled); |
||
421 | |||
422 | end); |
||
423 | |||
424 | return count; |
||
425 | |||
426 | end |
||
427 | |||
428 | |||
429 | ------------------------------------------------------------------------------ |
||
430 | -- GetTooltipSummary |
||
431 | -- Get the text to display in the tooltip. |
||
432 | ------------------------------------------------------------------------------ |
||
433 | |||
434 | function LT_GetTooltipSummary() |
||
435 | |||
436 | -- Use the tooltip mode to decide what to output. |
||
437 | |||
438 | local settings = LT_GetSettings(); |
||
439 | local mode = settings.TooltipMode; |
||
440 | |||
441 | if (mode == 1) then |
||
442 | return LT_GetItemsTooltipSummary(); |
||
443 | elseif (mode == 2) then |
||
444 | return LT_GetKillsTooltipSummary(); |
||
445 | elseif (mode == 3) then |
||
446 | return LT_GetPlayersTooltipSummary(); |
||
447 | end |
||
448 | |||
449 | -- Error: Should never happen |
||
450 | return "Unknown tooltip mode"; |
||
451 | |||
452 | end |
||
453 | |||
454 | |||
455 | ------------------------------------------------------------------------------ |
||
456 | -- NextTooltipMode |
||
457 | -- Change the tooltip mode. |
||
458 | ------------------------------------------------------------------------------ |
||
459 | |||
460 | function LT_NextTooltipMode() |
||
461 | |||
462 | local settings = LT_GetSettings(); |
||
463 | |||
464 | local mode = settings.TooltipMode + 1; |
||
465 | |||
466 | if (mode > LT_MaxTooltipMode) then |
||
467 | mode = LT_MinTooltipMode; |
||
468 | end |
||
469 | |||
470 | settings.TooltipMode = mode; |
||
471 | LT_FireChange(); |
||
472 | |||
473 | end |
||
474 | |||
475 | |||
476 | ------------------------------------------------------------------------------ |
||
477 | -- GetKillsTooltipSummary |
||
478 | -- Get the text to display in the tooltip. |
||
479 | ------------------------------------------------------------------------------ |
||
480 | |||
481 | function LT_GetKillsTooltipSummary() |
||
482 | |||
483 | local text = ""; |
||
484 | |||
485 | local killTextList = LT_GetSortedKillSummary(); |
||
486 | foreach(killTextList, function(k,killText) |
||
487 | text = text .. killText .. "\n" |
||
488 | end); |
||
489 | |||
490 | return text; |
||
491 | |||
492 | end |
||
493 | |||
494 | |||
495 | ------------------------------------------------------------------------------ |
||
496 | -- GetPlayersTooltipSummary |
||
497 | -- Get the text to display in the tooltip. |
||
498 | ------------------------------------------------------------------------------ |
||
499 | |||
500 | function LT_GetPlayersTooltipSummary() |
||
501 | |||
502 | local text = ""; |
||
503 | |||
504 | local playerTextList = LT_GetSortedPlayerSummary(); |
||
505 | foreach(playerTextList, function(k,playerText) |
||
506 | text = text .. playerText .. "\n" |
||
507 | end); |
||
508 | |||
509 | return text; |
||
510 | |||
511 | end |
||
512 | |||
513 | |||
514 | ------------------------------------------------------------------------------ |
||
515 | -- GetItemsTooltipSummary |
||
516 | -- Get the text to display in the tooltip. |
||
517 | ------------------------------------------------------------------------------ |
||
518 | |||
519 | function LT_GetItemsTooltipSummary() |
||
520 | |||
521 | local settings = LT_GetSettings(); |
||
522 | |||
523 | -- Put together a list of the items looted sorted by quality. |
||
524 | local itemsByQuality = LT_GetItemsByQuality(); |
||
525 | |||
526 | local totalValue = 0; |
||
527 | local playerValue = 0; |
||
528 | local textByQuality = {}; |
||
529 | local qualityHeadingInfo = {}; |
||
530 | local currentPlayer = UnitName("player") |
||
531 | |||
532 | -- The results come back unsorted. We need to walk through in a specific order |
||
533 | for quality = LT_MaxQuality, LT_MinQuality, -1 do |
||
534 | |||
535 | itemsInBucket = itemsByQuality[quality]; |
||
536 | |||
537 | if (itemsInBucket ~= nil) then |
||
538 | local qualityName = LT_QUALITY_NAME[tostring(quality)]; |
||
539 | |||
540 | local qualityColor = LT_QualityColors[tostring(quality)]; |
||
541 | |||
542 | local contentText = ""; |
||
543 | local valueInGroup = 0; |
||
544 | local countInGroup = 0; |
||
545 | |||
546 | local itemTextList = {}; |
||
547 | |||
548 | -- Get info from each item |
||
549 | foreach(itemsInBucket, function(k, item) |
||
550 | |||
551 | local itemText, itemCount, itemTotalValue, itemPlayerValue = LT_GetItemSummary(item, settings.QualityThreshold, currentPlayer, qualityColor); |
||
552 | |||
553 | countInGroup = countInGroup + itemCount; |
||
554 | valueInGroup = valueInGroup + itemTotalValue; |
||
555 | playerValue = playerValue + itemPlayerValue; |
||
556 | |||
557 | -- Add the item into the sorted array |
||
558 | if (itemText ~= nil) then |
||
559 | LT_InsertSorted(itemTextList, itemText, LT_StrCmp); |
||
560 | end |
||
561 | |||
562 | end); |
||
563 | |||
564 | -- Append the sorted results |
||
565 | foreach(itemTextList, function(k,itemText) |
||
566 | contentText = contentText .. itemText .. "\n" |
||
567 | end); |
||
568 | |||
569 | -- Group label |
||
570 | if (countInGroup > 0) then |
||
571 | totalValue = totalValue + valueInGroup; |
||
572 | |||
573 | local headingInfo = {}; |
||
574 | headingInfo.Name=qualityName; |
||
575 | headingInfo.Color=qualityColor; |
||
576 | headingInfo.Count=countInGroup; |
||
577 | headingInfo.Value=valueInGroup; |
||
578 | |||
579 | qualityHeadingInfo[quality] = headingInfo; |
||
580 | |||
581 | end |
||
582 | |||
583 | textByQuality[quality] = contentText; |
||
584 | end |
||
585 | end |
||
586 | |||
587 | -- Start the output text string |
||
588 | local text = ""; |
||
589 | |||
590 | -- Add a group total value label |
||
591 | if (totalValue > 0) then |
||
592 | local valueString = LT_GetValueString(totalValue, true); |
||
593 | |||
594 | -- Add a player total value label |
||
595 | if (playerValue ~= totalValue) then |
||
596 | local playerValueString = LT_GetValueString(playerValue, true); |
||
597 | if (playerValueString == "") then |
||
598 | playerValueString = 0; |
||
599 | end |
||
600 | |||
601 | text = text .. string.format(LT_TOOLTIP_VALUE2, valueString, playerValueString); |
||
602 | else |
||
603 | text = text .. string.format(LT_TOOLTIP_VALUE, valueString); |
||
604 | end |
||
605 | |||
606 | text = text .. "\n"; |
||
607 | end |
||
608 | |||
609 | local qualityHeadingsString = nil; |
||
610 | |||
611 | -- Quality headings |
||
612 | for quality = LT_MaxQuality, LT_MinQuality, -1 do |
||
613 | local headingInfo = qualityHeadingInfo[quality]; |
||
614 | if (headingInfo ~= nil) then |
||
615 | |||
616 | -- Get a colored string of the value sum in this rarity group |
||
617 | if (headingInfo.Value > 0) then |
||
618 | local percent = (headingInfo.Value / totalValue) * 100; |
||
619 | local percentString = string.format("%d%%", percent); |
||
620 | local headingString = string.format("%s (%s)", LT_ColorText(percentString, headingInfo.Color), LT_GetValueString(headingInfo.Value, true)); |
||
621 | |||
622 | -- Format: |
||
623 | -- Percent Name (TotalValue) |
||
624 | |||
625 | qualityHeadingsString = LT_StrAppend(qualityHeadingsString, headingString, ", "); |
||
626 | end |
||
627 | |||
628 | end |
||
629 | end |
||
630 | |||
631 | if (qualityHeadingsString ~= nil) then |
||
632 | text = text .. string.format(LT_TOOLTIP_BREAKDOWN, qualityHeadingsString) .. "\n"; |
||
633 | end |
||
634 | |||
635 | -- Append the full info, sorted by quality group |
||
636 | for quality = LT_MaxQuality, LT_MinQuality, -1 do |
||
637 | if (textByQuality[quality] ~= nil) then |
||
638 | text = text .. textByQuality[quality]; |
||
639 | end |
||
640 | end |
||
641 | |||
642 | return text; |
||
643 | |||
644 | end |
||
645 | |||
646 | |||
647 | ------------------------------------------------------------------------------ |
||
648 | -- GetRecipientsString |
||
649 | -- Get a string representation of the recipients of an item. |
||
650 | ------------------------------------------------------------------------------ |
||
651 | |||
652 | function LT_GetRecipientsString(item, default, separator) |
||
653 | |||
654 | local recipients = default; |
||
655 | |||
656 | if (item.Recipients ~= nil) then |
||
657 | |||
658 | -- Walk the recipients list, building up a recipient string |
||
659 | recipients = nil; |
||
660 | foreach(item.Recipients, function(recipientName, recipientCount) |
||
661 | |||
662 | -- Format: Name (CountReceived) |
||
663 | local recipient = recipientName .. " (" .. recipientCount .. ")"; |
||
664 | |||
665 | -- Append this entry to the list |
||
666 | if (recipients ~= nil) then |
||
667 | recipients = recipients .. separator .. recipient; |
||
668 | else |
||
669 | recipients = recipient; |
||
670 | end |
||
671 | |||
672 | end); |
||
673 | |||
674 | end |
||
675 | |||
676 | return recipients; |
||
677 | end |
||
678 | |||
679 | |||
680 | ------------------------------------------------------------------------------ |
||
681 | -- GetSortedItemSummary |
||
682 | -- Gets a sorted list of outputs GetItemSummary |
||
683 | ------------------------------------------------------------------------------ |
||
684 | |||
685 | function LT_GetSortedItemSummary() |
||
686 | |||
687 | local items = LT_GetItems(); |
||
688 | |||
689 | -- Get the item summaries and put them into a sorted list |
||
690 | local itemSummaries = {}; |
||
691 | foreach(items, function(k,v) |
||
692 | local summary = LT_GetItemSummary(v); |
||
693 | LT_InsertSorted(itemSummaries, summary, LT_StrCmp); |
||
694 | end); |
||
695 | |||
696 | return itemSummaries; |
||
697 | |||
698 | end |
||
699 | |||
700 | |||
701 | ------------------------------------------------------------------------------ |
||
702 | -- GetSortedKillSummary |
||
703 | -- Gets a sorted list of outputs GetKillSummary |
||
704 | ------------------------------------------------------------------------------ |
||
705 | |||
706 | function LT_GetSortedKillSummary() |
||
707 | |||
708 | local kills = LT_GetKills(); |
||
709 | |||
710 | -- Walk through the kills and get info on each one |
||
711 | local killTextList = {}; |
||
712 | foreach(kills, function(k,v) |
||
713 | LT_InsertSorted(killTextList, LT_GetKillSummary(v), LT_StrCmp); |
||
714 | end); |
||
715 | |||
716 | return killTextList; |
||
717 | |||
718 | end |
||
719 | |||
720 | |||
721 | ------------------------------------------------------------------------------ |
||
722 | -- GetSortedPlayerSummary |
||
723 | -- Gets a sorted list of outputs GetPlayerSummary |
||
724 | ------------------------------------------------------------------------------ |
||
725 | |||
726 | function LT_GetSortedPlayerSummary() |
||
727 | |||
728 | local players = LT_GetPlayers(); |
||
729 | local totalCountString, playerCountString = LT_GetTotalItemCountString(); |
||
730 | |||
731 | -- Walk through the kills and get info on each one |
||
732 | local playerTextList = {}; |
||
733 | foreach(players, function(k,v) |
||
734 | LT_InsertSorted(playerTextList, LT_GetPlayerSummary(v, playerCountString[k]), LT_StrCmp); |
||
735 | end); |
||
736 | |||
737 | return playerTextList; |
||
738 | |||
739 | end |
||
740 | |||
741 | |||
742 | ------------------------------------------------------------------------------ |
||
743 | -- OutputItemsSummary |
||
744 | -- Output a summary of all items to the console. |
||
745 | ------------------------------------------------------------------------------ |
||
746 | |||
747 | function LT_OutputItemsSummary(output) |
||
748 | |||
749 | if (output == nil) then |
||
750 | LT_DebugMessage(2, "Redirecting to standard output in LT_OutputItemsSummary"); |
||
751 | output = LT_StdOut; |
||
752 | end |
||
753 | |||
754 | -- Get the item summaries and put them into a sorted list |
||
755 | local itemTextList = LT_GetSortedItemSummary(); |
||
756 | foreach(itemTextList, function(k,v) |
||
757 | output.Write(v); |
||
758 | end); |
||
759 | |||
760 | end |
||
761 | |||
762 | |||
763 | ------------------------------------------------------------------------------ |
||
764 | -- OutputKillsSummary |
||
765 | -- Output a summary of all kills to the console. |
||
766 | ------------------------------------------------------------------------------ |
||
767 | |||
768 | function LT_OutputKillsSummary(output) |
||
769 | |||
770 | if (output == nil) then |
||
771 | LT_DebugMessage(2, "Redirecting to standard output in LT_OutputKillsSummary"); |
||
772 | output = LT_StdOut; |
||
773 | end |
||
774 | |||
775 | local killTextList = LT_GetSortedKillSummary(); |
||
776 | foreach(killTextList, function(k,v) |
||
777 | output.Write(v); |
||
778 | end); |
||
779 | |||
780 | end |
||
781 | |||
782 | |||
783 | ------------------------------------------------------------------------------ |
||
784 | -- OutputPlayersSummary |
||
785 | -- Output a summary of all players to the console. |
||
786 | ------------------------------------------------------------------------------ |
||
787 | |||
788 | function LT_OutputPlayersSummary(output) |
||
789 | |||
790 | if (output == nil) then |
||
791 | LT_DebugMessage(2, "Redirecting to standard output in LT_OutputKillsSummary"); |
||
792 | output = LT_StdOut; |
||
793 | end |
||
794 | |||
795 | local playerTextList = LT_GetSortedPlayerSummary(); |
||
796 | foreach(playerTextList, function(k,v) |
||
797 | output.Write(v); |
||
798 | end); |
||
799 | |||
800 | end |
||
801 |