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

Method makeIntoExClass

code/src/java/pcgen/core/PlayerCharacter.java:5187–5274  ·  view source on GitHub ↗
(final PCClass fromClass)

Source from the content-addressed store, hash-verified

5185 }
5186
5187 public void makeIntoExClass(final PCClass fromClass)
5188 {
5189 CDOMSingleRef<PCClass> exc = fromClass.get(ObjectKey.EX_CLASS);
5190
5191 try
5192 {
5193 PCClass cl = exc.get();
5194 PCClass toClass = getClassKeyed(cl.getKeyName());
5195
5196 boolean bClassNew;
5197 int toLevel;
5198 if (toClass == null)
5199 {
5200 toClass = cl.clone(); //Still required :(
5201 bClassNew = true;
5202 toLevel = 0;
5203 } else
5204 {
5205 bClassNew = false;
5206 toLevel = getLevel(toClass);
5207 }
5208
5209 //Capture necessary information
5210 final int fromLevel = getLevel(fromClass);
5211 Integer[] hpArray = new Integer[fromLevel];
5212 for (int i = 0; i < fromLevel; i++)
5213 {
5214 PCClassLevel frompcl = getActiveClassLevel(fromClass, i);
5215 Integer hp = getHP(frompcl);
5216 if (hp == null)
5217 {
5218 System.err.println("Did not find HP for " + fromClass + ' ' + (i + 1) + ' ' + frompcl);
5219 }
5220 hpArray[i] = hp;
5221 }
5222
5223 for (int i = 0; i < fromLevel; i++)
5224 {
5225 fromClass.doMinusLevelMods(this, fromLevel - i);
5226 }
5227 fromClass.setLevel(0, this);
5228
5229 //Do the class swap
5230 if (bClassNew)
5231 {
5232 classFacet.replaceClass(id, fromClass, toClass);
5233 } else
5234 {
5235 classFacet.removeClass(id, fromClass);
5236 }
5237 toClass.setLevel(toLevel + fromLevel, this);
5238
5239 //Restore capture info to new class
5240 for (int i = 0; i < fromLevel; i++)
5241 {
5242 PCClassLevel topcl = getActiveClassLevel(toClass, i);
5243 setHP(topcl, hpArray[i]);
5244 }

Callers 2

testMakeIntoExClassMethod · 0.95

Calls 15

getClassKeyedMethod · 0.95
cloneMethod · 0.95
getLevelMethod · 0.95
getActiveClassLevelMethod · 0.95
getHPMethod · 0.95
setLevelMethod · 0.95
setHPMethod · 0.95
getLevelInfoSizeMethod · 0.95
getClassKeyNameMethod · 0.95
setClassKeyNameMethod · 0.95
getSkillSetMethod · 0.95
replaceClassRankMethod · 0.95

Tested by 1

testMakeIntoExClassMethod · 0.76