mirror of
https://github.com/correl/mage.git
synced 2024-12-27 20:06:31 +00:00
changes to auto-text generation, unclean
This commit is contained in:
parent
efcbdf968b
commit
16fa496c04
6 changed files with 81 additions and 14 deletions
|
@ -103,6 +103,9 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
StringBuilder sb = new StringBuilder(getEffects().getText(modes.getMode()));
|
StringBuilder sb = new StringBuilder(getEffects().getText(modes.getMode()));
|
||||||
|
|
||||||
|
System.out.printf("Beg.OfEndStep getRule called:: ", sb);
|
||||||
|
|
||||||
if (this.optional) {
|
if (this.optional) {
|
||||||
if (sb.substring(0, 6).toLowerCase(Locale.ENGLISH).equals("target")) {
|
if (sb.substring(0, 6).toLowerCase(Locale.ENGLISH).equals("target")) {
|
||||||
sb.insert(0, "you may have ");
|
sb.insert(0, "you may have ");
|
||||||
|
@ -114,6 +117,10 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
if (abilityWord != null) {
|
if (abilityWord != null) {
|
||||||
abilityWordRule = "<i>" + abilityWord.toString() + "</i> &mdash ";
|
abilityWordRule = "<i>" + abilityWord.toString() + "</i> &mdash ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.printf("Beg.OfEndStep getRule called:: ", sb);
|
||||||
|
|
||||||
|
|
||||||
switch (targetController) {
|
switch (targetController) {
|
||||||
case YOU:
|
case YOU:
|
||||||
return sb.insert(0, generateConditionString()).insert(0, abilityWordRule + "At the beginning of your end step, ").toString();
|
return sb.insert(0, generateConditionString()).insert(0, abilityWordRule + "At the beginning of your end step, ").toString();
|
||||||
|
@ -122,6 +129,8 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
return sb.insert(0, generateConditionString()).insert(0, abilityWordRule + "At the beginning of each opponent's end step, ").toString();
|
return sb.insert(0, generateConditionString()).insert(0, abilityWordRule + "At the beginning of each opponent's end step, ").toString();
|
||||||
case ANY:
|
case ANY:
|
||||||
|
//System.out.print("Beg.EndStep - Final Out::");
|
||||||
|
//m.System.out.println(sb.insert(0, generateConditionString()).insert(0, abilityWordRule + "At the beginning of each end step, ").toString());
|
||||||
return sb.insert(0, generateConditionString()).insert(0, abilityWordRule + "At the beginning of each end step, ").toString();
|
return sb.insert(0, generateConditionString()).insert(0, abilityWordRule + "At the beginning of each end step, ").toString();
|
||||||
case EACH_PLAYER:
|
case EACH_PLAYER:
|
||||||
return sb.insert(0, generateConditionString()).insert(0, abilityWordRule + "At the beginning of each player's end step, ").toString();
|
return sb.insert(0, generateConditionString()).insert(0, abilityWordRule + "At the beginning of each player's end step, ").toString();
|
||||||
|
@ -132,10 +141,19 @@ public class BeginningOfEndStepTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConditionString() {
|
private String generateConditionString() {
|
||||||
|
System.out.println("GenCondString called");
|
||||||
if (interveningIfClauseCondition != null) {
|
if (interveningIfClauseCondition != null) {
|
||||||
if (interveningIfClauseCondition.toString().startsWith("if")) {
|
if (interveningIfClauseCondition.toString().startsWith("if")) {
|
||||||
|
//System.out.println("GenCondString called 2");
|
||||||
|
//System.out.println(interveningIfClauseCondition.toString());
|
||||||
|
|
||||||
|
if (interveningIfClauseCondition.toString().endsWith(".")){
|
||||||
|
return interveningIfClauseCondition.toString() + " ";
|
||||||
|
}
|
||||||
|
|
||||||
return interveningIfClauseCondition.toString() + ", ";
|
return interveningIfClauseCondition.toString() + ", ";
|
||||||
} else {
|
} else {
|
||||||
|
//System.out.println("GenCondString called 3");
|
||||||
return "if {this} is " + interveningIfClauseCondition.toString() + ", ";
|
return "if {this} is " + interveningIfClauseCondition.toString() + ", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,15 +133,15 @@ public class BeginningOfUpkeepTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
sb.insert(0, "you may ");
|
sb.insert(0, "you may ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.insert(0, generateZoneString()).insert(0, "At the beginning of your upkeep, ").toString();
|
return sb.insert(0, generateZoneString()).insert(0, "at the beginning of your upkeep, ").toString(); //removed captialization
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
return sb.insert(0, generateZoneString()).insert(0, "At the beginning of each opponent's upkeep, ").toString();
|
return sb.insert(0, generateZoneString()).insert(0, "at the beginning of each opponent's upkeep, ").toString(); //removed captialization
|
||||||
case ANY:
|
case ANY:
|
||||||
return sb.insert(0, generateZoneString()).insert(0, "At the beginning of each upkeep, ").toString();
|
return sb.insert(0, generateZoneString()).insert(0, "at the beginning of each upkeep, ").toString(); //removed captialization
|
||||||
case ACTIVE:
|
case ACTIVE:
|
||||||
return sb.insert(0, generateZoneString()).insert(0, "At the beginning of each player's upkeep, ").toString();
|
return sb.insert(0, generateZoneString()).insert(0, "at the beginning of each player's upkeep, ").toString(); //removed captialization
|
||||||
case CONTROLLER_ATTACHED_TO:
|
case CONTROLLER_ATTACHED_TO:
|
||||||
return sb.insert(0, generateZoneString()).insert(0, "At the beginning of the upkeep of enchanted creature's controller, ").toString();
|
return sb.insert(0, generateZoneString()).insert(0, "at the beginning of the upkeep of enchanted creature's controller, ").toString(); //removed captialization
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,16 +90,16 @@ public class AtTheBeginOfNextEndStepDelayedTriggeredAbility extends DelayedTrigg
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
switch (targetController) {
|
switch (targetController) {
|
||||||
case YOU:
|
case YOU:
|
||||||
sb.append("At the beginning of your next end step, ");
|
sb.append("at the beginning of your next end step, "); //remove capitalization
|
||||||
break;
|
break;
|
||||||
case OPPONENT:
|
case OPPONENT:
|
||||||
sb.append("At the beginning of an opponent's next end step, ");
|
sb.append("at the beginning of an opponent's next end step, "); //remove capitalization
|
||||||
break;
|
break;
|
||||||
case ANY:
|
case ANY:
|
||||||
sb.append("At the beginning of the next end step, ");
|
sb.append("at the beginning of the next end step, "); //remove capitalization
|
||||||
break;
|
break;
|
||||||
case CONTROLLER_ATTACHED_TO:
|
case CONTROLLER_ATTACHED_TO:
|
||||||
sb.append("At the beginning of the next end step of enchanted creature's controller, ");
|
sb.append("at the beginning of the next end step of enchanted creature's controller, "); //remove capitalization
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sb.append(getEffects().getText(modes.getMode()));
|
sb.append(getEffects().getText(modes.getMode()));
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class Effects extends ArrayList<Effect> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText(Mode mode) {
|
public String getText(Mode mode) {
|
||||||
|
System.out.println(" -- getText method called -- ");
|
||||||
StringBuilder sbText = new StringBuilder();
|
StringBuilder sbText = new StringBuilder();
|
||||||
String lastRule = null;
|
String lastRule = null;
|
||||||
int effectNum = 0;
|
int effectNum = 0;
|
||||||
|
@ -44,6 +45,12 @@ public class Effects extends ArrayList<Effect> {
|
||||||
String endString = "";
|
String endString = "";
|
||||||
String nextRule = effect.getText(mode);
|
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
|
// ignore empty rules
|
||||||
if (nextRule == null || nextRule.isEmpty()) {
|
if (nextRule == null || nextRule.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -52,20 +59,37 @@ public class Effects extends ArrayList<Effect> {
|
||||||
|
|
||||||
// concat effects (default: each effect with a new sentence)
|
// concat effects (default: each effect with a new sentence)
|
||||||
String concatPrefix = effect.getConcatPrefix();
|
String concatPrefix = effect.getConcatPrefix();
|
||||||
|
System.out.print("concatPrefix:");
|
||||||
|
System.out.println(concatPrefix);
|
||||||
|
|
||||||
if (effectNum > 1 && !concatPrefix.isEmpty() && !concatPrefix.equals(".")) {
|
if (effectNum > 1 && !concatPrefix.isEmpty() && !concatPrefix.equals(".")) {
|
||||||
nextRule = concatPrefix + " " + nextRule;
|
nextRule = concatPrefix + " " + nextRule;
|
||||||
|
System.out.println("Catch 1!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextRule != null) {
|
if (nextRule != null) {
|
||||||
if (nextRule.startsWith("and ") || nextRule.startsWith("with ") || nextRule.startsWith("then ")) {
|
if (nextRule.startsWith("and ") || nextRule.startsWith("with ") || nextRule.startsWith("then ")) {
|
||||||
endString = " ";
|
endString = " ";
|
||||||
|
System.out.println("Catch 2!!");
|
||||||
} else if (nextRule.startsWith(",") || nextRule.startsWith(" ")) {
|
} else if (nextRule.startsWith(",") || nextRule.startsWith(" ")) {
|
||||||
endString = "";
|
endString = "";
|
||||||
|
System.out.println("Catch 3!!");
|
||||||
} else if (lastRule != null && lastRule.length() > 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 = ". ";
|
endString = ". ";
|
||||||
|
System.out.println("Catch 5!!");
|
||||||
}
|
}
|
||||||
if (nextRule.length() > 3) {
|
if (nextRule.length() > 3) {
|
||||||
|
System.out.println("Catch 6!!");
|
||||||
nextRule = Character.toUpperCase(nextRule.charAt(0)) + nextRule.substring(1);
|
nextRule = Character.toUpperCase(nextRule.charAt(0)) + nextRule.substring(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,18 +97,35 @@ public class Effects extends ArrayList<Effect> {
|
||||||
String currentRule = endString + nextRule;
|
String currentRule = endString + nextRule;
|
||||||
// fix dot in the combined effect like IfDoCost
|
// fix dot in the combined effect like IfDoCost
|
||||||
if (sbText.length() > 0 && currentRule.length() > 0) {
|
if (sbText.length() > 0 && currentRule.length() > 0) {
|
||||||
|
System.out.println("Catch 7!!");
|
||||||
boolean prevTextEndsWithDot = sbText.charAt(sbText.length() - 1) == '.';
|
boolean prevTextEndsWithDot = sbText.charAt(sbText.length() - 1) == '.';
|
||||||
boolean currentTextStartsWithDot = currentRule.startsWith(",") || currentRule.startsWith(".");
|
boolean currentTextStartsWithDot = currentRule.startsWith(",") || currentRule.startsWith(".");
|
||||||
if (prevTextEndsWithDot && currentTextStartsWithDot) {
|
if (prevTextEndsWithDot && currentTextStartsWithDot) {
|
||||||
|
System.out.println("Catch 8!!");
|
||||||
sbText.delete(sbText.length() - 1, sbText.length());
|
sbText.delete(sbText.length() - 1, sbText.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (!prevTextEndsWithDot){
|
||||||
|
System.out.println("Catch 10!!");
|
||||||
|
currentRule = currentRule + ".";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sbText.append(currentRule);
|
sbText.append(currentRule);
|
||||||
}
|
}
|
||||||
lastRule = nextRule;
|
lastRule = nextRule;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add punctuation to last line
|
||||||
if (lastRule != null && lastRule.length() > 3
|
if (lastRule != null && lastRule.length() > 3
|
||||||
&& !lastRule.endsWith(".")
|
&& !lastRule.endsWith(".")
|
||||||
&& !lastRule.endsWith("\"")
|
&& !lastRule.endsWith("\"")
|
||||||
|
@ -94,7 +135,13 @@ public class Effects extends ArrayList<Effect> {
|
||||||
sbText.append('.');
|
sbText.append('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
System.out.print("sbText from Effects - getText ::");
|
||||||
|
System.out.println(sbText);
|
||||||
|
|
||||||
return sbText.toString();
|
return sbText.toString();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasOutcome(Ability source, Outcome outcome) {
|
public boolean hasOutcome(Ability source, Outcome outcome) {
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class RevealCardsFromLibraryUntilEffect extends OneShotEffect {
|
||||||
sb.append("a random");
|
sb.append("a random");
|
||||||
|
|
||||||
}
|
}
|
||||||
sb.append(" order.");
|
sb.append(" order"); //removed punctuation
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,10 +76,12 @@ public class DistributeCountersEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = counterType.getName();
|
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) {
|
if (removeAtEndOfTurn) {
|
||||||
text += " For each " + name + " counter you put on a creature this way, remove a "
|
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;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -94,7 +96,7 @@ class RemoveCountersAtEndOfTurn extends OneShotEffect {
|
||||||
this.counterType = counterType;
|
this.counterType = counterType;
|
||||||
String name = counterType.getName();
|
String name = counterType.getName();
|
||||||
staticText = "For each " + name + " counter you put on a creature this way, remove a "
|
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) {
|
public RemoveCountersAtEndOfTurn(final RemoveCountersAtEndOfTurn effect) {
|
||||||
|
|
Loading…
Reference in a new issue