Search in sources :

Example 6 with WeaponProf

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

the class AbstractGlobalTargetedSaveRestoreTest method testAutoWeaponProfList.

@Test
public void testAutoWeaponProfList() {
    WeaponProf granted = create(WeaponProf.class, "Granted");
    create(WeaponProf.class, "Ignored");
    T target = create(getObjectClass(), "Target");
    new WeaponProfToken().parseToken(context, target, "%LIST");
    new plugin.lsttokens.choose.WeaponProficiencyToken().parseToken(context, target, "Granted|Ignored");
    additionalChooseSet(target);
    Object o = prepare(target);
    finishLoad();
    assertFalse(pc.hasWeaponProf(granted));
    applyObject(target);
    assertTrue(pc.hasWeaponProf(granted));
    runRoundRobin(getPreEqualityCleanup());
    assertTrue(pc.hasWeaponProf(granted));
    assertTrue(reloadedPC.hasWeaponProf(granted));
    remove(o);
    reloadedPC.setDirty(true);
    if (isSymmetric()) {
        assertFalse(reloadedPC.hasWeaponProf(granted));
    }
}
Also used : WeaponProfToken(plugin.lsttokens.auto.WeaponProfToken) WeaponProf(pcgen.core.WeaponProf) CDOMObject(pcgen.cdom.base.CDOMObject) Test(org.junit.Test)

Example 7 with WeaponProf

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

the class WeaponToken method getWeaponProfTypeBonuses.

private static int getWeaponProfTypeBonuses(PlayerCharacter pc, Equipment eq, String bonusType, int index) {
    int bonus = 0;
    boolean hasBoth = (eq.isRanged() && eq.isMelee());
    CDOMSingleRef<WeaponProf> ref = eq.get(ObjectKey.WEAPON_PROF);
    if (ref == null) {
        return 0;
    }
    WeaponProf wp = ref.get();
    StringTokenizer aTok = new StringTokenizer(wp.getType(), ".");
    while (aTok.hasMoreTokens()) {
        String tString = aTok.nextToken();
        if (!hasBoth || !"RANGED".equalsIgnoreCase(tString)) {
            switch(index) {
                case WPTYPEBONUS_PC:
                    bonus += (int) pc.getTotalBonusTo("WEAPONPROF=TYPE." + tString, bonusType);
                    break;
                case WPTYPEBONUS_EQ:
                    bonus += (int) BonusCalc.charBonusTo(eq, "WEAPONPROF=TYPE." + tString, bonusType, pc);
                    break;
                case WPTYPEBONUS_FEAT:
                    bonus += (int) pc.getFeatBonusTo("WEAPONPROF=TYPE." + tString, bonusType);
                    break;
                case WPTYPEBONUS_TEMPLATE:
                    bonus += (int) pc.getTemplateBonusTo("WEAPONPROF=TYPE." + tString, bonusType);
                    break;
                default:
                    Logging.errorPrint("In getWeaponProfTypeBonuses there is an unhandled case in a switch (the value is " + index + ".");
                    break;
            }
        }
    }
    return bonus;
}
Also used : StringTokenizer(java.util.StringTokenizer) WeaponProf(pcgen.core.WeaponProf)

Example 8 with WeaponProf

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

the class KitProf method apply.

@Override
public void apply(PlayerCharacter aPC) {
    PersistentTransitionChoice<WeaponProf> wpPTC = getPTC(thePObject);
    Collection<?> choices = wpPTC.getChoices().getSet(aPC);
    for (CDOMSingleRef<WeaponProf> profKey : profList) {
        WeaponProf wp = profKey.get();
        if (choices.contains(wp)) {
            wpPTC.act(Collections.singleton(wp), thePObject, aPC);
        }
    }
}
Also used : WeaponProf(pcgen.core.WeaponProf)

Example 9 with WeaponProf

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

the class SourceFileLoader method loadCampaigns.

private void loadCampaigns(GameMode gamemode, final List<Campaign> aSelectedCampaignsList, LoadContext context) throws PersistenceLayerException {
    Logging.log(Logging.INFO, "Loading game " + gamemode + " and sources " + aSelectedCampaignsList + ".");
    //		// The first thing we need to do is load the
    //		// correct statsandchecks.lst file for this gameMode
    //		GameMode gamemode = SettingsHandler.getGame();
    //		if (gamemode == null)
    //		{
    //			// Autoload campaigns is set but there
    //			// is no current gameMode, so just return
    //			return;
    //		}
    File gameModeDir = new File(ConfigurationSettings.getSystemsDir(), "gameModes");
    File specificGameModeDir = new File(gameModeDir, gamemode.getFolderName());
    // Sort the campaigns
    sortCampaignsByRank(aSelectedCampaignsList);
    // Read the campaigns
    Collection<Campaign> loaded = readPccFiles(aSelectedCampaignsList);
    // Add custom campaign files at the start of the lists
    addCustomFilesToStartOfList();
    // Notify our observers of how many files we intend
    // to load in total so that they can set up any
    // progress meters that they want to.
    setMaximum(countTotalFilesToLoad());
    // Load using the new LstFileLoaders
    List<CampaignSourceEntry> dataDefFileList = fileLists.getListFor(ListKey.FILE_DATACTRL);
    dataDefFileList = addDefaultDataControlIfNeeded(dataDefFileList);
    dataControlLoader.loadLstFiles(context, dataDefFileList);
    processFactDefinitions(context);
    tableLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_DATATABLE));
    dynamicLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_DYNAMIC));
    //Load Variables (foundation for other items)
    variableLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_VARIABLE));
    defineBuiltinVariables(context);
    List<CampaignSourceEntry> globalModFileList = fileLists.getListFor(ListKey.FILE_GLOBALMOD);
    if (globalModFileList.isEmpty()) {
        File defaultGameModeDir = new File(gameModeDir, "default");
        File df = new File(defaultGameModeDir, "compatibilityGlobalModifier.lst");
        Campaign c = new Campaign();
        c.setName("Default Global Modifier File");
        CampaignSourceEntry cse = new CampaignSourceEntry(c, df.toURI());
        globalModFileList.add(cse);
    }
    globalModifierLoader.loadLstFiles(context, globalModFileList);
    // load ability categories first as they used to only be at the game mode
    abilityCategoryLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_ABILITY_CATEGORY));
    for (Campaign c : loaded) {
        c.applyTo(context.getReferenceContext());
    }
    sizeLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_SIZE));
    //Now load PCC stat, check, alignment
    statLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_STAT));
    savesLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_SAVE));
    alignmentLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_ALIGNMENT));
    // load weapon profs first
    wProfLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_WEAPON_PROF));
    WeaponProf wp = context.getReferenceContext().silentlyGetConstructedCDOMObject(WeaponProf.class, "Unarmed Strike");
    if (wp == null) {
        wp = new WeaponProf();
        wp.setName(LanguageBundle.getString("Equipment.UnarmedStrike"));
        wp.put(StringKey.KEY_NAME, "Unarmed Strike");
        wp.addToListFor(ListKey.TYPE, Type.SIMPLE);
        context.getReferenceContext().importObject(wp);
    }
    aProfLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_ARMOR_PROF));
    sProfLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_SHIELD_PROF));
    // load skills before classes to handle class skills
    skillLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_SKILL));
    // load before races to handle auto known languages
    languageLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_LANGUAGE));
    // load before race or class to handle feats
    featLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_FEAT));
    // load before race or class to handle abilities
    abilityLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_ABILITY));
    raceLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_RACE));
    //Domain must load before CLASS - thpr 10/29/06
    domainLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_DOMAIN));
    spellLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_SPELL));
    deityLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_DEITY));
    classLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_CLASS));
    templateLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_TEMPLATE));
    // loaded before equipment (required)
    eqModLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_EQUIP_MOD));
    equipmentLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_EQUIP));
    companionModLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_COMPANION_MOD));
    kitLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_KIT));
    // Load the bio settings files
    bioLoader.setGameMode(gamemode.getName());
    bioLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_BIO_SET));
    // Check for the default deities
    checkRequiredDeities(specificGameModeDir, context);
    // Add default EQ mods
    addDefaultEquipmentMods(context);
    classLoader.loadSubLines(context);
    /*
		 * This is technically bad behavior, but we at least want to provide the
		 * hint here since we are using WeakReferences as a container for
		 * references to ensure those that are not used are not resolved.
		 */
    System.gc();
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) WeaponProf(pcgen.core.WeaponProf) PCGFile(pcgen.io.PCGFile) File(java.io.File)

Example 10 with WeaponProf

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

the class ProfToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, KitProf obj, String value) {
    StringTokenizer tok = new StringTokenizer(value, Constants.PIPE);
    while (tok.hasMoreTokens()) {
        String tokText = tok.nextToken();
        CDOMSingleRef<WeaponProf> ref = context.getReferenceContext().getCDOMReference(WEAPONPROF_CLASS, tokText);
        obj.addProficiency(ref);
    }
    return ParseResult.SUCCESS;
}
Also used : StringTokenizer(java.util.StringTokenizer) WeaponProf(pcgen.core.WeaponProf)

Aggregations

WeaponProf (pcgen.core.WeaponProf)56 StringTokenizer (java.util.StringTokenizer)10 Test (org.junit.Test)10 Equipment (pcgen.core.Equipment)10 CDOMReference (pcgen.cdom.base.CDOMReference)6 ArrayList (java.util.ArrayList)5 CDOMObject (pcgen.cdom.base.CDOMObject)5 Deity (pcgen.core.Deity)5 ArmorProf (pcgen.core.ArmorProf)4 PCTemplate (pcgen.core.PCTemplate)4 ShieldProf (pcgen.core.ShieldProf)4 HashSet (java.util.HashSet)3 ChangeProf (pcgen.cdom.content.ChangeProf)3 WeaponProfProvider (pcgen.cdom.helper.WeaponProfProvider)3 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)3 PCClass (pcgen.core.PCClass)3 Race (pcgen.core.Race)3 Type (pcgen.cdom.enumeration.Type)2 EquipmentHead (pcgen.cdom.inst.EquipmentHead)2 CDOMGroupRef (pcgen.cdom.reference.CDOMGroupRef)2