Gets the cost attribute of the Equipment object @param aPC The PC with the Equipment @return The cost value
(final PlayerCharacter aPC)
| 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 |