annotate Core.lua @ 16:16b7e6390f42

Renamed a bunch of lists so I can tell easily what the primary key is and what is stored in that list. Trying to stop using the word "list" because it applies to basically everything
author John@Doomsday
date Thu, 08 Mar 2012 12:49:17 -0500
parents dbfb8f2052b6
children 71fc79846a5d
rev   line source
John@0 1 -- ideas: last attended data and/or remove people who haven't attended in X days
John@0 2 -- and/or just a "remove from all lists" option
John@0 3
John@0 4
John@0 5 -- order of implementation
John@1 6 -- (_) lists fully functional (/script interface)
John@1 7 -- (_) lists single-user functional via command line interface
John@15 8 -- (_) all actions should reference the player list rather than player names
John@6 9 -- ( ) player entries should persist as long as any list or change references
John@6 10 -- ( ) convert slist entries down to a delimited string - much smaller
John@6 11 -- ( ) lists store number slots rather than flat indexing
John@0 12 -- ( ) single user + admin gui (manual suicides)
John@0 13 -- ( ) single user + admin gui (master loot)
John@0 14 -- ( ) communication and list trimming
John@0 15 -- ( ) admins
John@0 16 -- ( ) players gui
John@0 17 -- ( ) crypto / protection against tampering
John@0 18 -- ( ) alt tracking
John@0 19 -- ( ) reserves
John@0 20
John@0 21 -- important things to remember:
John@1 22 -- 1) ipairs iterates from 1 until the first missing int index -> no gaps if int
John@1 23 -- indexing
John@0 24 -- 2) a.x === a["x"]
John@0 25 -- 3) a["1"] =/= a[1]
John@5 26 -- 4) table.remove() works ok if reverse iterating, terrible at anything else
John@5 27 -- 5) pairs() does not have a guaranteed iteration order
John@0 28
John@0 29 bsk = LibStub("AceAddon-3.0"):NewAddon("bsk","AceConsole-3.0", "AceHook-3.0", "AceComm-3.0", "AceSerializer-3.0")
John@0 30 local L = LibStub("AceLocale-3.0"):GetLocale("bsk", false)
John@0 31
John@0 32 local AceGUI = LibStub("AceGUI-3.0")
John@0 33
John@0 34 function bsk:OnInitialize()
John@0 35
John@0 36 self.db = LibStub("AceDB-3.0"):New("BskDB", self.defaults, "Default")
John@0 37
John@0 38 self.options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
John@0 39 LibStub("AceConfig-3.0"):RegisterOptionsTable("bsk", self.options)
John@0 40 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("bsk", "bsk")
John@0 41
John@0 42 self:RegisterChatCommand("bsk", "HandleCommand")
John@0 43 end
John@0 44
John@0 45 function bsk:OnEnable()
John@5 46 bsk:CreateWorkingStateFromChanges(self.db.profile.changes)
John@0 47 --self:HandleCommand()
John@0 48 end
John@0 49
John@0 50 function bsk:HandleCommand(paramIn)
John@0 51 local param = { strsplit(" ", paramIn) }
John@8 52 local FixPersonName = function(p)
John@0 53 p = p:lower()
John@0 54 -- next two lines from sylvanaar
John@0 55 local MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)"
John@0 56 return string.gsub(p, MULTIBYTE_FIRST_CHAR, string.upper, 1)
John@0 57 end
John@0 58
John@0 59 if param[1] == nil or param[1] == "" then
John@0 60 bsk:Print("need args")
John@0 61 return
John@0 62 end
John@8 63 if param[1] == "persons" then
John@8 64 bsk:PrintPersons()
John@8 65 elseif param[1] == "changes" then
John@8 66 bsk:PrintChanges()
John@0 67 elseif param[1] == "add" then
John@0 68 if param[2] == nil or param[2] == "" then
John@0 69 bsk:PrintTable(param)
John@0 70 return
John@0 71 end
John@0 72 if param[3] == nil or param[3] == "" then
John@0 73 bsk:PrintTable(param)
John@0 74 return
John@0 75 end
John@8 76 if param[2] == "person" then
John@1 77 if param[3] == "all" then
John@8 78 bsk:AddMissingPersons()
John@1 79 else
John@8 80 local person = FixPersonName(param[3])
John@8 81 bsk:AddPerson(person)
John@1 82 end
John@0 83 elseif param[2] == "list" then
John@0 84 bsk:CreateList(param[3])
John@11 85 elseif param[2] == "tolist" then
John@9 86 if param[4] == nil or param[4] == "" then
John@9 87 bsk:PrintTable(param)
John@9 88 return
John@9 89 end
John@9 90 local person = FixPersonName(param[3])
John@11 91 bsk:AddPersonToListEnd(person,param[4])
John@11 92 elseif param[2] == "tolistrandom" then
John@11 93 if param[4] == nil or param[4] == "" then
John@11 94 bsk:PrintTable(param)
John@11 95 return
John@11 96 end
John@11 97 local person = FixPersonName(param[3])
John@11 98 bsk:AddPersonToListRandom(person,param[4])
John@0 99 end
John@3 100 elseif param[1] == "populate" then
John@3 101 if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then
John@3 102 bsk:PrintTable(param)
John@3 103 return
John@3 104 end
John@3 105 -- list = p2
John@3 106 local index = bsk:GetListIndex(param[2])
John@3 107 if param[3] == "random" then
John@3 108 bsk:PopulateListRandom(index)
John@3 109 end
John@0 110 elseif param[1] == "suicide" then
John@0 111 if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then
John@0 112 bsk:PrintTable(param)
John@0 113 return
John@0 114 end
John@8 115 local person = FixPersonName(param[2])
John@8 116 bsk:Print(string.format("Fixed player name %s to %s",param[2],person))
John@8 117 bsk:SuicidePerson(person,param[3])
John@14 118 elseif param[1] == "lists" then
John@0 119 if param[2] == nil or param[2] == "" then
John@14 120 bsk:PrettyPrintLists()
John@14 121 return
John@14 122 else
John@14 123 local listIndex = bsk:GetListIndex(param[2])
John@14 124 bsk:PrettyPrintList(listIndex)
John@14 125 end
John@14 126 elseif param[1] == "reserve" then
John@14 127 if param[2] == nil or param[2] == "" then
John@14 128 bsk:printtable(param)
John@0 129 return
John@0 130 end
John@14 131 local person = FixPersonName(param[2])
John@14 132 bsk:AddReserve(person)
John@5 133 elseif param[1] == "trim" then
John@5 134 if param[2] == nil or param[2] == "" then
John@14 135 bsk:printtable(param)
John@5 136 return
John@5 137 end
John@5 138 bsk:TrimLists(param[2])
John@0 139 end
John@0 140
John@0 141 --if self.frame == nil then
John@0 142 --self:CreateGUI()
John@0 143 --self:ShowGUI()
John@0 144 --else
John@0 145 --self:ShowGUI()
John@0 146 --end
John@0 147
John@0 148 end
John@0 149
John@0 150 bsk.defaults = {
John@0 151 profile = {
John@8 152 persons = {},
John@0 153 changes = {},
John@0 154 listBase = {}
John@0 155 }
John@0 156 }
John@0 157
John@0 158