public static void addDomainsUpToLevel(PCClass cl, final int aLevel, final PlayerCharacter aPC) { // any domains set by level would have already been saved // and don't need to be re-set at level up time if (aPC.isImporting()) { return; } /* * Note this uses ALL of the domains up to and including this level, * because there is the possibility (albeit strange) that the PC was not * qualified at a previous level change, but the PlayerCharacter is now * qualified for the given Domain. Even this has quirks, since it is * only applied at the time of level increase, but I think that quirk * should be resolved by a CDOM system around 6.0 - thpr 10/23/06 */ for (QualifiedObject<CDOMSingleRef<Domain>> qo : cl.getSafeListFor(ListKey.DOMAIN)) { CDOMSingleRef<Domain> ref = qo.getObject(aPC, cl); if (ref != null) { addDomain(aPC, cl, ref.resolvesTo()); } } for (int i = 0; i <= aLevel; i++) { // TODO This stinks for really high level characters - can this ever // get null back? PCClassLevel pcl = aPC.getActiveClassLevel(cl, i); for (QualifiedObject<CDOMSingleRef<Domain>> qo : pcl.getSafeListFor(ListKey.DOMAIN)) { CDOMSingleRef<Domain> ref = qo.getObject(aPC, cl); if (ref != null) { addDomain(aPC, cl, ref.resolvesTo()); } } } }
public static void removeDomainsForLevel( PCClass cl, final int removedLevel, final PlayerCharacter aPC) { /* * Note this uses ALL of the domains up to and including this level, * because there is the possibility (albeit strange) that the PC was * qualified at a previous level change, but the PlayerCharacter is now * not qualified for the given Domain. Even this has quirks, since it is * only applied at the time of level increase, but I think that quirk * should be resolved by a CDOM system around 6.0 - thpr 10/23/06 */ for (QualifiedObject<CDOMSingleRef<Domain>> qo : cl.getSafeListFor(ListKey.DOMAIN)) { CDOMSingleRef<Domain> ref = qo.getObject(aPC, cl); if (ref == null) { ref = qo.getRawObject(); aPC.removeDomain(ref.resolvesTo()); } } for (int i = 0; i <= removedLevel; i++) { // TODO This stinks for really high level characters - can this ever // get null back? PCClassLevel pcl = aPC.getActiveClassLevel(cl, i); for (QualifiedObject<CDOMSingleRef<Domain>> qo : pcl.getSafeListFor(ListKey.DOMAIN)) { CDOMSingleRef<Domain> ref = qo.getObject(aPC, cl); if ((ref == null) || (i == removedLevel)) { ref = qo.getRawObject(); aPC.removeDomain(ref.resolvesTo()); } } } }
/* * CONSIDER Why does this not inherit classSkillChoices? */ public void inheritAttributesFrom(final PCClass otherClass) { Boolean hbss = otherClass.get(ObjectKey.HAS_BONUS_SPELL_STAT); if (hbss != null) { put(ObjectKey.HAS_BONUS_SPELL_STAT, hbss); CDOMSingleRef<PCStat> bss = otherClass.get(ObjectKey.BONUS_SPELL_STAT); if (bss != null) { put(ObjectKey.BONUS_SPELL_STAT, bss); } } Boolean usbs = otherClass.get(ObjectKey.USE_SPELL_SPELL_STAT); if (usbs != null) { put(ObjectKey.USE_SPELL_SPELL_STAT, usbs); } Boolean cwss = otherClass.get(ObjectKey.CASTER_WITHOUT_SPELL_STAT); if (cwss != null) { put(ObjectKey.CASTER_WITHOUT_SPELL_STAT, cwss); } CDOMSingleRef<PCStat> ss = otherClass.get(ObjectKey.SPELL_STAT); if (ss != null) { put(ObjectKey.SPELL_STAT, ss); } TransitionChoice<CDOMListObject<Spell>> slc = otherClass.get(ObjectKey.SPELLLIST_CHOICE); if (slc != null) { put(ObjectKey.SPELLLIST_CHOICE, slc); } List<QualifiedObject<CDOMReference<Equipment>>> e = otherClass.getListFor(ListKey.EQUIPMENT); if (e != null) { addAllToListFor(ListKey.EQUIPMENT, e); } List<WeaponProfProvider> wp = otherClass.getListFor(ListKey.WEAPONPROF); if (wp != null) { addAllToListFor(ListKey.WEAPONPROF, wp); } QualifiedObject<Boolean> otherWP = otherClass.get(ObjectKey.HAS_DEITY_WEAPONPROF); if (otherWP != null) { put(ObjectKey.HAS_DEITY_WEAPONPROF, otherWP); } List<ArmorProfProvider> ap = otherClass.getListFor(ListKey.AUTO_ARMORPROF); if (ap != null) { addAllToListFor(ListKey.AUTO_ARMORPROF, ap); } List<ShieldProfProvider> sp = otherClass.getListFor(ListKey.AUTO_SHIELDPROF); if (sp != null) { addAllToListFor(ListKey.AUTO_SHIELDPROF, sp); } List<BonusObj> bonusList = otherClass.getListFor(ListKey.BONUS); if (bonusList != null) { addAllToListFor(ListKey.BONUS, bonusList); } try { ownBonuses(this); } catch (CloneNotSupportedException ce) { // TODO Auto-generated catch block ce.printStackTrace(); } for (VariableKey vk : otherClass.getVariableKeys()) { put(vk, otherClass.get(vk)); } if (otherClass.containsListFor(ListKey.CSKILL)) { removeListFor(ListKey.CSKILL); addAllToListFor(ListKey.CSKILL, otherClass.getListFor(ListKey.CSKILL)); } if (otherClass.containsListFor(ListKey.LOCALCCSKILL)) { removeListFor(ListKey.LOCALCCSKILL); addAllToListFor(ListKey.LOCALCCSKILL, otherClass.getListFor(ListKey.LOCALCCSKILL)); } removeListFor(ListKey.KIT_CHOICE); addAllToListFor(ListKey.KIT_CHOICE, otherClass.getSafeListFor(ListKey.KIT_CHOICE)); remove(ObjectKey.REGION_CHOICE); if (otherClass.containsKey(ObjectKey.REGION_CHOICE)) { put(ObjectKey.REGION_CHOICE, otherClass.get(ObjectKey.REGION_CHOICE)); } removeListFor(ListKey.SAB); addAllToListFor(ListKey.SAB, otherClass.getSafeListFor(ListKey.SAB)); /* * TODO Does this need to have things from the Class Level objects? * I don't think so based on deferred processing of levels... */ addAllToListFor(ListKey.DAMAGE_REDUCTION, otherClass.getListFor(ListKey.DAMAGE_REDUCTION)); for (CDOMReference<Vision> ref : otherClass.getSafeListMods(Vision.VISIONLIST)) { for (AssociatedPrereqObject apo : otherClass.getListAssociations(Vision.VISIONLIST, ref)) { putToList(Vision.VISIONLIST, ref, apo); } } /* * TODO This is a clone problem, but works for now - thpr 10/3/08 */ if (otherClass instanceof SubClass) { levelMap.clear(); copyLevelsFrom(otherClass); } addAllToListFor(ListKey.NATURAL_WEAPON, otherClass.getListFor(ListKey.NATURAL_WEAPON)); put(ObjectKey.LEVEL_HITDIE, otherClass.get(ObjectKey.LEVEL_HITDIE)); }
/* (non-Javadoc) * @see pcgen.core.facade.SpellSupportFacade#getClassInfo(pcgen.core.facade.ClassFacade) */ @Override public String getClassInfo(ClassFacade spellcaster) { if (!(spellcaster instanceof PCClass)) { return ""; } PCClass aClass = (PCClass) spellcaster; SpellSupportForPCClass spellSupport = pc.getSpellSupport(aClass); int highestSpellLevel = spellSupport.getHighestLevelSpell(pc); final HtmlInfoBuilder b = new HtmlInfoBuilder(); b.append("<table border=1><tr><td><font size=-2><b>"); // $NON-NLS-1$ b.append(OutputNameFormatting.piString(aClass, false)).append(" ["); // $NON-NLS-1$ b.append( String.valueOf( charDisplay.getLevel(aClass) + (int) pc.getTotalBonusTo("PCLEVEL", aClass.getKeyName()))); // $NON-NLS-1$ b.append("]</b></font></td>"); // $NON-NLS-1$ for (int i = 0; i <= highestSpellLevel; ++i) { b.append("<td><font size=-2><b><center> "); // $NON-NLS-1$ b.append(String.valueOf(i)); b.append(" </b></center></font></td>"); // $NON-NLS-1$ } b.append("</tr>"); // $NON-NLS-1$ b.append("<tr><td><font size=-1><b>Cast</b></font></td>"); // $NON-NLS-1$ for (int i = 0; i <= highestSpellLevel; ++i) { b.append("<td><font size=-1><center>"); // $NON-NLS-1$ b.append(getNumCast(aClass, i, pc)); b.append("</center></font></td>"); // $NON-NLS-1$ } b.append("</tr>"); // $NON-NLS-1$ // Making sure KnownList can be handled safely and produces the correct behaviour if (spellSupport.hasKnownList() || spellSupport.hasKnownSpells(pc)) { b.append("<tr><td><font size=-1><b>Known</b></font></td>"); // $NON-NLS-1$ for (int i = 0; i <= highestSpellLevel; ++i) { final int a = spellSupport.getKnownForLevel(i, pc); final int bonus = spellSupport.getSpecialtyKnownForLevel(i, pc); b.append("<td><font size=-1><center>"); // $NON-NLS-1$ b.append(String.valueOf(a)); if (bonus > 0) { b.append('+').append(Integer.toString(bonus)); } b.append("</center></font></td>"); // $NON-NLS-1$ } b.append("</tr>"); // $NON-NLS-1$ } b.append("<tr><td><font size=-1><b>DC</b></font></td>"); // $NON-NLS-1$ for (int i = 0; i <= highestSpellLevel; ++i) { b.append("<td><font size=-1><center>"); // $NON-NLS-1$ b.append(String.valueOf(getDC(aClass, i, pc))); b.append("</center></font></td>"); // $NON-NLS-1$ } b.append("</tr></table>"); // $NON-NLS-1$ b.appendI18nElement("InfoSpells.caster.type", aClass.getSpellType()); // $NON-NLS-1$ b.appendLineBreak(); b.appendI18nElement("InfoSpells.stat.bonus", aClass.getSpellBaseStat()); // $NON-NLS-1$ if (pc.hasAssocs(aClass, AssociationKey.SPECIALTY) || charDisplay.hasDomains()) { boolean needComma = false; StringBuilder schoolInfo = new StringBuilder(); String spec = pc.getAssoc(aClass, AssociationKey.SPECIALTY); if (spec != null) { schoolInfo.append(spec); needComma = true; } for (Domain d : charDisplay.getSortedDomainSet()) { if (needComma) { schoolInfo.append(','); } needComma = true; schoolInfo.append(d.getKeyName()); } b.appendLineBreak(); b.appendI18nElement("InfoSpells.school", schoolInfo.toString()); // $NON-NLS-1$ } Set<String> set = new TreeSet<>(); for (SpellProhibitor sp : aClass.getSafeListFor(ListKey.PROHIBITED_SPELLS)) { set.addAll(sp.getValueList()); } Collection<? extends SpellProhibitor> prohibList = charDisplay.getProhibitedSchools(aClass); if (prohibList != null) { for (SpellProhibitor sp : prohibList) { set.addAll(sp.getValueList()); } } if (!set.isEmpty()) { b.appendLineBreak(); b.appendI18nElement( "InfoSpells.prohibited.school", //$NON-NLS-1$ StringUtil.join(set, ",")); // $NON-NLS-1$ } String bString = SourceFormat.getFormattedString(aClass, Globals.getSourceDisplay(), true); if (bString.length() > 0) { b.appendLineBreak(); b.appendI18nElement("in_source", bString); // $NON-NLS-1$ } return b.toString(); }