[BLB] Implement For the Common Good

This commit is contained in:
theelk801 2024-07-17 16:45:17 -04:00
parent 2c7f4bbc3f
commit 51f2f051bb
3 changed files with 101 additions and 0 deletions

View file

@ -0,0 +1,92 @@
package mage.cards.f;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenCopyTargetEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.permanent.TokenPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class ForTheCommonGood extends CardImpl {
private static final FilterPermanent filter = new FilterControlledPermanent("token you control");
static {
filter.add(TokenPredicate.TRUE);
}
private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(filter);
private static final Hint hint = new ValueHint("Tokens you control", xValue);
public ForTheCommonGood(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{X}{G}");
// Create X tokens that are copies of target token you control. Then tokens you control gain indestructible until your next turn. You gain 1 life for each token you control.
this.getSpellAbility().addEffect(new ForTheCommonGoodEffect());
this.getSpellAbility().addTarget(new TargetPermanent(filter));
this.getSpellAbility().addEffect(new GainAbilityControlledEffect(
IndestructibleAbility.getInstance(),
Duration.EndOfTurn, StaticFilters.FILTER_PERMANENT_TOKEN
));
this.getSpellAbility().addEffect(new GainLifeEffect(xValue));
this.getSpellAbility().addHint(hint);
}
private ForTheCommonGood(final ForTheCommonGood card) {
super(card);
}
@Override
public ForTheCommonGood copy() {
return new ForTheCommonGood(this);
}
}
class ForTheCommonGoodEffect extends OneShotEffect {
ForTheCommonGoodEffect() {
super(Outcome.Benefit);
staticText = "create X tokens that are copies of target token you control";
}
private ForTheCommonGoodEffect(final ForTheCommonGoodEffect effect) {
super(effect);
}
@Override
public ForTheCommonGoodEffect copy() {
return new ForTheCommonGoodEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
int xValue = source.getManaCostsToPay().getX();
return permanent != null
&& xValue > 0
&& new CreateTokenCopyTargetEffect(null, null, false, xValue)
.setSavedPermanent(permanent)
.apply(game, source);
}
}

View file

@ -70,6 +70,7 @@ public final class Bloomburrow extends ExpansionSet {
cards.add(new SetCardInfo("Finneas, Ace Archer", 212, Rarity.RARE, mage.cards.f.FinneasAceArcher.class));
cards.add(new SetCardInfo("Flame Lash", 391, Rarity.COMMON, mage.cards.f.FlameLash.class));
cards.add(new SetCardInfo("Flowerfoot Swordmaster", 14, Rarity.UNCOMMON, mage.cards.f.FlowerfootSwordmaster.class));
cards.add(new SetCardInfo("For the Common Good", 172, Rarity.RARE, mage.cards.f.ForTheCommonGood.class));
cards.add(new SetCardInfo("Forest", 278, Rarity.LAND, mage.cards.basiclands.Forest.class, FULL_ART_BFZ_VARIOUS));
cards.add(new SetCardInfo("Fountainport Bell", 245, Rarity.COMMON, mage.cards.f.FountainportBell.class));
cards.add(new SetCardInfo("Fountainport", 253, Rarity.RARE, mage.cards.f.Fountainport.class));

View file

@ -988,6 +988,14 @@ public final class StaticFilters {
FILTER_PERMANENT_TOKEN.setLockedFilter(true);
}
public static final FilterPermanent FILTER_PERMANENT_TOKENS = new FilterPermanent("tokens");
static {
FILTER_PERMANENT_TOKENS.add(TokenPredicate.TRUE);
FILTER_PERMANENT_TOKENS.setLockedFilter(true);
}
public static final FilterCreaturePermanent FILTER_CREATURE_TOKEN = new FilterCreaturePermanent("creature token");
static {