Improved rule text generation.

This commit is contained in:
LevelX2 2013-10-14 20:35:37 +02:00
parent b83634605c
commit e8d4fd1ead

View file

@ -28,13 +28,12 @@
package mage.abilities.effects; package mage.abilities.effects;
import mage.constants.Outcome;
import mage.abilities.Mode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import mage.abilities.Mode;
import mage.constants.Outcome;
/** /**
* *
@ -56,23 +55,32 @@ public class Effects extends ArrayList<Effect> {
public String getText(Mode mode) { public String getText(Mode mode) {
StringBuilder sbText = new StringBuilder(); StringBuilder sbText = new StringBuilder();
String rule = null;
for (Effect effect: this) { for (Effect effect: this) {
String rule = effect.getText(mode); String endString = "";
if (rule != null && rule.length()> 3 && !rule.endsWith(". ")) {
endString = ". ";
}
rule = effect.getText(mode);
if (rule != null) { if (rule != null) {
sbText.append(rule); if (rule.startsWith("and ")) {
if (!rule.endsWith(". ")) { endString = " ";
sbText.append(". "); }
sbText.append(endString).append(rule);
} }
} }
if (rule != null && rule.length()> 3 && !rule.endsWith(". ")) {
sbText.append(".");
} }
return sbText.toString(); return sbText.toString();
} }
public boolean hasOutcome(Outcome outcome) { public boolean hasOutcome(Outcome outcome) {
for (Effect effect: this) { for (Effect effect: this) {
if (effect.getOutcome() == outcome) if (effect.getOutcome() == outcome) {
return true; return true;
} }
}
return false; return false;
} }
@ -87,11 +95,13 @@ public class Effects extends ArrayList<Effect> {
public int getOutcomeTotal() { public int getOutcomeTotal() {
int total = 0; int total = 0;
for (Effect effect: this) { for (Effect effect: this) {
if (effect.getOutcome().isGood()) if (effect.getOutcome().isGood()) {
total++; total++;
else }
else {
total--; total--;
} }
}
return total; return total;
} }