@param bonus a Number (such as 2) @param aType "COMBAT.AC.Dodge" or "COMBAT.AC.Dodge.STACK"
(final double bonus, String aType)
| 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 |
no test coverage detected