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

Method processBonus

code/src/java/pcgen/core/BonusManager.java:531–603  ·  view source on GitHub ↗

- Get's a list of dependencies from aBonus - Finds all active bonuses that add to those dependencies and have not been processed and recursively calls itself - Once recursed in, it adds the computed bonus to activeBonusMap @param aBonus The bonus to be processed. @param prevProcessed

(final BonusObj aBonus, final Set<BonusObj> prevProcessed, Set<BonusObj> processedBonuses,
		Map<String, String> nonStackMap, Map<String, String> stackMap)

Source from the content-addressed store, hash-verified

529 * The map of stacking (i.e. total all) bonuses being built up.
530 */
531 private void processBonus(final BonusObj aBonus, final Set<BonusObj> prevProcessed, Set<BonusObj> processedBonuses,
532 Map<String, String> nonStackMap, Map<String, String> stackMap)
533 {
534 // Make sure we don't get into an infinite loop - can occur due to LST
535 // coding or best guess dependancy mapping
536 if (prevProcessed.contains(aBonus))
537 {
538 if (Logging.isDebugMode())
539 {
540 Logging.log(Logging.DEBUG, "Ignoring bonus loop for " //$NON-NLS-1$
541 + aBonus + " as it was already processed. Bonuses already processed: " //$NON-NLS-1$
542 + prevProcessed);
543 Logging.log(Logging.DEBUG, " Depend map is " + aBonus.listDependsMap()); //$NON-NLS-1$
544 }
545 return;
546 }
547 prevProcessed.add(aBonus);
548
549 final List<BonusObj> aList = new ArrayList<>();
550
551 // Go through all bonuses and check to see if they add to
552 // aBonus's dependencies and have not already been processed
553 for (BonusObj newBonus : getActiveBonusList())
554 {
555 if (processedBonuses.contains(newBonus))
556 {
557 continue;
558 }
559
560 if (aBonus.getDependsOn(newBonus.getUnparsedBonusInfoList())
561 || aBonus.getDependsOnBonusName(newBonus.getBonusName()))
562 {
563 aList.add(newBonus);
564 }
565 }
566
567 // go through all the BonusObj's that aBonus depends on
568 // and process them first
569 for (BonusObj newBonus : aList)
570 {
571 // Recursively call itself
572 processBonus(newBonus, prevProcessed, processedBonuses, nonStackMap, stackMap);
573 }
574
575 // Double check that it hasn't been processed yet
576 if (processedBonuses.contains(aBonus))
577 {
578 return;
579 }
580
581 // Add to processed list
582 //Logging.log(Logging.INFO, "Processing bonus " + aBonus + " depends on " + aBonus.listDependsMap());
583 processedBonuses.add(aBonus);
584
585 final CDOMObject anObj = (CDOMObject) getSourceObject(aBonus);
586
587 if (anObj == null)
588 {

Callers 1

buildActiveBonusMapMethod · 0.95

Calls 15

isDebugModeMethod · 0.95
logMethod · 0.95
getActiveBonusListMethod · 0.95
getSourceObjectMethod · 0.95
setActiveBonusStackMethod · 0.95
totalBonusesForTypeMethod · 0.95
listDependsMapMethod · 0.80
getDependsOnMethod · 0.80
getDependsOnBonusNameMethod · 0.80
doubleValueMethod · 0.80

Tested by

no test coverage detected