-- Character Classes
CLASS_WIZARD                                         	= 0	-- Fairy Elf, Muse Elf, High Elf
CLASS_KNIGHT                                         	= 1	-- Dark Wizard, Soul Master, Grand Master
CLASS_ELF                                            	= 2	-- Dark Knight, Blade Knight, Blade Master
CLASS_GLADIATOR                                       	= 3	-- Magic Gladiator, Duel Master
CLASS_DARKLORD                                        	= 4	-- Dark Lord, Lord Emperor
CLASS_SUMMONER                                        	= 5	-- Summoner, Bloody Summoner, Dimension Master
CLASS_RAGEFIGHTER                                     	= 6	-- Rage Fighter, Fist Master
CLASS_GROWLANCER                                    	= 7	-- Grow Lancer, Mirage Lancer

-- Options
STAT_OPTION_INC_ATTACK_POWER							= 1
STAT_OPTION_INC_ATTACK_RATE								= 2
STAT_OPTION_INC_ATTACK_RATE_PVP							= 3
STAT_OPTION_INC_DEFENSE									= 4
STAT_OPTION_INC_ATTACK_SPEED							= 5
STAT_OPTION_INC_DEFENSE_RATE							= 6
STAT_OPTION_INC_DEFENSE_RATE_PVP						= 7
STAT_OPTION_INC_LIFE									= 8 -- disabled at present
STAT_OPTION_INC_MAGIC_DAMAGE							= 9
STAT_OPTION_INC_CURSE_DAMAGE							= 10
STAT_OPTION_INC_MANA									= 11 -- disabled at present
STAT_OPTION_INC_PET_DAMAGE								= 12 -- disabled at present			

function StatSpec_GetPercent(Class, OptionID, Strength, Agility, Vitality, Energy, Leadership, Resets, GrandResets)
	local Percent = 0

	-- LogAdd(string.format('Class: %d OptionID: %d', Class, OptionID))
	
	if (Class == CLASS_KNIGHT and OptionID == STAT_OPTION_INC_ATTACK_POWER) then
		Percent = StatSpec_AtkPowerInc_Knight(Strength, Resets, GrandResets)
		
	elseif (Class == CLASS_ELF and OptionID == STAT_OPTION_INC_ATTACK_POWER) then
		Percent = StatSpec_AtkPowerInc_Elf(Agility, Resets, GrandResets)
		
	elseif (Class == CLASS_GLADIATOR and OptionID == STAT_OPTION_INC_ATTACK_POWER) then
		Percent = StatSpec_AtkPowerInc_Gladiator(Strength, Resets, GrandResets)
		
	elseif (Class == CLASS_DARKLORD and OptionID == STAT_OPTION_INC_ATTACK_POWER) then
		Percent = StatSpec_AtkPowerInc_Lord(Strength, Resets, GrandResets)
		
	elseif (Class == CLASS_RAGEFIGHTER and OptionID == STAT_OPTION_INC_ATTACK_POWER) then
		Percent = StatSpec_AtkPowerInc_Fighter(Strength, Resets, GrandResets)
		
	elseif (Class == CLASS_GROWLANCER and OptionID == STAT_OPTION_INC_ATTACK_POWER) then
		Percent = StatSpec_AtkPowerInc_Lancer(Strength, Resets, GrandResets)
		
	elseif (Class == CLASS_WIZARD and OptionID == STAT_OPTION_INC_ATTACK_RATE) then
		Percent = StatSpec_AtkRatePvMInc_Wizard(Agility, Resets, GrandResets)
	
	elseif (Class == CLASS_WIZARD and OptionID == STAT_OPTION_INC_ATTACK_RATE_PVP) then
		Percent = StatSpec_AtkRatePvPInc_Wizard(Agility, Resets, GrandResets)
		
	elseif (Class == CLASS_KNIGHT and OptionID == STAT_OPTION_INC_DEFENSE) then
		Percent = StatSpec_DefenseInc_Knight(Agility, Resets, GrandResets)
		
	elseif (Class == CLASS_DARKLORD and OptionID == STAT_OPTION_INC_DEFENSE) then
		Percent = StatSpec_DefenseInc_Lord(Agility, Resets, GrandResets)
		
	elseif (Class == CLASS_GROWLANCER and OptionID == STAT_OPTION_INC_DEFENSE) then
		Percent = StatSpec_DefenseInc_Lancer(Agility, Resets, GrandResets)
		
	elseif (Class == CLASS_ELF and OptionID == STAT_OPTION_INC_DEFENSE_RATE) then
		Percent = StatSpec_DefRatePvMInc_Elf(Agility, Resets, GrandResets)
		
	elseif (Class == CLASS_ELF and OptionID == STAT_OPTION_INC_DEFENSE_RATE_PVP) then
		Percent = StatSpec_DefRatePvPInc_Elf(Agility, Resets, GrandResets)
		
	elseif (Class == CLASS_WIZARD and OptionID == STAT_OPTION_INC_MAGIC_DAMAGE) then
		Percent = StatSpec_MagicPowerInc_Wizard(Energy, Resets, GrandResets)
		
	elseif (Class == CLASS_GLADIATOR and OptionID == STAT_OPTION_INC_MAGIC_DAMAGE) then
		Percent = StatSpec_MagicPowerInc_Gladiator(Energy, Resets, GrandResets)
		
	elseif (Class == CLASS_SUMMONER and OptionID == STAT_OPTION_INC_MAGIC_DAMAGE) then
		Percent = StatSpec_MagicPowerInc_Summoner(Energy, Resets, GrandResets)
	
	elseif (Class == CLASS_SUMMONER and OptionID == STAT_OPTION_INC_CURSE_DAMAGE) then
		Percent = StatSpec_CursePowerInc_Summoner(Energy, Resets, GrandResets)
	
	end
	
	return Percent	
end
		
function StatSpec_AtkPowerInc_Knight(Strength, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Strength > 1 and Strength < 1501) then
		Percent = Strength / 150
	  elseif (Strength >= 1501 and Strength < 2001) then
		Percent = 10 + (Strength - 1500) / 25
	  elseif (Strength >= 2001 and Strength < 3000) then
		Percent = 30 + (Strength - 2000) / 66
	  end
	end
	
	return Percent
end

function StatSpec_DefenseInc_Knight(Agility, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Agility > 1 and Agility < 1501) then
		Percent = Agility / 150
	  elseif (Agility >= 1501 and Agility < 2001) then
		Percent = 10 + (Agility - 1500) / 25
	  elseif (Agility >= 2001 and Agility < 3000) then
		Percent = 30 + (Agility - 2000) / 66
	  end
	end
	
	return Percent
end

function StatSpec_MagicPowerInc_Wizard(Energy, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Energy > 1 and Energy < 1501) then
		Percent = Energy / 150
	  elseif (Energy >= 1501 and Energy < 2001) then
		Percent = 10 + (Energy - 1500) / 25
	  elseif (Energy >= 2001 and Energy < 3000) then
		Percent = 30 + (Energy - 2000) / 66
	  end
	end
	
	return Percent
end

function StatSpec_AtkRatePvMInc_Wizard(Agility, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Agility > 1 and Agility < 1501) then
		Percent = Agility / 150
	  elseif (Agility >= 1501 and Agility < 2001) then
		Percent = 10 + (Agility - 1500) / 25
	  elseif (Agility >= 2001 and Agility < 3000) then
		Percent = 30 + (Agility - 2000) / 66
	  end
	end
	
	return Percent
end

function StatSpec_AtkRatePvPInc_Wizard(Agility, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Agility > 1 and Agility < 1501) then
		Percent = Agility / 150
	  elseif (Agility >= 1501 and Agility < 2001) then
		Percent = 10 + (Agility - 1500) / 25
	  elseif (Agility >= 2001 and Agility < 3000) then
		Percent = 30 + (Agility - 2000) / 66
	  end
	end
	
	return Percent
end

function StatSpec_AtkPowerInc_Elf(Agility, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Agility > 1 and Agility < 1801) then
		Percent = Agility / 180
	  elseif (Agility >= 1801 and Agility < 2101) then
		Percent = 10 + (Agility - 1800) / 15
	  elseif (Agility >= 2101 and Agility < 3000) then
		Percent = 30 + (Agility - 2100) / 45
	  end
	end
	
	return Percent
end

function StatSpec_DefRatePvMInc_Elf(Agility, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Agility > 1 and Agility < 1801) then
		Percent = Agility / 180
	  elseif (Agility >= 1801 and Agility < 2101) then
		Percent = 10 + (Agility - 1800) / 15
	  elseif (Agility >= 2101 and Agility < 3000) then
		Percent = 30 + (Agility - 2100) / 45
	  end
	end
	
	return Percent
end

function StatSpec_DefRatePvPInc_Elf(Agility, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Agility > 1 and Agility < 1801) then
		Percent = Agility / 180
	  elseif (Agility >= 1801 and Agility < 2101) then
		Percent = 10 + (Agility - 1800) / 15
	  elseif (Agility >= 2101 and Agility < 3000) then
		Percent = 30 + (Agility - 2100) / 45
	  end
	end
	
	return Percent
end

function StatSpec_MagicPowerInc_Summoner(Energy, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Energy > 1 and Energy < 1501) then
		Percent = Energy / 150
	  elseif (Energy >= 1501 and Energy < 2001) then
		Percent = 10 + (Energy - 1500) / 25
	  elseif (Energy >= 2001 and Energy < 3000) then
		Percent = 30 + (Energy - 2000) / 66
	  end
	end
	
	return Percent
end

function StatSpec_CursePowerInc_Summoner(Energy, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Energy > 1 and Energy < 1501) then
		Percent = Energy / 150
	  elseif (Energy >= 1501 and Energy < 2001) then
		Percent = 10 + (Energy - 1500) / 25
	  elseif (Energy >= 2001 and Energy < 3000) then
		Percent = 30 + (Energy - 2000) / 66
	  end
	end
	
	return Percent
end

function StatSpec_AtkPowerInc_Gladiator(Strength, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Strength > 1 and Strength < 1501) then
		Percent = Strength / 150
	  elseif (Strength >= 1501 and Strength < 2001) then
		Percent = 10 + (Strength - 1500) / 25
	  elseif (Strength >= 2001 and Strength < 3000) then
		Percent = 30 + (Strength - 2000) / 66
	  end
	end
	
	-- LogAdd(string.format('Percent: %d', Percent))
	
	return Percent
end

function StatSpec_MagicPowerInc_Gladiator(Energy, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Energy > 1 and Energy < 1801) then
		Percent = Energy / 180
	  elseif (Energy >= 1801 and Energy < 2101) then
		Percent = 10 + (Energy - 1500) / 15
	  elseif (Energy >= 2101 and Energy < 3000) then
		Percent = 30 + (Energy - 2000) / 45
	  end
	end
	
	return Percent
end

function StatSpec_AtkPowerInc_Lord(Strength, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Strength > 1 and Strength < 1501) then
		Percent = Strength / 150
	  elseif (Strength >= 1501 and Strength < 2001) then
		Percent = 10 + (Strength - 1500) / 25
	  elseif (Strength >= 2001 and Strength < 3000) then
		Percent = 30 + (Strength - 2000) / 66
	  end
	end
	
	return Percent
end

function StatSpec_DefenseInc_Lord(Agility, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Agility > 1 and Agility < 1501) then
		Percent = Agility / 150
	  elseif (Agility >= 1501 and Agility < 2001) then
		Percent = 10 + (Agility - 1500) / 25
	  elseif (Agility >= 2001 and Agility < 3000) then
		Percent = 30 + (Agility - 2000) / 66
	  end
	end
	
	return Percent
end

function StatSpec_AtkPowerInc_Fighter(Strength, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Strength > 1 and Strength < 1501) then
		Percent = Strength / 150
	  elseif (Strength >= 1501 and Strength < 2001) then
		Percent = 10 + (Strength - 1500) / 25
	  elseif (Strength >= 2001 and Strength < 3000) then
		Percent = 30 + (Strength - 2000) / 66
	  end
	end
	
	return Percent
end
function StatSpec_AtkPowerInc_Lancer(Strength, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Strength > 1 and Strength < 1501) then
		Percent = Strength / 150
	  elseif (Strength >= 1501 and Strength < 2001) then
		Percent = 10 + (Strength - 1500) / 25
	  elseif (Strength >= 2001 and Strength < 3000) then
		Percent = 30 + (Strength - 2000) / 66
	  end
	end
	
	return Percent
end

function StatSpec_DefenseInc_Lancer(Agility, Resets, GrandResets)
	local Percent = 0
	
        if(Resets < 9999 and GrandResets < 9999)then
	  if (Agility > 1 and Agility < 1501) then
		Percent = Agility / 150
	  elseif (Agility >= 1501 and Agility < 2001) then
		Percent = 10 + (Agility - 1500) / 25
	  elseif (Agility >= 2001 and Agility < 3000) then
		Percent = 30 + (Agility - 2000) / 66
	  end
        end
	
	return Percent
end	