Search in sources :

Example 11 with CompanionList

use of pcgen.cdom.list.CompanionList in project pcgen by PCGen.

the class FollowerLimitFacet method add.

private void add(CharID id, FollowerLimit fo, CDOMObject cdo) {
    if (fo == null) {
        throw new IllegalArgumentException("Object to add may not be null");
    }
    CompanionList cl = fo.getCompanionList().get();
    Map<FollowerLimit, Set<CDOMObject>> foMap = getConstructingCachedMap(id, cl);
    Set<CDOMObject> set = foMap.get(fo);
    if (set == null) {
        set = new WrappedMapSet<>(IdentityHashMap.class);
        foMap.put(fo, set);
    }
    set.add(cdo);
}
Also used : Set(java.util.Set) WrappedMapSet(pcgen.base.util.WrappedMapSet) CompanionList(pcgen.cdom.list.CompanionList) CDOMObject(pcgen.cdom.base.CDOMObject) IdentityHashMap(java.util.IdentityHashMap) FollowerLimit(pcgen.cdom.helper.FollowerLimit)

Example 12 with CompanionList

use of pcgen.cdom.list.CompanionList in project pcgen by PCGen.

the class PCGVer2Parser method parseMasterLine.

private void parseMasterLine(final String line) {
    final PCGTokenizer tokens;
    try {
        tokens = new PCGTokenizer(line);
    } catch (PCGParseException pcgpex) {
        final String msg = LanguageBundle.getFormattedString(//$NON-NLS-1$
        "Warnings.PCGenParser.IllegalMaster", line, pcgpex.getMessage());
        warnings.add(msg);
        return;
    }
    final Follower aMaster = new Follower(Constants.EMPTY_STRING, Constants.EMPTY_STRING, null);
    for (PCGElement element : tokens.getElements()) {
        final String tag = element.getName();
        if (IOConstants.TAG_MASTER.equals(tag)) {
            aMaster.setName(EntityEncoder.decode(element.getText()));
        } else if (IOConstants.TAG_TYPE.equals(tag)) {
            String cType = EntityEncoder.decode(element.getText());
            CompanionList cList = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(CompanionList.class, cType);
            if (cList == null) {
                Logging.errorPrint("Cannot find CompanionList: " + cType);
            } else {
                aMaster.setType(cList);
            }
        } else if (IOConstants.TAG_HITDICE.equals(tag)) {
            try {
                aMaster.setUsedHD(Integer.parseInt(element.getText()));
            } catch (NumberFormatException nfe) {
            // nothing we can do about it
            }
        } else if (IOConstants.TAG_FILE.equals(tag)) {
            String inputFileName = EntityEncoder.decode(element.getText());
            String masterFileName = makeFilenameAbsolute(inputFileName);
            if (masterFileName == null) {
                final String msg = LanguageBundle.getFormattedString(//$NON-NLS-1$
                "Warnings.PCGenParser.CantFindMaster", inputFileName);
                warnings.add(msg);
            } else {
                aMaster.setFileName(masterFileName);
            }
        } else if (IOConstants.TAG_ADJUSTMENT.equals(tag)) {
            aMaster.setAdjustment(Integer.parseInt(element.getText()));
        }
    }
    if (!Constants.EMPTY_STRING.equals(aMaster.getFileName()) && !Constants.EMPTY_STRING.equals(aMaster.getName()) && !Constants.EMPTY_STRING.equals(aMaster.getType().toString())) {
        thePC.setMaster(aMaster);
    }
}
Also used : CompanionList(pcgen.cdom.list.CompanionList) Follower(pcgen.core.character.Follower)

Aggregations

CompanionList (pcgen.cdom.list.CompanionList)12 Follower (pcgen.core.character.Follower)6 FollowerOption (pcgen.core.FollowerOption)5 Race (pcgen.core.Race)4 File (java.io.File)3 CDOMObject (pcgen.cdom.base.CDOMObject)3 FollowerLimit (pcgen.cdom.helper.FollowerLimit)3 IdentityHashMap (java.util.IdentityHashMap)2 Set (java.util.Set)2 WrappedMapSet (pcgen.base.util.WrappedMapSet)2 CDOMDirectSingleRef (pcgen.cdom.reference.CDOMDirectSingleRef)2 CDOMSimpleSingleRef (pcgen.cdom.reference.CDOMSimpleSingleRef)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Formula (pcgen.base.formula.Formula)1 ParsingSeparator (pcgen.base.text.ParsingSeparator)1 Ungranted (pcgen.cdom.base.Ungranted)1 DataSet (pcgen.core.DataSet)1 CompanionMod (pcgen.core.character.CompanionMod)1