use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class PreSizeTester method getTargetSizeInt.
private int getTargetSizeInt(String size) {
AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
SizeAdjustment sa = ref.silentlyGetConstructedCDOMObject(SizeAdjustment.class, size);
return sa.get(IntegerKey.SIZEORDER);
}
use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class WieldCategory method adjustForSize.
/**
* Get the WieldCategory adjusted for the size difference between the weapon
* and the PC. This uses the 3.5 equipment sizes.
*
* @param pc
* Player character to get the weild category for.
* @param eq
* Equipment to get the weild category for.
* @return The ajusted WieldCategory
*/
public WieldCategory adjustForSize(final PlayerCharacter pc, final Equipment eq) {
if (pc == null || eq == null || eq.get(ObjectKey.WIELD) == null) {
return this;
}
// Check if we have a bonus that changes the weapons effective size
// for wield purposes.
SizeAdjustment oldEqSa = eq.getSizeAdjustment();
if (pc.sizeInt() != eq.sizeInt()) {
int aBump = 0;
aBump += (int) pc.getTotalBonusTo("WIELDCATEGORY", eq.getWieldName());
aBump += (int) pc.getTotalBonusTo("WIELDCATEGORY", "ALL");
// loops for each equipment type
int modWield = 0;
for (String eqType : eq.typeList()) {
final StringBuilder sB = new StringBuilder("WEAPONPROF=TYPE.");
sB.append(eqType);
// get the type bonus (ex TYPE.MARTIAL)
final int i = (int) pc.getTotalBonusTo(sB.toString(), "WIELDCATEGORY");
// get the highest bonus
if (i < modWield) {
modWield = i;
}
}
aBump += modWield;
if (aBump != 0) {
final int newSizeInt = eq.sizeInt() + aBump;
AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
SizeAdjustment sadj = ref.getSortedList(SizeAdjustment.class, IntegerKey.SIZEORDER).get(newSizeInt);
eq.put(ObjectKey.SIZE, CDOMDirectSingleRef.getRef(sadj));
}
}
WieldCategory pcWCat = getSwitch(pc, eq);
eq.put(ObjectKey.SIZE, CDOMDirectSingleRef.getRef(oldEqSa));
return pcWCat;
}
use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class SizeToken method process.
@Override
public boolean process(LoadContext context, PCTemplate template) {
String value = template.get(StringKey.SIZEFORMULA);
if (value == null) {
return true;
}
SizeAdjustment size = context.getReferenceContext().silentlyGetConstructedCDOMObject(SizeAdjustment.class, value);
Formula sizeFormula;
if (size == null) {
sizeFormula = FormulaFactory.getFormulaFor(value);
} else {
sizeFormula = new FixedSizeFormula(CDOMDirectSingleRef.getRef(size));
}
if (!sizeFormula.isValid()) {
Logging.errorPrint("Size in " + getTokenName() + " was not valid: " + sizeFormula.toString(), context);
return false;
}
context.getObjectContext().put(template, FormulaKey.SIZE, sizeFormula);
return false;
}
Aggregations