diff --git a/Mage.Sets/src/mage/cards/h/HeraldicBanner.java b/Mage.Sets/src/mage/cards/h/HeraldicBanner.java new file mode 100644 index 0000000000..6e40a48304 --- /dev/null +++ b/Mage.Sets/src/mage/cards/h/HeraldicBanner.java @@ -0,0 +1,83 @@ +package mage.cards.h; + +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.AsEntersBattlefieldAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.ChooseColorEffect; +import mage.abilities.effects.mana.AddManaChosenColorEffect; +import mage.abilities.mana.SimpleManaAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.common.FilterCreaturePermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; + +import java.util.UUID; + +/** + * @author jmharmon + */ + +public final class HeraldicBanner extends CardImpl { + + public HeraldicBanner(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); + + // As Heraldic Banner enters the battlefield, choose a color. + this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Benefit))); + + // Creatures you control of the chosen color get +1/+0. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HeraldicBannerEffect())); + + // {T}: Add one mana of the chosen color. + this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, new AddManaChosenColorEffect(), new TapSourceCost())); + } + + public HeraldicBanner(final HeraldicBanner card) { + super(card); + } + + @Override + public HeraldicBanner copy() { + return new HeraldicBanner(this); + } +} + +class HeraldicBannerEffect extends ContinuousEffectImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent(); + + public HeraldicBannerEffect() { + super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature); + staticText = "Creatures you control of the chosen color get +1/+0"; + } + + public HeraldicBannerEffect(final HeraldicBannerEffect effect) { + super(effect); + } + + @Override + public HeraldicBannerEffect copy() { + return new HeraldicBannerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent != null) { + ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color"); + if (color != null) { + for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { + if (perm.getColor(game).contains(color)) { + perm.addPower(1); + } + } + } + } + return true; + } +}