AbilityScoreIncreases = 6; // every 6 levels

// ROLES
function Role( p_aParams )
{
	this.name = p_aParams["name"];
	this.source = p_aParams["source"];
	this.coreAbility = p_aParams["core ability"]; // string
	this.statProgressions =
	{
		"ability scores" : ( p_aParams["ability scores"] ? p_aParams["ability scores"] : AbilityScoreProgressions["every six"] ), // AbilityScoreProgressions[ every six ]
		"combat" : p_aParams["combat"], // CombatProgressions[ very slow | slow | medium | fast ]
		"power" : p_aParams["power"], // PowerProgressions[ none | very slow | slow | medium | fast ]
		"reputation" : p_aParams["reputation"], // RepProgressions[ round down plus one | round off ]
		"fortitude" : p_aParams["fortitude"],
		"reflex" : p_aParams["reflex"],
		"will" : p_aParams["will"]
	}
	this.skillPoints = p_aParams["skill points"];
	this.saveProgression = ( p_aParams["save progression"] ? p_aParams["save progression"] : SaveProgressions["one good, two normal"] );
	
	this.initialLevel = p_aParams["initial level"]; // RoleLevel used in place of level 1 if first this is the character's first role
	this.levels = p_aParams["levels"]; // array of RoleLevels
}

function StatProgression( p_aParams )
{
	this.name = p_aParams["name"];
	this.rate = p_aParams["rate"];
	this.cost = ( p_aParams["cost"] ? p_aParams["cost"] : 0 );
	this.rounding = ( p_aParams["rounding"] ? p_aParams["rounding"] : "round down" ); // round down | round up | round off
	this.bonus = ( p_aParams["bonus"] ? p_aParams["bonus"] : 0 );
	this.bonusApplication = ( p_aParams["bonus application"] ? p_aParams["bonus application"] : "first only" ); // first only | every role
}
AbilityScoreProgressions =
{
	"every six" : new StatProgression
	({
		"name" : "every six",
		"rate" : .167
	})
}
ConvictionProgressions =
{
	"round up plus two" : new StatProgression
	({
		"name" : "round up plus two",
		"rate" : .5,
		"rounding" : "round up",
		"bonus" : 2,
		"bonus application" : "first only"
	})
}
CombatProgressions =
{
	"very slow" : new StatProgression
	({
		"name" : "very slow",
		"rate" : .25,
		"cost" : 1
	}),
	"slow" : new StatProgression
	({
		"name" : "slow",
		"rate" : .5,
		"cost" : 2
	}),
	"medium" : new StatProgression
	({
		"name" : "medium",
		"rate" : .75,
		"cost" : 3
	}),
	"fast" : new StatProgression
	({
		"name" : "fast",
		"rate" : 1,
		"cost" : 4
	})
}
SkillProgressions =
{
	"two" : new StatProgression( {
		"name" : "2",
		"rate" : 2,
		"cost" : .5
	} ),
	"four" : new StatProgression( {
		"name" : "4",
		"rate" : 4,
		"cost" : 1
	} ),
	"six" : new StatProgression( {
		"name" : "6",
		"rate" : 6,
		"cost" : 1.5
	} ),
	"eight" : new StatProgression( {
		"name" : "8",
		"rate" : 8,
		"cost" : 2
	} ),
	"ten" : new StatProgression( {
		"name" : "10",
		"rate" : 10,
		"cost" : 2.5
	} ),
	"twelve" : new StatProgression( {
		"name" : "12",
		"rate" : 12,
		"cost" : 3
	} ),
	"fourteen" : new StatProgression( {
		"name" : "14",
		"rate" : 14,
		"cost" : 3.5
	} ),
	"sixteen" : new StatProgression( {
		"name" : "16",
		"rate" : 16,
		"cost" : 4
	} )
}
PowerProgressions =
{
	"none" : new StatProgression( {
		"name" : "none",
		"rate" : 0,
		"cost" : 0,
		"bonus" : 0,
		"bonus application" : "first only"
	} ),
	"very slow" : new StatProgression( {
		"name" : "very slow",
		"rate" : .25,
		"cost" : .5,
		"bonus" : 0,
		"bonus application" : "first only"
	} ),
	"slow" : new StatProgression( {
		"name" : "slow",
		"rate" : .5,
		"cost" : 1,
		"bonus" : 1,
		"bonus application" : "first only"
	} ),
	"medium" : new StatProgression( {
		"name" : "medium",
		"rate" : .75,
		"cost" : 1.5,
		"bonus" : 2,
		"bonus application" : "first only"
	} ),
	"fast" : new StatProgression( {
		"name" : "fast",
		"rate" : 1,
		"cost" : 2,
		"bonus" : 3,
		"bonus application" : "first only"
	} )
}
SaveRates =
{
	"normal" : new StatProgression( {
		"name" : "normal",
		"rate" : .34,
		"bonus" : 0,
		"bonus application" : "first only"
	} ),
	"medium" : new StatProgression( {
		"name" : "medium",
		"rate" : .4,
		"bonus" : 1,
		"bonus application" : "first only"
	} ),
	"good" : new StatProgression( {
		"name" : "good",
		"rate" : .5,
		"bonus" : 2,
		"bonus application" : "first only"
	} )
}
RepProgressions =
{
	"round down plus one" : new StatProgression( {
		"name" : "round down plus one",
		"rate" : .25,
		"rounding" : "round down",
		"bonus" : 1,
		"bonus application" : "every role"
	} ),
	"round off" : new StatProgression( {
		"name" : "round off",
		"rate" : .25,
		"rounding" : "round off",
		"bonus" : 0,
		"bonus application" : "every role"
	} )
}

function SaveProgression( p_aParams )
{
	this.name = p_aParams["name"]; // normal | medium | good
	this.cost = ( p_aParams["cost"] ? p_aParams["cost"] : 0 ); // 0 | .25
	this.normal = ( p_aParams["normal"] ? p_aParams["normal"] : 0 ); // number of normal saves
	this.medium = ( p_aParams["medium"] ? p_aParams["medium"] : 0 ); // number of medium saves
	this.good = ( p_aParams["good"] ? p_aParams["good"] : 0 ); // number of good saves
}
SaveProgressions = {
	"one good, two normal" : new SaveProgression( {
		"name" : "one good, two normal",
		"cost" : 0,
		"good" : 1,
		"medium" : 0,
		"normal" : 2
	} )
}

function RoleLevel( p_aParams )
{
	this.options = p_aParams["options"]; // array of choices
}

function fInitializeRoles()
{
	var aLevels = null;
	var oInitLevel = null;
	Roles = new Array();
	
	oInitLevel = new RoleLevel
	({
		"options" : new Choices
		({
			"num choices" : 4,
			"options" : new Array
			(
				new Option
				({
					"type" : "ChoiceFeatList",
					"object" : new ChoiceFeatList({ "num times to display" : 4, "feat lists" : new Array( "general", "adept", "adept powers" ) })
				})
			)
		})
	});
	aLevels = new Array();
	for ( var i = 0; i < 20; i++ )
	{
		aLevels.push
		(
			new RoleLevel
			({
				"options" : new Choices
				({
					"num choices" : 1,
					"options" : new Array
					(
						new Option
						({
							"type" : "ChoiceFeatList",
							"object" : new ChoiceFeatList({ "feat lists" : new Array( "general", "adept", "adept powers" ) })
						})
					)
				})
			})
		);
	}
	Roles["adept"] = new Role
	( {
		"name" : "Adept",
		"source" : "True20 Adventure Roleplaying",
		"core ability" : "The Talent",
		"combat" : CombatProgressions["slow"],
		"fortitude" : SaveRates["normal"],
		"reflex" : SaveRates["normal"],
		"will" : SaveRates["good"],
		"skill points" : 4,
		"power" : PowerProgressions["fast"],
		"reputation" : RepProgressions["round down plus one"],
		"initial level" : oInitLevel,
		"levels" : aLevels // array of RoleLevels...
	} )
	
	oInitLevel = new RoleLevel
	({
		"options" : new Choices
		({
			"num choices" : 4,
			"options" : new Array
			(
				new Option({ "type" : "ChoiceFeatList", "object" : new ChoiceFeatList({ "num times to display" : 4, "feat lists" : new Array( "general", "expert" ) }) })
			)
		})
	});
	aLevels = new Array();
	for ( var i = 0; i < 20; i++ )
	{
		aLevels.push
		(
			new RoleLevel
			({
				"options" : new Choices
				({
					"num choices" : 1,
					"options" : new Array
					(
						new Option
						({
							"type" : "ChoiceFeatList",
							"object" : new ChoiceFeatList({ "feat lists" : new Array( "general", "expert" ) })
						})
					)
				})
			})
		);
	}
	Roles["expert"] = new Role
	( {
		"name" : "Expert",
		"source" : "True20 Adventure Roleplaying",
		"core ability" : "Expertise",
		"combat" : CombatProgressions["medium"],
		"fortitude" : SaveRates["normal"],
		"reflex" : SaveRates["good"],
		"will" : SaveRates["normal"],
		"skill points" : 8,
		"power" : PowerProgressions["none"],
		"reputation" : RepProgressions["round down plus one"],
		"initial level" : oInitLevel,
		"levels" : aLevels // array of RoleLevels...
	})
	
	oInitLevel = new RoleLevel
	({
		"options" : new Choices
		({
			"num choices" : 4,
			"options" : new Array
			(
				new Option
				({
					"type" : "Choices",
					"object" : new Choices
					({
						"num choices" : 1,
						"options" : new Array
						(
							new Option({ "type" : "FeatOption", "object" : new FeatOption({ "id" : "firearms training" }) }),
							new Option({ "type" : "FeatOption", "object" : new FeatOption({ "id" : "weapon training" }) })
						)
					})
				}),
				new Option({ "type" : "ChoiceFeatList", "object" : new ChoiceFeatList({ "num times to display" : 3, "feat lists" : new Array( "general", "warrior" ) }) })
			)
		})
	});
	aLevels = new Array();
	for ( var i = 0; i < 20; i++ )
	{
		aLevels.push
		(
			new RoleLevel
			({
				"options" : new Choices
				({
					"num choices" : 1,
					"options" : new Array
					(
						new Option
						({
							"type" : "ChoiceFeatList",
							"object" : new ChoiceFeatList({ "feat lists" : new Array( "general", "warrior" ) })
						})
					)
				})
			})
		);
	}
	Roles["warrior"] = new Role
	( {
		"name" : "Warrior",
		"source" : "True20 Adventure Roleplaying",
		"core ability" : "Determination",
		"combat" : CombatProgressions["fast"],
		"fortitude" : SaveRates["good"],
		"reflex" : SaveRates["normal"],
		"will" : SaveRates["normal"],
		"skill points" : 4,
		"power" : PowerProgressions["none"],
		"reputation" : RepProgressions["round off"],
		"initial level" : oInitLevel,
		"levels" : aLevels // array of RoleLevels...
	} )
	
	fGenerateRoleSelection();
}
