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

Method getBonusFromName

code/src/java/pcgen/io/PCGVer2Parser.java:339–426  ·  view source on GitHub ↗
(String sName, String tName)

Source from the content-addressed store, hash-verified

337 * return a List of BonusObj's
338 */
339 private Map<BonusObj, TempBonusInfo> getBonusFromName(String sName, String tName)
340 {
341 //sName = NAME=Haste
342 //tName = PC
343 String sourceStr = sName.substring(IOConstants.TAG_TEMPBONUS.length() + 1);
344 String targetStr = tName.substring(IOConstants.TAG_TEMPBONUSTARGET.length() + 1);
345 CDOMObject oSource = null;
346
347 if (sourceStr.startsWith(IOConstants.TAG_FEAT + '='))
348 {
349 sourceStr = sourceStr.substring(5);
350 oSource = Globals.getContext().getReferenceContext().getManufacturerId(AbilityCategory.FEAT)
351 .getActiveObject(sourceStr);
352 oSource = thePC.getAbilityKeyed(AbilityCategory.FEAT, sourceStr);
353 if (oSource == null)
354 {
355 for (final AbilityCategory cat : SettingsHandler.getGameAsProperty().get().getAllAbilityCategories())
356 {
357 Ability abilSourceObj = Globals.getContext().getReferenceContext().getManufacturerId(cat)
358 .getActiveObject(sourceStr);
359 if (abilSourceObj != null)
360 {
361 oSource = abilSourceObj;
362 }
363 }
364 }
365 }
366 else if (sourceStr.startsWith(IOConstants.TAG_SPELL + '='))
367 {
368 sourceStr = sourceStr.substring(6);
369
370 //oSource = aPC.getSpellNamed(sourceStr);
371 oSource =
372 Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Spell.class, sourceStr);
373 }
374 else if (sourceStr.startsWith(IOConstants.TAG_EQUIPMENT + '='))
375 {
376 sourceStr = sourceStr.substring(10);
377 oSource = thePC.getEquipmentNamed(sourceStr);
378 }
379 else if (sourceStr.startsWith(IOConstants.TAG_CLASS + '='))
380 {
381 sourceStr = sourceStr.substring(6);
382 oSource = thePC.getClassKeyed(sourceStr);
383 }
384 else if (sourceStr.startsWith(IOConstants.TAG_TEMPLATE + '='))
385 {
386 sourceStr = sourceStr.substring(9);
387 oSource = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCTemplate.class,
388 sourceStr);
389 }
390 else if (sourceStr.startsWith(IOConstants.TAG_SKILL + '='))
391 {
392 sourceStr = sourceStr.substring(6);
393 Skill aSkill =
394 Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Skill.class, sourceStr);
395 if (thePC.hasSkill(aSkill))
396 {

Callers 1

Calls 15

getContextMethod · 0.95
getGameAsPropertyMethod · 0.95
errorPrintMethod · 0.95
getKeyNameMethod · 0.95
getDisplayNameMethod · 0.95
getAbilityKeyedMethod · 0.80
getEquipmentNamedMethod · 0.80
getActiveObjectMethod · 0.65
getReferenceContextMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected