Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Creating a chat proxy and setting long and short addon tag names
- -- Each print will be prefixed by the addon tag, depending on user settings the long, short or neither tag will be used
- local chat = LibChatMessage("Undaunted Shoulder Collector", "USC")
- UndauntedShoulderCollector = {
- dashedLines = "------------------------------------------------",
- mysteryCofferMaj = "Maj's Mystery Coffer",
- mysteryCofferGlirion = "Glirion's Mystery Coffer",
- mysteryCofferUrgarlag = "Urgarlag's Mystery Coffer",
- }
- UndauntedShoulderCollector.name = "UndauntedShoulderCollector"
- -- Accepts a number
- -- Returns imported number truncated to 2 decimal places
- function UndauntedShoulderCollector.RoundToDecimalPoints(num, decPoints)
- return tonumber(string.format("%." .. (decPoints) .. "f", num))
- end
- -- Accepts set ID of an item
- -- Generates a string that ESO interprats as a link for an item
- function UndauntedShoulderCollector.MakeItemLink(id)
- local itemLink = string.format("|H1:item:%d:364:50:0:0:0:0:0:0:0:0:0:0:0:0:ITEMSTYLE_NONE:0:0:0:10000:0|h|h", id)
- return(itemLink)
- end
- -- Accepts a coffer name, amount of shoulders in that coffer and the amount of shoulders collected from that coffer
- -- Returns a string that will display the box name, amount of shoulders from that coffer collected as a fraction and the chance of unlocking a new piece from that coffer
- function UndauntedShoulderCollector.printBoxData(boxName, totalBoxShoulders, collectedBoxShoulders)
- if totalBoxShoulders == collectedBoxShoulders then
- return (boxName .. " (" .. collectedBoxShoulders .. "/" .. totalBoxShoulders ..") - " .. "COMPLETED")
- end
- return (
- boxName .. " (" .. collectedBoxShoulders .. "/" .. totalBoxShoulders .. ") - " ..
- UndauntedShoulderCollector.RoundToDecimalPoints(100 - collectedBoxShoulders / totalBoxShoulders * 100, 2) .. "% chance for new"
- )
- end
- -- Accepts a mystery coffer name, amount of shoulders in that coffer and the amount of shoulders collected from that coffer
- -- If I've got X chance of unlocking a new piece from a mystery coffer, then i have 1 - (1-X)^5 chance of unlocking a new piece from 5 mystery coffers - Kyzeragon
- -- Returns a string that will display the box name and the chance of getting at least 1 shoulder piece from spending 5 keys on that coffer
- function UndauntedShoulderCollector.printMysteryBox5KeyData(boxName, totalBoxShoulders, collectedBoxShoulders)
- if totalBoxShoulders == collectedBoxShoulders then
- return (boxName .. " - " .. "COMPLETED")
- end
- chanceOfOldShoulder1Key = UndauntedShoulderCollector.RoundToDecimalPoints(collectedBoxShoulders / totalBoxShoulders, 4)
- chanceofNewShoulder5Key = UndauntedShoulderCollector.RoundToDecimalPoints(100 - (chanceOfOldShoulder1Key ^ 5 * 100), 2)
- return (boxName .. " - " .. chanceofNewShoulder5Key .. "%" .. " chance for at least one new from 5 keys")
- end
- -- Accepts a subtable of a pledge giver and prints links for all the tables items and states if each piece is collected
- -- Used only in early testing, probably should delete
- function UndauntedShoulderCollector.PrintLinksOfTable(inTable)
- d(inTable[7])
- for i = 1, #inTable - 1 do
- itemLink = UndauntedShoulderCollector.MakeItemLink(inTable[i])
- d(itemLink)
- d(IsItemSetCollectionPieceUnlocked(GetItemLinkItemId(itemLink)))
- end
- end
- -- Accepts a subtable from data file of one of the pledge givers
- -- Returns the amount of shoulders that are collected and name of dungeon group from table
- function UndauntedShoulderCollector.AmountOfShouldersInTableCollected(inTable)
- amountCollected = 0
- dungeonGroup = inTable[7]
- for i = 1, #inTable - 1 do
- itemLink = UndauntedShoulderCollector.MakeItemLink(inTable[i])
- if (IsItemSetCollectionPieceUnlocked(GetItemLinkItemId(itemLink)))
- then
- amountCollected = amountCollected + 1
- end
- end
- return amountCollected, dungeonGroup
- end
- -- Accepts a group of tables (Maj/Glirion/Urgarlag) and name of pledge givers mystery coffer
- -- Displays the amount of pieces collected from each coffer the pledge giver offers as well as the chance of getting a new piece from each coffer
- -- Returns nothing
- function UndauntedShoulderCollector.ShowAllPledgeGiver(inTable, inMysteryCofferName)
- totalShoulders = 0
- collectedShoulders = 0
- boxDataOutputStrings = {}
- for k,v in pairs(inTable) do
- amountCollected, dungeonGroup = UndauntedShoulderCollector.AmountOfShouldersInTableCollected(inTable[k])
- table.insert(boxDataOutputStrings, UndauntedShoulderCollector.printBoxData(dungeonGroup, 6, amountCollected))
- totalShoulders = totalShoulders + 6
- collectedShoulders = collectedShoulders + amountCollected
- end
- chat:Print(
- UndauntedShoulderCollector.dashedLines ..
- "\n" .. table.concat(boxDataOutputStrings, "\n") ..
- "\n" .. UndauntedShoulderCollector.printBoxData(inMysteryCofferName, totalShoulders, collectedShoulders) ..
- "\n" .. UndauntedShoulderCollector.printMysteryBox5KeyData(inMysteryCofferName, totalShoulders, collectedShoulders)
- )
- end
- -- Accepts a group of tables (Maj/Glirion/Urgarlag)
- -- Calculates the shoulder box with the highest chance of producing an uncollected shoulder per key
- -- Returns name of most effficient box, the amount collected of the most efficient box, overall shoulders in table and overall collected shoulders in table
- function UndauntedShoulderCollector.MostEfficientBoxSetPerKey(inTable)
- -- Values to store data for 1 key boxes
- totalShouldersAmount = 0
- totalCollectedShouldersAmount = 0
- mostEfficientBox = ""
- mostEfficientAmount = 100 -- Any value > 6 should do
- for k,v in pairs(inTable) do
- tempAmount, tempName = UndauntedShoulderCollector.AmountOfShouldersInTableCollected(inTable[k])
- totalShouldersAmount = totalShouldersAmount + 6
- totalCollectedShouldersAmount = totalCollectedShouldersAmount + tempAmount
- if (tempAmount < mostEfficientAmount) then
- mostEfficientAmount = tempAmount
- mostEfficientBox = tempName
- end
- end
- return mostEfficientBox, mostEfficientAmount, totalShouldersAmount, totalCollectedShouldersAmount
- end
- -- Accepts nothing
- -- Prints the most efficient 1 key and 5 key purchase to chat
- -- Returns nothing
- function UndauntedShoulderCollector.CalculateMostEfficientKeyPurchases()
- mostEfficientBox, mostEfficientAmount, shouldersAmount, collectedShouldersAmount
- = UndauntedShoulderCollector.MostEfficientBoxSetPerKey(UndauntedShoulderCollectorData.Maj)
- mostEfficientMysteryBox = "Maj's Mystery Coffer"
- tempMostEfficientBox, tempMostEfficientAmount, tempShouldersAmount, tempCollectedShouldersAmount
- = UndauntedShoulderCollector.MostEfficientBoxSetPerKey(UndauntedShoulderCollectorData.Glirion)
- if (tempMostEfficientAmount < mostEfficientAmount) then
- mostEfficientAmount = tempMostEfficientAmount
- mostEfficientBox = tempMostEfficientBox
- end
- if (tempCollectedShouldersAmount / tempShouldersAmount < collectedShouldersAmount / shouldersAmount) then
- collectedShouldersAmount = tempCollectedShouldersAmount
- shouldersAmount = tempShouldersAmount
- mostEfficientMysteryBox = "Glirion's Mystery Coffer"
- end
- tempMostEfficientBox, tempMostEfficientAmount, tempShouldersAmount, tempCollectedShouldersAmount
- = UndauntedShoulderCollector.MostEfficientBoxSetPerKey(UndauntedShoulderCollectorData.Urgarlag)
- if (tempMostEfficientAmount < mostEfficientAmount) then
- mostEfficientAmount = tempMostEfficientAmount
- mostEfficientBox = tempMostEfficientBox
- end
- if (tempCollectedShouldersAmount / tempShouldersAmount < collectedShouldersAmount / shouldersAmount) then
- collectedShouldersAmount = tempCollectedShouldersAmount
- shouldersAmount = tempShouldersAmount
- mostEfficientMysteryBox = "Urgarlag's Mystery Coffer"
- end
- chat:Print(
- UndauntedShoulderCollector.dashedLines ..
- "\n" .. "Best 5 key deal: " .. UndauntedShoulderCollector.printBoxData(mostEfficientBox, 6, mostEfficientAmount) ..
- "\n" .. "Best 1 key deal: " .. UndauntedShoulderCollector.printBoxData(mostEfficientMysteryBox, shouldersAmount, collectedShouldersAmount) ..
- "\n" .. UndauntedShoulderCollector.printMysteryBox5KeyData(mostEfficientMysteryBox, shouldersAmount, collectedShouldersAmount)
- )
- end
- -- Accepts nothing
- -- Displays amount of pieces collected from all 1 key mystery coffers, in fraction and percentage formats
- -- Returns nothing
- function UndauntedShoulderCollector.ShowAllMysteryCoffers()
- _, _, majMaxShouldersAmount, majCollectedShouldersAmount
- = UndauntedShoulderCollector.MostEfficientBoxSetPerKey(UndauntedShoulderCollectorData.Maj)
- _, _, glirionMaxShouldersAmount, glirionCollectedShouldersAmount
- = UndauntedShoulderCollector.MostEfficientBoxSetPerKey(UndauntedShoulderCollectorData.Glirion)
- _, _, urgarlagMaxShouldersAmount, urgarlagCollectedShouldersAmount
- = UndauntedShoulderCollector.MostEfficientBoxSetPerKey(UndauntedShoulderCollectorData.Urgarlag)
- majOutput1 = UndauntedShoulderCollector.printBoxData(UndauntedShoulderCollector.mysteryCofferMaj, majMaxShouldersAmount, majCollectedShouldersAmount)
- glirionOutput1 = UndauntedShoulderCollector.printBoxData(UndauntedShoulderCollector.mysteryCofferGlirion, glirionMaxShouldersAmount, glirionCollectedShouldersAmount)
- urgarlagOutput1 = UndauntedShoulderCollector.printBoxData(UndauntedShoulderCollector.mysteryCofferUrgarlag, urgarlagMaxShouldersAmount, urgarlagCollectedShouldersAmount)
- majOutput2 = UndauntedShoulderCollector.printMysteryBox5KeyData(UndauntedShoulderCollector.mysteryCofferMaj, majMaxShouldersAmount, majCollectedShouldersAmount)
- glirionOutput2 = UndauntedShoulderCollector.printMysteryBox5KeyData(UndauntedShoulderCollector.mysteryCofferGlirion, glirionMaxShouldersAmount, glirionCollectedShouldersAmount)
- urgarlagOutput2 = UndauntedShoulderCollector.printMysteryBox5KeyData(UndauntedShoulderCollector.mysteryCofferUrgarlag, urgarlagMaxShouldersAmount, urgarlagCollectedShouldersAmount)
- chat:Print(
- UndauntedShoulderCollector.dashedLines ..
- "\n" .. majOutput1 ..
- "\n" .. majOutput2 ..
- "\n" .. glirionOutput1 ..
- "\n" .. glirionOutput2 ..
- "\n" .. urgarlagOutput1 ..
- "\n" .. urgarlagOutput2
- )
- end
- -- Accepts nothing
- -- Prints all commands along with a description of each command
- -- Returns nothing
- function UndauntedShoulderCollector.PrintHelpMessages()
- chat:Print(
- UndauntedShoulderCollector.dashedLines ..
- "\n" .. "List of commands available in Undaunted Shoulder Collector" ..
- "\n" .. "/usc : Displays most efficient 5 key and 1 key purchases along with the chance of unlocking a new set piece from each of those boxes" ..
- "\n" .. "/uscmystery : Displays collected amounts for each mystery coffer and the chance of unlocking a new piece from each one" ..
- "\n" .. "/uscmaj : Displays collected amounts for each coffer available from Maj and the chance of unlocking a new piece from each one" ..
- "\n" .. "/uscglirion : Displays collected amounts for each coffer available from Glirion and the chance of unlocking a new piece from each one" ..
- "\n" .. "/uscurgarlag : Displays collected amounts for each coffer available from Urgarlag and the chance of unlocking a new piece from each one" ..
- "\n" .. "/uschelp : Displays help message to chatbox listing available commands"
- )
- end
- SLASH_COMMANDS["/usc"] = function() UndauntedShoulderCollector.CalculateMostEfficientKeyPurchases() end
- SLASH_COMMANDS["/uscmystery"] = function() UndauntedShoulderCollector.ShowAllMysteryCoffers() end
- SLASH_COMMANDS["/uscmaj"] = function() UndauntedShoulderCollector.ShowAllPledgeGiver(UndauntedShoulderCollectorData.Maj, UndauntedShoulderCollector.mysteryCofferMaj) end
- SLASH_COMMANDS["/uscglirion"] = function() UndauntedShoulderCollector.ShowAllPledgeGiver(UndauntedShoulderCollectorData.Glirion, UndauntedShoulderCollector.mysteryCofferGlirion) end
- SLASH_COMMANDS["/uscurgarlag"] = function() UndauntedShoulderCollector.ShowAllPledgeGiver(UndauntedShoulderCollectorData.Urgarlag, UndauntedShoulderCollector.mysteryCofferUrgarlag) end
- SLASH_COMMANDS["/uschelp"] = function() UndauntedShoulderCollector.PrintHelpMessages() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement