MCPcopy Create free account
hub / github.com/PCGen/pcgen / parcePCGSourceOnly

Method parcePCGSourceOnly

code/src/java/pcgen/io/PCGVer2Parser.java:241–298  ·  view source on GitHub ↗

Check the game mode and then build a list of campaigns the character requires to be loaded. @param lines The PCG lines to be parsed. @return The list of campaigns. @throws PCGParseException If the lines are invalid

(String[] lines)

Source from the content-addressed store, hash-verified

239 * @throws PCGParseException If the lines are invalid
240 */
241 @Override
242 public SourceSelectionFacade parcePCGSourceOnly(String[] lines) throws PCGParseException
243 {
244 buildPcgLineCache(lines);
245
246 /*
247 * VERSION:x.x.x
248 */
249 if (cache.containsKey(IOConstants.TAG_VERSION))
250 {
251 parseVersionLine(cache.get(IOConstants.TAG_VERSION).get(0));
252 }
253
254 if (!cache.containsKey(IOConstants.TAG_GAMEMODE))
255 {
256 Logging.errorPrint("Character does not have game mode information.");
257 return null;
258 }
259 String line = cache.get(IOConstants.TAG_GAMEMODE).get(0);
260 String requestedMode = line.substring(IOConstants.TAG_GAMEMODE.length() + 1);
261 GameMode mode = SystemCollections.getGameModeNamed(requestedMode);
262 if (mode == null)
263 {
264 for (GameMode gameMode : SystemCollections.getUnmodifiableGameModeList())
265 {
266 if (gameMode.getAllowedModes().contains(requestedMode))
267 {
268 mode = gameMode;
269 break;
270 }
271 }
272 }
273 //if mode == null still then a game mode was not found
274 if (mode == null)
275 {
276 Logging.errorPrint("Character's game mode entry was not valid: " + line);
277 return null;
278 }
279 if (!cache.containsKey(IOConstants.TAG_CAMPAIGN))
280 {
281 Logging.errorPrint("Character does not have campaign information.");
282 return FacadeFactory.createSourceSelection(mode, new ArrayList<>());
283 }
284 /*
285 * #System Information
286 * CAMPAIGN:CMP - Monkey Book I - Book For Monkeys
287 * CAMPAIGN:CMP - Monkey Book II - Book By Monkeys
288 * ...
289 *
290 * first thing to do is checking campaigns - no matter what!
291 */
292 List<Campaign> campaigns = getCampaignList(cache.get(IOConstants.TAG_CAMPAIGN), mode.getName());
293 if (campaigns.isEmpty())
294 {
295 Logging.errorPrint("Character's campaign entry was empty.");
296 }
297 return FacadeFactory.createSourceSelection(mode, campaigns);
298 }

Callers 1

internalReadSourcesMethod · 0.95

Calls 13

buildPcgLineCacheMethod · 0.95
parseVersionLineMethod · 0.95
errorPrintMethod · 0.95
getGameModeNamedMethod · 0.95
createSourceSelectionMethod · 0.95
getCampaignListMethod · 0.95
getNameMethod · 0.95
getAllowedModesMethod · 0.80
containsKeyMethod · 0.65
getMethod · 0.65
containsMethod · 0.65

Tested by

no test coverage detected