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

Method parseSpellLine

code/src/java/pcgen/io/PCGVer2Parser.java:3785–4115  ·  view source on GitHub ↗
(final String line)

Source from the content-addressed store, hash-verified

3783 * ###############################################################
3784 */
3785 private void parseSpellLine(final String line)
3786 {
3787 final PCGTokenizer tokens;
3788
3789 try
3790 {
3791 tokens = new PCGTokenizer(line);
3792 }
3793 catch (PCGParseException pcgpex)
3794 {
3795 final String message =
3796 "Illegal Spell line ignored: " + line + Constants.LINE_SEPARATOR + "Error: " + pcgpex.getMessage();
3797 warnings.add(message);
3798
3799 return;
3800 }
3801
3802 Spell aSpell = null;
3803 PCClass aPCClass = null;
3804 PObject source = null;
3805
3806 String spellBook = null;
3807
3808 int times = 1;
3809 int spellLevel = 0;
3810 int numPages = 0;
3811
3812 final List<Ability> metaFeats = new ArrayList<>();
3813
3814 int ppCost = -1;
3815
3816 for (final PCGElement element : tokens.getElements())
3817 {
3818 final String tag = element.getName();
3819
3820 if (IOConstants.TAG_SPELLNAME.equals(tag))
3821 {
3822 String spellName = EntityEncoder.decode(element.getText());
3823 spellName = SpellMigration.getNewSpellKey(spellName, pcgenVersion, SettingsHandler.getGameAsProperty().get().getName());
3824
3825 // either NULL (no spell) a Spell instance,
3826 aSpell = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Spell.class,
3827 spellName);
3828
3829 if (aSpell == null)
3830 {
3831 final String message = "Could not find spell named: " + spellName;
3832 warnings.add(message);
3833
3834 return;
3835 }
3836 }
3837 else if (IOConstants.TAG_TIMES.equals(tag))
3838 {
3839 try
3840 {
3841 times = Integer.parseInt(element.getText());
3842 }

Callers 1

parseCachedLinesMethod · 0.95

Calls 15

getElementsMethod · 0.95
decodeMethod · 0.95
getNewSpellKeyMethod · 0.95
getGameAsPropertyMethod · 0.95
getContextMethod · 0.95
levelForKeyMethod · 0.95
getDefaultSpellBookMethod · 0.95
addInfoMethod · 0.95
getSpellInfoForMethod · 0.95
addFeatsToListMethod · 0.95
setActualPPCostMethod · 0.95

Tested by

no test coverage detected