use of gmgen.plugin.dice.Dice in project pcgen by PCGen.
the class RuleSet method getRule.
/**
* Get the rule
*
* @return rule
* @throws Exception
*/
public Rule getRule() throws Exception {
int rangeTop = getRange();
int modifier;
try {
modifier = Integer.parseInt(allVars.getVal(getId() + "modifier"));
} catch (Exception e) {
modifier = 0;
}
// Determine which entry to choose
Dice die = new Dice(1, rangeTop, 0);
int choice = die.roll();
choice = choice + modifier;
choice = (choice < 0) ? rangeTop : choice;
//select the detail to return
int aWeight = 0;
//Iterate through the list of choices until the weights (from each DataValue) are greater the num chosen as the 'choice'
for (String key : this) {
Rule chkValue = (Rule) allVars.getDataElement(key);
int valueWeight = chkValue.getWeight();
if (valueWeight > 0) {
aWeight = aWeight + valueWeight;
if (aWeight >= choice) {
retRule = chkValue;
return chkValue;
}
}
}
return retRule;
}
use of gmgen.plugin.dice.Dice in project pcgen by PCGen.
the class EncounterPlugin method rollHP.
private static void rollHP(PlayerCharacter aPC) {
CharacterDisplay display = aPC.getDisplay();
for (PCClass pcClass : display.getClassSet()) {
for (int j = 0; j < display.getLevel(pcClass); j++) {
int bonus = (int) aPC.getTotalBonusTo("HD", "MIN") + (int) aPC.getTotalBonusTo("HD", "MIN;CLASS." + pcClass.getKeyName());
int size = display.getLevelHitDie(pcClass, j + 1).getDie();
PCClassLevel classLevel = display.getActiveClassLevel(pcClass, j);
aPC.setHP(classLevel, new Dice(1, size, bonus).roll());
}
}
aPC.setDirty(true);
}
Aggregations