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

Method addTemplate

code/src/java/pcgen/core/PlayerCharacter.java:4333–4416  ·  view source on GitHub ↗
(final PCTemplate inTemplate)

Source from the content-addressed store, hash-verified

4331 }
4332
4333 public boolean addTemplate(final PCTemplate inTemplate)
4334 {
4335 if (inTemplate == null)
4336 {
4337 return false;
4338 }
4339
4340 // Don't allow multiple copies of template.
4341 if (hasTemplate(inTemplate))
4342 {
4343 return false;
4344 }
4345
4346 int lockMonsterSkillPoints = 0; // this is what this value was before
4347 // adding this template
4348 for (PCClass pcClass : getClassSet())
4349 {
4350 if (pcClass.isMonster())
4351 {
4352 lockMonsterSkillPoints = (int) getTotalBonusTo("MONSKILLPTS", "LOCKNUMBER");
4353 break;
4354 }
4355 }
4356
4357 boolean added = templateInputFacet.add(id, inTemplate);
4358
4359 if (!added)
4360 {
4361 return false;
4362 }
4363
4364 this.setDirty(true);
4365
4366 calcActiveBonuses();
4367 // adding this template
4368 boolean first = true;
4369 for (PCClass pcClass : getClassSet())
4370 {
4371 if (pcClass.isMonster())
4372 {
4373 int postLockMonsterSkillPoints =
4374 (int) getTotalBonusTo("MONSKILLPTS", "LOCKNUMBER"); // this is what this value was before
4375
4376 if (postLockMonsterSkillPoints != lockMonsterSkillPoints && postLockMonsterSkillPoints > 0)
4377 {
4378 for (PCLevelInfo pi : getLevelInfo())
4379 {
4380 final int newSkillPointsGained = recalcSkillPointMod(pcClass, pi.getClassLevel());
4381 if (pi.getClassKeyName().equals(pcClass.getKeyName()))
4382 {
4383 final int formerGained = pi.getSkillPointsGained(this);
4384 pi.setSkillPointsGained(this, newSkillPointsGained);
4385 pi.setSkillPointsRemaining(
4386 pi.getSkillPointsRemaining() + newSkillPointsGained - formerGained);
4387 setSkillPool(pcClass, pcClass.getSkillPool(this) + newSkillPointsGained - formerGained);
4388 }
4389 }
4390 }

Callers 15

testListMethod · 0.95
testPositionalMethod · 0.95
testListMetricMethod · 0.95
testBonusSlotMethod · 0.95
testGetBaseStatForMethod · 0.95
testGetTotalStatForMethod · 0.95
testMinValueStatMethod · 0.95
testSizeModMethod · 0.95
testAddAbilityMethod · 0.95
testAddFeatAbilityMethod · 0.95
testAddLevelAbilityMethod · 0.95

Calls 15

hasTemplateMethod · 0.95
getClassSetMethod · 0.95
getTotalBonusToMethod · 0.95
setDirtyMethod · 0.95
calcActiveBonusesMethod · 0.95
getLevelInfoMethod · 0.95
recalcSkillPointModMethod · 0.95
setSkillPoolMethod · 0.95
getLevelMethod · 0.95
equalsMethod · 0.95
getLevelHitDieMethod · 0.95
rollHPMethod · 0.95

Tested by 15

testListMethod · 0.76
testPositionalMethod · 0.76
testListMetricMethod · 0.76
testBonusSlotMethod · 0.76
testGetBaseStatForMethod · 0.76
testGetTotalStatForMethod · 0.76
testMinValueStatMethod · 0.76
testSizeModMethod · 0.76
testAddAbilityMethod · 0.76
testAddFeatAbilityMethod · 0.76
testAddLevelAbilityMethod · 0.76