Search in sources :

Example 31 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PCGVer2Parser method parseTempBonusLine.

/**
	 * ###############################################################
	 * Temporary Bonuses
	 * ###############################################################
	 * @param line
	 **/
private void parseTempBonusLine(final String line) {
    PCGTokenizer tokens;
    try {
        tokens = new PCGTokenizer(line);
    } catch (PCGParseException pcgpex) {
        final String message = "Illegal TempBonus line ignored: " + line + Constants.LINE_SEPARATOR + "Error: " + pcgpex.getMessage();
        warnings.add(message);
        return;
    }
    String cTag = null;
    String tName = null;
    boolean active = true;
    for (PCGElement element : tokens.getElements()) {
        final String tag = element.getName();
        if (IOConstants.TAG_TEMPBONUS.equals(tag)) {
            cTag = EntityEncoder.decode(element.getText());
        } else if (IOConstants.TAG_TEMPBONUSTARGET.equals(tag)) {
            tName = EntityEncoder.decode(element.getText());
        } else if (IOConstants.TAG_TEMPBONUSACTIVE.equals(tag)) {
            active = element.getText().endsWith(IOConstants.VALUE_Y);
        }
    }
    if ((cTag == null) || (tName == null)) {
        warnings.add("Illegal TempBonus line ignored: " + line);
        return;
    }
    //$NON-NLS-1$
    final StringTokenizer aTok = new StringTokenizer(cTag, "=", false);
    if (aTok.countTokens() < 2) {
        return;
    }
    final String cType = aTok.nextToken();
    final String cKey = aTok.nextToken();
    Equipment aEq = null;
    if (!tName.equals(IOConstants.TAG_PC)) {
        // bonus is applied to an equipment item
        // so create a new one and add to PC
        final Equipment eq = thePC.getEquipmentNamed(tName);
        if (eq == null) {
            return;
        }
        aEq = eq.clone();
        //aEq.setWeight("0");
        aEq.resetTempBonusList();
    }
    for (PCGElement element : tokens.getElements()) {
        final String tag = element.getName();
        final String bonus;
        if (IOConstants.TAG_TEMPBONUSBONUS.equals(tag)) {
            bonus = EntityEncoder.decode(element.getText());
        } else {
            continue;
        }
        if ((bonus == null) || (bonus.length() <= 0)) {
            continue;
        }
        BonusObj newB = null;
        Object creator = null;
        LoadContext context = Globals.getContext();
        // type of object to set as the creator
        if (cType.equals(IOConstants.TAG_FEAT)) {
            for (AbilityCategory aCat : SettingsHandler.getGame().getAllAbilityCategories()) {
                Ability a = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, aCat, cKey);
                if (a != null) {
                    newB = Bonus.newBonus(context, bonus);
                    creator = a;
                    break;
                }
            }
        } else if (cType.equals(IOConstants.TAG_EQUIPMENT)) {
            Equipment aEquip = thePC.getEquipmentNamed(cKey);
            if (aEquip == null) {
                aEquip = context.getReferenceContext().silentlyGetConstructedCDOMObject(Equipment.class, cKey);
            }
            if (aEquip != null) {
                newB = Bonus.newBonus(context, bonus);
                creator = aEquip;
            }
        } else if (cType.equals(IOConstants.TAG_CLASS)) {
            final PCClass aClass = thePC.getClassKeyed(cKey);
            if (aClass == null) {
                continue;
            }
            int idx = bonus.indexOf('|');
            newB = Bonus.newBonus(context, bonus.substring(idx + 1));
            creator = aClass;
        } else if (cType.equals(IOConstants.TAG_TEMPLATE)) {
            PCTemplate aTemplate = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCTemplate.class, cKey);
            if (aTemplate != null) {
                newB = Bonus.newBonus(context, bonus);
                creator = aTemplate;
            }
        } else if (cType.equals(IOConstants.TAG_SKILL)) {
            Skill aSkill = context.getReferenceContext().silentlyGetConstructedCDOMObject(Skill.class, cKey);
            if (aSkill != null) {
                newB = Bonus.newBonus(context, bonus);
                creator = aSkill;
            }
        } else if (cType.equals(IOConstants.TAG_SPELL)) {
            final Spell aSpell = context.getReferenceContext().silentlyGetConstructedCDOMObject(Spell.class, cKey);
            if (aSpell != null) {
                newB = Bonus.newBonus(context, bonus);
                creator = aSpell;
            }
        } else if (cType.equals(IOConstants.TAG_NAME)) {
            newB = Bonus.newBonus(context, bonus);
        //newB.setCreatorObject(thePC);
        }
        if (newB == null) {
            return;
        }
        TempBonusInfo tempBonusInfo;
        // Check to see if the target was the PC or an Item
        if (tName.equals(IOConstants.TAG_PC)) {
            thePC.setApplied(newB, true);
            tempBonusInfo = thePC.addTempBonus(newB, creator, thePC);
        } else {
            thePC.setApplied(newB, true);
            aEq.addTempBonus(newB);
            tempBonusInfo = thePC.addTempBonus(newB, creator, aEq);
        }
        if (!active) {
            String bonusName = BonusDisplay.getBonusDisplayName(tempBonusInfo);
            thePC.setTempBonusFilter(bonusName);
        }
    }
    if (aEq != null) {
        aEq.setAppliedName(cKey);
        thePC.addTempBonusItemList(aEq);
    }
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) SpecialAbility(pcgen.core.SpecialAbility) BonusObj(pcgen.core.bonus.BonusObj) PCClass(pcgen.core.PCClass) Spell(pcgen.core.spell.Spell) CharacterSpell(pcgen.core.character.CharacterSpell) TempBonusInfo(pcgen.core.BonusManager.TempBonusInfo) StringTokenizer(java.util.StringTokenizer) Skill(pcgen.core.Skill) Equipment(pcgen.core.Equipment) LoadContext(pcgen.rules.context.LoadContext) CDOMObject(pcgen.cdom.base.CDOMObject) AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject) PObject(pcgen.core.PObject) PCTemplate(pcgen.core.PCTemplate) AbilityCategory(pcgen.core.AbilityCategory)

Example 32 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PCGVer2Parser method parseClassLine.

/*
	 * ###############################################################
	 * Character Class(es) methods
	 * ###############################################################
	 */
private void parseClassLine(final String line) throws PCGParseException {
    final PCGTokenizer tokens;
    try {
        tokens = new PCGTokenizer(line);
    } catch (PCGParseException pcgpex) {
        /*
			 * Classes are critical for characters,
			 * need to stop the load process
			 *
			 * Thomas Behr 14-08-02
			 */
        throw new PCGParseException("parseClassLine", line, //$NON-NLS-1$
        pcgpex.getMessage());
    }
    PCClass aPCClass = null;
    String tag;
    PCGElement element;
    final Iterator<PCGElement> it = tokens.getElements().iterator();
    // the first element defines the class key name!!!
    if (it.hasNext()) {
        element = it.next();
        String classKey = EntityEncoder.decode(element.getText());
        // First check for an existing class, say from a racial casting ability
        aPCClass = thePC.getClassKeyed(classKey);
        if (aPCClass == null) {
            aPCClass = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, classKey);
            if (aPCClass != null) {
                // Icky: Need to redesign the way classes work!
                // Icky: Having to clone the class here is UGLY!
                aPCClass = aPCClass.clone();
            } else {
                final String msg = LanguageBundle.getFormattedString(//$NON-NLS-1$
                "Warnings.PCGenParser.CouldntAddClass", element.getText());
                warnings.add(msg);
                return;
            }
        }
    }
    int level = -1;
    int skillPool = -1;
    String subClassKey = Constants.NONE;
    while (it.hasNext()) {
        element = it.next();
        tag = element.getName();
        if (IOConstants.TAG_SUBCLASS.equals(tag)) {
            subClassKey = EntityEncoder.decode(element.getText());
            if ((!subClassKey.isEmpty()) && !subClassKey.equals(Constants.NONE)) {
                SubClass sc = aPCClass.getSubClassKeyed(subClassKey);
                if (sc == null) {
                    if (subClassKey.equals(aPCClass.getKeyName())) {
                        subClassKey = Constants.NONE;
                    } else {
                        final String msg = LanguageBundle.getFormattedString(//$NON-NLS-1$
                        "Warnings.PCGenParser.InvalidSubclass", element.getText());
                        warnings.add(msg);
                    }
                }
            }
        }
        if (IOConstants.TAG_LEVEL.equals(tag)) {
            try {
                level = Integer.parseInt(element.getText());
            } catch (NumberFormatException nfe) {
                final String msg = LanguageBundle.getFormattedString(//$NON-NLS-1$
                "Warnings.PCGenParser.InvalidLevel", element.getText());
                warnings.add(msg);
            }
        } else if (IOConstants.TAG_SKILLPOOL.equals(tag)) {
            try {
                skillPool = Integer.parseInt(element.getText());
            } catch (NumberFormatException nfe) {
                final String msg = LanguageBundle.getFormattedString(//$NON-NLS-1$
                "Warnings.PCGenParser.InvalidSkillPool", element.getText());
                warnings.add(msg);
            }
        } else if (IOConstants.TAG_CANCASTPERDAY.equals(tag)) {
        // TODO
        } else if (IOConstants.TAG_SPELLBASE.equals(tag)) {
            final String spellBase = EntityEncoder.decode(element.getText());
            if (!Constants.NONE.equals(spellBase)) {
                Globals.getContext().unconditionallyProcess(aPCClass, "SPELLSTAT", spellBase);
            }
        } else if (IOConstants.TAG_PROHIBITED.equals(tag)) {
            String prohib = EntityEncoder.decode(element.getText());
            StringTokenizer st = new StringTokenizer(prohib, Constants.COMMA);
            while (st.hasMoreTokens()) {
                String choice = st.nextToken();
                if (!"None".equalsIgnoreCase(choice)) {
                    SpellProhibitor prohibSchool = new SpellProhibitor();
                    prohibSchool.setType(ProhibitedSpellType.SCHOOL);
                    prohibSchool.addValue(choice);
                    SpellProhibitor prohibSubSchool = new SpellProhibitor();
                    prohibSubSchool.setType(ProhibitedSpellType.SUBSCHOOL);
                    prohibSubSchool.addValue(choice);
                    thePC.addProhibitedSchool(prohibSchool, aPCClass);
                    thePC.addProhibitedSchool(prohibSubSchool, aPCClass);
                }
            }
        }
    }
    if (level > -1) {
        thePC.addClass(aPCClass);
        if (StringUtils.isNotBlank(subClassKey) && !subClassKey.equals(Constants.NONE)) {
            SubClassApplication.setSubClassKey(thePC, aPCClass, subClassKey);
        }
        for (int i = 0; i < level; ++i) {
            PCLevelInfo levelInfo = thePC.addLevelInfo(aPCClass.getKeyName());
            aPCClass.addLevel(false, false, thePC, true);
        }
    }
    //Must process ADD after CLASS is added to the PC
    for (PCGElement e : new PCGTokenizer(line).getElements()) {
        tag = e.getName();
        if (tag.equals(IOConstants.TAG_ADDTOKEN)) {
            parseAddTokenInfo(e, aPCClass);
        }
    }
    if (skillPool > -1) {
        thePC.setSkillPool(aPCClass, skillPool);
    }
}
Also used : SubClass(pcgen.core.SubClass) StringTokenizer(java.util.StringTokenizer) PCLevelInfo(pcgen.core.pclevelinfo.PCLevelInfo) PCClass(pcgen.core.PCClass) SpellProhibitor(pcgen.core.SpellProhibitor)

Example 33 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PCGVer2Creator method appendClassLines.

/*
	 * ###############################################################
	 * Character Class(es) methods
	 * ###############################################################
	 */
private void appendClassLines(StringBuilder buffer) {
    Cache specials = new Cache();
    for (PCClass pcClass : charDisplay.getClassSet()) {
        int classLevel = charDisplay.getLevel(pcClass);
        buffer.append(IOConstants.TAG_CLASS).append(':');
        buffer.append(EntityEncoder.encode(pcClass.getKeyName()));
        final String subClassKey = charDisplay.getSubClassName(pcClass);
        if (subClassKey != null && !Constants.EMPTY_STRING.equals(subClassKey)) {
            buffer.append('|');
            buffer.append(IOConstants.TAG_SUBCLASS).append(':');
            buffer.append(EntityEncoder.encode(subClassKey));
        }
        buffer.append('|');
        buffer.append(IOConstants.TAG_LEVEL).append(':');
        buffer.append(classLevel);
        buffer.append('|');
        buffer.append(IOConstants.TAG_SKILLPOOL).append(':');
        Integer currentPool = thePC.getSkillPool(pcClass);
        buffer.append(currentPool == null ? 0 : currentPool);
        // determine if this class can cast spells
        boolean isCaster = false;
        if (!thePC.getSpellSupport(pcClass).canCastSpells(thePC)) {
            isCaster = true;
        }
        boolean isPsionic = thePC.getSpellSupport(pcClass).hasKnownList() && !isCaster;
        if (isCaster || isPsionic) {
            buffer.append('|');
            buffer.append(IOConstants.TAG_SPELLBASE).append(':');
            buffer.append(EntityEncoder.encode(pcClass.getSpellBaseStat()));
            buffer.append('|');
            buffer.append(IOConstants.TAG_CANCASTPERDAY).append(':');
            buffer.append(StringUtil.join(thePC.getSpellSupport(pcClass).getCastListForLevel(classLevel), ","));
        }
        Collection<? extends SpellProhibitor> prohib = charDisplay.getProhibitedSchools(pcClass);
        if (prohib != null) {
            Set<String> set = new TreeSet<>();
            for (SpellProhibitor sp : prohib) {
                set.addAll(sp.getValueList());
            }
            if (!set.isEmpty()) {
                buffer.append('|');
                buffer.append(IOConstants.TAG_PROHIBITED).append(':');
                buffer.append(EntityEncoder.encode(StringUtil.join(set, ",")));
            }
        }
        appendAddTokenInfo(buffer, pcClass);
        buffer.append(IOConstants.LINE_SEP);
        String spec = thePC.getAssoc(pcClass, AssociationKey.SPECIALTY);
        if (spec != null) {
            specials.put(pcClass.getKeyName() + IOConstants.TAG_SPECIALTY + '0', spec);
        }
        String key;
        key = pcClass.getKeyName() + IOConstants.TAG_SAVE + '0';
        List<? extends SpecialAbility> salist = charDisplay.getUserSpecialAbilityList(pcClass);
        if (salist != null && !salist.isEmpty()) {
            SpecialAbility sa = salist.get(0);
            specials.put(pcClass.getKeyName() + IOConstants.TAG_SA + 0, sa.getKeyName());
        }
        for (BonusObj save : thePC.getSaveableBonusList(pcClass)) {
            specials.put(key, "BONUS|" + save);
        }
        for (int i = 1; i <= charDisplay.getLevel(pcClass); i++) {
            key = pcClass.getKeyName() + IOConstants.TAG_SAVE + (i - 1);
            PCClassLevel pcl = charDisplay.getActiveClassLevel(pcClass, i);
            for (BonusObj save : thePC.getSaveableBonusList(pcl)) {
                specials.put(key, "BONUS|" + save);
            }
        }
    }
    //
    for (PCLevelInfo pcl : charDisplay.getLevelInfo()) {
        final String classKeyName = pcl.getClassKeyName();
        int lvl = pcl.getClassLevel() - 1;
        PCClass pcClass = thePC.getClassKeyed(classKeyName);
        buffer.append(IOConstants.TAG_CLASSABILITIESLEVEL).append(':');
        if (pcClass == null) {
            pcClass = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, classKeyName);
            if (pcClass != null) {
                pcClass = thePC.getClassKeyed(pcClass.get(ObjectKey.EX_CLASS).get().getKeyName());
            }
        }
        if (pcClass != null) {
            buffer.append(EntityEncoder.encode(pcClass.getKeyName()));
        } else {
            //$NON-NLS-1$
            buffer.append(EntityEncoder.encode("???"));
        }
        buffer.append('=').append(lvl + 1);
        if (pcClass != null) {
            String aKey = charDisplay.getSubstitutionClassName(charDisplay.getActiveClassLevel(pcClass, lvl + 1));
            if (aKey != null) {
                buffer.append('|');
                buffer.append(IOConstants.TAG_SUBSTITUTIONLEVEL).append(':');
                buffer.append(aKey);
            }
            buffer.append('|');
            buffer.append(IOConstants.TAG_HITPOINTS).append(':');
            PCClassLevel classLevel = charDisplay.getActiveClassLevel(pcClass, lvl);
            Integer hp = charDisplay.getHP(classLevel);
            buffer.append(hp == null ? 0 : hp);
            appendSpecials(buffer, specials.get(pcClass.getKeyName() + IOConstants.TAG_SAVE + lvl), IOConstants.TAG_SAVES, IOConstants.TAG_SAVE, lvl);
            appendSpecials(buffer, specials.get(pcClass.getKeyName() + IOConstants.TAG_SPECIALTY + lvl), IOConstants.TAG_SPECIALTIES, IOConstants.TAG_SPECIALTY, lvl);
            appendSpecials(buffer, specials.get(pcClass.getKeyName() + IOConstants.TAG_SA + lvl), IOConstants.TAG_SPECIALABILITIES, IOConstants.TAG_SA, lvl);
            if (lvl == 0) {
                appendSpecials(buffer, specials.get(pcClass.getKeyName() + IOConstants.TAG_SA + (lvl - 1)), IOConstants.TAG_SPECIALABILITIES, IOConstants.TAG_SA, -1);
            }
            //
            // Remember what choices were made for each of the ADD: tags
            //
            appendAddTokenInfo(buffer, charDisplay.getActiveClassLevel(pcClass, lvl + 1));
        }
        List<PCLevelInfoStat> statList = pcl.getModifiedStats(true);
        if (statList != null) {
            for (PCLevelInfoStat stat : statList) {
                buffer.append('|').append(IOConstants.TAG_PRESTAT).append(':').append(stat.toString());
            }
        }
        statList = pcl.getModifiedStats(false);
        if (statList != null) {
            for (PCLevelInfoStat stat : statList) {
                buffer.append('|').append(IOConstants.TAG_PRESTAT).append(':').append(stat.toString());
            }
        }
        int sp = pcl.getSkillPointsGained(thePC);
        //if (sp != 0)
        {
            buffer.append('|').append(IOConstants.TAG_SKILLPOINTSGAINED).append(':').append(sp);
        }
        sp = pcl.getSkillPointsRemaining();
        //if (sp != 0)
        {
            buffer.append('|').append(IOConstants.TAG_SKILLPOINTSREMAINING).append(':').append(sp);
        }
        buffer.append(IOConstants.LINE_SEP);
    }
}
Also used : PCLevelInfoStat(pcgen.core.pclevelinfo.PCLevelInfoStat) BonusObj(pcgen.core.bonus.BonusObj) SpecialAbility(pcgen.core.SpecialAbility) PCClass(pcgen.core.PCClass) SpellProhibitor(pcgen.core.SpellProhibitor) PCClassLevel(pcgen.cdom.inst.PCClassLevel) TreeSet(java.util.TreeSet) PCLevelInfo(pcgen.core.pclevelinfo.PCLevelInfo)

Example 34 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PCGVer2Parser method parseSkillLine.

/*
	 * ###############################################################
	 * Character Skills methods
	 * ###############################################################
	 */
private void parseSkillLine(final String line) {
    final PCGTokenizer tokens;
    try {
        tokens = new PCGTokenizer(line);
    } catch (PCGParseException pcgpex) {
        final String message = "Illegal Skill line ignored: " + line + Constants.LINE_SEPARATOR + "Error: " + pcgpex.getMessage();
        warnings.add(message);
        return;
    }
    Skill aSkill = null;
    final Iterator<PCGElement> it = tokens.getElements().iterator();
    // the first element defines the skill key name!!!
    String skillKey = "";
    if (it.hasNext()) {
        final PCGElement element = it.next();
        skillKey = EntityEncoder.decode(element.getText());
        aSkill = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Skill.class, skillKey);
    }
    while (it.hasNext()) {
        final PCGElement element = it.next();
        final String tag = element.getName();
        if (IOConstants.TAG_SYNERGY.equals(tag)) {
        // TODO
        // for now it's ok to ignore it!
        } else if (IOConstants.TAG_OUTPUTORDER.equals(tag)) {
            int outputindex = 0;
            try {
                outputindex = Integer.parseInt(element.getText());
            } catch (NumberFormatException nfe) {
            // This is not critical.
            // Maybe warn the user?
            }
            if (aSkill != null) {
                thePC.setSkillOrder(aSkill, outputindex);
            }
        } else if (IOConstants.TAG_CLASSBOUGHT.equals(tag)) {
            PCGElement childClass = null;
            PCGElement childRanks = null;
            for (PCGElement child : element.getChildren()) {
                if (IOConstants.TAG_CLASS.equals(child.getName())) {
                    childClass = child;
                } else if (IOConstants.TAG_RANKS.equals(child.getName())) {
                    childRanks = child;
                }
            }
            if (childClass == null) {
                final String message = "Invalid class/ranks specification: " + line;
                warnings.add(message);
                continue;
            }
            if (childRanks == null) {
                final String message = "Invalid class/ranks specification: " + line;
                warnings.add(message);
                continue;
            }
            //None for a class is a special key word.  It is used when a familiar inherits a skill from its master
            PCClass aPCClass = null;
            if (//$NON-NLS-1$
            !childClass.getText().equals("None")) {
                final String childClassKey = EntityEncoder.decode(childClass.getText());
                aPCClass = thePC.getClassKeyed(childClassKey);
                if (aPCClass == null) {
                    final String message = "Could not find class: " + childClassKey;
                    warnings.add(message);
                    continue;
                }
            }
            if (aSkill == null) {
                // We only need to report this if the skill had ranks.
                final String message = "Could not add skill: " + skillKey;
                warnings.add(message);
                return;
            }
            try {
                double ranks = Double.parseDouble(childRanks.getText());
                SkillRankControl.modRanks(ranks, aPCClass, true, thePC, aSkill);
            } catch (NumberFormatException nfe) {
                final String message = "Invalid ranks specification: " + childRanks.getText();
                warnings.add(message);
                continue;
            }
        } else if (aSkill != null && IOConstants.TAG_ASSOCIATEDDATA.equals(tag)) {
            String key = EntityEncoder.decode(element.getText());
            ChoiceManagerList<Object> controller = ChooserUtilities.getConfiguredController(aSkill, thePC, null, new ArrayList<>());
            if (controller != null) {
                String[] assoc = key.split(Constants.COMMA, -1);
                for (String string : assoc) {
                    controller.restoreChoice(thePC, aSkill, string);
                }
            } else {
                warnings.add("Failed to find choose controller for skill " + aSkill);
            }
        } else if (aSkill != null && tag.equals(IOConstants.TAG_LEVELABILITY)) {
            parseLevelAbilityInfo(element, aSkill);
        } else if (aSkill != null && tag.equals(IOConstants.TAG_ADDTOKEN)) {
            parseAddTokenInfo(element, aSkill);
        }
    }
}
Also used : Skill(pcgen.core.Skill) ArrayList(java.util.ArrayList) ChoiceManagerList(pcgen.core.chooser.ChoiceManagerList) PCClass(pcgen.core.PCClass)

Example 35 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PCGVer2Creator method appendWeaponProficiencyLines.

/*
	 * ###############################################################
	 * Character Weapon proficiencies methods
	 * ###############################################################
	 */
private void appendWeaponProficiencyLines(StringBuilder buffer) {
    final int size = charDisplay.getWeaponProfSet().size();
    if (size > 0) {
        /*
			 * since aPC.getWeaponProfList() returns a TreeSet,
			 * we have to put them into an array first.
			 * we do not use TreeSet's toArray()-method since it
			 * makes no guarantees on element order.
			 *
			 * author: Thomas Behr 08-09-02
			 */
        final String[] weaponProficiencies = new String[size];
        int j = 0;
        for (WeaponProf wp : charDisplay.getSortedWeaponProfs()) {
            weaponProficiencies[j++] = wp.getKeyName();
        }
        // as per Mynex's request do not write more than 10 weapons per line
        final int step = 10;
        final int times = (size / step) + (((size % step) > 0) ? 1 : 0);
        for (int k = 0; k < times; ++k) {
            buffer.append(IOConstants.TAG_WEAPONPROF).append(':');
            buffer.append('[');
            String del = Constants.EMPTY_STRING;
            int stop = Math.min(size, (k * step) + 10);
            for (int i = k * step; i < stop; ++i) {
                buffer.append(del);
                buffer.append(IOConstants.TAG_WEAPON).append(':');
                buffer.append(EntityEncoder.encode(weaponProficiencies[i]));
                //$NON-NLS-1$
                del = "|";
            }
            buffer.append(']');
            buffer.append(IOConstants.LINE_SEP);
        }
    }
    //
    // Save any selected racial bonus weapons
    //
    appendWeaponProficiencyLines(buffer, charDisplay.getRace());
    //
    for (PCTemplate pct : charDisplay.getTemplateSet()) {
        appendWeaponProficiencyLines(buffer, pct);
    }
    //
    for (final PCClass pcClass : charDisplay.getClassSet()) {
        appendWeaponProficiencyLines(buffer, pcClass);
    }
}
Also used : WeaponProf(pcgen.core.WeaponProf) PCTemplate(pcgen.core.PCTemplate) PCClass(pcgen.core.PCClass)

Aggregations

PCClass (pcgen.core.PCClass)359 Test (org.junit.Test)96 PlayerCharacter (pcgen.core.PlayerCharacter)61 Skill (pcgen.core.Skill)55 ArrayList (java.util.ArrayList)35 Domain (pcgen.core.Domain)30 LoadContext (pcgen.rules.context.LoadContext)28 PCClassLevel (pcgen.cdom.inst.PCClassLevel)26 CDOMObject (pcgen.cdom.base.CDOMObject)23 CharacterSpell (pcgen.core.character.CharacterSpell)20 Spell (pcgen.core.spell.Spell)20 StringTokenizer (java.util.StringTokenizer)19 CharID (pcgen.cdom.enumeration.CharID)19 ClassSource (pcgen.cdom.helper.ClassSource)19 PreClassTester (plugin.pretokens.test.PreClassTester)16 SkillCost (pcgen.cdom.enumeration.SkillCost)15 ParseResult (pcgen.rules.persistence.token.ParseResult)15 Ability (pcgen.core.Ability)14 Race (pcgen.core.Race)14 BonusObj (pcgen.core.bonus.BonusObj)14