use of pcgen.core.Race in project pcgen by PCGen.
the class SizeFacet method update.
/**
* Forces a complete update of the size information for the Player Character
* identified by the given CharID.
*
* @param id
* The CharID indicating the Player Character on which to update
* the size information
*/
public void update(CharID id) {
SizeFacetInfo info = getConstructingInfo(id);
int iSize = calcRacialSizeInt(id);
Race race = raceFacet.get(id);
if (race != null) {
// Now check and see if a class has modified
// the size of the character with something like:
// BONUS:SIZEMOD|NUMBER|+1
iSize += (int) bonusCheckingFacet.getBonus(id, "SIZEMOD", "NUMBER");
// Now see if there is a HD advancement in size
// (Such as for Dragons)
iSize += sizesToAdvance(id, race);
//
// Must still be a valid size
//
int maxIndex = Globals.getContext().getReferenceContext().getConstructedObjectCount(SIZEADJUSTMENT_CLASS) - 1;
iSize = Math.min(maxIndex, Math.max(0, iSize));
}
info.sizeInt = iSize;
SizeAdjustment oldSize = info.sizeAdj;
SizeAdjustment newSize = Globals.getContext().getReferenceContext().getSortedList(SizeAdjustment.class, IntegerKey.SIZEORDER).get(sizeInt(id));
info.sizeAdj = newSize;
if (oldSize != newSize) {
if (oldSize != null) {
fireDataFacetChangeEvent(id, oldSize, DataFacetChangeEvent.DATA_REMOVED);
}
fireDataFacetChangeEvent(id, newSize, DataFacetChangeEvent.DATA_ADDED);
}
}
use of pcgen.core.Race in project pcgen by PCGen.
the class ReachFacet method getReach.
/**
* Returns the Reach for a Player Character represented by the given CharID.
*
* @param id
* The CharID representing the Player Character for which the
* Reach should be returned.
* @return The Reach for the Player Character represented by the given
* CharID
*/
public int getReach(CharID id) {
final Race aRace = raceFacet.get(id);
int reach = 0;
if (aRace != null) {
reach = aRace.getSafe(IntegerKey.REACH);
}
// Scan templates for any overrides
for (PCTemplate template : templateFacet.getSet(id)) {
Integer r = template.get(IntegerKey.REACH);
if (r != null) {
reach = r;
}
}
reach += (int) bonusCheckingFacet.getBonus(id, "COMBAT", "REACH");
return reach;
}
use of pcgen.core.Race in project pcgen by PCGen.
the class UnarmedDamageFacet method getUDamForRace.
/**
* Returns the unarmed damage String for the Race of the Player Character
* identified by the given CharID.
*
* @param id
* The CharID identifying the Player Character
* @return The unarmed damage String for the Race of the Player Character
* identified by the given CharID
*/
public String getUDamForRace(CharID id) {
Race race = raceFacet.get(id);
int iSize = formulaResolvingFacet.resolve(id, race.getSafe(FormulaKey.SIZE), race.getQualifiedKey()).intValue();
SizeAdjustment defAdj = SizeUtilities.getDefaultSizeAdjustment();
SizeAdjustment sizAdj = Globals.getContext().getReferenceContext().getSortedList(SizeAdjustment.class, IntegerKey.SIZEORDER).get(iSize);
if (sizAdj != null) {
return Globals.adjustDamage("1d3", defAdj, sizAdj);
}
return "1d3";
}
use of pcgen.core.Race in project pcgen by PCGen.
the class RaceInputFacet method remove.
public void remove(CharID id) {
Race r = raceFacet.remove(id);
PlayerCharacter pc = trackingFacet.getPC(id);
if (pc.isAllowInteraction() && (r != null)) {
raceSelectionFacet.remove(id, r);
}
}
use of pcgen.core.Race in project pcgen by PCGen.
the class ChooseLst method parseNonEmptyToken.
@Override
protected ParseResult parseNonEmptyToken(LoadContext context, CDOMObject obj, String value) {
if (obj instanceof Ungranted) {
return new ParseResult.Fail("Cannot use " + getTokenName() + " on an Ungranted object type: " + obj.getClass().getSimpleName(), context);
}
if (obj instanceof NonInteractive) {
return new ParseResult.Fail("Cannot use " + getTokenName() + " on an Non-Interactive object type: " + obj.getClass().getSimpleName(), context);
}
String key;
String val;
int pipeLoc = value.indexOf(Constants.PIPE);
if (value.startsWith("FEAT=")) {
key = "FEATEQ";
val = value.substring(5);
} else if (value.startsWith("LANGAUTO:")) {
key = "LANGAUTO";
val = value.substring(9);
} else if (pipeLoc == -1) {
key = value;
val = null;
} else {
key = value.substring(0, pipeLoc);
val = value.substring(pipeLoc + 1);
}
if (!((obj instanceof Ability) || (obj instanceof Domain) || (obj instanceof Race) || (obj instanceof PCTemplate) || (obj instanceof Skill) || (obj instanceof EquipmentModifier))) {
//Allow TEMPBONUS related choose
if (!"NUMBER".equals(key)) {
return new ParseResult.Fail(getTokenName() + " is not supported for " + obj.getClass().getSimpleName(), context);
}
}
if (key.startsWith("NUMCHOICES=")) {
String maxCount = key.substring(11);
if (maxCount == null || maxCount.isEmpty()) {
return new ParseResult.Fail("NUMCHOICES in CHOOSE must be a formula: " + value, context);
}
Formula f = FormulaFactory.getFormulaFor(maxCount);
if (!f.isValid()) {
return new ParseResult.Fail("Number of Choices in " + getTokenName() + " was not valid: " + f.toString(), context);
}
context.getObjectContext().put(obj, FormulaKey.NUMCHOICES, f);
pipeLoc = val.indexOf(Constants.PIPE);
if (pipeLoc == -1) {
key = val;
val = null;
} else {
key = val.substring(0, pipeLoc);
val = val.substring(pipeLoc + 1);
}
}
return context.processSubToken(obj, getTokenName(), key, val);
}
Aggregations