--===================================================
--
--				GHI_MarySueAPI
--  			GHI_MarySueAPI.lua
--
--	  API for accessing data from Mary Sue Protocol Addons
--
-- 	  (c)2013 The Gryphonheart Team
--			All rights reserved
--===================================================

local class;
function GHI_MarySueAPI()
	if class then
		return class;
	end
	class = GHClass("GHI_MarySueAPI");

	local api = {};

	--[[ MSP table flags
	HH = Home
	HI = Character History
	DE = Decription
	NT = Title
	GC = Game Class
	AG = Age
	HB = Birth Place
	AH = Height
	NA = Name
	RA = RP Race
	AW = Weigth
	FC = In Character Flag
	GR = Game Race
	NH = House Name
	NI = Nick Name
	FR = RP Style
	MO = Motto
	AE = Eyes
	CU = Currently
	]]
	-- fuinctions for getting info about another character.
	api.GHI_GetCharacterPhysical = function(player)
		if msp:PlayerKnownAbout(player) == true then
			local char = msp.char[player]["field"]
			-- Race, Age, Height, Weight, Eye Color, Description
			return char["RA"], char["AG"], char["AH"], char["AW"], char["AE"], char["DE"]
		end
	end
	
	api.GHI_GetCharacterHistory = function(player)
		if msp:PlayerKnownAbout(player) == true then
			local char = msp.char[player]["field"]
			-- Home, Birthplace, History
			return char["HH"], char["HB"], char["HI"]
		end
	end
	
	api.GHI_GetCharacterWho = function(player)
		if msp:PlayerKnownAbout(player) == true then
			local char = msp.char[player]["field"]
			-- Name, Title, House, Nickname
			return char["NA"], char["NT"], char["NH"], char["NI"]
		end
	end
	
	api.GHI_GetCharacterStatus = function(player)
		if msp:PlayerKnownAbout(player) == true then
			local char = msp.char[player]["field"]
			-- Currently, RP Style, Character Status
			return char["CU"], char["FR"], char["FC"]
		end
	end
	-- functions for gettign the current player's info
	api.GHI_GetPlayerPhysical = function()
		local char = msp.my
		-- Race, Age, Height, Weight, Eye Color, Description
		return char["RA"], char["AG"], char["AH"], char["AW"], char["AE"], char["DE"]
	end
	
	api.GHI_GetPlayerHistory = function()
		local char = msp.my
		-- Home, Birthplace, History
		return char["HH"], char["HB"], char["HI"]
	end
	
	api.GHI_GetPlayerWho = function()
		local char = msp.my
		-- Name, Title, House, Nickname
		return char["NA"], char["NT"], char["NH"], char["NI"]
	end
	
	api.GHI_GetPlayerStatus = function()
		local char = msp.my
		-- Currently, RP Style, Character Status
		return char["CU"], char["FR"], char["FC"]
	end
	-- function to allow updating the currently field of the player.
	api.GHI_SetPlayerCurrently = function(text)
		local char = msp.my
		char["CU"] = text
		msp:Update()
		--
		local RPAddon = _G.msp_RPAddOn
		if RPAddon == "MyRolePlay" then
			mrp:SaveField( "CU", text )		
		end
	end


	class.GetAPI = function()
		local a = {};
		for i, f in pairs(api) do
			a[i] = f;
		end
		return a;
	end



	return class;
end

