[MKM] Implement Case of the Stashed Skeleton (#11729)

* [MKM] Implement Case of the Stashed Skeleton

* Address PR comments

---------

Co-authored-by: Matthew Wilson <matthew_w@vaadin.com>
This commit is contained in:
Matthew Wilson 2024-01-31 06:49:17 +02:00 committed by GitHub
parent 40d48d49fb
commit af622a235e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 154 additions and 0 deletions

View file

@ -0,0 +1,127 @@
package mage.cards.c;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.CaseAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.condition.common.SolvedSourceCondition;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalActivatedAbility;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect;
import mage.abilities.hint.common.CaseSolvedHint;
import mage.constants.ComparisonType;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.TimingRule;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.SuspectedPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.SkeletonToken2;
import mage.target.common.TargetCardInLibrary;
/**
*
* @author DominionSpy
*/
public final class CaseOfTheStashedSkeleton extends CardImpl {
static final FilterPermanent filter = new FilterControlledCreaturePermanent(SubType.SKELETON, "You control no suspected Skeletons");
static {
filter.add(SuspectedPredicate.instance);
}
public CaseOfTheStashedSkeleton(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}");
this.subtype.add(SubType.CASE);
// When this Case enters the battlefield, create a 2/1 black Skeleton creature token and suspect it.
Ability initialAbility = new EntersBattlefieldTriggeredAbility(
new CaseOfTheStashedSkeletonEffect());
// To solve -- You control no suspected Skeletons.
Condition toSolveCondition = new PermanentsOnTheBattlefieldCondition(
filter, ComparisonType.EQUAL_TO, 0, true);
// Solved -- {1}{B}, Sacrifice this Case: Search your library for a card, put it into your hand, then shuffle. Activate only as a sorcery.
Ability solvedAbility = new ConditionalActivatedAbility(
new SearchLibraryPutInHandEffect(new TargetCardInLibrary(), false)
.setText("Search your library for a card, put it into your hand, then shuffle. Activate only as a sorcery."),
new ManaCostsImpl<>("{1}{B}"),
SolvedSourceCondition.SOLVED)
.setTiming(TimingRule.SORCERY);
solvedAbility.addCost(new SacrificeSourceCost().setText("sacrifice this Case"));
this.addAbility(new CaseAbility(initialAbility, toSolveCondition, solvedAbility)
.addHint(new CaseOfTheStashedSkeletonHint(toSolveCondition)));
}
private CaseOfTheStashedSkeleton(final CaseOfTheStashedSkeleton card) {
super(card);
}
@Override
public CaseOfTheStashedSkeleton copy() {
return new CaseOfTheStashedSkeleton(this);
}
}
class CaseOfTheStashedSkeletonEffect extends CreateTokenEffect {
CaseOfTheStashedSkeletonEffect() {
super(new SkeletonToken2());
staticText = "create a 2/1 black Skeleton creature token and suspect it";
}
private CaseOfTheStashedSkeletonEffect(final CaseOfTheStashedSkeletonEffect effect) {
super(effect);
}
@Override
public CaseOfTheStashedSkeletonEffect copy() {
return new CaseOfTheStashedSkeletonEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
super.apply(game, source);
Permanent token = game.getPermanent(this.getLastAddedTokenIds().stream().findFirst().orElse(null));
if (token != null) {
token.setSuspected(true, game, source);
return true;
}
return false;
}
}
class CaseOfTheStashedSkeletonHint extends CaseSolvedHint {
CaseOfTheStashedSkeletonHint(Condition condition) {
super(condition);
}
private CaseOfTheStashedSkeletonHint(final CaseOfTheStashedSkeletonHint hint) {
super(hint);
}
@Override
public CaseOfTheStashedSkeletonHint copy() {
return new CaseOfTheStashedSkeletonHint(this);
}
@Override
public String getConditionText(Game game, Ability ability) {
int suspectedSkeletons = game.getBattlefield()
.count(CaseOfTheStashedSkeleton.filter, ability.getControllerId(),
ability, game);
return "Suspected skeletons: " + suspectedSkeletons + " (need 0).";
}
}

View file

@ -53,8 +53,10 @@ public final class MurdersAtKarlovManor extends ExpansionSet {
cards.add(new SetCardInfo("Case of the Gateway Express", 8, Rarity.UNCOMMON, mage.cards.c.CaseOfTheGatewayExpress.class));
cards.add(new SetCardInfo("Case of the Gorgon's Kiss", 79, Rarity.UNCOMMON, mage.cards.c.CaseOfTheGorgonsKiss.class));
cards.add(new SetCardInfo("Case of the Locked Hothouse", 155, Rarity.RARE, mage.cards.c.CaseOfTheLockedHothouse.class));
cards.add(new SetCardInfo("Case of the Stashed Skeleton", 80, Rarity.RARE, mage.cards.c.CaseOfTheStashedSkeleton.class));
cards.add(new SetCardInfo("Case of the Ransacked Lab", 45, Rarity.RARE, mage.cards.c.CaseOfTheRansackedLab.class));
cards.add(new SetCardInfo("Case of the Shattered Pact", 1, Rarity.UNCOMMON, mage.cards.c.CaseOfTheShatteredPact.class));
cards.add(new SetCardInfo("Case of the Stashed Skeleton", 80, Rarity.RARE, mage.cards.c.CaseOfTheStashedSkeleton.class));
cards.add(new SetCardInfo("Case of the Trampled Garden", 156, Rarity.UNCOMMON, mage.cards.c.CaseOfTheTrampledGarden.class));
cards.add(new SetCardInfo("Caught Red-Handed", 115, Rarity.UNCOMMON, mage.cards.c.CaughtRedHanded.class));
cards.add(new SetCardInfo("Cease // Desist", 246, Rarity.UNCOMMON, mage.cards.c.CeaseDesist.class));

View file

@ -0,0 +1,25 @@
package mage.game.permanent.token;
import mage.MageInt;
import mage.constants.CardType;
import mage.constants.SubType;
public class SkeletonToken2 extends TokenImpl {
public SkeletonToken2() {
super("Skeleton Token", "2/1 black Skeleton creature token");
cardType.add(CardType.CREATURE);
this.subtype.add(SubType.SKELETON);
color.setBlack(true);
power = new MageInt(2);
toughness = new MageInt(1);
}
private SkeletonToken2(final SkeletonToken2 token) {
super(token);
}
public SkeletonToken2 copy() {
return new SkeletonToken2(this);
}
}