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

Method setBonusStackFor

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

@param bonus a Number (such as 2) @param aType "COMBAT.AC.Dodge" or "COMBAT.AC.Dodge.STACK"

(final double bonus, String aType)

Source from the content-addressed store, hash-verified

5805 * @param aType "COMBAT.AC.Dodge" or "COMBAT.AC.Dodge.STACK"
5806 */
5807 public void setBonusStackFor(final double bonus, String aType)
5808 {
5809 String bType = (aType != null) ? aType.toUpperCase() : null;
5810
5811 // Default to non-stacking bonuses
5812 int index = -1;
5813
5814 // e.g. "COMBAT.AC.DODGE"
5815 if (aType != null)
5816 {
5817 final StringTokenizer aTok = new StringTokenizer(bType, ".");
5818 if (aTok.countTokens() >= 2)
5819 {
5820
5821 // we need to get the 3rd token to see
5822 // if it should .STACK or .REPLACE
5823 aTok.nextToken(); // Discard token
5824 String aString = aTok.nextToken();
5825 String nextTok = null;
5826
5827 // if the 3rd token is "BASE" we have something like
5828 // CHECKS.BASE.Fortitude
5829 // Type: .DODGE
5830 if ("BASE".equals(aString))
5831 {
5832 if (aTok.hasMoreTokens())
5833 {
5834 // discard next token (Fortitude)
5835 aTok.nextToken();
5836 }
5837
5838 }
5839 if (aTok.hasMoreTokens())
5840 {
5841 // check for a TYPE
5842 nextTok = aTok.nextToken();
5843 }
5844
5845 if (nextTok != null)
5846 {
5847 index = SettingsHandler.getGameAsProperty().get().getUnmodifiableBonusStackList().indexOf(nextTok); // e.g.
5848 // Dodge
5849 }
5850
5851 // un-named (or un-TYPE'd) bonus should stack
5852 if ((nextTok == null) || "NULL".equals(nextTok))
5853 {
5854 index = 1;
5855 }
5856 }
5857 }
5858 // .STACK means stack
5859 // .REPLACE stacks with other .REPLACE bonuses
5860 if ((bType != null) && (bType.endsWith(".STACK") || bType.endsWith(".REPLACE")))
5861 {
5862 index = 1;
5863 }
5864

Callers 1

calcBonusMethod · 0.80

Calls 11

getGameAsPropertyMethod · 0.95
getBonusMapMethod · 0.95
putBonusMapMethod · 0.95
nextTokenMethod · 0.80
hasMoreTokensMethod · 0.80
equalsMethod · 0.65
indexOfMethod · 0.65
getMethod · 0.65
valueOfMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected