Search in sources :

Example 1 with BioSet

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

the class AgeSetFacet method getAgeSetIndex.

/**
	 * Returns the index of the active AgeSet on the Player Character.
	 * 
	 * In general, use of this method outside of AgeSetFacet is discouraged. If
	 * this method is being used, a serious analysis should be taking place to
	 * determine if the AgeSet itself (in other words, the get method of
	 * AgeSetFacet) can be used instead.
	 * 
	 * @param id
	 *            The CharID identifying the Player Character for which the
	 *            index of the active AgeSet should be returned.
	 * @return The index of the active AgeSet on the Player Character.
	 */
public int getAgeSetIndex(CharID id) {
    BioSet bioSet = bioSetFacet.get(id);
    String region = regionFacet.getRegion(id);
    Race race = raceFacet.get(id);
    String raceName = race == null ? "" : race.getKeyName().trim();
    List<String> values = bioSet.getValueInMaps(region, raceName, "BASEAGE");
    if (values == null) {
        return 0;
    }
    int pcAge = ageFacet.getAge(id);
    int ageSet = -1;
    for (String s : values) {
        int setBaseAge = Integer.parseInt(s);
        if (pcAge < setBaseAge) {
            break;
        }
        ++ageSet;
    }
    //
    if (ageSet < 0) {
        ageSet = 0;
    }
    return ageSet;
}
Also used : BioSet(pcgen.core.BioSet) Race(pcgen.core.Race)

Example 2 with BioSet

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

the class BioSetLoaderTest method testParseLine.

/**
	 * Validate the data loaded in setUp() to verify that the parseLine fucntion in
	 * BioSetLoader is functioning properly.
	 */
public void testParseLine() {
    final String[] TEST_TAGS = new String[] { "HAIR", "EYES", "SKINTONE", "AGEDIEROLL", "CLASS", "BASEAGE", "MAXAGE", "SEX" };
    final String[][] EXPECTED_VALUES = new String[][] { { "[Blond|Brown]", "[Blue]", "[Tanned|Pasty]", "[5d4, 3d6, 4d4+1, 4d10]", "[Barbarian,Rogue,Sorcerer[BASEAGEADD:1d4]|Bard,Fighter,Paladin,Ranger[BASEAGEADD:1d6]|Cleric,Druid,Monk,Wizard[BASEAGEADD:2d6]]", "[15, 35, 53, 70]", "[34, 52, 69, 110]", "[Male[BASEHT:58|HTDIEROLL:2d10|BASEWT:120|WTDIEROLL:2d4|TOTALWT:BASEWT+(HTDIEROLL*WTDIEROLL)]Female[BASEHT:53|HTDIEROLL:2d10|BASEWT:85|WTDIEROLL:2d4|TOTALWT:BASEWT+(HTDIEROLL*WTDIEROLL)]]" }, { "[Blond|Brown|Bald|Gray]", "[Blue|Black|Brown|Gray]", "[Tanned|Pasty|Fair|Gray]", "[4d20+1d4, (7d8+1d6), 10d6+1, 2d100]", "[Barbarian,Rogue,Sorcerer[BASEAGEADD:3d6]|Bard,Fighter,Paladin,Ranger[BASEAGEADD:5d6]|Cleric,Druid,Monk,Wizard[BASEAGEADD:7d6]]", "[40, 125, 188, 250]", "[124, 187, 249, 450]", "[Male[BASEHT:45|HTDIEROLL:2d4|BASEWT:130|WTDIEROLL:2d6|TOTALWT:BASEWT+(HTDIEROLL*WTDIEROLL)]Female[BASEHT:43|HTDIEROLL:2d4|BASEWT:100|WTDIEROLL:2d6|TOTALWT:BASEWT+(HTDIEROLL*WTDIEROLL)]]" }, { "[White|Pale Yellow|Silver-White|Black|Blue|Golden Blonde|Copper|Brown]", "[Violet|Silver|Pink|Pale Blue|Gold-flecked Green|Gold-flecked Blue|Green|Gold|Brown|Hazel]", "[Obsidian|Fair|Tanned|Pasty|Bronze|Dark Brown|Copper]", "[7d6, 5d6, 5d6+1, 6d10]", "[Barbarian,Rogue,Sorcerer[BASEAGEADD:1d6]|Bard,Fighter,Paladin,Ranger[BASEAGEADD:2d6]|Cleric,Druid,Monk,Wizard[BASEAGEADD:3d6]]", "[20, 62, 93, 125]", "[61, 92, 124, 185]", "[Male[BASEHT:55|HTDIEROLL:2d8|BASEWT:100|WTDIEROLL:2d4|TOTALWT:BASEWT+(HTDIEROLL*WTDIEROLL)]Female[BASEHT:53|HTDIEROLL:2d8|BASEWT:80|WTDIEROLL:2d4|TOTALWT:BASEWT+(HTDIEROLL*WTDIEROLL)]]" } };
    // Check the data loaded in setup to ensure that it has been loaded correctly.
    final BioSet currBioSet = SettingsHandler.getGame().getBioSet();
    List<String> baseRaceTag;
    for (int i = 0; i < BASE_RACE_NAME.length; i++) {
        final String raceName = BASE_RACE_NAME[i];
        for (int j = 0; j < TEST_TAGS.length; j++) {
            final String testArg = TEST_TAGS[j];
            baseRaceTag = currBioSet.getTagForRace(Constants.NONE, raceName, testArg);
            //				System.out.println(
            //					"Got '"
            //						+ testArg
            //						+ "' tag for race '"
            //						+ raceName
            //						+ "' of "
            //						+ baseRaceTag
            //						+ ".");
            assertEquals("BioSet tag " + testArg + " for race " + raceName + ":", EXPECTED_VALUES[i][j], baseRaceTag.toString());
        }
    }
}
Also used : BioSet(pcgen.core.BioSet)

Example 3 with BioSet

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

the class BioSetFacetTest method getItem.

@Override
protected BioSet getItem() {
    BioSet b = new BioSet();
    b.setName("BioSet" + n++);
    return b;
}
Also used : BioSet(pcgen.core.BioSet)

Example 4 with BioSet

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

the class AgeSetKitFacet method dataAdded.

/**
	 * Drives the selection of the AgeSet Kit for a Player Character when
	 * relevant changes (change to an AgeSet) are made to a Player Character.
	 * 
	 * Triggered when one of the Facets to which AgeSetKitFacet listens fires a
	 * DataFacetChangeEvent to indicate a CDOMObject was added to a Player
	 * Character.
	 * 
	 * @param dfce
	 *            The DataFacetChangeEvent containing the information about the
	 *            change
	 * 
	 * @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
	 */
@Override
public void dataAdded(DataFacetChangeEvent<CharID, Integer> dfce) {
    CharID id = dfce.getCharID();
    AgeSet ageSet = ageSetFacet.get(id);
    PlayerCharacter pc = trackingFacet.getPC(id);
    // TODO Is ageSet null check necessary?
    if (ageSet == null || pc.isImporting()) {
        return;
    }
    int ageSetIndex = ageSetFacet.getAgeSetIndex(id);
    /*
		 * TODO The method of storing what AgeSets have had kit selections made
		 * should be converted to store the actual AgeSet rather than the index,
		 * in order to reduce the number of calls to ageSetFacet.getAgeSetIndex.
		 * This (of course) drives the move of the AgeSets for which a kit
		 * selection has been made into a Facet. It is possible that the
		 * CacheInfo of AgeSetKitFacet is actually a good place to store that
		 * information (or it may be implicit with the information already
		 * stored there??)
		 */
    if (!pc.hasMadeKitSelectionForAgeSet(ageSetIndex)) {
        CacheInfo cache = getConstructingClassInfo(id);
        List<Kit> kits = cache.get(ageSet);
        if (kits != null) {
            // Need to do selection
            BioSet bioSet = bioSetFacet.get(id);
            for (TransitionChoice<Kit> kit : ageSet.getKits()) {
                Collection<? extends Kit> choice = kit.driveChoice(pc);
                cache.put(ageSet, choice);
                kit.act(choice, bioSet, pc);
            }
        }
        pc.setHasMadeKitSelectionForAgeSet(ageSetIndex, true);
    }
}
Also used : BioSet(pcgen.core.BioSet) PlayerCharacter(pcgen.core.PlayerCharacter) AgeSet(pcgen.core.AgeSet) Kit(pcgen.core.Kit) CharID(pcgen.cdom.enumeration.CharID)

Aggregations

BioSet (pcgen.core.BioSet)4 CharID (pcgen.cdom.enumeration.CharID)1 AgeSet (pcgen.core.AgeSet)1 Kit (pcgen.core.Kit)1 PlayerCharacter (pcgen.core.PlayerCharacter)1 Race (pcgen.core.Race)1