Refactor: moved flavor word from effects list to ability/mode;

This commit is contained in:
Oleg Agafonov 2021-06-30 08:57:06 +04:00
parent 2d1e11dfa9
commit 6dafb3ad81
13 changed files with 52 additions and 40 deletions

View file

@ -14,14 +14,11 @@ import java.util.Arrays;
*/
public class Effects extends ArrayList<Effect> {
private String flavorWord = null;
public Effects(Effect... effects) {
this.addAll(Arrays.asList(effects));
}
public Effects(final Effects effects) {
this.flavorWord = effects.flavorWord;
for (Effect effect : effects) {
this.add(effect.copy());
}
@ -64,7 +61,6 @@ public class Effects extends ArrayList<Effect> {
}
}
//check if nextRule is a new sentence or not.
if (nextRule.startsWith("and ") || nextRule.startsWith("with ") || nextRule.startsWith("then ")) {
endString = " ";
@ -100,10 +96,9 @@ public class Effects extends ArrayList<Effect> {
sbText.append(currentRule);
lastRule = nextRule;
}
//add punctuation to very last rule.
// add punctuation to very last rule.
if (lastRule != null && lastRule.length() > 3
&& !lastRule.endsWith(".")
&& !lastRule.endsWith("\"")
@ -113,11 +108,12 @@ public class Effects extends ArrayList<Effect> {
sbText.append('.');
}
if (flavorWord != null) {
return "<i>" + flavorWord + "</i> &mdash; " + CardUtil.getTextWithFirstCharUpperCase(sbText.toString());
}
return sbText.toString();
// flavor word
if (mode.getFlavorWord() != null) {
return "<i>" + mode.getFlavorWord() + "</i> &mdash; " + CardUtil.getTextWithFirstCharUpperCase(sbText.toString());
};
return sbText.toString();
}
public boolean hasOutcome(Ability source, Outcome outcome) {
@ -195,8 +191,4 @@ public class Effects extends ArrayList<Effect> {
effect.setValue(key, value);
}
}
public void setFlavorWord(String flavorWord) {
this.flavorWord = flavorWord;
}
}