annotate Core.lua @ 2:00286ba3b9c4

Bug: forgot raid list was keyed with the names
author John@Yosemite-PC
date Fri, 02 Mar 2012 22:44:30 -0500
parents 21c58930f74e
children 431ddc8bdb4a
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@1 8 -- ( ) all actions should reference the player list
John@0 9 -- ( ) single user + admin gui (manual suicides)
John@0 10 -- ( ) single user + admin gui (master loot)
John@0 11 -- ( ) communication and list trimming
John@0 12 -- ( ) admins
John@0 13 -- ( ) players gui
John@0 14 -- ( ) crypto / protection against tampering
John@0 15 -- ( ) alt tracking
John@0 16 -- ( ) reserves
John@0 17
John@0 18 -- important things to remember:
John@1 19 -- 1) ipairs iterates from 1 until the first missing int index -> no gaps if int
John@1 20 -- indexing
John@0 21 -- 2) a.x === a["x"]
John@0 22 -- 3) a["1"] =/= a[1]
John@0 23
John@0 24 bsk = LibStub("AceAddon-3.0"):NewAddon("bsk","AceConsole-3.0", "AceHook-3.0", "AceComm-3.0", "AceSerializer-3.0")
John@0 25 local L = LibStub("AceLocale-3.0"):GetLocale("bsk", false)
John@0 26
John@0 27 local AceGUI = LibStub("AceGUI-3.0")
John@0 28
John@0 29 function bsk:OnInitialize()
John@0 30
John@0 31 self.db = LibStub("AceDB-3.0"):New("BskDB", self.defaults, "Default")
John@0 32
John@0 33 self.options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
John@0 34 LibStub("AceConfig-3.0"):RegisterOptionsTable("bsk", self.options)
John@0 35 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("bsk", "bsk")
John@0 36
John@0 37 self:RegisterChatCommand("bsk", "HandleCommand")
John@0 38 end
John@0 39
John@0 40 function bsk:OnEnable()
John@1 41 bsk:CreateWorkingStateFromChanges()
John@0 42 --self:HandleCommand()
John@0 43 end
John@0 44
John@0 45 function bsk:HandleCommand(paramIn)
John@0 46 local param = { strsplit(" ", paramIn) }
John@0 47 local FixPlayerName = function(p)
John@0 48 p = p:lower()
John@0 49 -- next two lines from sylvanaar
John@0 50 local MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)"
John@0 51 return string.gsub(p, MULTIBYTE_FIRST_CHAR, string.upper, 1)
John@0 52 end
John@0 53
John@0 54 if param[1] == nil or param[1] == "" then
John@0 55 bsk:Print("need args")
John@0 56 return
John@0 57 end
John@0 58 if param[1] == "players" then
John@0 59 bsk:PrintPlayers()
John@0 60 elseif param[1] == "add" then
John@0 61 if param[2] == nil or param[2] == "" then
John@0 62 bsk:PrintTable(param)
John@0 63 return
John@0 64 end
John@0 65 if param[3] == nil or param[3] == "" then
John@0 66 bsk:PrintTable(param)
John@0 67 return
John@0 68 end
John@0 69 if param[2] == "player" then
John@1 70 if param[3] == "all" then
John@1 71 bsk:AddMissingPlayers()
John@1 72 else
John@0 73 local player = FixPlayerName(param[3])
John@0 74 bsk:AddPlayer(player)
John@1 75 end
John@0 76 elseif param[2] == "list" then
John@0 77 bsk:CreateList(param[3])
John@0 78 end
John@0 79 elseif param[1] == "suicide" then
John@0 80 if param[2] == nil or param[2] == "" or param[3] == nil or param[3] == "" then
John@0 81 bsk:PrintTable(param)
John@0 82 return
John@0 83 end
John@0 84 local player = FixPlayerName(param[2])
John@0 85 bsk:Print(string.format("Fixed player name %s to %s",param[2],player))
John@0 86 bsk:SuicidePlayer(player,param[3])
John@0 87 elseif param[1] == "show" then
John@0 88 if param[2] == nil or param[2] == "" then
John@0 89 bsk:PrintTable(param)
John@0 90 return
John@0 91 end
John@0 92 bsk:PrintLists(param[2])
John@0 93 end
John@0 94
John@0 95 --if self.frame == nil then
John@0 96 --self:CreateGUI()
John@0 97 --self:ShowGUI()
John@0 98 --else
John@0 99 --self:ShowGUI()
John@0 100 --end
John@0 101
John@0 102 end
John@0 103
John@0 104 bsk.defaults = {
John@0 105 profile = {
John@0 106 players = {},
John@0 107 changes = {},
John@0 108 listBase = {}
John@0 109 }
John@0 110 }
John@0 111
John@0 112