Skip to content
27 changes: 27 additions & 0 deletions code/src/java/pcgen/core/PlayerCharacter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.awt.Rectangle;
import java.math.BigDecimal;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -8179,6 +8180,9 @@ public String getDescription(List<? extends Object> objList)
if (b instanceof PObject)
{
cdo = (PObject) b;
String dString = getInfoToken(".INFO.DESC", cdo);
if (!dString.equals(".INFO.DESC"))
return dString;
}
else if (b instanceof CNAbility)
{
Expand Down Expand Up @@ -8213,6 +8217,29 @@ else if (b instanceof CNAbility)
return sb.toString();
}

public String getInfoToken(String token, PObject po) {
// looking for a token in the form of RACE.INFO.TAG where
// RACE indicate which token map to check for a INFO label of TAG to return
int i = token.indexOf(".INFO.");
String ts = token;
if (i>-1)
ts = token.substring(i+6).toUpperCase();
else
return token;
Set<MapKey<?, ?>> keys = po.getMapKeys();
for (MapKey<?, ?> key : keys) {
Map<?, ?> key2 = po.getMapFor(key);
for(Object k : key2.keySet()) {
if (k.toString().equals(ts)) {
MessageFormat m = (MessageFormat) key2.get(k);
return m.toPattern();
}
}
}
return token;
}


/**
* This method gets the information about the levels at which classes and
* domains may cast the spell.
Expand Down
4 changes: 2 additions & 2 deletions code/src/java/pcgen/io/ExportHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ else if (tokenString.indexOf(".INFO.")>-1) {
for (CDOMObject cd : plist) {
if (cd instanceof PObject) {
PObject po = (PObject) cd;
v = token.getInfoToken(tokenString, po);
v = aPC.getInfoToken(tokenString, po);
if (!v.equals(tokenString)) {
FileAccess.encodeWrite(output, v);
break;
Expand All @@ -1632,7 +1632,7 @@ else if (TOKEN_MAP.get(firstToken) != null)
{
Token token = TOKEN_MAP.get(firstToken);
if (tokenString.indexOf(".INFO.")>-1) {
FileAccess.encodeWrite(output, token.getInfoToken(tokenString, aPC.getDisplay().getRace()));
FileAccess.encodeWrite(output, aPC.getInfoToken(tokenString, aPC.getDisplay().getRace()));
}
else if (token.isEncoded())
{
Expand Down
22 changes: 0 additions & 22 deletions code/src/java/pcgen/io/exporttoken/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,4 @@ protected static int getIntToken(String token, int defaultVal)
}
return retInt;
}

public String getInfoToken(String token, PObject po) {
// looking for a token in the form of RACE.INFO.TAG where
// RACE indicate which token map to check for a INFO label of TAG to return
int i = token.indexOf(".INFO.");
String ts = token;
if (i>-1)
ts = token.substring(i+6).toUpperCase();
else
return token;
Set<MapKey<?, ?>> keys = po.getMapKeys();
for (MapKey<?, ?> key : keys) {
Map<?, ?> key2 = po.getMapFor(key);
for(Object k : key2.keySet()) {
if (k.toString().equals(ts)) {
MessageFormat m = (MessageFormat) key2.get(k);
return m.toPattern();
}
}
}
return token;
}
}
4 changes: 3 additions & 1 deletion code/src/java/plugin/exporttokens/SpellMemToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ else if ("DURATION".equals(aLabel))
}
else if ("DESC".equals(aLabel) || "EFFECT".equals(aLabel))
{
String mString = aPC.parseSpellString(selectedCSpell, aPC.getDescription(aSpell));
String mString = aPC.getInfoToken(".INFO.DESC", aSpell);
if (mString.equals(".INFO.DESC"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mertonmonk
CheckstyleMain doesn't allow IFs without curly brackets, because the code might be misleading. Should append be within IF, or not?
What variant you meant?
image
or
image
thanks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The append should be outside of the if statement so it appends mString whether it was re-defined within the if statement or not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out the gradlew target. It's been quite a while since I did much coding for PCGen, so there is a lot of new code and I'm not particularly familiar with gradle. I wish I had the time and energy to pull out all the interfaces - I think code should be simple so it's easier for newer developers to understand.

mString = aPC.parseSpellString(selectedCSpell, aPC.getDescription(aSpell));
retValue.append(mString);
}
else if ("TARGET".equals(aLabel) || "EFFECTYPE".equals(aLabel))
Expand Down