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

Method getUDamForEffLevel

code/src/java/pcgen/core/PCClass.java:746–801  ·  view source on GitHub ↗

Get the unarmed Damage for this class at the given level. @param aLevel the given level. @param aPC the PC with the level. @param adjustForPCSize whether to adjust the result for the PC's size. @return the unarmed damage string

(int aLevel, final PlayerCharacter aPC, boolean adjustForPCSize)

Source from the content-addressed store, hash-verified

744 * @return the unarmed damage string
745 */
746 String getUDamForEffLevel(int aLevel, final PlayerCharacter aPC, boolean adjustForPCSize)
747 {
748 int pcSize = adjustForPCSize ? aPC.sizeInt() : aPC.racialSizeInt();
749
750 //
751 // Check "Unarmed Strike", then default to "1d3"
752 //
753 String aDamage;
754
755 AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
756 final Equipment eq = ref.silentlyGetConstructedCDOMObject(Equipment.class, "KEY_Unarmed Strike");
757
758 if (eq != null)
759 {
760 aDamage = eq.getDamage(aPC);
761 }
762 else
763 {
764 aDamage = "1d3";
765 }
766
767 // resize the damage as if it were a weapon
768 if (adjustForPCSize)
769 {
770 int defSize = SizeUtilities.getDefaultSizeAdjustment().get(IntegerKey.SIZEORDER);
771 aDamage = Globals.adjustDamage(aDamage, pcSize - defSize);
772 }
773
774 //
775 // Check the UDAM list for monk-like damage
776 //
777 List<CDOMObject> classObjects = new ArrayList<>();
778 //Negative increment to start at highest level until an UDAM is found
779 for (int i = aLevel; i >= 1; i--)
780 {
781 classObjects.add(aPC.getActiveClassLevel(this, i));
782 }
783 classObjects.add(this);
784 for (CDOMObject cdo : classObjects)
785 {
786 List<String> udam = cdo.getListFor(ListKey.UNARMED_DAMAGE);
787 if (udam != null)
788 {
789 if (udam.size() == 1)
790 {
791 aDamage = udam.get(0);
792 }
793 else
794 {
795 aDamage = udam.get(pcSize);
796 }
797 break;
798 }
799 }
800 return aDamage;
801 }
802
803 /**

Callers 1

getUdamForLevelMethod · 0.95

Calls 13

getContextMethod · 0.95
getDamageMethod · 0.95
adjustDamageMethod · 0.95
getReferenceContextMethod · 0.65
getMethod · 0.65
addMethod · 0.65
getListForMethod · 0.65
sizeMethod · 0.65
sizeIntMethod · 0.45
racialSizeIntMethod · 0.45

Tested by

no test coverage detected