- Momir Avatar was completely broken

This commit is contained in:
Sol
2013-05-11 04:02:59 +00:00
parent 5d157fafbf
commit ee0f3e04dc
3 changed files with 35 additions and 7 deletions

View File

@@ -2,8 +2,8 @@ Name:Momir Vig, Simic Visionary Avatar
ManaCost:no cost ManaCost:no cost
Types:Vanguard Types:Vanguard
HandLifeModifier:+0/+4 HandLifeModifier:+0/+4
A:AB$ ChooseCard | Cost$ X Discard<1/Card> | ActivationZone$ Command | AtRandom$ True | Choices$ Creature.cmcEQX | References$ X | Amount$ 1 | SubAbility$ DBToken | SorcerySpeed$ True | ActivationLimit$ 1 | SpellDescription$ Put a token onto the battlefield that's a copy of a creature card with converted mana cost X chosen at random. Activate this ability only any time you could cast a sorcery and only once each turn. A:AB$ NameCard | Cost$ X Discard<1/Card> | ActivationZone$ Command | AtRandom$ True | ValidCards$ Creature | ValidAttribute$ cmcEQX | References$ X | Amount$ 1 | SubAbility$ DBToken | SorcerySpeed$ True | ActivationLimit$ 1 | AILogic$ MomirAvatar | SpellDescription$ Put a token onto the battlefield that's a copy of a creature card with converted mana cost X chosen at random. Activate this ability only any time you could cast a sorcery and only once each turn. | StackDescription$ SpellDescription
SVar:DBToken:DB$ CopyPermanent | Defined$ ChosenCard | NumCopies$ 1 SVar:DBToken:DB$ CopyPermanent | ValidSupportedCopy$ Card | DefinedName$ NamedCard | NumCopies$ 1 | StackDescription$
SVar:X:Count$xPaid SVar:X:Count$xPaid
SVar:Picture:http://www.cardforge.org/fpics/vgd-lq/momir_vig_simic_visionary_avatar.jpg SVar:Picture:http://www.cardforge.org/fpics/vgd-lq/momir_vig_simic_visionary_avatar.jpg
Oracle:Hand +0, life +4\n{X}, Discard a card: Put a token onto the battlefield that's a copy of a creature card with converted mana cost X chosen at random. Activate this ability only any time you could cast a sorcery and only once each turn. Oracle:Hand +0, life +4\n{X}, Discard a card: Put a token onto the battlefield that's a copy of a creature card with converted mana cost X chosen at random. Activate this ability only any time you could cast a sorcery and only once each turn.

View File

@@ -13,7 +13,9 @@ import com.google.common.collect.Lists;
import forge.Card; import forge.Card;
import forge.CardLists; import forge.CardLists;
import forge.CardPredicates.Presets; import forge.CardPredicates.Presets;
import forge.card.CardRules;
import forge.card.CardRulesPredicates; import forge.card.CardRulesPredicates;
import forge.card.ability.AbilityUtils;
import forge.card.ability.SpellAbilityEffect; import forge.card.ability.SpellAbilityEffect;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
import forge.card.spellability.Target; import forge.card.spellability.Target;
@@ -23,6 +25,8 @@ import forge.game.zone.ZoneType;
import forge.gui.GuiChoose; import forge.gui.GuiChoose;
import forge.item.CardDb; import forge.item.CardDb;
import forge.item.CardPrinted; import forge.item.CardPrinted;
import forge.util.Aggregates;
import forge.util.ComparableOp;
public class ChooseCardNameEffect extends SpellAbilityEffect { public class ChooseCardNameEffect extends SpellAbilityEffect {
@@ -56,8 +60,23 @@ public class ChooseCardNameEffect extends SpellAbilityEffect {
if ((tgt == null) || p.canBeTargetedBy(sa)) { if ((tgt == null) || p.canBeTargetedBy(sa)) {
boolean ok = false; boolean ok = false;
while (!ok) { while (!ok) {
if (p.isHuman()) { if (sa.hasParam("AtRandom")) {
// Currently only used for Momir Avatar, if something else gets added here, make it more generic
Predicate<CardRules> baseRule = CardRulesPredicates.Presets.IS_CREATURE;
String numericAmount = "X";
final int validAmount = StringUtils.isNumeric(numericAmount) ? Integer.parseInt(numericAmount) :
AbilityUtils.calculateAmount(host, numericAmount, sa);
Predicate<CardRules> additionalRule = CardRulesPredicates.cmc(ComparableOp.EQUALS, validAmount);
List<CardPrinted> cards = Lists.newArrayList(CardDb.instance().getUniqueCards());
Predicate<CardPrinted> cpp = Predicates.and(Predicates.compose(baseRule, CardPrinted.FN_GET_RULES),
Predicates.compose(additionalRule, CardPrinted.FN_GET_RULES));
cards = Lists.newArrayList(Iterables.filter(cards, cpp));
host.setNamedCard(Aggregates.random(cards).getName());
ok = true;
} else if (p.isHuman()) {
final String message = validDesc.equals("card") ? "Name a card" : "Name a " + validDesc + " card."; final String message = validDesc.equals("card") ? "Name a card" : "Name a " + validDesc + " card.";
List<CardPrinted> cards = Lists.newArrayList(CardDb.instance().getUniqueCards()); List<CardPrinted> cards = Lists.newArrayList(CardDb.instance().getUniqueCards());

View File

@@ -96,12 +96,21 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
} }
tgtCards = choice; tgtCards = choice;
} else if (sa.hasParam("DefinedName")) { } else if (sa.hasParam("DefinedName")) {
final String name = sa.getParam("DefinedName"); String name = sa.getParam("DefinedName");
if (name.equals("NamedCard")) {
if (!hostCard.getNamedCard().isEmpty()) {
name = hostCard.getNamedCard();
}
}
Predicate<CardPrinted> cpp = Predicates.compose(CardRulesPredicates.name(StringOp.EQUALS, name), CardPrinted.FN_GET_RULES); Predicate<CardPrinted> cpp = Predicates.compose(CardRulesPredicates.name(StringOp.EQUALS, name), CardPrinted.FN_GET_RULES);
cards = Lists.newArrayList(Iterables.filter(cards, cpp)); cards = Lists.newArrayList(Iterables.filter(cards, cpp));
Card c = cards.get(0).getMatchingForgeCard();
tgtCards.clear(); tgtCards.clear();
tgtCards.add(c); if (!cards.isEmpty()) {
Card c = cards.get(0).getMatchingForgeCard();
tgtCards.add(c);
}
} }
} }