forked from External/mage
changes to auto-text generation, unclean
This commit is contained in:
parent
efcbdf968b
commit
16fa496c04
6 changed files with 81 additions and 14 deletions
|
|
@ -37,6 +37,7 @@ public class Effects extends ArrayList<Effect> {
|
|||
}
|
||||
|
||||
public String getText(Mode mode) {
|
||||
System.out.println(" -- getText method called -- ");
|
||||
StringBuilder sbText = new StringBuilder();
|
||||
String lastRule = null;
|
||||
int effectNum = 0;
|
||||
|
|
@ -44,6 +45,12 @@ public class Effects extends ArrayList<Effect> {
|
|||
String endString = "";
|
||||
String nextRule = effect.getText(mode);
|
||||
|
||||
System.out.printf("Effect Num: %d\n", effectNum);
|
||||
System.out.print("nextRule from Effects - getText:: ");
|
||||
System.out.println(nextRule);
|
||||
System.out.print("lastRule from Effects - getText:: ");
|
||||
System.out.println(lastRule);
|
||||
|
||||
// ignore empty rules
|
||||
if (nextRule == null || nextRule.isEmpty()) {
|
||||
continue;
|
||||
|
|
@ -52,20 +59,37 @@ public class Effects extends ArrayList<Effect> {
|
|||
|
||||
// concat effects (default: each effect with a new sentence)
|
||||
String concatPrefix = effect.getConcatPrefix();
|
||||
System.out.print("concatPrefix:");
|
||||
System.out.println(concatPrefix);
|
||||
|
||||
if (effectNum > 1 && !concatPrefix.isEmpty() && !concatPrefix.equals(".")) {
|
||||
nextRule = concatPrefix + " " + nextRule;
|
||||
System.out.println("Catch 1!!");
|
||||
}
|
||||
|
||||
if (nextRule != null) {
|
||||
if (nextRule.startsWith("and ") || nextRule.startsWith("with ") || nextRule.startsWith("then ")) {
|
||||
endString = " ";
|
||||
System.out.println("Catch 2!!");
|
||||
} else if (nextRule.startsWith(",") || nextRule.startsWith(" ")) {
|
||||
endString = "";
|
||||
System.out.println("Catch 3!!");
|
||||
} else if (lastRule != null && lastRule.length() > 3) {
|
||||
if (!lastRule.endsWith(".") && !lastRule.endsWith("<br>")) {
|
||||
System.out.println("Catch 4!!");
|
||||
//check if lastRule already has appropriate punctuation, if so, add a space
|
||||
if (lastRule.endsWith(".\"") ||
|
||||
lastRule.endsWith(".)") ||
|
||||
lastRule.endsWith(".)</i>") ||
|
||||
lastRule.endsWith(".")){
|
||||
endString = " ";
|
||||
System.out.println("Catch 9!!");
|
||||
// if lastRule does not have appropriate punctuation, add the default ". "
|
||||
} else if (!lastRule.endsWith(".") && !lastRule.endsWith("<br>")) {
|
||||
endString = ". ";
|
||||
System.out.println("Catch 5!!");
|
||||
}
|
||||
if (nextRule.length() > 3) {
|
||||
System.out.println("Catch 6!!");
|
||||
nextRule = Character.toUpperCase(nextRule.charAt(0)) + nextRule.substring(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -73,18 +97,35 @@ public class Effects extends ArrayList<Effect> {
|
|||
String currentRule = endString + nextRule;
|
||||
// fix dot in the combined effect like IfDoCost
|
||||
if (sbText.length() > 0 && currentRule.length() > 0) {
|
||||
System.out.println("Catch 7!!");
|
||||
boolean prevTextEndsWithDot = sbText.charAt(sbText.length() - 1) == '.';
|
||||
boolean currentTextStartsWithDot = currentRule.startsWith(",") || currentRule.startsWith(".");
|
||||
if (prevTextEndsWithDot && currentTextStartsWithDot) {
|
||||
System.out.println("Catch 8!!");
|
||||
sbText.delete(sbText.length() - 1, sbText.length());
|
||||
}
|
||||
|
||||
/*
|
||||
if (!prevTextEndsWithDot){
|
||||
System.out.println("Catch 10!!");
|
||||
currentRule = currentRule + ".";
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
sbText.append(currentRule);
|
||||
}
|
||||
lastRule = nextRule;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//add punctuation to last line
|
||||
if (lastRule != null && lastRule.length() > 3
|
||||
&& !lastRule.endsWith(".")
|
||||
&& !lastRule.endsWith("\"")
|
||||
|
|
@ -94,7 +135,13 @@ public class Effects extends ArrayList<Effect> {
|
|||
sbText.append('.');
|
||||
}
|
||||
|
||||
|
||||
System.out.print("sbText from Effects - getText ::");
|
||||
System.out.println(sbText);
|
||||
|
||||
return sbText.toString();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean hasOutcome(Ability source, Outcome outcome) {
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ public class RevealCardsFromLibraryUntilEffect extends OneShotEffect {
|
|||
sb.append("a random");
|
||||
|
||||
}
|
||||
sb.append(" order.");
|
||||
sb.append(" order"); //removed punctuation
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,10 +76,12 @@ public class DistributeCountersEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
String name = counterType.getName();
|
||||
String text = "distribute " + CardUtil.numberToText(amount) + ' ' + name + " counters among " + targetDescription + '.';
|
||||
//String text = "distribute " + CardUtil.numberToText(amount) + ' ' + name + " counters among " + targetDescription + '.';
|
||||
//removed punctuation
|
||||
String text = "distribute " + CardUtil.numberToText(amount) + ' ' + name + " counters among " + targetDescription;
|
||||
if (removeAtEndOfTurn) {
|
||||
text += " For each " + name + " counter you put on a creature this way, remove a "
|
||||
+ name + " counter from that creature at the beginning of the next cleanup step.";
|
||||
+ name + " counter from that creature at the beginning of the next cleanup step."; //should this period be removed?
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
|
@ -94,7 +96,7 @@ class RemoveCountersAtEndOfTurn extends OneShotEffect {
|
|||
this.counterType = counterType;
|
||||
String name = counterType.getName();
|
||||
staticText = "For each " + name + " counter you put on a creature this way, remove a "
|
||||
+ name + " counter from that creature at the beginning of the next cleanup step.";
|
||||
+ name + " counter from that creature at the beginning of the next cleanup step."; //should this period be removed?
|
||||
}
|
||||
|
||||
public RemoveCountersAtEndOfTurn(final RemoveCountersAtEndOfTurn effect) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue