John@0: -- ideas: last attended data and/or remove people who haven't attended in X days John@0: -- and/or just a "remove from all lists" option John@0: John@0: John@0: -- order of implementation John@1: -- (_) lists fully functional (/script interface) John@1: -- (_) lists single-user functional via command line interface John@15: -- (_) all actions should reference the player list rather than player names John@6: -- ( ) player entries should persist as long as any list or change references John@6: -- ( ) convert slist entries down to a delimited string - much smaller John@18: -- (*) lists store number slots rather than flat indexing John@18: -- ( ) limited communication - everyone trusts the loot master John@0: -- ( ) single user + admin gui (manual suicides) John@0: -- ( ) single user + admin gui (master loot) John@18: -- ( ) communication and list merging/trimming John@0: -- ( ) admins John@0: -- ( ) players gui John@0: -- ( ) crypto / protection against tampering John@0: -- ( ) alt tracking John@0: -- ( ) reserves John@0: John@0: -- important things to remember: John@1: -- 1) ipairs iterates from 1 until the first missing int index -> no gaps if int John@1: -- indexing John@0: -- 2) a.x === a["x"] John@0: -- 3) a["1"] =/= a[1] John@5: -- 4) table.remove() works ok if reverse iterating, terrible at anything else John@5: -- 5) pairs() does not have a guaranteed iteration order John@0: John@0: bsk = LibStub("AceAddon-3.0"):NewAddon("bsk","AceConsole-3.0", "AceHook-3.0", "AceComm-3.0", "AceSerializer-3.0") John@0: local L = LibStub("AceLocale-3.0"):GetLocale("bsk", false) John@0: John@0: local AceGUI = LibStub("AceGUI-3.0") John@0: John@0: function bsk:OnInitialize() John@0: John@0: self.db = LibStub("AceDB-3.0"):New("BskDB", self.defaults, "Default") John@0: John@0: self.options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) John@0: LibStub("AceConfig-3.0"):RegisterOptionsTable("bsk", self.options) John@0: self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("bsk", "bsk") John@0: John@0: self:RegisterChatCommand("bsk", "HandleCommand") John@0: end John@0: John@0: function bsk:OnEnable() John@5: bsk:CreateWorkingStateFromChanges(self.db.profile.changes) John@0: --self:HandleCommand() John@0: end John@0: John@0: function bsk:HandleCommand(paramIn) John@0: local param = { strsplit(" ", paramIn) } John@8: local FixPersonName = function(p) John@0: p = p:lower() John@0: -- next two lines from sylvanaar John@0: local MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)" John@0: return string.gsub(p, MULTIBYTE_FIRST_CHAR, string.upper, 1) John@0: end John@0: John@0: if param[1] == nil or param[1] == "" then John@0: bsk:Print("need args") John@0: return John@0: end John@8: if param[1] == "persons" then John@8: bsk:PrintPersons() John@8: elseif param[1] == "changes" then John@8: bsk:PrintChanges() John@21: elseif param[1] == "delete" then John@21: if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then John@21: bsk:PrintTable(param) John@21: return John@21: end John@21: if param[2] == "list" then John@21: bsk:DeleteList(param[3]) John@22: elseif param[2] == "personfromlist" then John@22: if param[4] == nil or param[4] == "" then John@22: bsk:PrintTable(param) John@22: return John@22: end John@22: local person = FixPersonName(param[3]) John@22: bsk:RemovePersonFromList(person, param[4]) John@21: else John@21: bsk:Print(sformat("Deleting anything of type %s is not supported",param[2])) John@21: end John@0: elseif param[1] == "add" then John@0: if param[2] == nil or param[2] == "" then John@0: bsk:PrintTable(param) John@0: return John@0: end John@0: if param[3] == nil or param[3] == "" then John@0: bsk:PrintTable(param) John@0: return John@0: end John@8: if param[2] == "person" then John@1: if param[3] == "all" then John@8: bsk:AddMissingPersons() John@1: else John@8: local person = FixPersonName(param[3]) John@8: bsk:AddPerson(person) John@1: end John@0: elseif param[2] == "list" then John@0: bsk:CreateList(param[3]) John@11: elseif param[2] == "tolist" then John@9: if param[4] == nil or param[4] == "" then John@9: bsk:PrintTable(param) John@9: return John@9: end John@9: local person = FixPersonName(param[3]) John@11: bsk:AddPersonToListEnd(person,param[4]) John@11: elseif param[2] == "tolistrandom" then John@11: if param[4] == nil or param[4] == "" then John@11: bsk:PrintTable(param) John@11: return John@11: end John@11: local person = FixPersonName(param[3]) John@11: bsk:AddPersonToListRandom(person,param[4]) John@0: end John@3: elseif param[1] == "populate" then John@3: if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then John@3: bsk:PrintTable(param) John@3: return John@3: end John@3: -- list = p2 John@3: local index = bsk:GetListIndex(param[2]) John@3: if param[3] == "random" then John@3: bsk:PopulateListRandom(index) John@3: end John@0: elseif param[1] == "suicide" then John@0: if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then John@0: bsk:PrintTable(param) John@0: return John@0: end John@8: local person = FixPersonName(param[2]) John@8: bsk:SuicidePerson(person,param[3]) John@14: elseif param[1] == "lists" then John@0: if param[2] == nil or param[2] == "" then John@14: bsk:PrettyPrintLists() John@14: return John@14: else John@14: local listIndex = bsk:GetListIndex(param[2]) John@14: bsk:PrettyPrintList(listIndex) John@14: end John@14: elseif param[1] == "reserve" then John@14: if param[2] == nil or param[2] == "" then John@14: bsk:printtable(param) John@0: return John@0: end John@14: local person = FixPersonName(param[2]) John@14: bsk:AddReserve(person) John@5: elseif param[1] == "trim" then John@5: if param[2] == nil or param[2] == "" then John@14: bsk:printtable(param) John@5: return John@5: end John@5: bsk:TrimLists(param[2]) John@20: elseif param[1] == "rename" then John@20: if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then John@20: bsk:printtable(param) John@20: return John@20: end John@20: bsk:RenameList(param[2],param[3]) John@17: elseif param[1] == "selfdestruct" then John@17: bsk:SelfDestruct() John@0: end John@0: John@0: --if self.frame == nil then John@0: --self:CreateGUI() John@0: --self:ShowGUI() John@0: --else John@0: --self:ShowGUI() John@0: --end John@0: John@0: end John@0: John@0: bsk.defaults = { John@0: profile = { John@8: persons = {}, John@0: changes = {}, John@0: listBase = {} John@0: } John@0: } John@0: John@0: