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

Method getPostSizingCostForHead

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

Calculate the parts of the cost for the equipment's head that are not affected by size. @param aPC The character who owns the equipment. @param modifierCosts The array of costs to be doubled if the location demands it @param primaryHead Are we calculating for the primary or alternate head. @return

(final PlayerCharacter aPC,
		final List<BigDecimal> modifierCosts, boolean primaryHead)

Source from the content-addressed store, hash-verified

801 * @return The cost, non doubling cost and total plus of the head
802 */
803 private EquipmentHeadCostSummary getPostSizingCostForHead(final PlayerCharacter aPC,
804 final List<BigDecimal> modifierCosts, boolean primaryHead)
805 {
806 EquipmentHeadCostSummary costSum = new EquipmentHeadCostSummary();
807 EquipmentHead head = getEquipmentHeadReference(primaryHead ? 1 : 2);
808
809 if (head != null)
810 {
811 for (EquipmentModifier eqMod : head.getSafeListFor(ListKey.EQMOD))
812 {
813 int iCount = getSelectCorrectedAssociationCount(eqMod);
814
815 if (iCount < 1)
816 {
817 iCount = 1;
818 }
819
820 BigDecimal eqModCost;
821 Formula cost = eqMod.getSafe(FormulaKey.COST);
822 String costFormula = cost.toString();
823
824 if (hasAssociations(eqMod) && !costFormula.equals(EqModCost.getCost(eqMod, getFirstAssociation(eqMod))))
825 {
826 eqModCost = BigDecimal.ZERO;
827
828 for (String assoc : getAssociationList(eqMod))
829 {
830 String v = calcEqModCost(aPC, EqModCost.getCost(eqMod, assoc), primaryHead);
831 final BigDecimal thisModCost = new BigDecimal(v);
832 eqModCost = eqModCost.add(thisModCost);
833
834 if (!EqModCost.getCostDouble(eqMod))
835 {
836 costSum.nonDoubleCost = costSum.nonDoubleCost.add(thisModCost);
837 }
838 else
839 {
840 modifierCosts.add(thisModCost);
841 }
842 }
843
844 iCount = 1;
845 }
846 else
847 {
848 String v = calcEqModCost(aPC, cost.toString(), primaryHead);
849 eqModCost = new BigDecimal(v);
850
851 if (EqModCost.getCostDouble(eqMod))
852 {
853 modifierCosts.add(eqModCost);
854 }
855 else
856 {
857 costSum.nonDoubleCost = costSum.nonDoubleCost.add(eqModCost);
858 }
859 }
860

Callers 1

getCostMethod · 0.95

Calls 15

hasAssociationsMethod · 0.95
getCostMethod · 0.95
getFirstAssociationMethod · 0.95
getAssociationListMethod · 0.95
calcEqModCostMethod · 0.95
getCostDoubleMethod · 0.95
getSafeMethod · 0.80
getSafeListForMethod · 0.65
toStringMethod · 0.65
equalsMethod · 0.65

Tested by

no test coverage detected