[WOE] Implement Likeness Looter (#10867)

Co-authored-by: Evan Kranzler <theelk801@gmail.com>
This commit is contained in:
Susucre 2023-08-19 00:24:17 +02:00 committed by GitHub
parent cc6949156a
commit c6b49253c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 139 additions and 0 deletions

View file

@ -0,0 +1,138 @@
package mage.cards.l;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.ActivateAsSorceryActivatedAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CopyEffect;
import mage.abilities.effects.common.DrawDiscardControllerEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ManaValuePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetadjustment.TargetAdjuster;
import mage.util.functions.CopyApplier;
import java.util.UUID;
/**
* @author Susucr
*/
public final class LikenessLooter extends CardImpl {
public LikenessLooter(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U}{B}");
this.subtype.add(SubType.FAERIE);
this.subtype.add(SubType.SHAPESHIFTER);
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// Flying
this.addAbility(FlyingAbility.getInstance());
// {T}: Draw a card, then discard a card.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawDiscardControllerEffect(), new TapSourceCost()));
// {X}: Likeness Looter becomes a copy of target creature card in your graveyard with mana value X, except it has flying and this ability. Activate only as a sorcery.
Ability ability = new ActivateAsSorceryActivatedAbility(
new LikenessLooterEffect(),
new ManaCostsImpl<>("{X}")
);
ability.setTargetAdjuster(LikenessLooterAdjuster.instance);
this.addAbility(ability);
}
private LikenessLooter(final LikenessLooter card) {
super(card);
}
@Override
public LikenessLooter copy() {
return new LikenessLooter(this);
}
}
enum LikenessLooterAdjuster implements TargetAdjuster {
instance;
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = ability.getManaCostsToPay().getX();
FilterCard filterCard = new FilterCreatureCard("creature card in your graveyard with mana value " + xValue);
filterCard.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
ability.getTargets().clear();
ability.getTargets().add(new TargetCardInYourGraveyard(filterCard));
}
}
class LikenessLooterEffect extends OneShotEffect {
LikenessLooterEffect() {
super(Outcome.Copy);
staticText = "{this} becomes a copy of target creature card in your graveyard with mana value X, "
+ "except it has flying and this ability.";
}
LikenessLooterEffect(final LikenessLooterEffect effect) {
super(effect);
}
@Override
public LikenessLooterEffect copy() {
return new LikenessLooterEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
Card copyFromCard = game.getCard(source.getFirstTarget());
if (controller == null || permanent == null || source == null) {
return false;
}
Permanent newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game);
newBluePrint.assignNewId();
CopyApplier applier = new LikenessLooterCopyApplier();
applier.apply(game, newBluePrint, source, permanent.getId());
CopyEffect copyEffect = new CopyEffect(Duration.Custom, newBluePrint, permanent.getId());
copyEffect.newId();
copyEffect.setApplier(applier);
Ability newAbility = source.copy();
copyEffect.init(newAbility, game);
game.addEffect(copyEffect, newAbility);
return true;
}
}
class LikenessLooterCopyApplier extends CopyApplier {
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
// has flying
blueprint.getAbilities().add(FlyingAbility.getInstance());
// has the copy ability
Ability ability = new ActivateAsSorceryActivatedAbility(
new LikenessLooterEffect(),
new ManaCostsImpl<>("{X}")
);
ability.setTargetAdjuster(LikenessLooterAdjuster.instance);
blueprint.getAbilities().add(ability);
return true;
}
}

View file

@ -58,6 +58,7 @@ public final class WildsOfEldraine extends ExpansionSet {
cards.add(new SetCardInfo("Johann, Apprentice Sorcerer", 207, Rarity.UNCOMMON, mage.cards.j.JohannApprenticeSorcerer.class));
cards.add(new SetCardInfo("Kellan, the Fae-Blooded", 230, Rarity.MYTHIC, mage.cards.k.KellanTheFaeBlooded.class));
cards.add(new SetCardInfo("Knight of Doves", 19, Rarity.UNCOMMON, mage.cards.k.KnightOfDoves.class));
cards.add(new SetCardInfo("Likeness Looter", 208, Rarity.RARE, mage.cards.l.LikenessLooter.class));
cards.add(new SetCardInfo("Lich-Knights' Conquest", 96, Rarity.RARE, mage.cards.l.LichKnightsConquest.class));
cards.add(new SetCardInfo("Living Lectern", 59, Rarity.COMMON, mage.cards.l.LivingLectern.class));
cards.add(new SetCardInfo("Lord Skitter's Blessing", 98, Rarity.RARE, mage.cards.l.LordSkittersBlessing.class));