{@literal SPELLS: |[ ] | [, ] | [, ] |PRExxx |PRExxx CASTERLEVEL= Casterlevel of spells TIMES= Cast Times per day, -1=At Will } @param sourceLine Line from the LST
(LoadContext context, CDOMObject obj, String sourceLine)
| 71 | * @return spells list |
| 72 | */ |
| 73 | @Override |
| 74 | protected ParseResult parseNonEmptyToken(LoadContext context, CDOMObject obj, String sourceLine) |
| 75 | { |
| 76 | if (obj instanceof Ungranted) |
| 77 | { |
| 78 | return new ParseResult.Fail( |
| 79 | "Cannot use " + getTokenName() + " on an Ungranted object type: " + obj.getClass().getSimpleName()); |
| 80 | } |
| 81 | if ((sourceLine == null) || sourceLine.isEmpty()) |
| 82 | { |
| 83 | return new ParseResult.Fail("Argument in " + getTokenName() + " cannot be empty"); |
| 84 | } |
| 85 | if (sourceLine.equals(Constants.LST_DOT_CLEAR_ALL)) |
| 86 | { |
| 87 | context.getListContext().removeAllFromList(getTokenName(), obj, Spell.SPELLS); |
| 88 | return ParseResult.SUCCESS; |
| 89 | } |
| 90 | ParsingSeparator sep = new ParsingSeparator(sourceLine, '|'); |
| 91 | sep.addGroupingPair('[', ']'); |
| 92 | sep.addGroupingPair('(', ')'); |
| 93 | |
| 94 | String spellBook = sep.next(); |
| 95 | if (spellBook.isEmpty()) |
| 96 | { |
| 97 | return new ParseResult.Fail("SpellBook in " + getTokenName() + " cannot be empty"); |
| 98 | } |
| 99 | // Formula casterLevel = null; |
| 100 | String casterLevel = null; |
| 101 | String times = null; |
| 102 | String timeunit = null; |
| 103 | |
| 104 | if (!sep.hasNext()) |
| 105 | { |
| 106 | return new ParseResult.Fail(getTokenName() + ": minimally requires a Spell Name"); |
| 107 | } |
| 108 | String token = sep.next(); |
| 109 | |
| 110 | while (true) |
| 111 | { |
| 112 | if (token.startsWith("TIMES=")) |
| 113 | { |
| 114 | if (times != null) |
| 115 | { |
| 116 | return new ParseResult.Fail( |
| 117 | "Found two TIMES entries in " + getTokenName() + ": invalid: " + sourceLine); |
| 118 | } |
| 119 | times = token.substring(6); |
| 120 | if (times.isEmpty()) |
| 121 | { |
| 122 | return new ParseResult.Fail("Error in Times in " + getTokenName() + ": argument was empty"); |
| 123 | } |
| 124 | if (!sep.hasNext()) |
| 125 | { |
| 126 | return new ParseResult.Fail( |
| 127 | getTokenName() + ": minimally requires " + "a Spell Name (after TIMES=)"); |
| 128 | } |
| 129 | token = sep.next(); |
| 130 | } |
nothing calls this directly
no test coverage detected