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

Method setMaster

code/src/java/pcgen/core/PlayerCharacter.java:1370–1587  ·  view source on GitHub ↗

Set the master for this object also set the level dependent stats based on the masters level and info contained in the companionModList Array such as HitDie, SR, BONUS, SA, etc. @param aM The master to be set.

(final Follower aM)

Source from the content-addressed store, hash-verified

1368 * @param aM The master to be set.
1369 */
1370 public void setMaster(final Follower aM)
1371 {
1372 masterFacet.set(id, aM);
1373
1374 final PlayerCharacter mPC = getMasterPC();
1375
1376 if (mPC == null)
1377 {
1378 return;
1379 }
1380
1381 // make sure masters Name and fileName are correct
1382 if (!aM.getFileName().equals(mPC.getFileName()))
1383 {
1384 aM.setFileName(mPC.getFileName());
1385 setDirty(true);
1386 }
1387
1388 if (!aM.getName().equals(mPC.getName()))
1389 {
1390 aM.setName(mPC.getName());
1391 setDirty(true);
1392 }
1393
1394 // Get total wizard + sorcerer levels as they stack like a mother
1395 int mTotalLevel = 0;
1396 int addHD = 0;
1397
1398 for (PCClass mClass : mPC.getClassSet())
1399 {
1400 boolean found = false;
1401
1402 for (CompanionMod cMod : Globals.getContext().getReferenceContext().getManufacturerId(aM.getType())
1403 .getAllObjects())
1404 {
1405 if ((cMod.getLevelApplied(mClass) > 0) && !found)
1406 {
1407 mTotalLevel += getLevel(mClass);
1408 found = true;
1409 }
1410 }
1411 }
1412
1413 List<CompanionMod> newCompanionMods = new ArrayList<>();
1414
1415 // Clear the companionModList so we can add everything to it
1416 Collection<CompanionMod> oldCompanionMods = companionModFacet.removeAll(id);
1417
1418 for (CompanionMod cMod : Globals.getContext().getReferenceContext().getManufacturerId(aM.getType())
1419 .getAllObjects())
1420 {
1421 // Check all the masters classes
1422 for (PCClass mClass : mPC.getClassSet())
1423 {
1424 final int mLev = mPC.getLevel(mClass) + aM.getAdjustment();
1425 final int compLev = cMod.getLevelApplied(mClass);
1426
1427 if (compLev < 0)

Callers 4

refreshCompanionDataMethod · 0.95
addCompanionMethod · 0.80
linkCompanionMethod · 0.80
parseMasterLineMethod · 0.80

Calls 15

getMasterPCMethod · 0.95
getFileNameMethod · 0.95
setDirtyMethod · 0.95
getNameMethod · 0.95
getClassSetMethod · 0.95
getContextMethod · 0.95
getLevelMethod · 0.95
getVariableValueMethod · 0.95
getRaceMethod · 0.95
incrementClassLevelMethod · 0.95
getPCClassMethod · 0.95
getSkillSetMethod · 0.95

Tested by

no test coverage detected