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;
import mage.constants.Outcome;
import mage.abilities.Mode;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
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) {
StringBuilder sbText = new StringBuilder();
String rule = null;
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) {
sbText.append(rule);
if (!rule.endsWith(". ")) {
sbText.append(". ");
if (rule.startsWith("and ")) {
endString = " ";
}
sbText.append(endString).append(rule);
}
}
if (rule != null && rule.length()> 3 && !rule.endsWith(". ")) {
sbText.append(".");
}
return sbText.toString();
}
public boolean hasOutcome(Outcome outcome) {
for (Effect effect: this) {
if (effect.getOutcome() == outcome)
if (effect.getOutcome() == outcome) {
return true;
}
}
return false;
}
@ -87,11 +95,13 @@ public class Effects extends ArrayList<Effect> {
public int getOutcomeTotal() {
int total = 0;
for (Effect effect: this) {
if (effect.getOutcome().isGood())
if (effect.getOutcome().isGood()) {
total++;
else
}
else {
total--;
}
}
return total;
}