[PIP] Implement Lumbering Megasloth

This commit is contained in:
Susucre 2024-04-09 22:34:01 +02:00
parent 3974f60952
commit fd0da67e46
3 changed files with 148 additions and 0 deletions

View file

@ -0,0 +1,104 @@
package mage.cards.l;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.cost.SpellCostReductionForEachSourceEffect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import java.util.Objects;
import java.util.UUID;
/**
* @author Susucr
*/
public final class LumberingMegasloth extends CardImpl {
public LumberingMegasloth(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{10}{G}{G}");
this.subtype.add(SubType.SLOTH);
this.subtype.add(SubType.MUTANT);
this.power = new MageInt(8);
this.toughness = new MageInt(8);
// This spell costs {1} less to cast for each counter among players and permanents.
this.addAbility(
new SimpleStaticAbility(Zone.ALL,
new SpellCostReductionForEachSourceEffect(1, LumberingMegaslothValue.instance)
).addHint(LumberingMegaslothValue.getHint())
);
// Trample
this.addAbility(TrampleAbility.getInstance());
// Lumbering Megasloth enters the battlefield tapped.
this.addAbility(new EntersBattlefieldTappedAbility());
}
private LumberingMegasloth(final LumberingMegasloth card) {
super(card);
}
@Override
public LumberingMegasloth copy() {
return new LumberingMegasloth(this);
}
}
enum LumberingMegaslothValue implements DynamicValue {
instance;
private static final Hint hint = new ValueHint("Number of Counters:", instance);
public static Hint getHint() {
return hint;
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int onPermanents = game.getBattlefield()
.getActivePermanents(sourceAbility.getControllerId(), game)
.stream()
.filter(Objects::nonNull)
.map(perm -> perm.getCounters(game))
.flatMap(counters -> counters.values().stream())
.mapToInt(counter -> counter.getCount())
.sum();
int onPlayers = game.getState()
.getPlayersInRange(sourceAbility.getControllerId(), game)
.stream()
.map(game::getPlayer)
.filter(Objects::nonNull)
.map(player -> player.getCounters())
.flatMap(counters -> counters.values().stream())
.mapToInt(counter -> counter.getCount())
.sum();
return onPermanents + onPlayers;
}
@Override
public LumberingMegaslothValue copy() {
return this;
}
@Override
public String toString() {
return "1";
}
@Override
public String getMessage() {
return "counters among players and permanents";
}
}

View file

@ -172,6 +172,7 @@ public final class Fallout extends ExpansionSet {
cards.add(new SetCardInfo("Lily Bowen, Raging Grandma", 927, Rarity.RARE, mage.cards.l.LilyBowenRagingGrandma.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Lord of the Undead", 345, Rarity.RARE, mage.cards.l.LordOfTheUndead.class));
cards.add(new SetCardInfo("Loyal Apprentice", 190, Rarity.UNCOMMON, mage.cards.l.LoyalApprentice.class));
cards.add(new SetCardInfo("Lumbering Megasloth", 80, Rarity.UNCOMMON, mage.cards.l.LumberingMegasloth.class));
cards.add(new SetCardInfo("MacCready, Lamplight Mayor", 108, Rarity.RARE, mage.cards.m.MacCreadyLamplightMayor.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("MacCready, Lamplight Mayor", 417, Rarity.RARE, mage.cards.m.MacCreadyLamplightMayor.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("MacCready, Lamplight Mayor", 636, Rarity.RARE, mage.cards.m.MacCreadyLamplightMayor.class, NON_FULL_USE_VARIOUS));

View file

@ -0,0 +1,43 @@
package org.mage.test.cards.single.pip;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author Susucr
*/
public class LumberingMegaslothTest extends CardTestPlayerBase {
/**
* {@link mage.cards.l.LumberingMegasloth Lumbering Megasloth} {10}{G}{G}
* Creature Sloth Mutant
* This spell costs {1} less to cast for each counter among players and permanents.
* Trample
* Lumbering Megasloth enters the battlefield tapped.
* <p>
* 8/8
*/
private static final String sloth = "Lumbering Megasloth";
@Test
public void test_Reduction() {
setStrictChooseMode(true);
addCard(Zone.HAND, playerA, sloth);
addCard(Zone.BATTLEFIELD, playerA, "Adaptive Shimmerer"); // enters with 3 +1/+1
addCard(Zone.HAND, playerA, "Aether Herder"); // {3}{G}, etb: you get {E}{E}
addCard(Zone.BATTLEFIELD, playerB, "Arlinn Kord"); // PW with 3 loyalty counters
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4 + 4); // 4 for Herder, then 4 for sloth as 9 counters total.
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Aether Herder", true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, sloth);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, sloth, 1);
assertTappedCount("Forest", true, 8);
}
}