(final PCClass toClass, final PCClass fromClass, int iCount)
| 5589 | } |
| 5590 | |
| 5591 | public void giveClassesAway(final PCClass toClass, final PCClass fromClass, int iCount) |
| 5592 | { |
| 5593 | if ((toClass == null) || (fromClass == null)) |
| 5594 | { |
| 5595 | return; |
| 5596 | } |
| 5597 | |
| 5598 | // Will take destination class over maximum? |
| 5599 | if (toClass.hasMaxLevel() && (getLevel(toClass) + iCount) > toClass.getSafe(IntegerKey.LEVEL_LIMIT)) |
| 5600 | { |
| 5601 | iCount = toClass.getSafe(IntegerKey.LEVEL_LIMIT) - getLevel(toClass); |
| 5602 | } |
| 5603 | |
| 5604 | // Enough levels to move? |
| 5605 | if ((getLevel(fromClass) <= iCount) || (iCount < 1)) |
| 5606 | { |
| 5607 | return; |
| 5608 | } |
| 5609 | |
| 5610 | final int fromLevel = getLevel(fromClass); |
| 5611 | final int iFromLevel = fromLevel - iCount; |
| 5612 | final int toLevel = getLevel(toClass); |
| 5613 | |
| 5614 | //Capture necessary information |
| 5615 | Integer[] hpArray = new Integer[iCount + toLevel]; |
| 5616 | for (int i = 0; i < iCount; i++) |
| 5617 | { |
| 5618 | PCClassLevel frompcl = getActiveClassLevel(fromClass, i + iFromLevel); |
| 5619 | hpArray[i] = getHP(frompcl); |
| 5620 | } |
| 5621 | for (int i = 0; i < toLevel; i++) |
| 5622 | { |
| 5623 | PCClassLevel topcl = getActiveClassLevel(toClass, i); |
| 5624 | hpArray[i + iCount] = getHP(topcl); |
| 5625 | } |
| 5626 | |
| 5627 | for (int i = 0; i < iCount; i++) |
| 5628 | { |
| 5629 | fromClass.doMinusLevelMods(this, fromLevel - i); |
| 5630 | } |
| 5631 | |
| 5632 | //Do the class level swap |
| 5633 | fromClass.setLevel(iFromLevel, this); |
| 5634 | toClass.setLevel(toLevel + iCount, this); |
| 5635 | |
| 5636 | //Restore capture info to new class |
| 5637 | for (int i = 0; i < iCount + toLevel; i++) |
| 5638 | { |
| 5639 | PCClassLevel topcl = getActiveClassLevel(toClass, i); |
| 5640 | setHP(topcl, hpArray[i]); |
| 5641 | } |
| 5642 | |
| 5643 | // first, change the toClass current PCLevelInfo level |
| 5644 | for (PCLevelInfo pcl : getLevelInfo()) |
| 5645 | { |
| 5646 | if (pcl.getClassKeyName().equals(toClass.getKeyName())) |
| 5647 | { |
| 5648 | final int iTo = (pcl.getClassLevel() + getLevel(toClass)) - toLevel; |
no test coverage detected