function CRoll(intSideCount, intDieCount, intModifier, intMin)
{
	// Prepare the result members
	this.m_aThrows = new Array();
	this.m_intTotal = 0;

	// Protect from non-number parameters
	if (intSideCount/1 != intSideCount) return;
	if (intDieCount/1 != intDieCount) intDieCount = 1;
	if (intModifier/1 != intModifier) intModifier = 0;

	for (intThrowIndex = 0; intThrowIndex < intDieCount; intThrowIndex++)
	{
		var intDieRoll = Math.floor( (Math.random() * intSideCount) + 1 );
		this.m_aThrows[intThrowIndex] = intDieRoll;
		this.m_intTotal += intDieRoll;
	}

	this.m_intTotal += intModifier;

	if (intMin/1 != intMin) return;
	if (this.m_intTotal < intMin)
	{
		this.m_intTotal = intMin;
	}
}

function CRolls(intRollCount, intSideCount, intDieCount, intModifier, intMin)
{
	this.m_aRolls = new Array();
	this.m_intTotal = 0;

	// Protect from non-number parameter
	if (intRollCount/1 != intRollCount) return;

	for (intRollIndex = 0; intRollIndex < intRollCount; intRollIndex++)
	{
		this.m_aRolls[intRollIndex] =
			new CRoll(intSideCount, intDieCount, intModifier, intMin);
		this.m_intTotal += this.m_aRolls[intRollIndex].m_intTotal;
	}
}