Card.getText()
I have recently spent some time in this section. We have a number of new keywords that were not showing up on Instants and Sorceries. I just added "CARDNAME is {color} for Ghostfire and Ancestral Vision. I also cleaned up and consolidated the code in this section.
I think that I am starting to understand why we have had this problem ever since Rob added the cantrip code. Instants and Sorceries have the spell abilities and the spellText combined but it had no code for adding keywords which do not create a spell ability with it's own spell ability description.
So things are a little bit better now but with the large number of new keywords added this summer it is possible that I may have overlooked a few. So the Card.getText() code for Instants and Sorceries now look like this:
I think that I am starting to understand why we have had this problem ever since Rob added the cantrip code. Instants and Sorceries have the spell abilities and the spellText combined but it had no code for adding keywords which do not create a spell ability with it's own spell ability description.
So things are a little bit better now but with the large number of new keywords added this summer it is possible that I may have overlooked a few. So the Card.getText() code for Instants and Sorceries now look like this:
- Code: Select all
public String getText() {
if(isInstant() || isSorcery()) {
String s = getSpellText();
StringBuilder sb = new StringBuilder();
// Give spellText line breaks for easier reading
sb.append(s.replaceAll("\\\\r\\\\n", "\r\n"));
// NOTE:
if (sb.toString().contains(" (NOTE: ")) {
sb.insert(sb.indexOf("(NOTE: "), "\r\n");
}
if (sb.toString().contains("(NOTE: ") && sb.toString().endsWith(".)") && !sb.toString().endsWith("\r\n")) {
sb.append("\r\n");
}
// Add SpellAbilities
SpellAbility[] sa = getSpellAbility();
for (int i = 0; i < sa.length; i++) {
sb.append(sa[i].toString() + "\r\n");
}
// Add Keywords
ArrayList<String> kw = getKeyword();
// Ripple + Dredge + Madness + CARDNAME is {color}.
for (int i = 0; i < kw.size(); i++) {
if ((kw.get(i).startsWith("Ripple") && !sb.toString().contains("Ripple"))
|| (kw.get(i).startsWith("Dredge") && !sb.toString().contains("Dredge"))
|| (kw.get(i).startsWith("Madness") && !sb.toString().contains("Madness"))
|| (kw.get(i).startsWith("CARDNAME is ") && !sb.toString().contains("CARDNAME is "))) {
sb.append(kw.get(i).replace(":", " ")).append("\r\n");
}
}
// Draw a card. + Changeling + CARDNAME can't be countered. + Cascade
for (int i = 0; i < kw.size(); i++) {
if ((kw.get(i).contains("Draw a card.") && !sb.toString().contains("Draw a card."))
|| (kw.get(i).contains("Changeling") && !sb.toString().contains("Changeling"))
|| (kw.get(i).contains("CARDNAME can't be countered.") && !sb.toString().contains("CARDNAME can't be countered."))
|| (kw.get(i).contains("Cascade") && !sb.toString().contains("Cascade"))) {
sb.append(kw.get(i)).append("\r\n");
}
}
// Storm
if (getKeyword().contains("Storm") && !sb.toString().contains("Storm (When you ")) {
if (sb.toString().endsWith("\r\n\r\n")) {
sb.delete(sb.lastIndexOf("\r\n"), sb.lastIndexOf("\r\n")+3);
}
sb.append("Storm (When you cast this spell, copy it for each spell cast before it this turn.");
if (sb.toString().contains("Target") || sb.toString().contains("target")) {
sb.append(" You may choose new targets for the copies.");
}
sb.append(")\r\n");
}
// Scry
if(!sb.toString().contains("Scry")) for(int i = 0; i < getKeyword().size(); i++) {
String k = getKeyword().get(i);
if(k.startsWith("Scry")) {
String kk[] = k.split(" ");
//sb.append("Scry " + kk[1] + " (To scry X, look at the top X cards of your library, then put any number of them on the bottom of your library and the rest on top in any order.)\r\n");
sb.append("Scry ");
sb.append(kk[1]);
sb.append(" (To scry X, look at the top X cards of your library, then put any number of them on the bottom of your library and the rest on top in any order.)\r\n");
}
}
while (sb.toString().endsWith("\r\n")) {
sb.delete(sb.lastIndexOf("\r\n"), sb.lastIndexOf("\r\n")+3);
}
return sb.toString().replaceAll("CARDNAME", getName());
}