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;
}
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);
}
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);
}
}
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() };
}
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);
}
}
}
Aggregations