//////////////////////////////////////////////////
//	Author: Drammel								//
//	Date: 6/1/2009								//
//	Title: gui_select_maneuver					//
//	Description: Adds a maneuver for the PC to	//
//	gain when they level.  Does not actually add//
//	the maneuver, but prepares it for selection.//
//////////////////////////////////////////////////

#include "bot9s_inc_levelup"
#include "bot9s_inc_levelup2"

void main(string sData)
{
	object oOrigin = OBJECT_SELF;
	object oPC = GetControlledCharacter(oOrigin);
	string sToB = GetFirstName(oPC) + "tob";
	object oToB = GetObjectByTag(sToB);
	int nManeuver = StringToInt(sData);
	int nKnown = GetLocalInt(oToB, "KnownManeuverTotal");
	int nLevel = GetLocalInt(oToB, "CurrentLevelupLevel");
	int nClass = GetLocalInt(oToB, "LevelupClass");
	int nLearn = GetLocalInt(oToB, "LevelupLearn");
	int nStance = GetLocalInt(oToB, "LevelupStance");
	int nLevelCap = GetLocalInt(oToB, "LevelupCap");
	int nDiscipline, nNumber;

	if (GetLocalInt(oToB, "CurrentLevelupLevel") == 0)
	{
		nNumber = nStance;
	}
	else nNumber = nLearn;

	if (nNumber > 0)
	{
		ClearListBox(oPC, "SCREEN_LEVELUP_MANEUVERS", "AVAILABLE_MANEUVER_LIST");
		ClearListBox(oPC, "SCREEN_LEVELUP_MANEUVERS", "ADDED_MANEUVER_LIST");

		if ((nManeuver > 0) && (nManeuver < 28)) // Determine the maneuver's Discipline.
		{
			nDiscipline = 1;
		}
		else if ((nManeuver > 27) && (nManeuver < 54))
		{
			nDiscipline = 2;
		}
		else if ((nManeuver > 53) && (nManeuver < 76))
		{
			nDiscipline = 3;
		}
		else if ((nManeuver > 75) && (nManeuver < 97))
		{
			nDiscipline = 4;
		}
		else if (((nManeuver > 96) && (nManeuver < 116)) || nManeuver == 209)
		{
			nDiscipline = 5;
		}
		else if ((nManeuver > 115) && (nManeuver < 141))
		{
			nDiscipline = 6;
		}
		else if ((nManeuver > 140) && (nManeuver < 165))
		{
			nDiscipline = 7;
		}
		else if ((nManeuver > 164) && (nManeuver < 188))
		{
			nDiscipline = 8;
		}
		else if ((nManeuver > 187) && (nManeuver < 208))
		{
			nDiscipline = 9;
		}

		if (GetIsStance(nManeuver) == TRUE)
		{
			SetLocalInt(oToB, "LevelupStance", nStance - 1);
			int nNew = GetLocalInt(oToB, "LevelupStance");
			SetGUIObjectText(oPC, "SCREEN_LEVELUP_MANEUVERS", "POINT_POOL_TEXT", -1, IntToString(nNew));
		}
		else if (GetIsStance(nManeuver) == FALSE)
		{
			SetLocalInt(oToB, "LevelupLearn", nLearn - 1);
			int nNew = GetLocalInt(oToB, "LevelupLearn");
			SetGUIObjectText(oPC, "SCREEN_LEVELUP_MANEUVERS", "POINT_POOL_TEXT", -1, IntToString(nNew));
		}

		if ((GetLocalInt(oToB, "LevelupStance") == 0) && (GetLocalInt(oToB, "LevelupLearn") == 0))
		{
			SetGUIObjectDisabled(oPC, "SCREEN_LEVELUP_MANEUVERS", "CHOICE_NEXT", FALSE);
		}

		SetLocalString(oToB, "AddedManeuver" + sData, sData);
		SetLocalInt(oToB, "KnownManeuver" + IntToString(nKnown), StringToInt(sData));
		SetLocalInt(oToB, "KnownManeuverTotal", nKnown + 1);
		PredictDisciplineStatus(nDiscipline, TRUE);
		DisplayManeuversByClass(nLevel, nClass, nLevelCap);
		DisplayAddedManeuvers();
	}
}