[OTC] Implement Cactus Preserve

This commit is contained in:
Susucre 2024-04-06 13:41:08 +02:00
parent 24e3a5b7ac
commit b5d0943b9d
4 changed files with 126 additions and 36 deletions

View file

@ -0,0 +1,78 @@
package mage.cards.c;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.CommanderGreatestManaValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
import mage.abilities.keyword.ReachAbility;
import mage.abilities.mana.AnyColorLandsProduceManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.token.custom.CreatureToken;
import java.util.UUID;
/**
* @author Susucr
*/
public final class CactusPreserve extends CardImpl {
public CactusPreserve(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
this.subtype.add(SubType.DESERT);
// Cactus Preserve enters the battlefield tapped.
this.addAbility(new EntersBattlefieldTappedAbility());
// {T}: Add one mana of any type that a land you control could produce.
this.addAbility(new AnyColorLandsProduceManaAbility(TargetController.YOU, false));
// {3}: Until end of turn, Cactus Preserve becomes an X/X green Plant creature with reach, where X is the greatest mana value among your commanders. It's still a land.
this.addAbility(new SimpleActivatedAbility(new CactusPreserveEffect(), new ManaCostsImpl<>("{3}")));
}
private CactusPreserve(final CactusPreserve card) {
super(card);
}
@Override
public CactusPreserve copy() {
return new CactusPreserve(this);
}
}
class CactusPreserveEffect extends OneShotEffect {
CactusPreserveEffect() {
super(Outcome.BecomeCreature);
this.staticText = "{this} becomes an X/X green Plant creature with reach, where X is the greatest mana value among your commanders. It's still a land.";
}
private CactusPreserveEffect(final CactusPreserveEffect effect) {
super(effect);
}
@Override
public CactusPreserveEffect copy() {
return new CactusPreserveEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
int xValue = CommanderGreatestManaValue.instance.calculate(game, source, this);
game.addEffect(new BecomesCreatureSourceEffect(
new CreatureToken(xValue, xValue,
"X/X green Plant creature with reach, where X is the greatest mana value among your commanders")
.withColor("G").withSubType(SubType.PLANT)
.withAbility(ReachAbility.getInstance()),
CardType.LAND, Duration.EndOfTurn), source
);
return true;
}
}

View file

@ -1,18 +1,17 @@
package mage.cards.t;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.dynamicvalue.common.CommanderGreatestManaValue;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.abilities.keyword.LivingWeaponAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import java.util.UUID;
@ -30,7 +29,7 @@ public final class TangleweaveArmor extends CardImpl {
// Equipped creature gets +X/+X, where X is the greatest mana value among your commanders
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD, new BoostEquippedEffect(TangleweaveArmorDynamicValue.instance, TangleweaveArmorDynamicValue.instance)
Zone.BATTLEFIELD, new BoostEquippedEffect(CommanderGreatestManaValue.instance, CommanderGreatestManaValue.instance)
));
// Equip {4}
@ -46,32 +45,3 @@ public final class TangleweaveArmor extends CardImpl {
return new TangleweaveArmor(this);
}
}
enum TangleweaveArmorDynamicValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return game.getCommanderCardsFromAnyZones(
game.getPlayer(sourceAbility.getControllerId()), CommanderCardType.ANY, Zone.ALL)
.stream()
.mapToInt(MageObject::getManaValue)
.max()
.orElse(0);
}
@Override
public TangleweaveArmorDynamicValue copy() {
return this;
}
@Override
public String toString() {
return "X";
}
@Override
public String getMessage() {
return "the greatest mana value among your commanders";
}
}

View file

@ -47,6 +47,7 @@ public final class OutlawsOfThunderJunctionCommander extends ExpansionSet {
cards.add(new SetCardInfo("Boros Charm", 216, Rarity.UNCOMMON, mage.cards.b.BorosCharm.class));
cards.add(new SetCardInfo("Brainstealer Dragon", 127, Rarity.RARE, mage.cards.b.BrainstealerDragon.class));
cards.add(new SetCardInfo("Breena, the Demagogue", 217, Rarity.MYTHIC, mage.cards.b.BreenaTheDemagogue.class));
cards.add(new SetCardInfo("Cactus Preserve", 40, Rarity.RARE, mage.cards.c.CactusPreserve.class));
cards.add(new SetCardInfo("Canyon Slough", 275, Rarity.RARE, mage.cards.c.CanyonSlough.class));
cards.add(new SetCardInfo("Captain Lannery Storm", 158, Rarity.RARE, mage.cards.c.CaptainLanneryStorm.class));
cards.add(new SetCardInfo("Captivating Crew", 159, Rarity.RARE, mage.cards.c.CaptivatingCrew.class));

View file

@ -0,0 +1,41 @@
package mage.abilities.dynamicvalue.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.CommanderCardType;
import mage.constants.Zone;
import mage.game.Game;
/**
* @author PurpleCrowbar
*/
public enum CommanderGreatestManaValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return game.getCommanderCardsFromAnyZones(
game.getPlayer(sourceAbility.getControllerId()), CommanderCardType.ANY, Zone.ALL)
.stream()
.mapToInt(MageObject::getManaValue)
.max()
.orElse(0);
}
@Override
public CommanderGreatestManaValue copy() {
return this;
}
@Override
public String toString() {
return "X";
}
@Override
public String getMessage() {
return "the greatest mana value among your commanders";
}
}