John@0: -- ideas: last attended data and/or remove people who haven't attended in X days John@0: John@0: -- order of implementation John@31: -- (*) lists fully functional (/script interface) John@31: -- (*) lists single-user functional via command line interface John@27: -- (*) all actions should reference the player list rather than player names John@27: -- (?) player entries should persist as long as any list or change references John@18: -- (*) lists store number slots rather than flat indexing John@33: -- ( ) database and comm versioning John@18: -- ( ) limited communication - everyone trusts the loot master John@70: -- (_) 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@70: -- (_) players gui John@35: -- ( ) undo John@0: -- ( ) crypto / protection against tampering John@0: -- ( ) alt tracking John@70: -- (*) reserves John@32: John@42: local _G=_G John@42: local strsplit=strsplit John@42: local string=string John@42: local sformat=string.format John@43: local bsk = LibStub("AceAddon-3.0"):NewAddon("bsk","AceConsole-3.0") John@43: -- "AceHook-3.0", "AceComm-3.0", "AceSerializer-3.0" John@42: _G.bsk=bsk John@42: local L = LibStub("AceLocale-3.0"):GetLocale("bsk", false) John@42: setfenv(1,bsk) John@42: John@34: local pkgrev = " @project-revision@ " 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@42: function OnInitialize() John@0: John@69: debug = true John@69: John@42: db = _G.LibStub("AceDB-3.0"):New("BskDB", defaults, "Default") John@0: John@42: options.args.profile = _G.LibStub("AceDBOptions-3.0"):GetOptionsTable(db) John@42: _G.LibStub("AceConfig-3.0"):RegisterOptionsTable("bsk", options) John@42: --optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("bsk", "bsk") John@0: John@42: local HandlePassThrough = function(...) HandleCommand(...) end John@42: bsk:RegisterChatCommand("bsk", HandlePassThrough) John@68: bsk:OnInitializeSetStaticData() John@70: InitializeComm() John@0: end John@0: John@42: function OnEnable() John@42: CreateWorkingStateFromChanges(db.profile.changes) John@66: --CreateGUI() John@0: end John@0: John@42: function 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@49: action,arg1,arg2,arg3 = bsk:GetArgs(paramIn,4) John@0: John@49: if not action then John@43: print("need args") John@0: return John@0: end John@49: if action == "persons" then John@42: PrintPersons() John@49: elseif action == "changes" then John@42: PrintChanges() John@49: elseif action == "selfdestruct" then John@49: SelfDestruct() John@49: elseif action == "delete" or action == "remove" then John@49: if not arg1 or not arg2 then John@42: PrintTable(param) John@21: return John@21: end John@49: if arg1 == "list" then John@49: DeleteList(arg2) John@49: elseif arg1 == "personfromlist" or "fromlist" then John@49: if not arg3 then John@42: PrintTable(param) John@22: return John@22: end John@49: local person = FixPersonName(arg2) John@49: RemovePersonFromList(person, arg3) John@49: elseif arg1 == "person" then John@49: local person = FixPersonName(arg2) John@42: RemovePerson(person) John@21: else John@49: printf("Deleting anything of type %s is not supported",arg1) John@21: end John@49: elseif action == "nuke" then John@49: if not arg1 then John@42: PrintTable(param) John@30: return John@30: end John@49: local person = FixPersonName(arg1) John@42: NukePerson(person) John@49: elseif action == "add" or action == "create" then John@49: if not arg1 or not arg2 then John@42: PrintTable(param) John@0: return John@0: end John@49: if arg1 == "person" then John@49: if arg2 == "all" or arg2 == "missing" then John@49: PersonList:AddMissing() John@1: else John@49: local person = FixPersonName(arg2) John@42: AddPerson(person) John@1: end John@49: elseif arg1 == "list" then John@49: CreateList(arg2) John@49: elseif arg1 == "tolist" then John@49: if not arg3 then John@42: PrintTable(param) John@9: return John@9: end John@49: local person = FixPersonName(arg2) John@49: AddPersonToListEnd(person,arg3) John@49: elseif arg1 == "tolistrandom" then John@49: if not arg3 then John@42: PrintTable(param) John@11: return John@11: end John@49: local person = FixPersonName(arg2) John@49: AddPersonToListRandom(person,arg3) John@0: end John@49: elseif action == "populate" then John@49: if not arg1 then John@42: PrintTable(param) John@3: return John@3: end John@3: -- list = p2 John@49: PopulateListRandom(arg1) John@49: elseif action == "suicide" then John@49: if not arg1 or not arg2 then John@42: PrintTable(param) John@0: return John@0: end John@49: local person = FixPersonName(arg1) John@49: SuicidePerson(person,arg2) John@49: elseif action == "lists" then John@49: if not arg1 then John@42: PrettyPrintLists() John@14: return John@14: else John@49: PrettyPrintList(arg1) John@14: end John@49: elseif action == "reserve" then John@49: if not arg1 then John@49: PrintTable(param) John@49: return John@49: end John@49: local person = FixPersonName(arg1) John@49: ReservePerson(person) John@49: elseif action == "trim" then John@49: if not arg1 then John@42: printtable(param) John@0: return John@0: end John@49: TrimLists(arg1) John@49: elseif action == "rename" then John@49: if not arg1 or not arg2 then John@49: PrintTable(param) John@5: return John@5: end John@49: RenameList(arg1,arg2) John@66: elseif action == "generate" then John@66: if not arg1 then John@66: PrintTable(param) John@66: return John@66: end John@66: PersonList:AddMissing() John@66: CreateList(arg1) John@66: PopulateListRandom(arg1) John@38: else John@42: CreateGUI() John@0: end John@0: John@42: --if frame == nil then John@42: --CreateGUI() John@42: --ShowGUI() John@0: --else John@42: --ShowGUI() John@0: --end John@0: John@0: end John@0: John@42: defaults = { John@0: profile = { John@8: persons = {}, John@0: changes = {}, John@34: lists = {} John@0: } John@0: } John@0: John@0: