| 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 | } |