still pre-alpha

Talen-Shei [08-11-15 - 22:49]
still pre-alpha
Filename
AutomatedGuildManager.lua
diff --git a/AutomatedGuildManager.lua b/AutomatedGuildManager.lua
index 590b8b0..5ec77a6 100644
--- a/AutomatedGuildManager.lua
+++ b/AutomatedGuildManager.lua
@@ -1,25 +1,36 @@
 -- @Author: Cody Smith
 -- @Date:   2015-08-11 12:49:48
 -- @Last Modified by:   Cody Smith
--- @Last Modified time: 2015-08-11 14:18:08
+-- @Last Modified time: 2015-08-11 15:46:35
 local LAM2 = LibStub("LibAddonMenu-2.0")

 local AGM = {}
+AGM.SettingsFile = "AutomatedGuildManagerSettings"
+AGM.SAVED_VAR_VERSION = 0.1
+AGM.CODE_VERSION = 0.1
+AGM.SVProfile = nil
+
 AGM.Defaults = {}
+AGM.Defaults.Account = {}
+AGM.Defaults.Account.gid = 1
+AGM.Defaults.Account.Notes = {}
+AMG.ValidNotes = {}
+AGM.ValidNotes.Recruited = "Date Recruited"


 function getSavedNotes(playername)
 	--access save table and return table of notes only neccesary for double checking that we have information saved.
 	-- do some checking to make sure that our gid hasn't changed first and fix tables around if it did
 	local table = {}
-	if savedtable[AGM.gid].name == nil then --TODO: finish this. Check guild names and gids against items in db
+	if savedtable[AGM.Account.gid].name == nil then --TODO: finish this. Check guild names and gids against items in db
+	end
 end

 function readNotes(playername)
 	local tbl = {}
-	local numGuildMembers = GetNumGuildMembers(AGM.gid)
+	local numGuildMembers = GetNumGuildMembers(AGM.Account.gid)
 	for i = 1, numGuildMembers do
-		local name,note,rankIndex = GetGuildMemberInfo(AGM.gid, i)
+		local name,note,rankIndex = GetGuildMemberInfo(AGM.Account.gid, i)
 		if name == playername then
 			tbl = parseNotes(note)
 		end
@@ -40,18 +51,42 @@ function parseNotes(noteString)
 end

 local function dateRecruited()
+	local date = os.time("%x")
+	local str = "["..AGM.ValidNotes.Recruited..":"..date"]"
 	--get current date and build our string to add to the notes.
+	return str
 end

 local function onMemberAdd(eventCode, guildId, DisplayName)
-	if guildId == AGM.gid then
+	if guildId == AGM.Account.gid then
 		local notes = readNotes(DisplayName)
 		if notes ~= "" then
 			--operate on notes
+		else
+			notes = dateRecruited()
+			d(notes)
+		end
+	end
+end
+
+function setGuild(name)
+	local gid = false
+	for g=1, #AGM.Account.Guilds do
+		if name == AGM.Account.Guilds[i] then
+			AGM.Account.gid = i
 		end
 	end
 end

+function listGuilds()
+	local tbl
+	for i in GetNumGuilds() do
+		local name = GetGuildName(i)
+		table.insert(tbl,name)
+	end
+	AGM.Account.Guilds = tbl
+	return tbl
+end
 ---------------------LAM 2.0 SETTINGS--------------------------

 local function CreateSettingsMenu()
@@ -59,8 +94,8 @@ local function CreateSettingsMenu()

 	local panelData = {
 		type = "panel",
-		name = "Guild Note Manager",
-		displayName = colorYellow.."Talen-Shei's Guild Note Manager",
+		name = "Automated Guild Manager",
+		displayName = colorYellow.."Talen-Shei's Automated Guild Manager",
 		author = "Talen-Shei",
 		version = AGM.CODE_VERSION,
 		slashCommand = "/AGM",
@@ -80,6 +115,18 @@ local function CreateSettingsMenu()
 			type = "description",
 			text = "A Tool to manage guild notes and automated deletion.",
 		},
+		[4] = {
+			type = "dropdown",
+			name = "Guild",
+			choices = AGM.Account.Guilds,
+			tooltip = "Profile to load/save to",
+			sort = "name-up",
+			reference = "KBSProfiles",
+			default = AGM.Account.Guilds[AGM.Account.gid],
+			getFunc = function() local Guild = AGM.Accounts.Guilds[AGM.Account.gid] return Guild end,
+			setFunc = function(bValue) setBindingTarget(bValue) end,
+			 -- KBS.Character.BindingTarget = bValue end,
+		},
 	}

 	LAM2:RegisterOptionControls("AGM_Options", optionsData)
@@ -88,6 +135,7 @@ end

 local function Initialize()
 	--set up settings files and such
+	AGM.Account = ZO_SavedVars:NewAccountWide(AGM.SettingsFile, AGM.SAVED_VAR_VERSION, nil, AGM.Defaults.Account, AGM.SVProfile)
 end

 local function OnLoad(event,addon)