mirror of
https://github.com/correl/mage.git
synced 2024-12-25 19:25:41 +00:00
Refactor: moved flavor word from effects list to ability/mode;
This commit is contained in:
parent
2d1e11dfa9
commit
6dafb3ad81
13 changed files with 52 additions and 40 deletions
|
@ -31,11 +31,12 @@ public final class BalefulBeholder extends CardImpl {
|
|||
// When Baleful Beholder enters the battlefield, choose one —
|
||||
// • Antimagic Cone — Each opponent sacrifices an enchantment.
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(new SacrificeOpponentsEffect(StaticFilters.FILTER_ENCHANTMENT_PERMANENT));
|
||||
ability.getEffects().setFlavorWord("Antimagic Cone");
|
||||
ability.withFlavorWord("Antimagic Cone");
|
||||
|
||||
// • Fear Ray — Creatures you control gain menace until end of turn.
|
||||
ability.addMode(new Mode(new GainAbilityControlledEffect(
|
||||
new MenaceAbility(), Duration.EndOfTurn, StaticFilters.FILTER_PERMANENT_CREATURES)).setFlavorWord("Fear Ray"));
|
||||
new MenaceAbility(), Duration.EndOfTurn, StaticFilters.FILTER_PERMANENT_CREATURES))
|
||||
.withFlavorWord("Fear Ray"));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,17 +32,17 @@ public final class DawnbringerCleric extends CardImpl {
|
|||
// When Dawnbringer Cleric enters the battlefield, choose one —
|
||||
// • Cure Wounds — You gain 2 life.
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(new GainLifeEffect(1));
|
||||
ability.getEffects().setFlavorWord("Cure Wounds");
|
||||
ability.withFlavorWord("Cure Wounds");
|
||||
|
||||
// • Dispel Magic — Destroy target enchantment.
|
||||
Mode mode = new Mode(new DestroyTargetEffect());
|
||||
mode.addTarget(new TargetEnchantmentPermanent());
|
||||
ability.addMode(mode.setFlavorWord("Dispel Magic"));
|
||||
ability.addMode(mode.withFlavorWord("Dispel Magic"));
|
||||
|
||||
// • Gentle Repose — Exile target card from a graveyard.
|
||||
mode = new Mode(new ExileTargetEffect());
|
||||
mode.addTarget(new TargetCardInGraveyard());
|
||||
ability.addMode(mode.setFlavorWord("Gentle Repose"));
|
||||
ability.addMode(mode.withFlavorWord("Gentle Repose"));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public final class GuildThief extends CardImpl {
|
|||
// Cunning Action — {3}{U}: Guild Thief can't be blocked this turn.
|
||||
this.addAbility(new SimpleActivatedAbility(
|
||||
new CantBeBlockedSourceEffect(Duration.EndOfTurn), new ManaCostsImpl<>("{3}{U}")
|
||||
).setFlavorWord("Cunning Action"));
|
||||
).withFlavorWord("Cunning Action"));
|
||||
}
|
||||
|
||||
private GuildThief(final GuildThief card) {
|
||||
|
|
|
@ -31,10 +31,12 @@ public final class InspiringBard extends CardImpl {
|
|||
// • Bardic Inspiration — Target creature gets +2/+2 until end of turn.
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(new BoostTargetEffect(2, 2));
|
||||
ability.addTarget(new TargetCreaturePermanent());
|
||||
ability.getEffects().setFlavorWord("Bardic Inspiration");
|
||||
ability.withFlavorWord("Bardic Inspiration");
|
||||
|
||||
// • Song of Rest — You gain 3 life.
|
||||
ability.addMode(new Mode(new GainLifeEffect(3)).setFlavorWord("Song of Rest"));
|
||||
ability.addMode(new Mode(
|
||||
new GainLifeEffect(3)
|
||||
).withFlavorWord("Song of Rest"));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,12 @@ public final class PlunderingBarbarian extends CardImpl {
|
|||
// • Smash the Chest — Destroy target artifact.
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(new DestroyTargetEffect());
|
||||
ability.addTarget(new TargetArtifactPermanent());
|
||||
ability.getEffects().setFlavorWord("Smash the Chest");
|
||||
ability.withFlavorWord("Smash the Chest");
|
||||
|
||||
// • Pry It Open — Creature a Treasure token.
|
||||
ability.addMode(new Mode(new CreateTokenEffect(new TreasureToken())).setFlavorWord("Pry It Open"));
|
||||
ability.addMode(new Mode(
|
||||
new CreateTokenEffect(new TreasureToken())
|
||||
).withFlavorWord("Pry It Open"));
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@ public final class YouFindTheVillainsLair extends CardImpl {
|
|||
// • Foil Their Scheme — Counter target spell.
|
||||
this.getSpellAbility().addEffect(new CounterTargetEffect());
|
||||
this.getSpellAbility().addTarget(new TargetSpell());
|
||||
this.getSpellAbility().getEffects().setFlavorWord("Foil Their Scheme");
|
||||
this.getSpellAbility().withFlavorWord("Foil Their Scheme");
|
||||
|
||||
// • Learn Their Secrets — Draw two cards, then discard two cards.
|
||||
this.getSpellAbility().addMode(new Mode(
|
||||
new DrawDiscardControllerEffect(2, 2)
|
||||
).setFlavorWord("Learn Their Secrts"));
|
||||
).withFlavorWord("Learn Their Secrts"));
|
||||
}
|
||||
|
||||
private YouFindTheVillainsLair(final YouFindTheVillainsLair card) {
|
||||
|
|
|
@ -25,12 +25,12 @@ public final class YouSeeAGuardApproach extends CardImpl {
|
|||
// • Distract the Guard — Tap target creature.
|
||||
this.getSpellAbility().addEffect(new TapTargetEffect());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
this.getSpellAbility().getEffects().setFlavorWord("Distract the Guard");
|
||||
this.getSpellAbility().withFlavorWord("Distract the Guard");
|
||||
|
||||
// • Hide — Target creature you control gains hexproof until end of turn.
|
||||
Mode mode = new Mode(new GainAbilityTargetEffect(HexproofAbility.getInstance(), Duration.EndOfTurn));
|
||||
mode.addTarget(new TargetControlledCreaturePermanent());
|
||||
this.getSpellAbility().addMode(mode.setFlavorWord("Hide"));
|
||||
this.getSpellAbility().addMode(mode.withFlavorWord("Hide"));
|
||||
}
|
||||
|
||||
private YouSeeAGuardApproach(final YouSeeAGuardApproach card) {
|
||||
|
|
|
@ -22,12 +22,12 @@ public final class YouSeeAPairOfGoblins extends CardImpl {
|
|||
// Choose one —
|
||||
// • Charge Them — Creatures you control get +2/+0 until end of turn.
|
||||
this.getSpellAbility().addEffect(new BoostControlledEffect(2, 0, Duration.EndOfTurn));
|
||||
this.getSpellAbility().getEffects().setFlavorWord("Charge Them");
|
||||
this.getSpellAbility().withFlavorWord("Charge Them");
|
||||
|
||||
// • Befriend Them — Create two 1/1 red Goblin creature tokens.
|
||||
this.getSpellAbility().addMode(new Mode(
|
||||
new CreateTokenEffect(new GoblinToken(), 2)
|
||||
).setFlavorWord("Befriend Them"));
|
||||
).withFlavorWord("Befriend Them"));
|
||||
}
|
||||
|
||||
private YouSeeAPairOfGoblins(final YouSeeAPairOfGoblins card) {
|
||||
|
|
|
@ -466,7 +466,13 @@ public interface Ability extends Controllable, Serializable {
|
|||
*/
|
||||
Ability setAbilityWord(AbilityWord abilityWord);
|
||||
|
||||
Ability setFlavorWord(String flavorWord);
|
||||
/**
|
||||
* Set Flavor word for current mode
|
||||
*
|
||||
* @param flavorWord
|
||||
* @return
|
||||
*/
|
||||
Ability withFlavorWord(String flavorWord);
|
||||
|
||||
/**
|
||||
* Creates the message about the ability casting/triggering/activating to
|
||||
|
|
|
@ -60,7 +60,6 @@ public abstract class AbilityImpl implements Ability {
|
|||
protected Zone zone;
|
||||
protected String name;
|
||||
protected AbilityWord abilityWord;
|
||||
protected String flavorWord;
|
||||
protected boolean usesStack = true;
|
||||
protected boolean ruleAtTheTop = false;
|
||||
protected boolean ruleVisible = true;
|
||||
|
@ -118,7 +117,6 @@ public abstract class AbilityImpl implements Ability {
|
|||
this.ruleAdditionalCostsVisible = ability.ruleAdditionalCostsVisible;
|
||||
this.worksFaceDown = ability.worksFaceDown;
|
||||
this.abilityWord = ability.abilityWord;
|
||||
this.flavorWord = ability.flavorWord;
|
||||
this.sourceObjectZoneChangeCounter = ability.sourceObjectZoneChangeCounter;
|
||||
this.canFizzle = ability.canFizzle;
|
||||
this.targetAdjuster = ability.targetAdjuster;
|
||||
|
@ -805,8 +803,6 @@ public abstract class AbilityImpl implements Ability {
|
|||
String prefix;
|
||||
if (abilityWord != null) {
|
||||
prefix = abilityWord.formatWord();
|
||||
} else if (flavorWord != null) {
|
||||
prefix = "<i>" + flavorWord + "</i> — ";
|
||||
} else {
|
||||
prefix = null;
|
||||
}
|
||||
|
@ -1072,8 +1068,9 @@ public abstract class AbilityImpl implements Ability {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Ability setFlavorWord(String flavorWord) {
|
||||
this.flavorWord = flavorWord;
|
||||
@Override
|
||||
public Ability withFlavorWord(String flavorWord) {
|
||||
this.getModes().getMode().withFlavorWord(flavorWord);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ public class Mode implements Serializable {
|
|||
protected UUID id;
|
||||
protected final Targets targets;
|
||||
protected final Effects effects;
|
||||
protected String flavorWord;
|
||||
|
||||
public Mode() {
|
||||
this((Effect) null);
|
||||
|
@ -34,6 +35,7 @@ public class Mode implements Serializable {
|
|||
this.id = mode.id;
|
||||
this.targets = mode.targets.copy();
|
||||
this.effects = mode.effects.copy();
|
||||
this.flavorWord = mode.flavorWord;
|
||||
}
|
||||
|
||||
public UUID setRandomId() {
|
||||
|
@ -71,8 +73,18 @@ public class Mode implements Serializable {
|
|||
effects.add(effect);
|
||||
}
|
||||
|
||||
public Mode setFlavorWord(String flavorWord) {
|
||||
effects.setFlavorWord(flavorWord);
|
||||
public String getFlavorWord() {
|
||||
return flavorWord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Flavor word to the mode (same as ability/ancher words, but uses for lore/info and represents a possible choices)
|
||||
*
|
||||
* @param flavorWord
|
||||
* @return
|
||||
*/
|
||||
public Mode withFlavorWord(String flavorWord) {
|
||||
this.flavorWord = flavorWord;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,7 +96,6 @@ public class Effects extends ArrayList<Effect> {
|
|||
sbText.append(currentRule);
|
||||
|
||||
lastRule = nextRule;
|
||||
|
||||
}
|
||||
|
||||
// add punctuation to very last rule.
|
||||
|
@ -113,11 +108,12 @@ public class Effects extends ArrayList<Effect> {
|
|||
sbText.append('.');
|
||||
}
|
||||
|
||||
if (flavorWord != null) {
|
||||
return "<i>" + flavorWord + "</i> — " + CardUtil.getTextWithFirstCharUpperCase(sbText.toString());
|
||||
}
|
||||
return sbText.toString();
|
||||
// flavor word
|
||||
if (mode.getFlavorWord() != null) {
|
||||
return "<i>" + mode.getFlavorWord() + "</i> — " + 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -497,7 +497,7 @@ public class StackAbility extends StackObjectImpl implements Ability {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Ability setFlavorWord(String flavorWord) {
|
||||
public Ability withFlavorWord(String flavorWord) {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue