[DRC] Implement Prophet of the Scarab

Also adds a DynamicValue that finds the largest of multiple DynamicValues.
This commit is contained in:
Grath 2025-01-24 15:47:17 -05:00
parent 9172a9eba8
commit 7bfb0d2dec
4 changed files with 125 additions and 45 deletions

View file

@ -0,0 +1,65 @@
package mage.cards.p;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.MaximumDynamicValue;
import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.FilterCard;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import java.util.UUID;
/**
*
* @author Grath
*/
public final class ProphetOfTheScarab extends CardImpl {
private static final FilterPermanent filter = new FilterControlledPermanent(SubType.ZOMBIE);
private static final FilterCard filter2 = new FilterCard();
static {
filter2.add(SubType.ZOMBIE.getPredicate());
}
private static final DynamicValue xValue = new MaximumDynamicValue(
new PermanentsOnBattlefieldCount(filter),
new CardsInControllerGraveyardCount(filter2)
);
public ProphetOfTheScarab(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{U}");
this.subtype.add(SubType.ZOMBIE);
this.subtype.add(SubType.WIZARD);
this.power = new MageInt(3);
this.toughness = new MageInt(4);
// Vigilance
this.addAbility(VigilanceAbility.getInstance());
// When this creature enters, draw cards equal to the number of Zombies you control or the number of Zombie cards in your graveyard, whichever is greater.
this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(xValue)
.setText("draw cards equal to the number of Zombies you control or the number of Zombie cards in your graveyard, whichever is greater"))
.addHint(new ValueHint("Current draw", xValue)));
}
private ProphetOfTheScarab(final ProphetOfTheScarab card) {
super(card);
}
@Override
public ProphetOfTheScarab copy() {
return new ProphetOfTheScarab(this);
}
}

View file

@ -1,12 +1,10 @@
package mage.cards.t; package mage.cards.t;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect; import mage.abilities.dynamicvalue.MaximumDynamicValue;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint; import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
@ -14,7 +12,6 @@ import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent; import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import java.util.UUID; import java.util.UUID;
@ -23,15 +20,20 @@ import java.util.UUID;
* @author TheElk801 * @author TheElk801
*/ */
public final class TriumphantChomp extends CardImpl { public final class TriumphantChomp extends CardImpl {
private static final FilterPermanent filter = new FilterControlledPermanent(SubType.DINOSAUR);
private static final DynamicValue xValue = new MaximumDynamicValue(
StaticValue.get(2),
new PermanentsOnBattlefieldCount(filter)
);
public TriumphantChomp(UUID ownerId, CardSetInfo setInfo) { public TriumphantChomp(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{R}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{R}");
// Triumphant Chomp deals damage to target creature equal to 2 or the greatest power among Dinosaurs you control, whichever is greater. // Triumphant Chomp deals damage to target creature equal to 2 or the greatest power among Dinosaurs you control, whichever is greater.
this.getSpellAbility().addEffect(new DamageTargetEffect(TriumphantChompValue.instance) this.getSpellAbility().addEffect(new DamageTargetEffect(xValue)
.setText("{this} deals damage to target creature equal to 2 or the greatest power among Dinosaurs you control, whichever is greater")); .setText("{this} deals damage to target creature equal to 2 or the greatest power among Dinosaurs you control, whichever is greater"));
this.getSpellAbility().addTarget(new TargetCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addHint(TriumphantChompValue.getHint()); this.getSpellAbility().addHint(new ValueHint("Current damage", xValue));
} }
private TriumphantChomp(final TriumphantChomp card) { private TriumphantChomp(final TriumphantChomp card) {
@ -43,40 +45,3 @@ public final class TriumphantChomp extends CardImpl {
return new TriumphantChomp(this); return new TriumphantChomp(this);
} }
} }
enum TriumphantChompValue implements DynamicValue {
instance;
private static final FilterPermanent filter = new FilterControlledPermanent(SubType.DINOSAUR);
private static final Hint hint = new ValueHint("Current damage", instance);
public static Hint getHint() {
return hint;
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int power = game.getBattlefield()
.getActivePermanents(filter, sourceAbility.getControllerId(), sourceAbility, game)
.stream()
.map(MageObject::getPower)
.mapToInt(MageInt::getValue)
.max()
.orElse(0);
return Math.max(2, power);
}
@Override
public TriumphantChompValue copy() {
return this;
}
@Override
public String getMessage() {
return "";
}
@Override
public String toString() {
return "1";
}
}

View file

@ -76,6 +76,7 @@ public final class AetherdriftCommander extends ExpansionSet {
cards.add(new SetCardInfo("Path of Ancestry", 166, Rarity.COMMON, mage.cards.p.PathOfAncestry.class)); cards.add(new SetCardInfo("Path of Ancestry", 166, Rarity.COMMON, mage.cards.p.PathOfAncestry.class));
cards.add(new SetCardInfo("Peema Aether-Seer", 113, Rarity.UNCOMMON, mage.cards.p.PeemaAetherSeer.class)); cards.add(new SetCardInfo("Peema Aether-Seer", 113, Rarity.UNCOMMON, mage.cards.p.PeemaAetherSeer.class));
cards.add(new SetCardInfo("Pia and Kiran Nalaar", 105, Rarity.RARE, mage.cards.p.PiaAndKiranNalaar.class)); cards.add(new SetCardInfo("Pia and Kiran Nalaar", 105, Rarity.RARE, mage.cards.p.PiaAndKiranNalaar.class));
cards.add(new SetCardInfo("Prophet of the Scarab", 9, Rarity.RARE, mage.cards.p.ProphetOfTheScarab.class));
cards.add(new SetCardInfo("Reality Shift", 39, Rarity.UNCOMMON, mage.cards.r.RealityShift.class)); cards.add(new SetCardInfo("Reality Shift", 39, Rarity.UNCOMMON, mage.cards.r.RealityShift.class));
cards.add(new SetCardInfo("Reckless Fireweaver", 106, Rarity.COMMON, mage.cards.r.RecklessFireweaver.class)); cards.add(new SetCardInfo("Reckless Fireweaver", 106, Rarity.COMMON, mage.cards.r.RecklessFireweaver.class));
cards.add(new SetCardInfo("Retrofitter Foundry", 136, Rarity.RARE, mage.cards.r.RetrofitterFoundry.class)); cards.add(new SetCardInfo("Retrofitter Foundry", 136, Rarity.RARE, mage.cards.r.RetrofitterFoundry.class));

View file

@ -0,0 +1,49 @@
package mage.abilities.dynamicvalue;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.game.Game;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class MaximumDynamicValue implements DynamicValue {
private final List<DynamicValue> dynamicValues;
/**
* Creates a {@link DynamicValue} that finds the maximum of multiple
* {@link DynamicValue}s.
*
* @param dynamicValues The dynamic values to add together.
*/
public MaximumDynamicValue(DynamicValue... dynamicValues) {
this.dynamicValues = Arrays.asList(dynamicValues);
}
/**
* Creates a {@link DynamicValue} that finds the maximum of multiple
* {@link DynamicValue}s.
*
* @param dynamicValues The dynamic values to add together.
*/
public MaximumDynamicValue(List<DynamicValue> dynamicValues) {
this.dynamicValues = dynamicValues;
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return dynamicValues.stream().mapToInt(d -> d.calculate(game, sourceAbility, effect)).max().orElse(0);
}
@Override
public MaximumDynamicValue copy() {
return new MaximumDynamicValue(this.dynamicValues);
}
@Override
public String getMessage() {
return this.dynamicValues.stream().map(DynamicValue::getMessage).collect(Collectors.joining(" "));
}
}