//=============================================================================
// SkillManager
//=============================================================================
class MMRPGSkillManager extends CBPSkillManager;



function CreateSkills (DeusExPlayer V9B)
{
	if (!_MMRPGPlayer(V9B).Skillage)
		Super.CreateSkills(V9B);
}

// ----------------------------------------------------------------------
// IsSkilled()
// ----------------------------------------------------------------------

simulated function bool IsSkilled(class SkillClass, int TestLevel)
{
	local Skill aSkill;

	aSkill = GetSkillFromClass(SkillClass);

	if (aSkill != None)
	{
		if (aSkill.Use())
		{
			if (aSkill.CurrentLevel >= TestLevel)
			{
				Player.ClientMessage(SuccessMessage);
				return True;
			}
			else
				Player.ClientMessage(Sprintf(NoSkillMessage, aSkill.SkillName, GetItemName(String(aSkill.itemNeeded))));
		}
		else
			Player.ClientMessage(Sprintf(NoToolMessage, GetItemName(String(aSkill.itemNeeded))));
	}

	return False;
}

// ----------------------------------------------------------------------
// accessor functions
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
// GetSkillFromClass()
// ----------------------------------------------------------------------

simulated function Skill GetSkillFromClass(class SkillClass)
{
	local Skill aSkill;

	aSkill = FirstSkill;
	while(aSkill != None)
	{
		if (aSkill.Class == SkillClass)
			break;

		aSkill = aSkill.next;
	}

	return aSkill;
}

// ----------------------------------------------------------------------
// GetSkillLevelValue()
//
// takes a class instead of being called by actual skill
// ----------------------------------------------------------------------

simulated function float GetSkillLevelValue(class SkillClass)
{
	local Skill aSkill;
	local float retval;

	retval = 0;

	if(SkillClass == class'SkillLockpicking')
	{
		aSkill = GetSkillFromClass(Class'SkillThief');

		retval = aSkill.LevelValues[aSkill.CurrentLevel];

		return retval;
	}

	aSkill = GetSkillFromClass(SkillClass);

	if (aSkill != None)
		retval = aSkill.LevelValues[aSkill.CurrentLevel];

	return retval;
}

// ----------------------------------------------------------------------
// GetSkillLevel()
//
// takes a class instead of being called by actual skill
// ----------------------------------------------------------------------

simulated function float GetSkillLevel(class SkillClass)
{
	local Skill aSkill;
	local float retval;

	retval = 0;

	aSkill = GetSkillFromClass(SkillClass);

	if (aSkill != None)
		retval = aSkill.CurrentLevel;

	return retval;
}

// ----------------------------------------------------------------------
// AddSkill()
// ----------------------------------------------------------------------

function AddSkill(Skill aNewSkill)
{
	if (aNewSkill.IncLevel())
		Player.ClientMessage(Sprintf(YourSkillLevelAt, aNewSkill.SkillName, aNewSkill.CurrentLevel));
}

// ----------------------------------------------------------------------
// SetPlayer()
//
// Kind of a hack, until we figure out why the player doesn't get set 
// correctly initially.
// ----------------------------------------------------------------------

function SetPlayer(DeusExPlayer newPlayer)
{
	local Skill aSkill;

	Player = newPlayer;

	aSkill = FirstSkill;
	while(aSkill != None)
	{
		aSkill.player = newPlayer;
		aSkill = aSkill.next;
	}
}

// ----------------------------------------------------------------------
// AddAllSkills()
// ----------------------------------------------------------------------

function AddAllSkills()
{
	local Skill aSkill;
	local int levelIndex;

	aSkill = FirstSkill;
	while(aSkill != None)
	{
		for (levelIndex=0; levelIndex<3; levelIndex++)
			AddSkill(aSkill);

		aSkill = aSkill.next;
	}
}

// ----------------------------------------------------------------------
// ResetSkills()
// ----------------------------------------------------------------------

function ResetSkills()
{
	local Skill aSkill;

	aSkill = FirstSkill;
	while(aSkill != None)
	{
		aSkill.CurrentLevel = aSkill.CurrentLevel;
		aSkill = aSkill.next;
	}
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------


defaultproperties
{
     NetPriority=1.40
     skillClasses(0)=Class'Contender.SkillPhysical'
     skillClasses(1)=Class'Contender.SkillAgility'
     skillClasses(2)=Class'DeusEx.SkillMedicine'
     skillClasses(3)=Class'Contender.SkillThief'
     skillClasses(4)=Class'Contender.SkillCraft'
     skillClasses(5)=Class'Contender.Skill'
     skillClasses(6)=Class'Contender.Skill'
     skillClasses(7)=Class'DeusEx.SkillWeaponPistol'
     skillClasses(8)=Class'DeusEx.SkillWeaponRifle'
     skillClasses(9)=Class'DeusEx.SkillWeaponLowTech'
     skillClasses(10)=None
}
