MCPcopy Create free account
hub / github.com/PCGen/pcgen / getCost

Method getCost

code/src/java/pcgen/core/Equipment.java:641–756  ·  view source on GitHub ↗

Gets the cost attribute of the Equipment object @param aPC The PC with the Equipment @return The cost value

(final PlayerCharacter aPC)

Source from the content-addressed store, hash-verified

639 * @return The cost value
640 */
641 public BigDecimal getCost(final PlayerCharacter aPC)
642 {
643 BigDecimal c = BigDecimal.ZERO;
644
645 if (this.isVirtual())
646 {
647 return c;
648 }
649
650 //
651 // Do pre-sizing cost increment.
652 // eg. in the case of adamantine armor, want to add
653 // the cost of the metal before the armor gets resized.
654 //
655 c = c.add(getPreSizingCostForHead(aPC, true));
656 c = c.add(getPreSizingCostForHead(aPC, false));
657
658 // c has cost of the item's modifications at the item's original size
659
660 BigDecimal currentcost = get(ObjectKey.CURRENT_COST);
661 if (currentcost == null)
662 {
663 currentcost = getSafe(ObjectKey.COST);
664 }
665 BigDecimal itemCost = currentcost.add(c);
666
667 final List<BigDecimal> modifierCosts = new ArrayList<>();
668
669 calculatingCost = true;
670 weightAlreadyUsed = false;
671
672 EquipmentHeadCostSummary costSum = getPostSizingCostForHead(aPC, modifierCosts, true);
673 BigDecimal nonDoubleCost = costSum.nonDoubleCost;
674 BigDecimal c1 = costSum.postSizeCost;
675 int iPlus = costSum.headPlus;
676
677 //
678 // Get costs from lowest to highest
679 //
680 if (modifierCosts.size() > 1)
681 {
682 Collections.sort(modifierCosts);
683 }
684
685 // Note: When calculating the second head's costs we expect not to see
686 // any modifier costs and discard them if they do occur. These should be
687 // applicable for weapons, which are the only dual headed items currently.
688 EquipmentHeadCostSummary altCostSum = getPostSizingCostForHead(aPC, new ArrayList<>(), false);
689 nonDoubleCost = nonDoubleCost.add(altCostSum.nonDoubleCost);
690 c1 = c1.add(altCostSum.postSizeCost);
691 int altPlus = altCostSum.headPlus;
692
693 calculatingCost = false;
694
695 c1 = c1.add(getCostFromPluses(iPlus, altPlus));
696
697 // Items with values less than 1 gp have their prices rounded up to 1 gp
698 // per item

Callers 3

testGetCostMethod · 0.95
selectClothesMethod · 0.95

Calls 15

isVirtualMethod · 0.95
getCostFromPlusesMethod · 0.95
isAmmunitionMethod · 0.95
isArmorMethod · 0.95
isShieldMethod · 0.95
isWeaponMethod · 0.95
isMagicLimitedTypeMethod · 0.95
ignoresCostDoubleMethod · 0.95
getSafeMethod · 0.80
subtractMethod · 0.80

Tested by 2

testGetCostMethod · 0.76