Search in sources :

Example 6 with Region

use of pcgen.cdom.enumeration.Region in project pcgen by PCGen.

the class BioSet method mapFind.

private List<String> mapFind(final TripleKeyMapToList<Region, String, String, String> argMap, final String argRegionName, final String argRaceName, final String addKey, final String altRaceName) {
    // First check for region.racename.key
    Region region = Region.getConstant(argRegionName);
    List<String> r = argMap.getListFor(region, argRaceName, addKey);
    if (r != null && !r.isEmpty()) {
        return r;
    }
    //
    // If not found, try the race name without any parenthesis
    //
    final int altRaceLength = altRaceName.length();
    if (altRaceLength != 0) {
        r = argMap.getListFor(region, altRaceName, addKey);
        if (r != null) {
            return r;
        }
    }
    //
    if (!argRegionName.equals(Constants.NONE)) {
        region = Region.getConstant("None");
        r = argMap.getListFor(region, argRaceName, addKey);
        if (r != null) {
            return r;
        }
        if (altRaceLength != 0) {
            r = argMap.getListFor(region, altRaceName, addKey);
        }
    }
    return r;
}
Also used : Region(pcgen.cdom.enumeration.Region)

Example 7 with Region

use of pcgen.cdom.enumeration.Region in project pcgen by PCGen.

the class BioSet method getRacePCCText.

/**
	 * Builds a string describing the bio settings for the specified race
	 * This string is formatted so that it can be read in by BioSetLoader
	 *
	 * @param region The region of the race to be output
	 * @param race   The name of the race to be output
	 * @return String A lst string describing the region's biosets.
	 */
public String getRacePCCText(final String region, final String race) {
    final StringBuilder sb = new StringBuilder(1000);
    sb.append("REGION:").append(region).append("\n\n");
    Region r = Region.getConstant(region);
    final SortedMap<Integer, SortedMap<String, SortedMap<String, String>>> ageSets = getRaceTagsByAge(r, race);
    return appendAgesetInfo(r, ageSets, sb);
}
Also used : SortedMap(java.util.SortedMap) Region(pcgen.cdom.enumeration.Region)

Example 8 with Region

use of pcgen.cdom.enumeration.Region in project pcgen by PCGen.

the class AgeSetFacet method update.

/**
	 * This method simply drives a global update of the active AgeSet of a
	 * PlayerCharacter. This is asserted to be simpler to comprehend than
	 * attempting to do a change-by-change matrix of possible moves between
	 * AgeSets (which would have to be built from the BioSet).
	 * 
	 * Since the processing to determine the AgeSet is reasonably simple, since
	 * this facet will only throw an event if the AgeSet actually changes, and
	 * since there are a disparate set of objects that can cause a change in the
	 * AgeSet (e.g. change of Race, change of Age, change of Region), the
	 * quantity of extra facets to listen to those changes in a unique fashion
	 * and the complex storage of AgeSets would seem an unreasonable trade in
	 * complexity vs. this global update.
	 * 
	 * @param id
	 *            The CharID identifying the Player Character for which the
	 *            active AgeSet should be established (and updated if necessary)
	 */
private void update(CharID id) {
    Region region = Region.getConstant(regionFacet.getRegion(id));
    AgeSet ageSet = bioSetFacet.get(id).getAgeSet(region, getAgeSetIndex(id));
    if (ageSet == null) {
        remove(id);
    } else {
        set(id, ageSet);
    }
}
Also used : AgeSet(pcgen.core.AgeSet) Region(pcgen.cdom.enumeration.Region)

Example 9 with Region

use of pcgen.cdom.enumeration.Region in project pcgen by PCGen.

the class RegionLst method unparse.

@Override
public String[] unparse(LoadContext context, CDOMObject pcc) {
    TransitionChoice<Region> tc = context.getObjectContext().getObject(pcc, ObjectKey.REGION_CHOICE);
    if (tc == null) {
        // indicates no Token
        return null;
    }
    StringBuilder sb = new StringBuilder();
    Formula count = tc.getCount();
    if (!FormulaFactory.ONE.equals(count)) {
        sb.append(count);
        sb.append(Constants.PIPE);
    }
    sb.append(tc.getChoices().getLSTformat().replaceAll(Constants.COMMA, Constants.PIPE));
    return new String[] { sb.toString() };
}
Also used : Formula(pcgen.base.formula.Formula) Region(pcgen.cdom.enumeration.Region)

Example 10 with Region

use of pcgen.cdom.enumeration.Region in project pcgen by PCGen.

the class RegionChoiceFacet method dataAdded.

/**
	 * Drives selection of a Region (reacting to a REGION: token on a
	 * CDOMObject) for a CDOMObject which was added to a Player Character.
	 * 
	 * Triggered when one of the Facets to which RegionChoiceFacet 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, CDOMObject> dfce) {
    CharID id = dfce.getCharID();
    PlayerCharacter aPC = trackingFacet.getPC(id);
    if (!aPC.isImporting()) {
        CDOMObject cdo = dfce.getCDOMObject();
        TransitionChoice<Region> region = cdo.get(ObjectKey.REGION_CHOICE);
        if (region != null) {
            region.act(region.driveChoice(aPC), cdo, aPC);
        }
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) CDOMObject(pcgen.cdom.base.CDOMObject) Region(pcgen.cdom.enumeration.Region) CharID(pcgen.cdom.enumeration.CharID)

Aggregations

Region (pcgen.cdom.enumeration.Region)12 Test (org.junit.Test)2 Formula (pcgen.base.formula.Formula)2 ArrayList (java.util.ArrayList)1 SortedMap (java.util.SortedMap)1 StringTokenizer (java.util.StringTokenizer)1 CDOMObject (pcgen.cdom.base.CDOMObject)1 ChoiceSet (pcgen.cdom.base.ChoiceSet)1 ConcreteTransitionChoice (pcgen.cdom.base.ConcreteTransitionChoice)1 NonInteractive (pcgen.cdom.base.NonInteractive)1 Ungranted (pcgen.cdom.base.Ungranted)1 SimpleChoiceSet (pcgen.cdom.choiceset.SimpleChoiceSet)1 LevelCommandFactory (pcgen.cdom.content.LevelCommandFactory)1 CharID (pcgen.cdom.enumeration.CharID)1 ClassSource (pcgen.cdom.helper.ClassSource)1 PCClassLevel (pcgen.cdom.inst.PCClassLevel)1 AgeSet (pcgen.core.AgeSet)1 PlayerCharacter (pcgen.core.PlayerCharacter)1 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)1