mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
[CMM] Implement Omarthis, Ghostfire Initiate (#10681)
ManifestEffect now takes a DynamicValue
This commit is contained in:
parent
2b3f775aaf
commit
286696800e
4 changed files with 117 additions and 14 deletions
|
|
@ -39,16 +39,17 @@ public class PutCounterOnCreatureTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
|
||||
public PutCounterOnCreatureTriggeredAbility(Effect effect, Counter counter, FilterPermanent filter, boolean setTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
this(effect, counter, filter, setTargetPointer, false);
|
||||
}
|
||||
|
||||
|
||||
public PutCounterOnCreatureTriggeredAbility(Effect effect, Counter counter, FilterPermanent filter, boolean setTargetPointer, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.counterType = counter;
|
||||
this.filter = filter;
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
if (counter == null) {
|
||||
setTriggerPhrase("Whenever you put one or more counters on a " + filter.getMessage() + ", ");
|
||||
}
|
||||
else {
|
||||
setTriggerPhrase("Whenever you put one or more " + counter.getName() + " counters on a " + filter.getMessage() + ", ");
|
||||
}
|
||||
|
||||
setFilterMessage();
|
||||
}
|
||||
|
||||
public PutCounterOnCreatureTriggeredAbility(final PutCounterOnCreatureTriggeredAbility ability) {
|
||||
|
|
@ -89,4 +90,17 @@ public class PutCounterOnCreatureTriggeredAbility extends TriggeredAbilityImpl {
|
|||
getEffects().setValue("countersAdded", event.getAmount());
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setFilterMessage() {
|
||||
String filterMessage = filter.getMessage();
|
||||
if (!filterMessage.startsWith("another")) {
|
||||
filterMessage = "a " + filterMessage;
|
||||
}
|
||||
|
||||
if (this.counterType == null) {
|
||||
setTriggerPhrase("Whenever you put one or more counters on " + filterMessage + ", ");
|
||||
} else {
|
||||
setTriggerPhrase("Whenever you put one or more " + this.counterType.getName() + " counters on " + filterMessage + ", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import mage.MageObjectReference;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect;
|
||||
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect.FaceDownType;
|
||||
|
|
@ -20,22 +22,32 @@ import mage.util.CardUtil;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ManifestEffect extends OneShotEffect {
|
||||
|
||||
private final int amount;
|
||||
private final DynamicValue amount;
|
||||
private final boolean isPlural;
|
||||
|
||||
public ManifestEffect(int amount) {
|
||||
this(StaticValue.get(amount), amount > 1);
|
||||
}
|
||||
|
||||
public ManifestEffect(DynamicValue amount) {
|
||||
this(amount, true);
|
||||
}
|
||||
|
||||
private ManifestEffect(DynamicValue amount, boolean isPlural) {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.amount = amount;
|
||||
this.isPlural = isPlural;
|
||||
this.staticText = setText();
|
||||
}
|
||||
|
||||
public ManifestEffect(final ManifestEffect effect) {
|
||||
private ManifestEffect(final ManifestEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount;
|
||||
this.isPlural = effect.isPlural;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -49,7 +61,8 @@ public class ManifestEffect extends OneShotEffect {
|
|||
if (controller != null) {
|
||||
Ability newSource = source.copy();
|
||||
newSource.setWorksFaceDown(true);
|
||||
Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
|
||||
int value = amount.calculate(game, source, this);
|
||||
Set<Card> cards = controller.getLibrary().getTopCards(game, value);
|
||||
for (Card card : cards) {
|
||||
ManaCosts manaCosts = null;
|
||||
if (card.isCreature(game)) {
|
||||
|
|
@ -76,13 +89,13 @@ public class ManifestEffect extends OneShotEffect {
|
|||
|
||||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder("manifest the top ");
|
||||
if (amount > 1) {
|
||||
sb.append(CardUtil.numberToText(amount)).append(" cards ");
|
||||
if (isPlural) {
|
||||
sb.append(CardUtil.numberToText(amount.toString())).append(" cards ");
|
||||
} else {
|
||||
sb.append("card ");
|
||||
}
|
||||
sb.append("of your library. ");
|
||||
if (amount > 1) {
|
||||
if (isPlural) {
|
||||
sb.append("<i>(To manifest a card, put it onto the battlefield face down as a 2/2 creature. You may turn it face up at any time for its mana cost if it's a creature card.)</i>");
|
||||
} else {
|
||||
sb.append("<i>(Put it onto the battlefield face down as a 2/2 creature. Turn it face up at any time for its mana cost if it's a creature card.)</i>");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue