use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class LoadFacet method getLoadMultForSize.
/**
* Returns the Load Multiplier for the size of the Player Character
* identified by the given CharID.
*
* @param id
* The CharID identifying the Player Character for which the Load
* Multiplier will be returned.
* @return The Load Multiplier for the size of the Player Character
* identified by the given CharID
*/
private double getLoadMultForSize(CharID id) {
SizeAdjustment sadj = sizeFacet.get(id);
double mult = SettingsHandler.getGame().getLoadInfo().getSizeAdjustment(sadj).doubleValue();
mult += bonusCheckingFacet.getBonus(id, "LOADMULT", "TYPE=SIZE");
return mult;
}
use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class WeaponToken method getMonkUnarmed.
private static String getMonkUnarmed(PlayerCharacter pc, Equipment eq, String damString) {
if (eq.isMonk() && eq.isUnarmed()) {
int eqSize = pc.getDisplay().getRace().getSafe(FormulaKey.SIZE).resolve(pc, "").intValue();
int iMod = pc.getDisplay().sizeInt();
/* This modifies damage (by size) from the default when the race is
* not the default size and the character is the default size for
* their race */
boolean applySize = (eqSize == iMod);
String uDamString = UnarmedDamageDisplay.getUnarmedDamageString(pc, false, applySize);
StringTokenizer bTok = new StringTokenizer(damString, " d+-", false);
bTok.nextToken();
String b1String = bTok.nextToken();
StringTokenizer cTok = new StringTokenizer(uDamString, " d+-", false);
cTok.nextToken();
String c1String = cTok.nextToken();
if (Integer.parseInt(b1String) < Integer.parseInt(c1String)) {
damString = uDamString;
}
/*
* This modifies damage by size when the character is a different size
* than the race. It also modifies it by applying any Bonuses to damage
* size.
*/
iMod += (int) pc.getTotalBonusTo("WEAPONPROF=Unarmed Strike", "DAMAGESIZE");
iMod += (int) pc.getTotalBonusTo("COMBAT", "DAMAGESIZE");
/* If not applying the race size modifier, then damString will
* represent the damage as if this Character were the default
* size. Set eqSize to adjust from damage for the default size,
* not the race's actual size.
*/
if (!applySize) {
final SizeAdjustment defAdj = SizeUtilities.getDefaultSizeAdjustment();
if (defAdj != null) {
eqSize = defAdj.get(IntegerKey.SIZEORDER);
}
}
damString = Globals.adjustDamage(damString, eqSize, iMod);
}
return damString;
}
use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class SizeIntegrationTest method setUp.
@Override
@Before
public void setUp() throws PersistenceLayerException, URISyntaxException {
super.setUp();
SizeAdjustment ps = BuildUtilities.createSize("Small", 0);
primaryContext.getReferenceContext().importObject(ps);
SizeAdjustment pm = BuildUtilities.createSize("Medium", 1);
primaryContext.getReferenceContext().importObject(pm);
SizeAdjustment ss = BuildUtilities.createSize("Small", 0);
secondaryContext.getReferenceContext().importObject(ss);
SizeAdjustment sm = BuildUtilities.createSize("Medium", 1);
secondaryContext.getReferenceContext().importObject(sm);
}
use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class KitGear method testApply.
@Override
public boolean testApply(Kit aKit, PlayerCharacter aPC, List<String> warnings) {
actingQuantity = quantity;
actingCost = maxCost;
actingMods = mods == null ? null : new ArrayList<>(mods);
actingLocation = theLocationStr;
if (size != null) {
actingSize = size.get();
}
theEquipment = null;
theQty = 0;
theLocation = "";
theCost = BigDecimal.ZERO;
processLookups(aKit, aPC);
int aBuyRate = aKit.getBuyRate(aPC);
final BigDecimal pcGold = aPC.getGold();
final BigDecimal fixedTotalCost = aKit.getTotalCost(aPC);
if (fixedTotalCost != null) {
// We are going to charge fr the kit once, rather than for every piece of gear
aBuyRate = 0;
}
List<Equipment> eqList = new ArrayList<>(equip.getContainedObjects());
if (actingCost != null) {
final BigDecimal bdMaxCost = new BigDecimal(Integer.toString(actingCost));
for (Iterator<Equipment> i = eqList.iterator(); i.hasNext(); ) {
if (i.next().getCost(aPC).compareTo(bdMaxCost) > 0) {
i.remove();
}
}
}
if (eqList.size() == 1) {
theEquipment = eqList.get(0);
} else {
List<Equipment> selected = new ArrayList<>(1);
selected = Globals.getChoiceFromList("Choose equipment", eqList, selected, 1, aPC);
if (selected.size() == 1) {
theEquipment = selected.get(0);
}
}
//
// TODO: Check to see if the user has selected an item that
// requires modification (MOD:R)
theEquipment = theEquipment.clone();
//
// Resize item for character--never resize weapons or ammo, unless it's a
// natural (weapon)
boolean tryResize = false;
SizeAdjustment sizeToSet = aPC.getSizeAdjustment();
if (actingSize == null) {
if (theEquipment.isType("Natural") || (sizeToPC != null && sizeToPC) || (!theEquipment.isWeapon() && !theEquipment.isAmmunition())) {
tryResize = Globals.canResizeHaveEffect(theEquipment, null);
}
} else {
if (sizeToPC != null && sizeToPC) {
tryResize = Globals.canResizeHaveEffect(theEquipment, null);
} else {
sizeToSet = actingSize;
tryResize = true;
}
}
if (tryResize) {
theEquipment.resizeItem(aPC, sizeToSet);
} else {
// We need setBase() called. The only way to do that is to resize.
// We will set the size to itself.
theEquipment.resizeItem(aPC, theEquipment.getSafe(ObjectKey.SIZE).get());
}
//
if (actingMods != null) {
for (EqModRef modref : actingMods) {
/*
* Going to do this the long way for now to avoid ugly entanglements
*/
StringBuilder sb = new StringBuilder(50);
EquipmentModifier eqMod = modref.getRef().get();
sb.append(eqMod.getKeyName());
for (String assoc : modref.getChoices()) {
sb.append(Constants.PIPE).append(eval(aPC, assoc));
}
theEquipment.addEqModifiers(sb.toString(), true);
}
}
if (tryResize || (actingMods != null)) {
theEquipment.nameItemFromModifiers(aPC);
}
if (actingQuantity == null) {
theQty = 1;
} else {
theQty = actingQuantity.resolve(aPC, "").intValue();
}
int origQty = theQty;
final BigDecimal eqCost = theEquipment.getCost(aPC);
if (aBuyRate != 0) {
if (fixedTotalCost == null) {
final BigDecimal bdBuyRate = new BigDecimal(Integer.toString(aBuyRate)).multiply(new BigDecimal("0.01"));
// Check to see if the PC can afford to buy this equipment. If
// not, then decrement the quantity and try again.
theCost = eqCost.multiply(new BigDecimal(Integer.toString(theQty))).multiply(bdBuyRate);
while (theQty > 0) {
if (// PC has enough?
theCost.compareTo(pcGold) <= 0) {
break;
}
theCost = eqCost.multiply(new BigDecimal(Integer.toString(--theQty))).multiply(bdBuyRate);
}
}
aPC.setGold(aPC.getGold().subtract(theCost));
}
boolean outOfFunds = false;
if (theQty != origQty) {
outOfFunds = true;
}
if (outOfFunds) {
warnings.add("GEAR: Could not purchase " + (origQty - theQty) + " " + theEquipment.getName() + ". Not enough funds.");
}
//
if (theQty == 0) {
return false;
}
Equipment testApplyEquipment = theEquipment.clone();
// Temporarily add the equipment so we can see if we can equip it.
testApplyEquipment.setQty(new Float(theQty));
aPC.addEquipment(testApplyEquipment);
Equipment theTarget = null;
if (actingLocation != null) {
theLocation = actingLocation;
if (!theLocation.equalsIgnoreCase("DEFAULT") && !theLocation.equalsIgnoreCase(Constants.EQUIP_LOCATION_CARRIED) && !theLocation.equalsIgnoreCase(Constants.EQUIP_LOCATION_NOTCARRIED) && !theLocation.equalsIgnoreCase(Constants.EQUIP_LOCATION_EQUIPPED)) {
theTarget = EquipmentUtilities.findEquipmentByBaseKey(aPC.getEquipmentMasterList(), theLocation);
} else if (theLocation.equalsIgnoreCase("DEFAULT")) {
theLocation = "";
}
EquipSet eSet = null;
if (theTarget != null) {
eSet = aPC.getEquipSetForItem(aPC.getEquipSetByIdPath(EquipSet.DEFAULT_SET_PATH), theTarget);
}
if (eSet == null) {
eSet = aPC.getEquipSetByIdPath(EquipSet.DEFAULT_SET_PATH);
}
if (eSet == null) {
warnings.add("GEAR: Could not find location " + theLocation + " for gear " + testApplyEquipment.getName() + ".");
return false;
} else {
EquipSet eqSet = aPC.addEquipToTarget(eSet, theTarget, theLocation, testApplyEquipment, new Float(-1.0f));
if (eqSet == null) {
warnings.add("GEAR: Could not equip " + testApplyEquipment.getName() + " to " + theLocation);
}
}
}
return true;
}
use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class SizeIntegrationTest method setUp.
@Override
@Before
public void setUp() throws PersistenceLayerException, URISyntaxException {
super.setUp();
SizeAdjustment ps = BuildUtilities.createSize("Small", 0);
primaryContext.getReferenceContext().importObject(ps);
SizeAdjustment pm = BuildUtilities.createSize("Medium", 1);
primaryContext.getReferenceContext().importObject(pm);
SizeAdjustment ss = BuildUtilities.createSize("Small", 0);
secondaryContext.getReferenceContext().importObject(ss);
SizeAdjustment sm = BuildUtilities.createSize("Medium", 1);
secondaryContext.getReferenceContext().importObject(sm);
}
Aggregations