use of pcgen.core.kit.KitStat in project pcgen by PCGen.
the class Kit method processKit.
/**
* The method that actually adds the various items in this Kit to the PC.
* Takes account of Kit Number
*
* @param pc The Player Character object that we will be applying
* the kit to.
* @param thingsToAdd The list of things that will be added by this kit
* wrapped in KitWrapper objects
* @param kitNo An integer that will be used to set the kit number
* in items of equipment added by this kit
*/
public void processKit(final PlayerCharacter pc, final List<BaseKit> thingsToAdd, final int kitNo) {
BigDecimal totalCostToBeCharged = getTotalCostToBeCharged(pc);
if (totalCostToBeCharged != null) {
pc.setGold(pc.getGold().subtract(totalCostToBeCharged));
}
for (KitStat kStat : getStats()) {
kStat.apply(pc);
}
for (BaseKit bk : thingsToAdd) {
bk.apply(pc);
}
pc.setCalcEquipmentList();
if (getSafe(ObjectKey.APPLY_MODE) == KitApply.PERMANENT) {
pc.addKit(this);
}
}
use of pcgen.core.kit.KitStat in project pcgen by PCGen.
the class Kit method testApplyKit.
/**
* Test applying the kit and record the choices made and any warnings
* encountered. Note these changes are made on a copy of the character.
*
* @param aPC PlayerCharacter
* @param thingsToAdd List of kit actions to be taken.
* @param warnings List of issues to be reported to the user.
* @param subkit Is this kit being added by a parent kit?
*/
public void testApplyKit(PlayerCharacter aPC, List<BaseKit> thingsToAdd, List<String> warnings, boolean subkit) {
// Ensure a reset of random values from a prior run
selectValue = -1;
// We will create a copy of the PC since we may need to add classes and
// levels to the PC that the user may choose not to apply.
// NOTE: These methods need to be called in the correct order.
PlayerCharacter tempPC = subkit ? aPC : aPC.clone();
for (KitStat kStat : getStats()) {
kStat.testApply(this, tempPC, warnings);
}
for (BaseKit bk : getSafeListFor(ListKey.KIT_TASKS)) {
if (!PrereqHandler.passesAll(bk.getPrerequisiteList(), tempPC, this)) {
continue;
}
if (selectValue != -1 && bk.isOptional() && !bk.isOption(tempPC, selectValue)) {
continue;
}
if (bk.testApply(this, tempPC, warnings)) {
thingsToAdd.add(bk);
}
}
BigDecimal totalCostToBeCharged = getTotalCostToBeCharged(tempPC);
if (totalCostToBeCharged != null) {
BigDecimal pcGold = tempPC.getGold();
if (pcGold.compareTo(BigDecimal.ZERO) >= 0 && pcGold.compareTo(totalCostToBeCharged) < 0) {
warnings.add("Could not purchase kit. Not enough funds.");
} else {
tempPC.setGold(pcGold.subtract(totalCostToBeCharged));
}
}
}
use of pcgen.core.kit.KitStat in project pcgen by PCGen.
the class StatToken method process.
@Override
public boolean process(LoadContext context, Kit obj) {
for (BaseKit bk : obj.getSafeListFor(ListKey.KIT_TASKS)) {
if (bk instanceof KitStat) {
obj.removeFromListFor(ListKey.KIT_TASKS, bk);
obj.addStat((KitStat) bk);
}
}
return true;
}
Aggregations