[C21] Implemented Cunning Rhetoric

This commit is contained in:
Evan Kranzler 2021-04-19 09:01:20 -04:00
parent beaae98bd1
commit 96d48d0ca4
3 changed files with 127 additions and 20 deletions

View file

@ -0,0 +1,117 @@
package mage.cards.c;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class CunningRhetoric extends CardImpl {
public CunningRhetoric(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}");
// Whenever an opponent attacks you and/or one or more planeswalkers you control, exile the top card of that player's library. You may play that card for as long as it remains exiled, and you may spend mana as though it were mana of any color to cast it.
this.addAbility(new CunningRhetoricTriggeredAbility());
}
private CunningRhetoric(final CunningRhetoric card) {
super(card);
}
@Override
public CunningRhetoric copy() {
return new CunningRhetoric(this);
}
}
class CunningRhetoricTriggeredAbility extends TriggeredAbilityImpl {
public CunningRhetoricTriggeredAbility() {
super(Zone.BATTLEFIELD, new CunningRhetoricEffect(), false);
}
public CunningRhetoricTriggeredAbility(final CunningRhetoricTriggeredAbility ability) {
super(ability);
}
@Override
public CunningRhetoricTriggeredAbility copy() {
return new CunningRhetoricTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
UUID playerId = game.getCombat()
.getAttackers()
.stream()
.filter(attacker -> isControlledBy(game.getCombat().getDefendingPlayerId(attacker, game)))
.map(game::getControllerId)
.filter(game.getOpponents(getControllerId())::contains)
.findFirst()
.orElse(null);
if (playerId == null) {
return false;
}
getEffects().setTargetPointer(new FixedTarget(playerId));
return true;
}
@Override
public String getRule() {
return "Whenever an opponent attacks you and/or one or more planeswalkers you control, " +
"exile the top card of that player's library. You may play that card for as long " +
"as it remains exiled, and you may spend mana as though it were mana of any color to cast it.";
}
}
class CunningRhetoricEffect extends OneShotEffect {
CunningRhetoricEffect() {
super(Outcome.Benefit);
}
private CunningRhetoricEffect(final CunningRhetoricEffect effect) {
super(effect);
}
@Override
public CunningRhetoricEffect copy() {
return new CunningRhetoricEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
if (opponent == null) {
return false;
}
Card card = opponent.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
opponent.moveCards(card, Zone.EXILED, source, game);
CardUtil.makeCardPlayable(game, source, card, Duration.Custom, true);
return true;
}
}

View file

@ -1,6 +1,5 @@
package mage.cards.e;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
@ -9,11 +8,10 @@ import mage.constants.CardType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class EverWatchingThreshold extends CardImpl {
@ -57,25 +55,16 @@ class EverWatchingThresholdTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player player = game.getPlayer(this.getControllerId());
if (player == null) {
return false;
}
for (UUID attacker : game.getCombat().getAttackers()) {
Permanent creature = game.getPermanent(attacker);
if (creature != null
&& player.hasOpponent(creature.getControllerId(), game)
&& player.getId().equals(game.getCombat().getDefendingPlayerId(attacker, game))) {
return true;
}
}
return false;
return game.getCombat()
.getAttackers()
.stream()
.filter(attacker -> isControlledBy(game.getCombat().getDefendingPlayerId(attacker, game)))
.map(game::getControllerId)
.anyMatch(game.getOpponents(getControllerId())::contains);
}
@Override
public String getRule() {
return "Whenever an opponent attacks you "
+ "and/or a planeswalker you control "
+ "with one or more creatures, draw a card.";
return "Whenever an opponent attacks, if they attacked you and/or a planeswalker you control, draw a card.";
}
}

View file

@ -77,6 +77,7 @@ public final class Commander2021Edition extends ExpansionSet {
cards.add(new SetCardInfo("Crafty Cutpurse", 117, Rarity.RARE, mage.cards.c.CraftyCutpurse.class));
cards.add(new SetCardInfo("Creative Technique", 49, Rarity.RARE, mage.cards.c.CreativeTechnique.class));
cards.add(new SetCardInfo("Cultivate", 187, Rarity.UNCOMMON, mage.cards.c.Cultivate.class));
cards.add(new SetCardInfo("Cunning Rhetoric", 38, Rarity.RARE, mage.cards.c.CunningRhetoric.class));
cards.add(new SetCardInfo("Curiosity Crafter", 24, Rarity.RARE, mage.cards.c.CuriosityCrafter.class));
cards.add(new SetCardInfo("Curse of Disturbance", 138, Rarity.UNCOMMON, mage.cards.c.CurseOfDisturbance.class));
cards.add(new SetCardInfo("Curse of the Swine", 118, Rarity.RARE, mage.cards.c.CurseOfTheSwine.class));