static int Roll(StatBlock stats, Skills skill) { int total = 0; // Roll a number of dice equal to the derivative attribute of the skill. // Replace a number of d4 rolls in the total with d8 rolls. // Avg of 4d4 = 10, Avg of 2d4 + 2d8 = 14, for example int attributeScore = stats.GetAttributeScoreFor(GetSkillBaseAttribute(skill)); for (int i = 0; i < attributeScore; i++) { if (i <= stats.GetSkillScore(skill)) { total += Random.Range(1, 9); } else { total += Random.Range(1, 5); } } return(total); }