See the PCGen Docs on Token Syntax @param aString @param aPC @param eh The ExportHandler to advise if there are no more items. @return int
(String aString, PlayerCharacter aPC, ExportHandler eh)
| 67 | * @return int |
| 68 | */ |
| 69 | private static String replaceTokenArmor(String aString, PlayerCharacter aPC, ExportHandler eh) |
| 70 | { |
| 71 | final StringTokenizer aTok = new StringTokenizer(aString, "."); |
| 72 | final String[] tokens = new String[aTok.countTokens()]; |
| 73 | for (int i = 0; aTok.hasMoreTokens(); ++i) |
| 74 | { |
| 75 | tokens[i] = aTok.nextToken(); |
| 76 | } |
| 77 | String property = ""; |
| 78 | // When removing old syntax, this if should be removed |
| 79 | if (tokens.length > 0) |
| 80 | { |
| 81 | property = tokens[tokens.length - 1]; |
| 82 | } |
| 83 | int equipped = 3; |
| 84 | int index = 0; |
| 85 | String type = ""; |
| 86 | String subtype = ""; |
| 87 | int merge = Constants.MERGE_ALL; |
| 88 | for (int i = 0; i < tokens.length; ++i) |
| 89 | { |
| 90 | if ("ARMOR".equals(tokens[i])) |
| 91 | { |
| 92 | continue; |
| 93 | } |
| 94 | // When removing old syntax, delete this if |
| 95 | else if (tokens[i].startsWith("ARMOR")) |
| 96 | { |
| 97 | try |
| 98 | { |
| 99 | index = Integer.parseInt(tokens[i].substring(5)); |
| 100 | } |
| 101 | catch (NumberFormatException nfe) |
| 102 | { |
| 103 | index = 0; |
| 104 | } |
| 105 | Logging.errorPrint("Old syntax ARMORx will be replaced for ARMOR.x"); |
| 106 | } |
| 107 | else if ("ALL".equals(tokens[i])) |
| 108 | { |
| 109 | equipped = 3; |
| 110 | } |
| 111 | // When removing old syntax, delete this if |
| 112 | else if (tokens[i].startsWith("ALL")) |
| 113 | { |
| 114 | Logging.errorPrint("Old syntax ALLx will be replaced for ALL.x"); |
| 115 | |
| 116 | index = Integer.parseInt(tokens[i].substring(3)); |
| 117 | equipped = 3; |
| 118 | } |
| 119 | else if ("EQUIPPED".equals(tokens[i])) |
| 120 | { |
| 121 | equipped = 1; |
| 122 | } |
| 123 | // When removing old syntax, delete this if |
| 124 | else if (tokens[i].startsWith("EQUIPPED")) |
| 125 | { |
| 126 | Logging.errorPrint("Old syntax EQUIPPEDx will be replaced for EQUIPPED.x"); |
no test coverage detected