mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
[DMU] Implemented Anointed Peacekeeper (#9478)
This commit is contained in:
parent
71feacf9de
commit
a5621cf247
7 changed files with 168 additions and 60 deletions
103
Mage.Sets/src/mage/cards/a/AnointedPeacekeeper.java
Normal file
103
Mage.Sets/src/mage/cards/a/AnointedPeacekeeper.java
Normal file
|
@ -0,0 +1,103 @@
|
|||
package mage.cards.a;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
|
||||
import mage.abilities.effects.common.cost.SpellsCostIncreasingAllEffect;
|
||||
import mage.constants.*;
|
||||
import mage.abilities.keyword.VigilanceAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.ChosenNamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author weirddan455
|
||||
*/
|
||||
public final class AnointedPeacekeeper extends CardImpl {
|
||||
|
||||
private static final FilterCard filter = new FilterCard("spells with the chosen name");
|
||||
|
||||
static {
|
||||
filter.add(ChosenNamePredicate.instance);
|
||||
}
|
||||
|
||||
public AnointedPeacekeeper(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}");
|
||||
|
||||
this.subtype.add(SubType.HUMAN);
|
||||
this.subtype.add(SubType.CLERIC);
|
||||
this.power = new MageInt(3);
|
||||
this.toughness = new MageInt(3);
|
||||
|
||||
// Vigilance
|
||||
this.addAbility(VigilanceAbility.getInstance());
|
||||
|
||||
// As Anointed Peacekeeper enters the battlefield, look at an opponent's hand, then choose any card name.
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.ALL, true)));
|
||||
|
||||
// Spells your opponents cast with the chosen name cost {2} more to cast.
|
||||
this.addAbility(new SimpleStaticAbility(
|
||||
new SpellsCostIncreasingAllEffect(2, filter, TargetController.OPPONENT)
|
||||
.setText("spells your opponents cast with the chosen name cost {2} more to cast")
|
||||
));
|
||||
|
||||
// Activated abilities of sources with the chosen name cost {2} more to activate unless they're mana abilities.
|
||||
this.addAbility(new SimpleStaticAbility(new AnointedPeacekeeperEffect()));
|
||||
}
|
||||
|
||||
private AnointedPeacekeeper(final AnointedPeacekeeper card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnointedPeacekeeper copy() {
|
||||
return new AnointedPeacekeeper(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AnointedPeacekeeperEffect extends CostModificationEffectImpl {
|
||||
|
||||
public AnointedPeacekeeperEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Detriment, CostModificationType.INCREASE_COST);
|
||||
this.staticText = "Activated abilities of sources with the chosen name cost {2} more to activate unless they're mana abilities.";
|
||||
}
|
||||
|
||||
private AnointedPeacekeeperEffect(final AnointedPeacekeeperEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnointedPeacekeeperEffect copy() {
|
||||
return new AnointedPeacekeeperEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
CardUtil.increaseCost(abilityToModify, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify.getAbilityType() != AbilityType.ACTIVATED) {
|
||||
return false;
|
||||
}
|
||||
MageObject activatedSource = game.getObject(abilityToModify.getSourceId());
|
||||
if (activatedSource == null) {
|
||||
return false;
|
||||
}
|
||||
String chosenName = (String) game.getState().getValue(
|
||||
source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY
|
||||
);
|
||||
return CardUtil.haveSameNames(activatedSource, chosenName, game);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package mage.cards.s;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
|
||||
|
@ -15,10 +14,7 @@ import mage.constants.SetTargetPointer;
|
|||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.predicate.ObjectSourcePlayer;
|
||||
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
import mage.filter.predicate.mageobject.ChosenNamePredicate;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -30,7 +26,7 @@ public final class SilverquillSilencer extends CardImpl {
|
|||
private static final FilterSpell filter = new FilterSpell("a spell with the chosen name");
|
||||
|
||||
static {
|
||||
filter.add(SilverquillSilencerPredicate.instance);
|
||||
filter.add(ChosenNamePredicate.instance);
|
||||
}
|
||||
|
||||
public SilverquillSilencer(UUID ownerId, CardSetInfo setInfo) {
|
||||
|
@ -64,15 +60,3 @@ public final class SilverquillSilencer extends CardImpl {
|
|||
return new SilverquillSilencer(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum SilverquillSilencerPredicate implements ObjectSourcePlayerPredicate<MageObject> {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(ObjectSourcePlayer<MageObject> input, Game game) {
|
||||
String cardName = (String) game.getState().getValue(
|
||||
input.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY
|
||||
);
|
||||
return CardUtil.haveSameNames(input.getObject().getName(), cardName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +24,7 @@ public final class SorcerousSpyglass extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
|
||||
|
||||
// As Sorcerous Spyglass enters the battlefield, look at an opponent's hand, then choose any card name.
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new SorcerousSpyglassEntersEffect()));
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.ALL, true)));
|
||||
|
||||
// Activated abilities of sources with the chosen name can't be activated unless they're mana abilities.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SorcerousSpyglassActivationEffect()));
|
||||
|
@ -42,42 +40,6 @@ public final class SorcerousSpyglass extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class SorcerousSpyglassEntersEffect extends ChooseACardNameEffect {
|
||||
|
||||
SorcerousSpyglassEntersEffect() {
|
||||
super(ChooseACardNameEffect.TypeOfName.ALL);
|
||||
staticText = "look at an opponent's hand, then choose any card name";
|
||||
}
|
||||
|
||||
SorcerousSpyglassEntersEffect(final SorcerousSpyglassEntersEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SorcerousSpyglassEntersEffect copy() {
|
||||
return new SorcerousSpyglassEntersEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
TargetOpponent target = new TargetOpponent(true);
|
||||
if (player.choose(Outcome.Benefit, target, source, game)) {
|
||||
Player opponent = game.getPlayer(target.getFirstTarget());
|
||||
if (opponent != null) {
|
||||
MageObject sourceObject = game.getObject(source);
|
||||
player.lookAtCards(sourceObject != null ? sourceObject.getIdName() : null, opponent.getHand(), game);
|
||||
player.chooseUse(Outcome.Benefit, "Press Ok to name a card",
|
||||
"You won't be able to resize the window showing opponents hand once you do",
|
||||
"Ok", "", source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.apply(game, source);
|
||||
}
|
||||
}
|
||||
|
||||
class SorcerousSpyglassActivationEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
public SorcerousSpyglassActivationEffect() {
|
||||
|
|
|
@ -33,6 +33,7 @@ public final class DominariaUnited extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Aether Channeler", 42, Rarity.RARE, mage.cards.a.AetherChanneler.class));
|
||||
cards.add(new SetCardInfo("Aggressive Sabotage", 78, Rarity.COMMON, mage.cards.a.AggressiveSabotage.class));
|
||||
cards.add(new SetCardInfo("Ajani, Sleeper Agent", 192, Rarity.MYTHIC, mage.cards.a.AjaniSleeperAgent.class));
|
||||
cards.add(new SetCardInfo("Anointed Peacekeeper", 2, Rarity.RARE, mage.cards.a.AnointedPeacekeeper.class));
|
||||
cards.add(new SetCardInfo("Archangel of Wrath", 3, Rarity.RARE, mage.cards.a.ArchangelOfWrath.class));
|
||||
cards.add(new SetCardInfo("Argivian Cavalier", 4, Rarity.COMMON, mage.cards.a.ArgivianCavalier.class));
|
||||
cards.add(new SetCardInfo("Argivian Phalanx", 5, Rarity.COMMON, mage.cards.a.ArgivianPhalanx.class));
|
||||
|
|
|
@ -11,6 +11,7 @@ import mage.constants.Outcome;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -86,20 +87,47 @@ public class ChooseACardNameEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
private final TypeOfName typeOfName;
|
||||
private final boolean lookAtOpponentHand;
|
||||
|
||||
public ChooseACardNameEffect(TypeOfName typeOfName) {
|
||||
this(typeOfName, false);
|
||||
}
|
||||
|
||||
public ChooseACardNameEffect(TypeOfName typeOfName, boolean lookAtOpponentHand) {
|
||||
super(Outcome.Detriment);
|
||||
this.typeOfName = typeOfName;
|
||||
staticText = "choose " + CardUtil.addArticle(typeOfName.description);
|
||||
this.lookAtOpponentHand = lookAtOpponentHand;
|
||||
if (lookAtOpponentHand) {
|
||||
staticText = "look at an opponent's hand, then choose any " + typeOfName.description;
|
||||
} else {
|
||||
staticText = "choose " + CardUtil.addArticle(typeOfName.description);
|
||||
}
|
||||
}
|
||||
|
||||
public ChooseACardNameEffect(final ChooseACardNameEffect effect) {
|
||||
super(effect);
|
||||
this.typeOfName = effect.typeOfName;
|
||||
this.lookAtOpponentHand = effect.lookAtOpponentHand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (lookAtOpponentHand) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
TargetOpponent target = new TargetOpponent(true);
|
||||
if (player.choose(Outcome.Benefit, target, source, game)) {
|
||||
Player opponent = game.getPlayer(target.getFirstTarget());
|
||||
if (opponent != null) {
|
||||
MageObject sourceObject = game.getObject(source);
|
||||
player.lookAtCards(sourceObject != null ? sourceObject.getIdName() : null, opponent.getHand(), game);
|
||||
player.chooseUse(Outcome.Benefit, "Press Ok to name a card",
|
||||
"You won't be able to resize the window showing opponents hand once you do",
|
||||
"Ok", "", source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return typeOfName.getChoice(game, source) != null;
|
||||
}
|
||||
|
||||
|
|
|
@ -126,12 +126,12 @@ public class SpellsCostIncreasingAllEffect extends CostModificationEffectImpl {
|
|||
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
|
||||
if (spell != null) {
|
||||
// real cast with put on stack
|
||||
return this.filter.match(spell, game);
|
||||
return this.filter.match(spell, sourceController.getId(), source, game);
|
||||
} else {
|
||||
// get playable and other staff without put on stack
|
||||
// used at least for flashback ability because Flashback ability doesn't use stack
|
||||
Card sourceCard = ((SpellAbility) abilityToModify).getCharacteristics(game);
|
||||
return this.filter.match(sourceCard, game);
|
||||
return this.filter.match(sourceCard, sourceController.getId(), source, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package mage.filter.predicate.mageobject;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||
import mage.filter.predicate.ObjectSourcePlayer;
|
||||
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
* To be used with ChooseACardNameEffect
|
||||
*
|
||||
* @author weirddan455
|
||||
*/
|
||||
public enum ChosenNamePredicate implements ObjectSourcePlayerPredicate<MageObject> {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(ObjectSourcePlayer<MageObject> input, Game game) {
|
||||
String cardName = (String) game.getState().getValue(
|
||||
input.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY
|
||||
);
|
||||
return CardUtil.haveSameNames(input.getObject().getName(), cardName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Chosen name";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue