/** * Retrieves a collection of the tags defined for a race grouped by the age brackets. * * @param region The region of the race * @param race The name of the race. * @param includeGenericMatches Should generic race references such as Elf% be included * @return SortedMap A map of the gae brackets. Within each age bracket is a sorted map of the * races (one only) and wihtin this is the tags for that race and age. */ private SortedMap<Integer, SortedMap<String, SortedMap<String, String>>> getRaceTagsByAge( Region region, String race) { // setup a mapped structure final SortedMap<Integer, SortedMap<String, SortedMap<String, String>>> ageSets = new TreeMap<Integer, SortedMap<String, SortedMap<String, String>>>(); // Read in the user settings, split where necessary and add to the appropriate age bracket for (String key : userMap.getTertiaryKeySet(region, race)) { addTagToAgeSet(ageSets, race, key, userMap.getListFor(region, race, key)); } return ageSets; }
@Override public String toString() { final StringBuilder sb = new StringBuilder(100); sb.append("AgeMap: ").append(ageMap.toString()).append("\n"); sb.append("UserMap: ").append(userMap.toString()).append("\n"); return sb.toString(); }
/** * Add the supplied line to the user map. The user map contains an array with an entry for each * age set. The supplied index is used to ensure that the value is placed in the correct age * bracket. * * @param regionString The region the race is defined in. * @param race The race to be updated. * @param tag The tag to be entered. Must be in the form key:value * @param ageSetIndex The age set to be updated. */ public void addToUserMap( String regionString, final String race, final String tag, final int ageSetIndex) { final int x = tag.indexOf(':'); if (x < 0) { Logging.errorPrint("Invalid value sent to map: " + tag + " (for Race " + race + ")"); return; // invalid tag } Region region = Region.getConstant(regionString); String key = tag.substring(0, x); List<String> r = userMap.getListFor(region, race, key); for (int i = (r == null) ? 0 : r.size(); i < ageSetIndex; i++) { userMap.addToListFor(region, race, key, "0"); } userMap.addToListFor(region, race, key, tag.substring(x + 1)); }
/** * Remove the user from the map * * @param region * @param race * @param tag */ public void removeFromUserMap(final String region, final String race, final String tag) { final String key; final int x = tag.indexOf(':'); if (x < 0) { key = tag; } else { key = tag.substring(0, x); } userMap.removeListFor(Region.getConstant(region), race, key); }
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 still not found, try the same two searches again without a region // 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; }
/** * Copies the bio data for one race to a new race. * * @param origRegion The region of the original race * @param origRace The name of the original race * @param copyRegion The region of the target race * @param copyRace The name of the target race */ public void copyRaceTags( final String origRegion, final String origRace, final String copyRegion, final String copyRace) { Region oldr = Region.getConstant(origRegion); Region newr = Region.getConstant(copyRegion); for (String key : userMap.getTertiaryKeySet(oldr, origRace)) { userMap.addAllToListFor(newr, copyRace, key, userMap.getListFor(oldr, origRace, key)); } final int idx = origRace.indexOf('('); String otherRace; if (idx >= 0) { otherRace = origRace.substring(0, idx).trim() + '%'; } else { otherRace = origRace + '%'; } for (String key : userMap.getTertiaryKeySet(oldr, otherRace)) { userMap.addAllToListFor(newr, copyRace, key, userMap.getListFor(oldr, otherRace, key)); } }
/** Clear the user map */ public void clearUserMap() { userMap.clear(); }