Implemented Altar of the Pantheon

This commit is contained in:
Evan Kranzler 2020-01-07 22:43:09 -05:00
parent a9739f12f1
commit 6bdd395e8f
3 changed files with 100 additions and 11 deletions

View file

@ -0,0 +1,64 @@
package mage.cards.a;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.mana.AnyColorManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.Predicates;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class AltarOfThePantheon extends CardImpl {
private static final FilterPermanent filter = new FilterControlledPermanent();
static {
filter.add(Predicates.or(
SubType.GOD.getPredicate(),
SubType.DEMIGOD.getPredicate(),
Predicates.and(
SuperType.LEGENDARY.getPredicate(),
CardType.ENCHANTMENT.getPredicate()
)
));
}
private static final Condition condition = new PermanentsOnTheBattlefieldCondition(filter);
public AltarOfThePantheon(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
// Your devotion to each color and each combination of colors is increased by one.
this.addAbility(new DevotionCount.IncreaseDevotionAbility());
// {T}: Add one mana of any color. If you control a God, a Demigod, or a legendary enchantment, you gain 1 life.
Ability ability = new AnyColorManaAbility();
ability.addEffect(new ConditionalOneShotEffect(
new GainLifeEffect(1), condition, "If you control " +
"a God, a Demigod, or a legendary enchantment, you gain 1 life."
));
this.addAbility(ability);
}
private AltarOfThePantheon(final AltarOfThePantheon card) {
super(card);
}
@Override
public AltarOfThePantheon copy() {
return new AltarOfThePantheon(this);
}
}

View file

@ -27,6 +27,7 @@ public final class TherosBeyondDeath extends ExpansionSet {
this.maxCardNumberInBooster = 254;
cards.add(new SetCardInfo("Allure of the Unknown", 207, Rarity.RARE, mage.cards.a.AllureOfTheUnknown.class));
cards.add(new SetCardInfo("Altar of the Pantheon", 231, Rarity.COMMON, mage.cards.a.AltarOfThePantheon.class));
cards.add(new SetCardInfo("Anax, Hardened in the Forge", 125, Rarity.UNCOMMON, mage.cards.a.AnaxHardenedInTheForge.class));
cards.add(new SetCardInfo("Aphemia, the Cacophony", 84, Rarity.RARE, mage.cards.a.AphemiaTheCacophony.class));
cards.add(new SetCardInfo("Arasta of the Endless Web", 165, Rarity.RARE, mage.cards.a.ArastaOfTheEndlessWeb.class));

View file

@ -2,9 +2,11 @@ package mage.abilities.dynamicvalue.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.constants.ColoredManaSymbol;
@ -13,6 +15,7 @@ import mage.game.Game;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;
/**
* Each colored mana symbol (e.g. {U}) in the mana costs of permanents you
@ -47,13 +50,22 @@ public enum DevotionCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return game.getBattlefield()
int devotion = game.getBattlefield()
.getAllActivePermanents(sourceAbility.getControllerId())
.stream()
.map(MageObject::getManaCost)
.flatMap(Collection::stream)
.mapToInt(this::checkCost)
.sum();
int countIncrease = game.getBattlefield()
.getAllActivePermanents(sourceAbility.getControllerId())
.stream()
.map(permanent -> permanent.getAbilities(game))
.flatMap(Collection::stream)
.filter(IncreaseDevotionAbility.class::isInstance)
.mapToInt(x -> 1)
.sum();
return devotion + countIncrease;
}
private int checkCost(ManaCost manaCost) {
@ -72,19 +84,31 @@ public enum DevotionCount implements DynamicValue {
@Override
public String getMessage() {
StringBuilder sb = new StringBuilder("your devotion to ");
int count = 0;
for (ColoredManaSymbol coloredManaSymbol : devotionColors) {
if (count > 0) {
sb.append(" and ");
}
sb.append(coloredManaSymbol.getColorName());
count++;
}
return sb.toString();
return "your devotion to " + String.join(
" and ",
devotionColors.stream()
.map(ColoredManaSymbol::getColorName)
.collect(Collectors.toList())
);
}
public Hint getHint() {
return hint;
}
public static final class IncreaseDevotionAbility extends SimpleStaticAbility {
public IncreaseDevotionAbility() {
super(new InfoEffect("Your devotion to each color and each combination of colors is increased by one."));
}
private IncreaseDevotionAbility(final IncreaseDevotionAbility ability) {
super(ability);
}
@Override
public IncreaseDevotionAbility copy() {
return new IncreaseDevotionAbility(this);
}
}
}