mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 11:02:00 -08:00
refactor: simplified code (related to 6bf8aedce7)
This commit is contained in:
parent
5bee368b81
commit
c0c27c81fa
3 changed files with 21 additions and 42 deletions
|
|
@ -238,9 +238,12 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public String getRule(boolean all) {
|
public String getRule(boolean all) {
|
||||||
if (all) {
|
if (all) {
|
||||||
return new StringBuilder(super.getRule(all)).append(name).toString();
|
// show full rules, e.g. for hand
|
||||||
|
return super.getRule(true) + this.name;
|
||||||
|
} else {
|
||||||
|
// hide spell ability, e.g. for permanent
|
||||||
|
return super.getRule(false);
|
||||||
}
|
}
|
||||||
return super.getRule(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package mage.cards;
|
package mage.cards;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Modes;
|
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.effects.common.ExileAdventureSpellEffect;
|
import mage.abilities.effects.common.ExileAdventureSpellEffect;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
|
@ -162,24 +161,13 @@ class AdventureCardSpellAbility extends SpellAbility {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule(boolean all) {
|
public String getRule(boolean all) {
|
||||||
return this.getRule();
|
// TODO: must hide rules in permanent like SpellAbility, but can't due effects text
|
||||||
}
|
return this.nameFull
|
||||||
|
+ " "
|
||||||
@Override
|
+ getManaCosts().getText()
|
||||||
public String getRule() {
|
+ " — "
|
||||||
StringBuilder sbRule = new StringBuilder();
|
+ super.getRule(false) // without cost
|
||||||
sbRule.append(this.nameFull);
|
+ " <i>(Then exile this card. You may cast the creature later from exile.)</i>";
|
||||||
sbRule.append(" ");
|
|
||||||
sbRule.append(getManaCosts().getText());
|
|
||||||
sbRule.append(" — ");
|
|
||||||
Modes modes = this.getModes();
|
|
||||||
if (modes.size() <= 1) {
|
|
||||||
sbRule.append(modes.getMode().getEffects().getTextStartingUpperCase(modes.getMode()));
|
|
||||||
} else {
|
|
||||||
sbRule.append(getModes().getText());
|
|
||||||
}
|
|
||||||
sbRule.append(" <i>(Then exile this card. You may cast the creature later from exile.)</i>");
|
|
||||||
return sbRule.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package mage.cards;
|
package mage.cards;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Modes;
|
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.common.ShuffleIntoLibrarySourceEffect;
|
import mage.abilities.effects.common.ShuffleIntoLibrarySourceEffect;
|
||||||
|
|
@ -134,8 +133,8 @@ class OmenCardSpellAbility extends SpellAbility {
|
||||||
this.nameFull = ability.nameFull;
|
this.nameFull = ability.nameFull;
|
||||||
if (!ability.finalized) {
|
if (!ability.finalized) {
|
||||||
throw new IllegalStateException("Wrong code usage. "
|
throw new IllegalStateException("Wrong code usage. "
|
||||||
+ "Omen (" + cardName + ") "
|
+ "Omen (" + cardName + ") "
|
||||||
+ "need to call finalizeOmen() at the very end of the card's constructor.");
|
+ "need to call finalizeOmen() at the very end of the card's constructor.");
|
||||||
}
|
}
|
||||||
this.finalized = true;
|
this.finalized = true;
|
||||||
}
|
}
|
||||||
|
|
@ -147,24 +146,13 @@ class OmenCardSpellAbility extends SpellAbility {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule(boolean all) {
|
public String getRule(boolean all) {
|
||||||
return this.getRule();
|
// TODO: must hide rules in permanent like SpellAbility, but can't due effects text
|
||||||
}
|
return this.nameFull
|
||||||
|
+ " "
|
||||||
@Override
|
+ getManaCosts().getText()
|
||||||
public String getRule() {
|
+ " — "
|
||||||
StringBuilder sbRule = new StringBuilder();
|
+ super.getRule(false) // without cost
|
||||||
sbRule.append(this.nameFull);
|
+ " <i>(Then shuffle this card into its owner's library.)</i>";
|
||||||
sbRule.append(" ");
|
|
||||||
sbRule.append(getManaCosts().getText());
|
|
||||||
sbRule.append(" — ");
|
|
||||||
Modes modes = this.getModes();
|
|
||||||
if (modes.size() <= 1) {
|
|
||||||
sbRule.append(modes.getMode().getEffects().getTextStartingUpperCase(modes.getMode()));
|
|
||||||
} else {
|
|
||||||
sbRule.append(getModes().getText());
|
|
||||||
}
|
|
||||||
sbRule.append(" <i>(Then shuffle this card into its owner's library.)<i>");
|
|
||||||
return sbRule.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue