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

Method getToken

code/src/java/pcgen/io/exporttoken/StatToken.java:69–191  ·  view source on GitHub ↗
(String tokenSource, PlayerCharacter pc, ExportHandler eh)

Source from the content-addressed store, hash-verified

67 }
68
69 @Override
70 public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh)
71 {
72 String retString;
73 StringTokenizer aTok = new StringTokenizer(tokenSource, ".");
74 if (aTok.countTokens() < 2)
75 {
76 Logging.errorPrint("Invalid STAT token:" + tokenSource, new Throwable());
77 return "";
78 }
79
80 aTok.nextToken();
81 int indexOfStat;
82 indexOfStat = Integer.parseInt(aTok.nextToken());
83 if ((indexOfStat < 0) || (indexOfStat >= pc.getDisplay().getStatCount()))
84 {
85 return "";
86 }
87 List<PCStat> statList = new ArrayList<>(pc.getDisplay().getStatSet());
88 statList.sort(Comparator.comparing(SortKeyRequired::getSortKey));
89 PCStat stat = statList.get(indexOfStat);
90
91 String findType = "STAT";
92
93 boolean useBase = false;
94 boolean useLevel = false;
95 int aLevel = 0;
96
97 boolean useEquip = true;
98 boolean useTemp = true;
99 boolean usePost = true;
100
101 while (aTok.hasMoreTokens())
102 {
103 String token = aTok.nextToken();
104
105 if ("NAME".equals(token))
106 {
107 return stat.getKeyName();
108 }
109 if ("LONGNAME".equals(token))
110 {
111 return stat.getDisplayName();
112 }
113
114 if ("ISNONABILITY".equals(token))
115 {
116 return pc.getDisplay().isNonAbility(stat) ? "Y" : "N";
117 }
118
119 if ("STAT".equals(token))
120 {
121 findType = "STAT";
122 }
123 else if ("MOD".equals(token))
124 {
125 findType = "MOD";
126 }

Callers 5

testMaxValueMethod · 0.95
testBonusStackingMethod · 0.95
testStatModsMethod · 0.95
testLevelStatMethod · 0.95
testLockedStatsMethod · 0.95

Calls 15

errorPrintMethod · 0.95
getBaseModTokenMethod · 0.95
getModTokenMethod · 0.95
getBaseTokenMethod · 0.95
getStatTokenMethod · 0.95
nextTokenMethod · 0.80
parseIntMethod · 0.80
getStatCountMethod · 0.80
hasMoreTokensMethod · 0.80
getMethod · 0.65
equalsMethod · 0.65
getKeyNameMethod · 0.65

Tested by 5

testMaxValueMethod · 0.76
testBonusStackingMethod · 0.76
testStatModsMethod · 0.76
testLevelStatMethod · 0.76
testLockedStatsMethod · 0.76