Figures out if a bonus should stack based on type, then adds it to the supplied map. @param bonus The value of the bonus. @param fullyQualifiedBonusType The type of the bonus e.g. STAT.DEX:LUCK @param nonStackbonusMap The map of non-stacking (i.e. highest wins) bonu
(double bonus, String fullyQualifiedBonusType, Map<String, String> nonStackbonusMap, Map<String, String> stackingBonusMap)
| 616 | * The map of stacking (i.e. total all) bonuses being built up. |
| 617 | */ |
| 618 | private static void setActiveBonusStack(double bonus, |
| 619 | String fullyQualifiedBonusType, |
| 620 | Map<String, String> nonStackbonusMap, |
| 621 | Map<String, String> stackingBonusMap) |
| 622 | { |
| 623 | if (fullyQualifiedBonusType != null) |
| 624 | { |
| 625 | fullyQualifiedBonusType = fullyQualifiedBonusType.toUpperCase(); |
| 626 | |
| 627 | // only specific bonuses can actually be fractional |
| 628 | // -> TODO should define this in external file |
| 629 | if (!fullyQualifiedBonusType.startsWith("ITEMWEIGHT") && !fullyQualifiedBonusType.startsWith("ITEMCOST") |
| 630 | && !fullyQualifiedBonusType.startsWith("ITEMCAPACITY") && !fullyQualifiedBonusType.startsWith("LOADMULT") |
| 631 | && !fullyQualifiedBonusType.startsWith("FEAT") && (!fullyQualifiedBonusType.contains("DAMAGEMULT"))) |
| 632 | { |
| 633 | bonus = ((int) bonus); // TODO: never used |
| 634 | } |
| 635 | } |
| 636 | else |
| 637 | { |
| 638 | return; |
| 639 | } |
| 640 | |
| 641 | // default to non-stacking bonuses |
| 642 | int index = -1; |
| 643 | |
| 644 | // bonusType is either of form: |
| 645 | // COMBAT.AC |
| 646 | // or |
| 647 | // COMBAT.AC:Luck |
| 648 | // or |
| 649 | // COMBAT.AC:Armor.REPLACE |
| 650 | // |
| 651 | final StringTokenizer aTok = new StringTokenizer(fullyQualifiedBonusType, ":"); |
| 652 | |
| 653 | if (aTok.countTokens() == 2) |
| 654 | { |
| 655 | // need 2nd token to see if it should stack |
| 656 | final String aString; |
| 657 | aTok.nextToken(); |
| 658 | aString = aTok.nextToken(); |
| 659 | |
| 660 | if (aString != null) |
| 661 | { |
| 662 | index = SettingsHandler.getGameAsProperty().get().getUnmodifiableBonusStackList().indexOf(aString); // e.g. |
| 663 | // Dodge |
| 664 | } |
| 665 | } |
| 666 | else |
| 667 | { |
| 668 | // un-named (or un-TYPE'd) bonuses stack |
| 669 | index = 1; |
| 670 | } |
| 671 | |
| 672 | // .STACK means stack with everything |
| 673 | // .REPLACE means stack with other .REPLACE |
| 674 | if (fullyQualifiedBonusType.endsWith(".STACK") || fullyQualifiedBonusType.endsWith(".REPLACE")) |
| 675 | { |
no test coverage detected