mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Added the possibility to hide a ability for rule text generation.
This commit is contained in:
parent
dc131fa8dd
commit
31616f876e
4 changed files with 50 additions and 2 deletions
|
@ -71,6 +71,9 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
||||||
List<String> rules = new ArrayList<String>();
|
List<String> rules = new ArrayList<String>();
|
||||||
|
|
||||||
for (T ability:this) {
|
for (T ability:this) {
|
||||||
|
if (!ability.getRuleVisible()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!(ability instanceof SpellAbility || ability instanceof PlayLandAbility)) {
|
if (!(ability instanceof SpellAbility || ability instanceof PlayLandAbility)) {
|
||||||
if (ability.getRuleAtTheTop()) {
|
if (ability.getRuleAtTheTop()) {
|
||||||
rules.add(0, ability.getRule());
|
rules.add(0, ability.getRule());
|
||||||
|
@ -304,7 +307,9 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
List<String> abilities = new ArrayList<String>();
|
List<String> abilities = new ArrayList<String>();
|
||||||
for (T ability: this) {
|
for (T ability: this) {
|
||||||
abilities.add(ability.toString());
|
if (ability.toString() != null) {
|
||||||
|
abilities.add(ability.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(abilities);
|
Collections.sort(abilities);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
|
@ -375,10 +375,30 @@ public interface Ability extends Controllable, Serializable {
|
||||||
/**
|
/**
|
||||||
* Sets the value for the ruleAtTheTop attribute
|
* Sets the value for the ruleAtTheTop attribute
|
||||||
*
|
*
|
||||||
|
* true = show the rule at the top position of the rules
|
||||||
|
*
|
||||||
* @param ruleAtTheTop
|
* @param ruleAtTheTop
|
||||||
*/
|
*/
|
||||||
void setRuleAtTheTop(boolean ruleAtTheTop);
|
void setRuleAtTheTop(boolean ruleAtTheTop);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this ability's rule is visible on the card tooltip
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean getRuleVisible();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value for the ruleVisible attribute
|
||||||
|
*
|
||||||
|
* true = rule will be shown for the card / permanent
|
||||||
|
* false = rule won't be shown
|
||||||
|
*
|
||||||
|
* @param ruleAtTheTop
|
||||||
|
*/
|
||||||
|
void setRuleVisible(boolean ruleVisible);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the originalId of the ability
|
* Get the originalId of the ability
|
||||||
*
|
*
|
||||||
|
|
|
@ -77,6 +77,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||||
protected String name;
|
protected String name;
|
||||||
protected boolean usesStack = true;
|
protected boolean usesStack = true;
|
||||||
protected boolean ruleAtTheTop = false;
|
protected boolean ruleAtTheTop = false;
|
||||||
|
protected boolean ruleVisible = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract T copy();
|
public abstract T copy();
|
||||||
|
@ -111,6 +112,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||||
}
|
}
|
||||||
this.modes = ability.modes.copy();
|
this.modes = ability.modes.copy();
|
||||||
this.ruleAtTheTop = ability.ruleAtTheTop;
|
this.ruleAtTheTop = ability.ruleAtTheTop;
|
||||||
|
this.ruleVisible = ability.ruleVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -417,7 +419,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||||
|
|
||||||
protected String formatRule(String rule, String source) {
|
protected String formatRule(String rule, String source) {
|
||||||
String replace = rule;
|
String replace = rule;
|
||||||
if (source != null && !source.isEmpty()) {
|
if (rule != null && source != null && !source.isEmpty()) {
|
||||||
replace = rule.replace("{this}", source);
|
replace = rule.replace("{this}", source);
|
||||||
replace = replace.replace("{source}", source);
|
replace = replace.replace("{source}", source);
|
||||||
}
|
}
|
||||||
|
@ -574,6 +576,17 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
|
||||||
this.ruleAtTheTop = ruleAtTheTop;
|
this.ruleAtTheTop = ruleAtTheTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getRuleVisible() {
|
||||||
|
return ruleVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRuleVisible(boolean ruleVisible) {
|
||||||
|
this.ruleVisible = ruleVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getOriginalId() {
|
public UUID getOriginalId() {
|
||||||
return this.originalId;
|
return this.originalId;
|
||||||
|
|
|
@ -373,6 +373,16 @@ public class StackAbility implements StackObject, Ability {
|
||||||
this.ability.setRuleAtTheTop(ruleAtTheTop);
|
this.ability.setRuleAtTheTop(ruleAtTheTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getRuleVisible() {
|
||||||
|
return this.ability.getRuleVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRuleVisible(boolean ruleVisible) {
|
||||||
|
this.ability.setRuleVisible(ruleVisible);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUID getOriginalId() {
|
public UUID getOriginalId() {
|
||||||
return this.ability.getOriginalId();
|
return this.ability.getOriginalId();
|
||||||
|
|
Loading…
Reference in a new issue