---------------------------------------------------------
--Instance Module Template for BossTactics
--refer www.bosstactics.net for howto create modules!
---------------------------------------------------------

--available buttontypes:
--f: rangedDPS, h: healer, t: tank, n:melee, b,x,y,z: boss
--empty captions are not "" please use " " or you will get exceptions!

--local variable definition dont change!!
local BT_main = LibStub("AceAddon-3.0"):GetAddon( "BossTactics" )

BT_Malygos = LibStub("AceAddon-3.0"):NewAddon("BT_Malygos","AceConsole-3.0");
local L = LibStub("AceLocale-3.0"):GetLocale("BT_Malygos")

--feel free to use localisations from the framework
local L_main = LibStub("AceLocale-3.0"):GetLocale("BossTactics")

local BabbleBoss = LibStub("LibBabble-Boss-3.0"):GetLookupTable();
local BabbleZone = LibStub("LibBabble-Zone-3.0"):GetLookupTable();

--db profile defaults add your boss-data here
local defaults = {
    profile = {
        ["instance"] = BabbleZone["The Eye of Eternity"], --instance name
		["version"] = 1, --change this to a higher value for update handling (explained in a tutorial)
		["initial"] = true, --never change this flag!
		["id"] = "BT_Malygos", --very important this must be the same name as your module case sensitive!
		["info"] = L["info"], --a short text you can add to the info frame, optional
		["patchlevel"] = "3.0.9", --put in the patchlevel to which this guide belongs to
		["bosses"] = {
			["mode25"] = {
		    -- first boss
                [1] = {
                    ["name"] = BabbleBoss["Malygos"],
                    ["ratext"] = L["ra Malygos"], --lines seperated by \n
                    ["tactictext"] = { [1] = {["name"] = "BossTactics", ["data"]=L["25-Malygos"],} },
                    ["imgdata"] = {
                        [1] = {
                            ["source"] = "Interface\\Addons\\BT_Malygos\\Img\\map_work_malygos",
                            ["btnId"] = 10, --start id of new buttons set this to the number of buttons on your current image +1
                            ["buttons"] = {
                                {
							   		["y"] = -124.0130156887306,
                                    ["type"] = "y",
                                    ["caption"] = " ",
                                    ["x"] = 51.05259409631698,
                                }, -- [1]
                                {
                                    ["y"] = -363.8158650556206,
                                    ["type"] = "f",
                                    ["caption"] = " ",
                                    ["x"] = 335.6579862077178,
                                }, -- [2]
                                {
                                    ["y"] = -379.6053656244788,
                                    ["type"] = "h",
                                    ["caption"] = " ",
                                    ["x"] = 215.4604355991865,
                                }, -- [3]
                                {
                                    ["y"] = -208.8816007871272,
                                    ["type"] = "t",
                                    ["caption"] = " ",
                                    ["x"] = 211.1184538660029,
                                }, -- [4]
                                {
                                    ["y"] = -277.9606560054897,
                                    ["type"] = "b",
                                    ["caption"] = " ",
                                    ["x"] = 261.0526605044499,
                                }, -- [5]
                                {
                                    ["y"] = -136.8419116229881,
                                    ["type"] = "y",
                                    ["caption"] = " ",
                                    ["x"] = 486.2499365497006,
                                }, -- [6]
                                {
                                    ["y"] = -505.9209402780974,
                                    ["type"] = "y",
                                    ["caption"] = " ",
                                    ["x"] = 47.10532642841413,
                                }, -- [7]
                                {
                                    ["y"] = -503.9473601813019,
                                    ["type"] = "y",
                                    ["caption"] = " ",
                                    ["x"] = 487.236863383586,
                                }, -- [8]
                                {
                                    ["y"] = -346.0527062268311,
                                    ["type"] = "n",
                                    ["caption"] = " ",
                                    ["x"] = 313.5526697786892,
                                }, -- [9]
                            },
                            ["fontstrings"] = { --optional, put text on your map
                               [1] = {
                                    ["x"] = 217,
                                    ["y"] = -22,
                                    ["text"] = L["Phase 1"],
                                },
                            },
                            ["legend"] = { --optional, puts buttons to the legend
                                ["entries"] = {
                                    [1] = {
                                        ["type"] = "h",
                                        ["caption"] = L_main["healer"],
                                        ["r"] = 0,   --not optional
                                        ["g"] = 1,   --not optional
                                        ["b"] = 0,   --not optional
                                    },
                                    [2] = {
                                        ["type"] = "f",
                                        ["caption"] = L_main["ranged DPS"],
                                        ["r"] = 0,
                                        ["g"] = 0,
                                        ["b"] = 1,
                                    },
                                    [3] = {
                                        ["type"] = "t",
                                        ["caption"] = L_main["tank"],
                                        ["r"] = 1,
                                        ["g"] = 1,
                                        ["b"] = 1,
                                    },
                                    [4] = {
                                        ["type"] = "n",
                                        ["caption"] = L_main["melee"],
                                        ["r"] = 235/255,
                                        ["g"] = 228/255,
                                        ["b"] = 45/255,
                                    },
                                    [5] = {
                                        ["type"] = "b",
                                        ["caption"] = BabbleBoss["Malygos"],
                                        ["r"] = 1,
                                        ["g"] = 0,
                                        ["b"] = 0,
                                    },
                                    [6] = {
                                        ["type"] = "y",
                                        ["caption"] = L["Power Spark Spawn"],
                                        ["r"] = 215/255,
                                        ["g"] = 121/255,
                                        ["b"] = 210/255,
                                    },
                                },
                            },
                		},
                    },
                },
            },
            ["mode10"] = {
		    -- first boss
                [1] = {
                    ["name"] = BabbleBoss["Malygos"],
                    ["ratext"] = L["ra Malygos"], --lines seperated by \n
                    ["tactictext"] = { [1] = {["name"] = "BossTactics", ["data"]=L["10-Malygos"],} },
                    ["imgdata"] = {
                        --first image
                        [1] = {
                            ["source"] = "Interface\\Addons\\BT_Malygos\\Img\\map_work_malygos",
                            ["btnId"] = 10, --start id of new buttons set this to the number of buttons on your current image +1
                            ["buttons"] = {
                                {
							   		["y"] = -124.0130156887306,
                                    ["type"] = "y",
                                    ["caption"] = " ",
                                    ["x"] = 51.05259409631698,
                                }, -- [1]
                                {
                                    ["y"] = -363.8158650556206,
                                    ["type"] = "f",
                                    ["caption"] = " ",
                                    ["x"] = 335.6579862077178,
                                }, -- [2]
                                {
                                    ["y"] = -379.6053656244788,
                                    ["type"] = "h",
                                    ["caption"] = " ",
                                    ["x"] = 215.4604355991865,
                                }, -- [3]
                                {
                                    ["y"] = -208.8816007871272,
                                    ["type"] = "t",
                                    ["caption"] = " ",
                                    ["x"] = 211.1184538660029,
                                }, -- [4]
                                {
                                    ["y"] = -277.9606560054897,
                                    ["type"] = "b",
                                    ["caption"] = " ",
                                    ["x"] = 261.0526605044499,
                                }, -- [5]
                                {
                                    ["y"] = -136.8419116229881,
                                    ["type"] = "y",
                                    ["caption"] = " ",
                                    ["x"] = 486.2499365497006,
                                }, -- [6]
                                {
                                    ["y"] = -505.9209402780974,
                                    ["type"] = "y",
                                    ["caption"] = " ",
                                    ["x"] = 47.10532642841413,
                                }, -- [7]
                                {
                                    ["y"] = -503.9473601813019,
                                    ["type"] = "y",
                                    ["caption"] = " ",
                                    ["x"] = 487.236863383586,
                                }, -- [8]
                                {
                                    ["y"] = -346.0527062268311,
                                    ["type"] = "n",
                                    ["caption"] = " ",
                                    ["x"] = 313.5526697786892,
                                }, -- [9]
                            },
                            ["fontstrings"] = { --optional, put text on your map
                               [1] = {
                                    ["x"] = 217,
                                    ["y"] = -22,
                                    ["text"] = L["Phase 1"],
                                },
                            },
                            ["legend"] = { --optional, puts buttons to the legend
                                ["entries"] = {
                                    [1] = {
                                        ["type"] = "h",
                                        ["caption"] = L_main["healer"],
                                        ["r"] = 0,   --not optional
                                        ["g"] = 1,   --not optional
                                        ["b"] = 0,   --not optional
                                    },
                                    [2] = {
                                        ["type"] = "f",
                                        ["caption"] = L_main["ranged DPS"],
                                        ["r"] = 0,
                                        ["g"] = 0,
                                        ["b"] = 1,
                                    },
                                    [3] = {
                                        ["type"] = "t",
                                        ["caption"] = L_main["tank"],
                                        ["r"] = 1,
                                        ["g"] = 1,
                                        ["b"] = 1,
                                    },
                                    [4] = {
                                        ["type"] = "n",
                                        ["caption"] = L_main["melee"],
                                        ["r"] = 235/255,
                                        ["g"] = 228/255,
                                        ["b"] = 45/255,
                                    },
                                    [5] = {
                                        ["type"] = "b",
                                        ["caption"] = BabbleBoss["Malygos"],
                                        ["r"] = 1,
                                        ["g"] = 0,
                                        ["b"] = 0,
                                    },
                                    [6] = {
                                        ["type"] = "y",
                                        ["caption"] = L["Power Spark Spawn"],
                                        ["r"] = 215/255,
                                        ["g"] = 121/255,
                                        ["b"] = 210/255,
                                    },
                                },
                            },
                		},
                    },
                },
            },
		},
    },
}

function BT_Malygos:OnInitialize()
 	--initialize database
    self.db = LibStub("AceDB-3.0"):New("BT_MalygosDB", defaults, "Default") --change the name here
    self:CheckUpdate()

    table.insert(BT_main.modules,self.db.profile)
end;

------------------------------------------------
--this function is needed by the main program! dont touch it!
------------------------------------------------
function BT_Malygos:GetDefaults()
	return defaults;
end;

-----------------------------------------------
--handels updates in data
--refer to the tutorial how to get version changes!
-----------------------------------------------

function BT_Malygos:CheckUpdate()

	--the versions stored by the client musst be one more
	--because otherwise it woudnt been saved in the savedVariables
	if(not self.db.profile.initial)then
		if(defaults.profile.version+1 > self.db.profile.version)then
			if(defaults.profile.version >= 2)then
				BT_main:ShowUpdateInfoFrame()
			end
		end
	end
	self.db.profile.version = defaults.profile.version+1
	self.db.profile.initial = false
end;


----------------------------------------------------------------
--dont touch this functions!
----------------------------------------------------------------

function BT_Malygos:ResetData()
	self.db:ResetDB()
	self.db.profile.version = defaults.profile.version+1
	self:Print(L["Module resetted"])
end;

function BT_Malygos:OnEnable()
    -- Called when the addon is enabled
end

function BT_Malygos:OnDisable()
    -- Called when the addon is disabled
end