Merge pull request #6124 from magefree/updateDevotion

Refactor Devotion dynamic value to enum (ready to merge)
This commit is contained in:
Evan Kranzler 2019-12-30 11:30:37 -05:00 committed by GitHub
commit a0888af73a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 562 additions and 725 deletions

View file

@ -3,17 +3,14 @@ package mage.cards.a;
import mage.MageInt;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.SacrificeControllerEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.filter.StaticFilters;
@ -26,8 +23,6 @@ import java.util.UUID;
*/
public final class AbhorrentOverlord extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.B);
public AbhorrentOverlord(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{B}{B}");
this.subtype.add(SubType.DEMON);
@ -39,15 +34,15 @@ public final class AbhorrentOverlord extends CardImpl {
this.addAbility(FlyingAbility.getInstance());
// When Abhorrent Overlord enters the battlefield, create a number of 1/1 black Harpy creature tokens with flying equal to your devotion to black.
Effect effect = new CreateTokenEffect(new AbhorrentOverlordHarpyToken(), xValue);
Effect effect = new CreateTokenEffect(new AbhorrentOverlordHarpyToken(), DevotionCount.B);
effect.setText("create a number of 1/1 black Harpy creature tokens with flying equal to your devotion to black. <i>(Each {B} in the mana costs of permanents you control counts toward your devotion to black.)</i>");
this.addAbility(new EntersBattlefieldTriggeredAbility(effect).addHint(new ValueHint("Devotion to black", xValue)));
this.addAbility(new EntersBattlefieldTriggeredAbility(effect).addHint(DevotionCount.B.getHint()));
// At the beginning of your upkeep, sacrifice a creature.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeControllerEffect(StaticFilters.FILTER_PERMANENT_CREATURE, 1, null), TargetController.YOU, false));
}
public AbhorrentOverlord(final AbhorrentOverlord card) {
private AbhorrentOverlord(final AbhorrentOverlord card) {
super(card);
}
@ -59,7 +54,7 @@ public final class AbhorrentOverlord extends CardImpl {
class AbhorrentOverlordHarpyToken extends TokenImpl {
public AbhorrentOverlordHarpyToken() {
AbhorrentOverlordHarpyToken() {
super("Harpy", "1/1 black Harpy creature tokens with flying");
cardType.add(CardType.CREATURE);
color.setBlack(true);
@ -70,7 +65,7 @@ class AbhorrentOverlordHarpyToken extends TokenImpl {
this.addAbility(FlyingAbility.getInstance());
}
public AbhorrentOverlordHarpyToken(final AbhorrentOverlordHarpyToken token) {
private AbhorrentOverlordHarpyToken(final AbhorrentOverlordHarpyToken token) {
super(token);
}

View file

@ -1,14 +1,11 @@
package mage.cards.a;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.PreventionEffectImpl;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.events.DamageEvent;
@ -33,10 +30,10 @@ public final class AcolytesReward extends CardImpl {
this.getSpellAbility().addEffect(new AcolytesRewardEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addTarget(new TargetAnyTarget());
this.getSpellAbility().addHint(new ValueHint("Devotion to white", AcolytesRewardEffect.xValue));
this.getSpellAbility().addHint(DevotionCount.W.getHint());
}
public AcolytesReward(final AcolytesReward card) {
private AcolytesReward(final AcolytesReward card) {
super(card);
}
@ -49,14 +46,13 @@ public final class AcolytesReward extends CardImpl {
class AcolytesRewardEffect extends PreventionEffectImpl {
protected int amount = 0;
static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.W);
public AcolytesRewardEffect() {
AcolytesRewardEffect() {
super(Duration.EndOfTurn);
staticText = "Prevent the next X damage that would be dealt to target creature this turn, where X is your devotion to white. If damage is prevented this way, {this} deals that much damage to any target";
}
public AcolytesRewardEffect(final AcolytesRewardEffect effect) {
private AcolytesRewardEffect(final AcolytesRewardEffect effect) {
super(effect);
this.amount = effect.amount;
}
@ -69,7 +65,7 @@ class AcolytesRewardEffect extends PreventionEffectImpl {
@Override
public void init(Ability source, Game game) {
super.init(source, game);
amount = xValue.calculate(game, source, this);
amount = DevotionCount.W.calculate(game, source, this);
}
@Override
@ -88,38 +84,42 @@ class AcolytesRewardEffect extends PreventionEffectImpl {
amount = 0;
}
GameEvent preventEvent = new PreventDamageEvent(source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent, ((DamageEvent) event).isCombatDamage());
if (!game.replaceEvent(preventEvent)) {
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
if (targetCreature != null) {
if (amount == 0) {
this.used = true;
this.discard();
}
if (event.getAmount() >= toPrevent) {
event.setAmount(event.getAmount() - toPrevent);
} else {
event.setAmount(0);
result = true;
}
if (toPrevent > 0) {
game.informPlayers("Acolyte's Reward prevented " + toPrevent + " to " + targetCreature.getName());
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent));
Player targetPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());
if (targetPlayer != null) {
targetPlayer.damage(toPrevent, source.getSourceId(), game, false, true);
game.informPlayers("Acolyte's Reward deals " + toPrevent + " damage to " + targetPlayer.getLogName());
} else {
Permanent targetDamageCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (targetDamageCreature != null) {
targetDamageCreature.damage(toPrevent, source.getSourceId(), game, false, true);
game.informPlayers("Acolyte's Reward deals " + toPrevent + " damage to " + targetDamageCreature.getName());
}
}
}
}
if (game.replaceEvent(preventEvent)) {
return result;
}
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
if (targetCreature == null) {
return result;
}
if (amount == 0) {
this.used = true;
this.discard();
}
if (event.getAmount() >= toPrevent) {
event.setAmount(event.getAmount() - toPrevent);
} else {
event.setAmount(0);
result = true;
}
if (toPrevent == 0) {
return result;
}
game.informPlayers("Acolyte's Reward prevented " + toPrevent + " to " + targetCreature.getName());
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent));
Player targetPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());
if (targetPlayer != null) {
targetPlayer.damage(toPrevent, source.getSourceId(), game, false, true);
game.informPlayers("Acolyte's Reward deals " + toPrevent + " damage to " + targetPlayer.getLogName());
return result;
}
Permanent targetDamageCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (targetDamageCreature == null) {
return result;
}
targetDamageCreature.damage(toPrevent, source.getSourceId(), game, false, true);
game.informPlayers("Acolyte's Reward deals " + toPrevent + " damage to " + targetDamageCreature.getName());
return result;
}

View file

@ -1,14 +1,11 @@
package mage.cards.a;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Duration;
import mage.target.common.TargetCreaturePermanent;
@ -19,20 +16,18 @@ import java.util.UUID;
*/
public final class AspectOfHydra extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.G);
public AspectOfHydra(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{G}");
// Target creature gets +X/+X until end of turn, where X is your devotion to green.
Effect effect = new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn, true);
Effect effect = new BoostTargetEffect(DevotionCount.G, DevotionCount.G, Duration.EndOfTurn, true);
effect.setText("Target creature gets +X/+X until end of turn, where X is your devotion to green");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addHint(new ValueHint("Devotion to green", xValue));
this.getSpellAbility().addHint(DevotionCount.G.getHint());
}
public AspectOfHydra(final AspectOfHydra card) {
private AspectOfHydra(final AspectOfHydra card) {
super(card);
}

View file

@ -6,12 +6,10 @@ import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -35,7 +33,6 @@ import java.util.UUID;
public final class AthreosGodOfPassage extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature you own");
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.W, ColoredManaSymbol.B);
static {
filter.add(AnotherPredicate.instance);
@ -54,9 +51,8 @@ public final class AthreosGodOfPassage extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to white and black is less than seven, Athreos isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 7);
effect.setText("As long as your devotion to white and black is less than seven, Athreos isn't a creature");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to white and black", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.WB, 7))
.addHint(DevotionCount.WB.getHint()));
// Whenever another creature you own dies, return it to your hand unless target opponent pays 3 life.
Ability ability = new AthreosDiesCreatureTriggeredAbility(new AthreosGodOfPassageReturnEffect(), false, filter);
@ -65,7 +61,7 @@ public final class AthreosGodOfPassage extends CardImpl {
}
public AthreosGodOfPassage(final AthreosGodOfPassage card) {
private AthreosGodOfPassage(final AthreosGodOfPassage card) {
super(card);
}
@ -77,12 +73,12 @@ public final class AthreosGodOfPassage extends CardImpl {
class AthreosGodOfPassageReturnEffect extends OneShotEffect {
public AthreosGodOfPassageReturnEffect() {
AthreosGodOfPassageReturnEffect() {
super(Outcome.Benefit);
this.staticText = "return it to your hand unless target opponent pays 3 life";
}
public AthreosGodOfPassageReturnEffect(final AthreosGodOfPassageReturnEffect effect) {
private AthreosGodOfPassageReturnEffect(final AthreosGodOfPassageReturnEffect effect) {
super(effect);
}
@ -94,30 +90,29 @@ class AthreosGodOfPassageReturnEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
UUID creatureId = (UUID) this.getValue("creatureId");
Card creature = game.getCard(creatureId);
if (creature != null) {
Player opponent = game.getPlayer(source.getFirstTarget());
boolean paid = false;
if (opponent != null) {
Cost cost = new PayLifeCost(3);
if (cost.canPay(source, source.getSourceId(), opponent.getId(), game)
&& opponent.chooseUse(outcome, "Pay 3 life to prevent that " + creature.getLogName() + " returns to " + controller.getLogName() + "'s hand?", source, game)) {
if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false, null)) {
paid = true;
}
}
}
if (opponent == null || !paid) {
if (game.getState().getZone(creature.getId()) == Zone.GRAVEYARD) {
controller.moveCards(creature, Zone.HAND, source, game);
}
}
}
if (controller == null) {
return false;
}
UUID creatureId = (UUID) this.getValue("creatureId");
Card creature = game.getCard(creatureId);
if (creature == null) {
return true;
}
return false;
Player opponent = game.getPlayer(source.getFirstTarget());
boolean paid = false;
if (opponent != null) {
Cost cost = new PayLifeCost(3);
if (cost.canPay(source, source.getSourceId(), opponent.getId(), game)
&& opponent.chooseUse(outcome, "Pay 3 life to prevent that " + creature.getLogName() + " returns to " + controller.getLogName() + "'s hand?", source, game)
&& cost.pay(source, game, source.getSourceId(), opponent.getId(), false, null)) {
paid = true;
}
}
if ((opponent != null && paid) || game.getState().getZone(creature.getId()) != Zone.GRAVEYARD) {
return true;
}
controller.moveCards(creature, Zone.HAND, source, game);
return true;
}
}
@ -125,12 +120,12 @@ class AthreosDiesCreatureTriggeredAbility extends TriggeredAbilityImpl {
protected FilterCreaturePermanent filter;
public AthreosDiesCreatureTriggeredAbility(Effect effect, boolean optional, FilterCreaturePermanent filter) {
AthreosDiesCreatureTriggeredAbility(Effect effect, boolean optional, FilterCreaturePermanent filter) {
super(Zone.BATTLEFIELD, effect, optional);
this.filter = filter;
}
public AthreosDiesCreatureTriggeredAbility(AthreosDiesCreatureTriggeredAbility ability) {
private AthreosDiesCreatureTriggeredAbility(AthreosDiesCreatureTriggeredAbility ability) {
super(ability);
this.filter = ability.filter;
}
@ -148,15 +143,16 @@ class AthreosDiesCreatureTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.isDiesEvent()) {
if (zEvent.getTarget() != null && filter.match(zEvent.getTarget(), sourceId, controllerId, game)) {
for (Effect effect : this.getEffects()) {
effect.setValue("creatureId", event.getTargetId());
}
return true;
}
if (!zEvent.isDiesEvent()) {
return false;
}
return false;
if (zEvent.getTarget() == null || !filter.match(zEvent.getTarget(), sourceId, controllerId, game)) {
return false;
}
for (Effect effect : this.getEffects()) {
effect.setValue("creatureId", event.getTargetId());
}
return true;
}
@Override

View file

@ -6,13 +6,10 @@ import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -36,7 +33,6 @@ import java.util.UUID;
*/
public final class AthreosShroudVeiled extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.W, ColoredManaSymbol.B);
private static final FilterPermanent filter = new FilterCreaturePermanent("another target creature");
static {
@ -55,10 +51,8 @@ public final class AthreosShroudVeiled extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to white and black is less than seven, Athreos isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 7);
effect.setText("As long as your devotion to white and black is less than seven, {this} isn't a creature");
this.addAbility(new SimpleStaticAbility(effect)
.addHint(new ValueHint("Devotion to white and black", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.WB, 7))
.addHint(DevotionCount.WB.getHint()));
// At the beginning of your end step, put a coin counter on another target creature.
Ability ability = new BeginningOfEndStepTriggeredAbility(

View file

@ -3,11 +3,9 @@ package mage.cards.d;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.continuous.SetToughnessSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
@ -23,8 +21,6 @@ import java.util.UUID;
*/
public final class DaxosBlessedByTheSun extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.W);
public DaxosBlessedByTheSun(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{W}{W}");
@ -35,9 +31,10 @@ public final class DaxosBlessedByTheSun extends CardImpl {
// Daxos's toughness is equal to your devotion to white.
this.addAbility(new SimpleStaticAbility(
Zone.ALL, new SetToughnessSourceEffect(xValue, Duration.EndOfGame
).setText("{this}'s toughness is equal to your devotion to white"))
.addHint(new ValueHint("Devotion to white", xValue)));
Zone.ALL,
new SetToughnessSourceEffect(DevotionCount.W, Duration.EndOfGame)
.setText("{this}'s toughness is equal to your devotion to white")
).addHint(DevotionCount.W.getHint()));
// Whenever another creature you control enters the battlefield or dies, you gain 1 life.
this.addAbility(new DaxosBlessedByTheSunAbility());

View file

@ -3,12 +3,13 @@ package mage.cards.d;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.*;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
@ -36,12 +37,12 @@ public final class DiscipleOfPhenax extends CardImpl {
// from their hand equal to your devotion to black. You choose one of them. That player discards that card.
Ability ability = new EntersBattlefieldTriggeredAbility(new DiscipleOfPhenaxEffect(), false);
ability.addTarget(new TargetPlayer());
ability.addHint(new ValueHint("Devotion to black", DiscipleOfPhenaxEffect.xValue));
ability.addHint(DevotionCount.B.getHint());
this.addAbility(ability);
}
public DiscipleOfPhenax(final DiscipleOfPhenax card) {
private DiscipleOfPhenax(final DiscipleOfPhenax card) {
super(card);
}
@ -53,14 +54,12 @@ public final class DiscipleOfPhenax extends CardImpl {
class DiscipleOfPhenaxEffect extends OneShotEffect {
static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.B);
public DiscipleOfPhenaxEffect() {
DiscipleOfPhenaxEffect() {
super(Outcome.Discard);
staticText = "target player reveals a number of cards from their hand equal to your devotion to black. You choose one of them. That player discards that card";
}
public DiscipleOfPhenaxEffect(final DiscipleOfPhenaxEffect effect) {
private DiscipleOfPhenaxEffect(final DiscipleOfPhenaxEffect effect) {
super(effect);
}
@ -71,48 +70,46 @@ class DiscipleOfPhenaxEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
int devotion = xValue.calculate(game, source, this);
int devotion = DevotionCount.B.calculate(game, source, this);
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (devotion > 0 && targetPlayer != null) {
Cards revealedCards = new CardsImpl();
int amount = Math.min(targetPlayer.getHand().size(), devotion);
if (targetPlayer.getHand().size() > amount) {
FilterCard filter = new FilterCard("card in target player's hand");
TargetCardInHand chosenCards = new TargetCardInHand(amount, amount, filter);
chosenCards.setNotTarget(true);
if (chosenCards.canChoose(targetPlayer.getId(), game) && targetPlayer.choose(Outcome.Discard, targetPlayer.getHand(), chosenCards, game)) {
if (!chosenCards.getTargets().isEmpty()) {
List<UUID> targets = chosenCards.getTargets();
for (UUID targetid : targets) {
Card card = game.getCard(targetid);
if (card != null) {
revealedCards.add(card);
}
if (devotion <= 0 || targetPlayer == null) {
return false;
}
Cards revealedCards = new CardsImpl();
int amount = Math.min(targetPlayer.getHand().size(), devotion);
if (targetPlayer.getHand().size() > amount) {
FilterCard filter = new FilterCard("card in target player's hand");
TargetCardInHand chosenCards = new TargetCardInHand(amount, amount, filter);
chosenCards.setNotTarget(true);
if (chosenCards.canChoose(targetPlayer.getId(), game) && targetPlayer.choose(Outcome.Discard, targetPlayer.getHand(), chosenCards, game)) {
if (!chosenCards.getTargets().isEmpty()) {
List<UUID> targets = chosenCards.getTargets();
for (UUID targetid : targets) {
Card card = game.getCard(targetid);
if (card != null) {
revealedCards.add(card);
}
}
}
} else {
revealedCards.addAll(targetPlayer.getHand());
}
if (!revealedCards.isEmpty()) {
targetPlayer.revealCards("Disciple of Phenax", revealedCards, game);
Player you = game.getPlayer(source.getControllerId());
if (you != null) {
TargetCard yourChoice = new TargetCard(Zone.HAND, new FilterCard());
yourChoice.setNotTarget(true);
if (you.choose(Outcome.Benefit, revealedCards, yourChoice, game)) {
Card card = targetPlayer.getHand().get(yourChoice.getFirstTarget(), game);
return targetPlayer.discard(card, source, game);
}
} else {
return false;
}
}
} else {
revealedCards.addAll(targetPlayer.getHand());
}
if (revealedCards.isEmpty()) {
return true;
}
targetPlayer.revealCards("Disciple of Phenax", revealedCards, game);
Player you = game.getPlayer(source.getControllerId());
if (you == null) {
return false;
}
TargetCard yourChoice = new TargetCard(Zone.HAND, new FilterCard());
yourChoice.setNotTarget(true);
if (you.choose(Outcome.Benefit, revealedCards, yourChoice, game)) {
Card card = targetPlayer.getHand().get(yourChoice.getFirstTarget(), game);
return targetPlayer.discard(card, source, game);
}
return false;
return true;
}
}

View file

@ -3,17 +3,18 @@ package mage.cards.e;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.effects.common.search.SearchLibraryGraveyardPutOntoBattlefieldEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.counters.CounterType;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
@ -33,8 +34,6 @@ public final class ElspethUndauntedHero extends CardImpl {
filter.add(new NamePredicate("Sunlit Hoplite"));
}
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.W);
public ElspethUndauntedHero(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{2}{W}{W}{W}");
@ -56,9 +55,9 @@ public final class ElspethUndauntedHero extends CardImpl {
StaticFilters.FILTER_PERMANENT_CREATURES
).setText("Until end of turn, creatures you control gain flying"), -8);
ability.addEffect(new BoostControlledEffect(
xValue, xValue, Duration.EndOfTurn
DevotionCount.W, DevotionCount.W, Duration.EndOfTurn
).setText("and get +X/+X, where X is your devotion to white"));
ability.addHint(new ValueHint("Devotion to white", xValue));
ability.addHint(DevotionCount.W.getHint());
this.addAbility(ability);
}

View file

@ -6,12 +6,9 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -27,8 +24,6 @@ import java.util.UUID;
*/
public final class EpharaGodOfThePolis extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.W, ColoredManaSymbol.U);
public EpharaGodOfThePolis(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{2}{W}{U}");
this.addSuperType(SuperType.LEGENDARY);
@ -41,19 +36,20 @@ public final class EpharaGodOfThePolis extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to white and blue is less than seven, Ephara isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 7);
effect.setText("As long as your devotion to white and blue is less than seven, Ephara isn't a creature");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to white and blue", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.WU, 7))
.addHint(DevotionCount.WU.getHint()));
// At the beginning of each upkeep, if you had another creature enter the battlefield under your control last turn, draw a card.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), TargetController.ANY, false, false),
HadAnotherCreatureEnterTheBattlefieldCondition.instance,
"At the beginning of each upkeep, if you had another creature enter the battlefield under your control last turn, draw a card."),
new PermanentsEnteredBattlefieldWatcher());
new BeginningOfUpkeepTriggeredAbility(
Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1),
TargetController.ANY, false, false
), EpharaGodOfThePolisCondition.instance, "At the beginning of each upkeep, " +
"if you had another creature enter the battlefield under your control last turn, draw a card."
), new PermanentsEnteredBattlefieldWatcher());
}
public EpharaGodOfThePolis(final EpharaGodOfThePolis card) {
private EpharaGodOfThePolis(final EpharaGodOfThePolis card) {
super(card);
}
@ -63,11 +59,10 @@ public final class EpharaGodOfThePolis extends CardImpl {
}
}
enum HadAnotherCreatureEnterTheBattlefieldCondition implements Condition {
enum EpharaGodOfThePolisCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());

View file

@ -6,13 +6,10 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.CantGainLifeAllEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -25,8 +22,6 @@ import java.util.UUID;
*/
public final class ErebosGodOfTheDead extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.B);
public ErebosGodOfTheDead(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{3}{B}");
addSuperType(SuperType.LEGENDARY);
@ -39,27 +34,24 @@ public final class ErebosGodOfTheDead extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to black is less than five, Erebos isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 5);
effect.setText("As long as your devotion to black is less than five, Erebos isn't a creature.<i>(Each {B} in the mana costs of permanents you control counts towards your devotion to black.)</i>");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to black", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.B, 5))
.addHint(DevotionCount.B.getHint()));
// Your opponents can't gain life.
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD,
new CantGainLifeAllEffect(
Duration.WhileOnBattlefield,
TargetController.OPPONENT
)
new CantGainLifeAllEffect(Duration.WhileOnBattlefield, TargetController.OPPONENT)
));
// {1}{B}, Pay 2 life: Draw a card.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new ManaCostsImpl("{1}{B}"));
Ability ability = new SimpleActivatedAbility(
new DrawCardSourceControllerEffect(1), new ManaCostsImpl("{1}{B}")
);
ability.addCost(new PayLifeCost(2));
this.addAbility(ability);
}
public ErebosGodOfTheDead(final ErebosGodOfTheDead card) {
private ErebosGodOfTheDead(final ErebosGodOfTheDead card) {
super(card);
}

View file

@ -2,14 +2,11 @@ package mage.cards.e;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.SubType;
import mage.game.permanent.token.SoldierToken;
@ -20,8 +17,6 @@ import java.util.UUID;
*/
public final class EvangelOfHeliod extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.W);
public EvangelOfHeliod(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{W}{W}");
this.subtype.add(SubType.HUMAN);
@ -31,11 +26,12 @@ public final class EvangelOfHeliod extends CardImpl {
this.toughness = new MageInt(3);
// When Evangel of Heliod enters the battlefield, create a number of 1/1 white Soldier creature tokens equal to your devotion to white.
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new SoldierToken(), xValue))
.addHint(new ValueHint("Devotion to white", xValue)));
this.addAbility(new EntersBattlefieldTriggeredAbility(
new CreateTokenEffect(new SoldierToken(), DevotionCount.W)
).addHint(DevotionCount.W.getHint()));
}
public EvangelOfHeliod(final EvangelOfHeliod card) {
private EvangelOfHeliod(final EvangelOfHeliod card) {
super(card);
}

View file

@ -2,14 +2,14 @@ package mage.cards.f;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamagePlayersEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController;
import java.util.UUID;
@ -18,8 +18,6 @@ import java.util.UUID;
*/
public final class FanaticOfMogis extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.R);
public FanaticOfMogis(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}");
this.subtype.add(SubType.MINOTAUR);
@ -29,12 +27,13 @@ public final class FanaticOfMogis extends CardImpl {
this.toughness = new MageInt(2);
// When Fanatic of Mogis enters the battlefield, it deals damage to each opponent equal to your devotion to red.
Effect effect = new DamagePlayersEffect(Outcome.Damage, xValue, TargetController.OPPONENT);
effect.setText("it deals damage to each opponent equal to your devotion to red. (Each {R} in the mana costs of permanents you control counts towards your devotion to red.)");
this.addAbility(new EntersBattlefieldTriggeredAbility(effect, false).addHint(new ValueHint("Devotion to red", xValue)));
this.addAbility(new EntersBattlefieldTriggeredAbility(
new DamagePlayersEffect(Outcome.Damage, DevotionCount.R, TargetController.OPPONENT)
.setText("it deals damage to each opponent equal to your devotion to red."), false
).addHint(DevotionCount.R.getHint()));
}
public FanaticOfMogis(final FanaticOfMogis card) {
private FanaticOfMogis(final FanaticOfMogis card) {
super(card);
}

View file

@ -3,19 +3,17 @@ package mage.cards.g;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.players.Player;
import java.util.Objects;
import java.util.UUID;
/**
@ -32,12 +30,11 @@ public final class GrayMerchantOfAsphodel extends CardImpl {
// When Gray Merchant of Asphodel enters the battlefield, each opponent loses X life, where X is your devotion to black. You gain life equal to the life lost this way.
this.addAbility(new EntersBattlefieldTriggeredAbility(
new GrayMerchantOfAsphodelEffect(),
false)
.addHint(new ValueHint("Devotion to black", GrayMerchantOfAsphodelEffect.xValue)));
new GrayMerchantOfAsphodelEffect(), false
).addHint(DevotionCount.B.getHint()));
}
public GrayMerchantOfAsphodel(final GrayMerchantOfAsphodel card) {
private GrayMerchantOfAsphodel(final GrayMerchantOfAsphodel card) {
super(card);
}
@ -49,9 +46,7 @@ public final class GrayMerchantOfAsphodel extends CardImpl {
class GrayMerchantOfAsphodelEffect extends OneShotEffect {
static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.B);
public GrayMerchantOfAsphodelEffect() {
GrayMerchantOfAsphodelEffect() {
super(Outcome.GainLife);
this.staticText = "each opponent loses X life, where X is your devotion to black. "
+ "You gain life equal to the life lost this way. "
@ -59,7 +54,7 @@ class GrayMerchantOfAsphodelEffect extends OneShotEffect {
+ "counts towards your devotion to black.)</i>";
}
public GrayMerchantOfAsphodelEffect(final GrayMerchantOfAsphodelEffect effect) {
private GrayMerchantOfAsphodelEffect(final GrayMerchantOfAsphodelEffect effect) {
super(effect);
}
@ -71,20 +66,20 @@ class GrayMerchantOfAsphodelEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int totalLifeLost = 0;
int lifeLost = xValue.calculate(game, source, this);
if (lifeLost > 0) {
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(playerId);
if (opponent != null) {
totalLifeLost += opponent.loseLife(lifeLost, game, false);
}
}
}
controller.gainLife(totalLifeLost, game, source);
if (controller == null) {
return false;
}
int lifeLost = DevotionCount.B.calculate(game, source, this);
if (lifeLost == 0) {
return true;
}
return false;
int totalLifeLost = game
.getOpponents(source.getControllerId())
.stream()
.map(game::getPlayer)
.filter(Objects::nonNull)
.mapToInt(opponent -> opponent.loseLife(lifeLost, game, false))
.sum();
return controller.gainLife(totalLifeLost, game, source) > 0;
}
}

View file

@ -4,18 +4,18 @@ import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.StaticFilters;
import mage.game.permanent.token.HeliodGodOfTheSunToken;
@ -26,8 +26,6 @@ import java.util.UUID;
*/
public final class HeliodGodOfTheSun extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.W);
public HeliodGodOfTheSun(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{3}{W}");
addSuperType(SuperType.LEGENDARY);
@ -40,19 +38,23 @@ public final class HeliodGodOfTheSun extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to white is less than five, Heliod isn't a creature.<i>(Each {W} in the mana costs of permanents you control counts towards your devotion to white.)</i>
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 5);
effect.setText("As long as your devotion to white is less than five, Heliod isn't a creature.<i>(Each {W} in the mana costs of permanents you control counts towards your devotion to white.)</i>");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to white", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.W, 5))
.addHint(DevotionCount.W.getHint()));
// Other creatures you control have vigilance.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(VigilanceAbility.getInstance(), Duration.WhileOnBattlefield, StaticFilters.FILTER_PERMANENT_CREATURE, true)));
this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect(
VigilanceAbility.getInstance(), Duration.WhileOnBattlefield,
StaticFilters.FILTER_PERMANENT_CREATURE, true
)));
// {2}{W}{W}: Create a 2/1 white Cleric enchantment creature token.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new HeliodGodOfTheSunToken()), new ManaCostsImpl("{2}{W}{W}")));
this.addAbility(new SimpleActivatedAbility(
new CreateTokenEffect(new HeliodGodOfTheSunToken()), new ManaCostsImpl("{2}{W}{W}")
));
}
public HeliodGodOfTheSun(final HeliodGodOfTheSun card) {
private HeliodGodOfTheSun(final HeliodGodOfTheSun card) {
super(card);
}

View file

@ -2,18 +2,16 @@ package mage.cards.i;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.PreventAllDamageToAllEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.abilities.keyword.MenaceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.AttackingPredicate;
@ -26,16 +24,16 @@ import java.util.UUID;
*/
public final class IroasGodOfVictory extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Creatures you control");
private static final FilterControlledCreaturePermanent filterAttacking = new FilterControlledCreaturePermanent("attacking creatures you control");
private static final FilterPermanent filter
= new FilterCreaturePermanent("Creatures you control");
private static final FilterPermanent filterAttacking
= new FilterControlledCreaturePermanent("attacking creatures you control");
static {
filter.add(new ControllerPredicate(TargetController.YOU));
filterAttacking.add(AttackingPredicate.instance);
}
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.R, ColoredManaSymbol.W);
public IroasGodOfVictory(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{2}{R}{W}");
addSuperType(SuperType.LEGENDARY);
@ -48,18 +46,21 @@ public final class IroasGodOfVictory extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to red and white is less than seven, Iroas isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 7);
effect.setText("As long as your devotion to red and white is less than seven, Iroas isn't a creature");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to red and white", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.RW, 7))
.addHint(DevotionCount.RW.getHint()));
// Creatures you control have menace. (They can't be blocked except by two or more creatures.)
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(new MenaceAbility(), Duration.WhileOnBattlefield, filter)));
this.addAbility(new SimpleStaticAbility(
new GainAbilityAllEffect(new MenaceAbility(), Duration.WhileOnBattlefield, filter)
));
// Prevent all damage that would be dealt to attacking creatures you control.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventAllDamageToAllEffect(Duration.WhileOnBattlefield, filterAttacking)));
this.addAbility(new SimpleStaticAbility(
new PreventAllDamageToAllEffect(Duration.WhileOnBattlefield, filterAttacking)
));
}
public IroasGodOfVictory(final IroasGodOfVictory card) {
private IroasGodOfVictory(final IroasGodOfVictory card) {
super(card);
}

View file

@ -3,16 +3,15 @@ package mage.cards.k;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.filter.predicate.Predicates;
@ -31,11 +30,10 @@ public final class KarametraGodOfHarvests extends CardImpl {
static {
filter.add(Predicates.or(
new SubtypePredicate(SubType.FOREST),
new SubtypePredicate(SubType.PLAINS)));
new SubtypePredicate(SubType.PLAINS)
));
}
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.G, ColoredManaSymbol.W);
public KarametraGodOfHarvests(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{3}{G}{W}");
addSuperType(SuperType.LEGENDARY);
@ -48,16 +46,17 @@ public final class KarametraGodOfHarvests extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to green and white is less than seven, Karametra isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 7);
effect.setText("As long as your devotion to green and white is less than seven, Karametra isn't a creature");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to green and white", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.GW, 7))
.addHint(DevotionCount.GW.getHint()));
// Whenever you cast a creature spell, you may search your library for a Forest or Plains card, put it onto the battlefield tapped, then shuffle your library.
this.addAbility(new SpellCastControllerTriggeredAbility(
new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), true), StaticFilters.FILTER_SPELL_A_CREATURE, true));
new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), true),
StaticFilters.FILTER_SPELL_A_CREATURE, true
));
}
public KarametraGodOfHarvests(final KarametraGodOfHarvests card) {
private KarametraGodOfHarvests(final KarametraGodOfHarvests card) {
super(card);
}

View file

@ -2,14 +2,11 @@ package mage.cards.k;
import mage.MageInt;
import mage.Mana;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.hint.ValueHint;
import mage.abilities.mana.DynamicManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.SubType;
import java.util.UUID;
@ -19,8 +16,6 @@ import java.util.UUID;
*/
public final class KarametrasAcolyte extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.G);
public KarametrasAcolyte(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}");
this.subtype.add(SubType.HUMAN);
@ -30,12 +25,13 @@ public final class KarametrasAcolyte extends CardImpl {
this.toughness = new MageInt(4);
// {T}: Add an amount of {G} equal to your devotion to green.
this.addAbility(new DynamicManaAbility(Mana.GreenMana(1), xValue,
"Add an amount of {G} equal to your devotion to green. (Each {G} in the mana costs of permanents you control counts towards your devotion to green.)")
.addHint(new ValueHint("Devotion to green", xValue)));
this.addAbility(new DynamicManaAbility(
Mana.GreenMana(1), DevotionCount.G, "Add an amount of {G} equal to your devotion to green. " +
"(Each {G} in the mana costs of permanents you control counts towards your devotion to green.)"
).addHint(DevotionCount.G.getHint()));
}
public KarametrasAcolyte(final KarametrasAcolyte card) {
private KarametrasAcolyte(final KarametrasAcolyte card) {
super(card);
}

View file

@ -3,20 +3,20 @@ package mage.cards.k;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
@ -32,8 +32,6 @@ import java.util.UUID;
*/
public final class KeranosGodOfStorms extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.U, ColoredManaSymbol.R);
public KeranosGodOfStorms(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{3}{U}{R}");
addSuperType(SuperType.LEGENDARY);
@ -46,19 +44,16 @@ public final class KeranosGodOfStorms extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to blue and red is less than seven, Keranos isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 7);
effect.setText("As long as your devotion to blue and red is less than seven, Keranos isn't a creature");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to blue and red", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.UR, 7))
.addHint(DevotionCount.UR.getHint()));
// Reveal the first card you draw on each of your turns.
// Whenever you reveal a land card this way, draw a card.
// Whenever you reveal a nonland card this way, Keranos deals 3 damage to any target.
this.addAbility(new KeranosGodOfStormsTriggeredAbility(), new CardsAmountDrawnThisTurnWatcher());
}
public KeranosGodOfStorms(final KeranosGodOfStorms card) {
private KeranosGodOfStorms(final KeranosGodOfStorms card) {
super(card);
}
@ -74,7 +69,7 @@ class KeranosGodOfStormsTriggeredAbility extends TriggeredAbilityImpl {
super(Zone.BATTLEFIELD, new InfoEffect(""), false);
}
KeranosGodOfStormsTriggeredAbility(final KeranosGodOfStormsTriggeredAbility ability) {
private KeranosGodOfStormsTriggeredAbility(final KeranosGodOfStormsTriggeredAbility ability) {
super(ability);
}
@ -90,36 +85,38 @@ class KeranosGodOfStormsTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(this.getControllerId())) {
if (game.isActivePlayer(this.getControllerId())) {
CardsAmountDrawnThisTurnWatcher watcher =
game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) != 1) {
return false;
}
Card card = game.getCard(event.getTargetId());
Player controller = game.getPlayer(this.getControllerId());
Permanent sourcePermanent = (Permanent) getSourceObject(game);
if (card != null && controller != null && sourcePermanent != null) {
controller.revealCards(sourcePermanent.getIdName(), new CardsImpl(card), game);
this.getTargets().clear();
this.getEffects().clear();
if (card.isLand()) {
this.addEffect(new DrawCardSourceControllerEffect(1));
} else {
this.addEffect(new DamageTargetEffect(3));
this.addTarget(new TargetAnyTarget());
}
return true;
}
}
if (!event.getPlayerId().equals(this.getControllerId())) {
return false;
}
return false;
if (!game.isActivePlayer(this.getControllerId())) {
return false;
}
CardsAmountDrawnThisTurnWatcher watcher =
game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
if (watcher != null && watcher.getAmountCardsDrawn(event.getPlayerId()) != 1) {
return false;
}
Card card = game.getCard(event.getTargetId());
Player controller = game.getPlayer(this.getControllerId());
Permanent sourcePermanent = (Permanent) getSourceObject(game);
if (card == null || controller == null || sourcePermanent == null) {
return false;
}
controller.revealCards(sourcePermanent.getIdName(), new CardsImpl(card), game);
this.getTargets().clear();
this.getEffects().clear();
if (card.isLand()) {
this.addEffect(new DrawCardSourceControllerEffect(1));
} else {
this.addEffect(new DamageTargetEffect(3));
this.addTarget(new TargetAnyTarget());
}
return true;
}
@Override
public String getRule() {
return "Reveal the first card you draw on each of your turns. Whenever you reveal a land card this way, draw a card. " +
"Whenever you reveal a nonland card this way, Keranos deals 3 damage to any target.";
"Whenever you reveal a nonland card this way, {this} deals 3 damage to any target.";
}
}

View file

@ -5,12 +5,9 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfPreCombatMainTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -28,8 +25,6 @@ import java.util.UUID;
*/
public final class KlothysGodOfDestiny extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.R, ColoredManaSymbol.G);
public KlothysGodOfDestiny(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{1}{R}{G}");
@ -42,9 +37,8 @@ public final class KlothysGodOfDestiny extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to red and green is less than seven, Klothys isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 7);
effect.setText("As long as your devotion to red and green is less than seven, {this} isn't a creature");
this.addAbility(new SimpleStaticAbility(effect).addHint(new ValueHint("Devotion to red and green", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.RG, 7))
.addHint(DevotionCount.RG.getHint()));
// At the beginning of your precombat main phase, exile target card from a graveyard. If it was a land card, add {R} or {G}. Otherwise, you gain 2 life and Klothys deals 2 damage to each opponent.
Ability ability = new BeginningOfPreCombatMainTriggeredAbility(

View file

@ -1,13 +1,10 @@
package mage.cards.k;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Duration;
import mage.filter.StaticFilters;
@ -18,18 +15,15 @@ import java.util.UUID;
*/
public final class KlothyssDesign extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.G);
public KlothyssDesign(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{5}{G}");
// Creatures you control get +X/+X until end of turn, where X is your devotion to green.
this.getSpellAbility().addEffect(new BoostControlledEffect(
xValue, xValue, Duration.EndOfTurn,
StaticFilters.FILTER_PERMANENT_CREATURES,
false, true
DevotionCount.G, DevotionCount.G, Duration.EndOfTurn,
StaticFilters.FILTER_PERMANENT_CREATURES, false, true
));
this.getSpellAbility().addHint(new ValueHint("Devotion to green", xValue));
this.getSpellAbility().addHint(DevotionCount.G.getHint());
}
private KlothyssDesign(final KlothyssDesign card) {

View file

@ -3,13 +3,10 @@ package mage.cards.k;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -24,8 +21,6 @@ import java.util.UUID;
*/
public final class KruphixGodOfHorizons extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.G, ColoredManaSymbol.U);
public KruphixGodOfHorizons(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{3}{G}{U}");
addSuperType(SuperType.LEGENDARY);
@ -36,20 +31,22 @@ public final class KruphixGodOfHorizons extends CardImpl {
// Indestructible
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to green and blue is less than seven, Kruhpix isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 7);
effect.setText("As long as your devotion to green and blue is less than seven, Kruhpix isn't a creature");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to green and blue", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.GU, 7))
.addHint(DevotionCount.GU.getHint()));
// You have no maximum hand size.
effect = new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Duration.WhileOnBattlefield, MaximumHandSizeControllerEffect.HandSizeModification.SET);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(new MaximumHandSizeControllerEffect(
Integer.MAX_VALUE, Duration.WhileOnBattlefield,
MaximumHandSizeControllerEffect.HandSizeModification.SET
)));
// If unused mana would empty from your mana pool, that mana becomes colorless instead.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new KruphixGodOfHorizonsEffect()));
this.addAbility(new SimpleStaticAbility(new KruphixGodOfHorizonsEffect()));
}
public KruphixGodOfHorizons(final KruphixGodOfHorizons card) {
private KruphixGodOfHorizons(final KruphixGodOfHorizons card) {
super(card);
}
@ -61,12 +58,12 @@ public final class KruphixGodOfHorizons extends CardImpl {
class KruphixGodOfHorizonsEffect extends ReplacementEffectImpl {
public KruphixGodOfHorizonsEffect() {
KruphixGodOfHorizonsEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "If you would lose unspent mana, that mana becomes colorless instead.";
}
public KruphixGodOfHorizonsEffect(final KruphixGodOfHorizonsEffect effect) {
private KruphixGodOfHorizonsEffect(final KruphixGodOfHorizonsEffect effect) {
super(effect);
}

View file

@ -5,10 +5,8 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
@ -30,10 +28,10 @@ public final class MarshmistTitan extends CardImpl {
// Marshmist Titan costs {X} less to cast, where X is your devotion to black.
this.addAbility(new SimpleStaticAbility(Zone.STACK, new MarshmistTitanCostReductionEffect())
.addHint(new ValueHint("Devotion to black", MarshmistTitanCostReductionEffect.xValue)));
.addHint(DevotionCount.B.getHint()));
}
public MarshmistTitan(final MarshmistTitan card) {
private MarshmistTitan(final MarshmistTitan card) {
super(card);
}
@ -45,14 +43,13 @@ public final class MarshmistTitan extends CardImpl {
class MarshmistTitanCostReductionEffect extends CostModificationEffectImpl {
static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.B);
public MarshmistTitanCostReductionEffect() {
MarshmistTitanCostReductionEffect() {
super(Duration.Custom, Outcome.Benefit, CostModificationType.REDUCE_COST);
staticText = "{this} costs {X} less to cast, where X is your devotion to black <i>(Each {B} in the mana costs of permanents you control counts toward your devotion to black.)</i> ";
staticText = "This spell costs {X} less to cast, where X is your devotion to black. " +
"<i>(Each {B} in the mana costs of permanents you control counts toward your devotion to black.)</i> ";
}
public MarshmistTitanCostReductionEffect(final MarshmistTitanCostReductionEffect effect) {
private MarshmistTitanCostReductionEffect(final MarshmistTitanCostReductionEffect effect) {
super(effect);
}
@ -60,22 +57,19 @@ class MarshmistTitanCostReductionEffect extends CostModificationEffectImpl {
public boolean apply(Game game, Ability source, Ability abilityToModify) {
SpellAbility spellAbility = (SpellAbility) abilityToModify;
Mana mana = spellAbility.getManaCostsToPay().getMana();
if (mana.getGeneric() > 0) {
int count = xValue.calculate(game, source, this);
int newCount = mana.getGeneric() - count;
if (newCount < 0) {
newCount = 0;
}
mana.setGeneric(newCount);
spellAbility.getManaCostsToPay().load(mana.toString());
return true;
if (mana.getGeneric() == 0) {
return false;
}
return false;
int count = DevotionCount.B.calculate(game, source, this);
mana.setGeneric(Math.max(mana.getGeneric() - count, 0));
spellAbility.getManaCostsToPay().load(mana.toString());
return true;
}
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
return abilityToModify.getSourceId().equals(source.getSourceId()) && (abilityToModify instanceof SpellAbility);
return abilityToModify instanceof SpellAbility
&& abilityToModify.getSourceId().equals(source.getSourceId());
}
@Override

View file

@ -4,18 +4,17 @@ import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.permanent.token.MasterOfWavesElementalToken;
import java.util.UUID;
@ -25,13 +24,8 @@ import java.util.UUID;
*/
public final class MasterOfWaves extends CardImpl {
private static final FilterCreaturePermanent filterBoost = new FilterCreaturePermanent("Elemental creatures");
static {
filterBoost.add(new SubtypePredicate(SubType.ELEMENTAL));
}
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.U);
private static final FilterCreaturePermanent filterBoost
= new FilterCreaturePermanent(SubType.ELEMENTAL, "Elemental creatures");
public MasterOfWaves(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}");
@ -45,13 +39,15 @@ public final class MasterOfWaves extends CardImpl {
this.addAbility(ProtectionAbility.from(ObjectColor.RED));
// Elemental creatures you control get +1/+1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filterBoost, false)));
this.addAbility(new SimpleStaticAbility(new BoostControlledEffect(
1, 1, Duration.WhileOnBattlefield, filterBoost, false
)));
// When Master of Waves enters the battlefield, create a number of 1/0 blue Elemental creature tokens equal to your devotion to blue.
// <i>(Each {U} in the mana costs of permanents you control counts toward your devotion to blue.)</i>
Effect effect = new CreateTokenEffect(new MasterOfWavesElementalToken(), xValue);
Effect effect = new CreateTokenEffect(new MasterOfWavesElementalToken(), DevotionCount.U);
effect.setText("create a number of 1/0 blue Elemental creature tokens equal to your devotion to blue. <i>(Each {U} in the mana costs of permanents you control counts toward your devotion to blue.)</i>");
this.addAbility(new EntersBattlefieldTriggeredAbility(effect).addHint(new ValueHint("Devotion to blue", xValue)));
this.addAbility(new EntersBattlefieldTriggeredAbility(effect).addHint(DevotionCount.U.getHint()));
}
public MasterOfWaves(final MasterOfWaves card) {

View file

@ -1,41 +1,30 @@
package mage.cards.m;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.util.CardUtil;
import java.util.Locale;
import java.util.UUID;
import static mage.filter.StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT;
/**
* @author LevelX2
*/
public final class MogisGodOfSlaughter extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.B, ColoredManaSymbol.R);
public MogisGodOfSlaughter(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{2}{B}{R}");
addSuperType(SuperType.LEGENDARY);
@ -48,20 +37,18 @@ public final class MogisGodOfSlaughter extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to black and red is less than seven, Mogis isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 7);
effect.setText("As long as your devotion to black and red is less than seven, Mogis isn't a creature");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to black and red", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.BR, 7))
.addHint(DevotionCount.BR.getHint()));
// At the beginning of each opponent's upkeep, Mogis deals 2 damage to that player unless they sacrifice a creature.
effect = new DoUnlessTargetPaysCost(new DamageTargetEffect(2, true, "that player"),
new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT)),
"Sacrifice a creature? (otherwise you get 2 damage)");
effect.setText("Mogis deals 2 damage to that player unless they sacrifice a creature");
Ability ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.OPPONENT, false, true);
Ability ability = new BeginningOfUpkeepTriggeredAbility(
Zone.BATTLEFIELD, new MogisGodOfSlaughterEffect(),
TargetController.OPPONENT, false, true
);
this.addAbility(ability);
}
public MogisGodOfSlaughter(final MogisGodOfSlaughter card) {
private MogisGodOfSlaughter(final MogisGodOfSlaughter card) {
super(card);
}
@ -71,76 +58,35 @@ public final class MogisGodOfSlaughter extends CardImpl {
}
}
class DoUnlessTargetPaysCost extends OneShotEffect {
class MogisGodOfSlaughterEffect extends OneShotEffect {
private final OneShotEffect executingEffect;
private final Cost cost;
private final String userMessage;
public DoUnlessTargetPaysCost(OneShotEffect effect, Cost cost) {
this(effect, cost, null);
MogisGodOfSlaughterEffect() {
super(Outcome.Damage);
staticText = "{this} deals 2 damage to that player unless they sacrifice a creature";
}
public DoUnlessTargetPaysCost(OneShotEffect effect, Cost cost, String userMessage) {
super(Outcome.Benefit);
this.executingEffect = effect;
this.cost = cost;
this.userMessage = userMessage;
}
public DoUnlessTargetPaysCost(final DoUnlessTargetPaysCost effect) {
private MogisGodOfSlaughterEffect(final MogisGodOfSlaughterEffect effect) {
super(effect);
this.executingEffect = (OneShotEffect) effect.executingEffect.copy();
this.cost = effect.cost.copy();
this.userMessage = effect.userMessage;
}
@Override
public MogisGodOfSlaughterEffect copy() {
return new MogisGodOfSlaughterEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
MageObject mageObject = game.getObject(source.getSourceId());
if (player != null && mageObject != null) {
String message = userMessage;
if (message == null) {
message = getCostText() + " to prevent " + executingEffect.getText(source.getModes().getMode()) + '?';
}
message = CardUtil.replaceSourceName(message, mageObject.getLogName());
cost.clearPaid();
if (cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(executingEffect.getOutcome(), message, source, game)) {
cost.pay(source, game, source.getSourceId(), player.getId(), false, null);
}
if (!cost.isPaid()) {
executingEffect.setTargetPointer(this.targetPointer);
return executingEffect.apply(game, source);
}
return true;
Player player = game.getPlayer(game.getActivePlayerId());
if (player == null || game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, game.getActivePlayerId(), game) == 0) {
return false;
}
return false;
}
@Override
public String getText(Mode mode) {
if (!staticText.isEmpty()) {
return staticText;
TargetPermanent target = new TargetControlledCreaturePermanent(1);
target.setNotTarget(true);
if (!player.chooseUse(outcome, "Sacrifice a creature to prevent 2 damage?", source, game)
|| !player.choose(outcome, target, source.getSourceId(), game)) {
return player.damage(2, source.getSourceId(), game) > 0;
}
return executingEffect.getText(mode) + "unless they" +
getCostText();
Permanent permanent = game.getPermanent(target.getFirstTarget());
return permanent != null && permanent.sacrifice(source.getSourceId(), game);
}
private String getCostText() {
StringBuilder sb = new StringBuilder();
String costText = cost.getText();
if (costText != null
&& !costText.toLowerCase(Locale.ENGLISH).startsWith("discard")
&& !costText.toLowerCase(Locale.ENGLISH).startsWith("sacrifice")
&& !costText.toLowerCase(Locale.ENGLISH).startsWith("remove")) {
sb.append("pay ");
}
return sb.append(costText).toString();
}
@Override
public DoUnlessTargetPaysCost copy() {
return new DoUnlessTargetPaysCost(this);
}
}
}

View file

@ -3,16 +3,13 @@ package mage.cards.m;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.HasteAbility;
import mage.abilities.keyword.IntimidateAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.game.Game;
@ -36,16 +33,21 @@ public final class MogissMarauder extends CardImpl {
// When Mogis's Marauder enters the battlefield, up to X target creatures each gain intimidate and haste, where X is your devotion to black.
Ability ability = new EntersBattlefieldTriggeredAbility(
new GainAbilityTargetEffect(IntimidateAbility.getInstance(), Duration.EndOfTurn,
"up to X target creatures each gain intimidate"), false);
ability.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn,
"and haste until end of turn, where X is your devotion to black"));
new GainAbilityTargetEffect(
IntimidateAbility.getInstance(), Duration.EndOfTurn,
"up to X target creatures each gain intimidate"
), false
);
ability.addEffect(new GainAbilityTargetEffect(
HasteAbility.getInstance(), Duration.EndOfTurn,
"and haste until end of turn, where X is your devotion to black"
));
ability.setTargetAdjuster(MogissMarauderAdjuster.instance);
ability.addHint(new ValueHint("Devotion to black", MogissMarauderAdjuster.xValue));
ability.addHint(DevotionCount.B.getHint());
this.addAbility(ability);
}
public MogissMarauder(final MogissMarauder card) {
private MogissMarauder(final MogissMarauder card) {
super(card);
}
@ -56,15 +58,12 @@ public final class MogissMarauder extends CardImpl {
}
enum MogissMarauderAdjuster implements TargetAdjuster {
instance;
static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.B);
@Override
public void adjustTargets(Ability ability, Game game) {
ability.getTargets().clear();
int numbTargets = xValue.calculate(game, ability, null);
int numbTargets = DevotionCount.B.calculate(game, ability, null);
if (numbTargets > 0) {
ability.addTarget(new TargetCreaturePermanent(0, numbTargets));
}

View file

@ -4,17 +4,14 @@ import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.common.ManaEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.game.Game;
@ -23,6 +20,7 @@ import mage.players.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* @author LevelX2
@ -35,17 +33,12 @@ public final class NykthosShrineToNyx extends CardImpl {
// {T}: Add {C}.
this.addAbility(new ColorlessManaAbility());
// {2}, {T}: Choose a color. Add an amount of mana of that color equal to your devotion to that color.
Ability ability = new NykthosShrineToNyxManaAbility();
ability.addHint(new ValueHint("Devotion to red", NykthosDynamicManaEffect.xValueR));
ability.addHint(new ValueHint("Devotion to blue", NykthosDynamicManaEffect.xValueU));
ability.addHint(new ValueHint("Devotion to white", NykthosDynamicManaEffect.xValueW));
ability.addHint(new ValueHint("Devotion to black", NykthosDynamicManaEffect.xValueB));
ability.addHint(new ValueHint("Devotion to green", NykthosDynamicManaEffect.xValueG));
this.addAbility(ability);
this.addAbility(new NykthosShrineToNyxManaAbility());
}
public NykthosShrineToNyx(final NykthosShrineToNyx card) {
private NykthosShrineToNyx(final NykthosShrineToNyx card) {
super(card);
}
@ -57,12 +50,17 @@ public final class NykthosShrineToNyx extends CardImpl {
class NykthosShrineToNyxManaAbility extends ActivatedManaAbilityImpl {
public NykthosShrineToNyxManaAbility() {
NykthosShrineToNyxManaAbility() {
super(Zone.BATTLEFIELD, new NykthosDynamicManaEffect(), new GenericManaCost(2));
this.addCost(new TapSourceCost());
this.addHint(DevotionCount.W.getHint());
this.addHint(DevotionCount.U.getHint());
this.addHint(DevotionCount.B.getHint());
this.addHint(DevotionCount.R.getHint());
this.addHint(DevotionCount.G.getHint());
}
public NykthosShrineToNyxManaAbility(final NykthosShrineToNyxManaAbility ability) {
private NykthosShrineToNyxManaAbility(final NykthosShrineToNyxManaAbility ability) {
super(ability);
}
@ -74,27 +72,22 @@ class NykthosShrineToNyxManaAbility extends ActivatedManaAbilityImpl {
@Override
public List<Mana> getNetMana(Game game) {
ArrayList<Mana> netManaCopy = new ArrayList<>();
if (game != null) {
netManaCopy.addAll(((ManaEffect) this.getEffects().get(0)).getNetMana(game, this));
if (game == null) {
return netManaCopy;
}
netManaCopy.addAll(((ManaEffect) this.getEffects().get(0)).getNetMana(game, this));
return netManaCopy;
}
}
class NykthosDynamicManaEffect extends ManaEffect {
static final DynamicValue xValueR = new DevotionCount(ColoredManaSymbol.R);
static final DynamicValue xValueU = new DevotionCount(ColoredManaSymbol.U);
static final DynamicValue xValueW = new DevotionCount(ColoredManaSymbol.W);
static final DynamicValue xValueB = new DevotionCount(ColoredManaSymbol.B);
static final DynamicValue xValueG = new DevotionCount(ColoredManaSymbol.G);
public NykthosDynamicManaEffect() {
NykthosDynamicManaEffect() {
super();
this.staticText = "Choose a color. Add an amount of mana of that color equal to your devotion to that color. <i>(Your devotion to a color is the number of mana symbols of that color in the mana costs of permanents you control.)</i>";
}
public NykthosDynamicManaEffect(final NykthosDynamicManaEffect effect) {
private NykthosDynamicManaEffect(final NykthosDynamicManaEffect effect) {
super(effect);
}
@ -106,60 +99,59 @@ class NykthosDynamicManaEffect extends ManaEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
checkToFirePossibleEvents(getMana(game, source), game, source);
controller.getManaPool().addMana(getMana(game, source), game, source);
return true;
if (controller == null) {
return false;
}
return false;
checkToFirePossibleEvents(getMana(game, source), game, source);
controller.getManaPool().addMana(getMana(game, source), game, source);
return true;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
List<Mana> netMana = new ArrayList<>();
for (String colorChoice : ChoiceColor.getBaseColors()) {
Mana mana = computeMana(colorChoice, game, source);
if (mana.count() > 0) {
netMana.add(mana);
}
}
return netMana;
return ChoiceColor.getBaseColors()
.stream()
.map(s -> computeMana(s, game, source))
.filter(mana -> mana.count() > 0)
.collect(Collectors.toList());
}
@Override
public Mana produceMana(boolean netMana, Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ChoiceColor choice = new ChoiceColor();
choice.setMessage("Choose a color for devotion of Nykthos");
if (controller.choose(outcome, choice, game)) {
return computeMana(choice.getChoice(), game, source);
}
if (controller == null) {
return null;
}
return null;
ChoiceColor choice = new ChoiceColor();
choice.setMessage("Choose a color for devotion of Nykthos");
if (!controller.choose(outcome, choice, game)) {
return null;
}
return computeMana(choice.getChoice(), game, source);
}
public Mana computeMana(String color, Game game, Ability source) {
private Mana computeMana(String color, Game game, Ability source) {
Mana mana = new Mana();
if (color != null && !color.isEmpty()) {
switch (color) {
case "Red":
mana.setRed(xValueR.calculate(game, source, this));
break;
case "Blue":
mana.setBlue(xValueU.calculate(game, source, this));
break;
case "White":
mana.setWhite(xValueW.calculate(game, source, this));
break;
case "Black":
mana.setBlack(xValueB.calculate(game, source, this));
break;
case "Green":
mana.setGreen(xValueG.calculate(game, source, this));
break;
}
if (color == null || color.isEmpty()) {
return mana;
}
switch (color) {
case "White":
mana.setWhite(DevotionCount.W.calculate(game, source, this));
break;
case "Blue":
mana.setBlue(DevotionCount.U.calculate(game, source, this));
break;
case "Black":
mana.setBlack(DevotionCount.B.calculate(game, source, this));
break;
case "Red":
mana.setRed(DevotionCount.R.calculate(game, source, this));
break;
case "Green":
mana.setGreen(DevotionCount.G.calculate(game, source, this));
break;
}
return mana;
}

View file

@ -5,18 +5,18 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.StaticFilters;
import mage.target.common.TargetCreaturePermanent;
@ -27,8 +27,6 @@ import java.util.UUID;
*/
public final class NyleaGodOfTheHunt extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.G);
public NyleaGodOfTheHunt(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{3}{G}");
addSuperType(SuperType.LEGENDARY);
@ -40,22 +38,26 @@ public final class NyleaGodOfTheHunt extends CardImpl {
// Indestructible
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to white is less than five, Nylea isn't a creature.<i>(Each {G} in the mana costs of permanents you control counts towards your devotion to green.)</i>
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 5);
effect.setText("As long as your devotion to green is less than five, Nylea isn't a creature.<i>(Each {G} in the mana costs of permanents you control counts towards your devotion to green.)</i>");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to green", xValue)));
// As long as your devotion to green is less than five, Nylea isn't a creature.<i>(Each {G} in the mana costs of permanents you control counts towards your devotion to green.)</i>
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.G, 5))
.addHint(DevotionCount.G.getHint()));
// Other creatures you control have trample.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(TrampleAbility.getInstance(), Duration.WhileOnBattlefield, StaticFilters.FILTER_PERMANENT_CREATURE, true)));
this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect(
TrampleAbility.getInstance(), Duration.WhileOnBattlefield,
StaticFilters.FILTER_PERMANENT_CREATURE, true
)));
// {3}{G}: Target creature gets +2/+2 until end of turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostTargetEffect(2, 2, Duration.EndOfTurn), new ManaCostsImpl("{3}{G}"));
Ability ability = new SimpleActivatedAbility(
new BoostTargetEffect(2, 2, Duration.EndOfTurn), new ManaCostsImpl("{3}{G}")
);
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}
public NyleaGodOfTheHunt(final NyleaGodOfTheHunt card) {
private NyleaGodOfTheHunt(final NyleaGodOfTheHunt card) {
super(card);
}

View file

@ -2,15 +2,11 @@ package mage.cards.n;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.SubType;
import java.util.UUID;
@ -20,8 +16,6 @@ import java.util.UUID;
*/
public final class NyleasDisciple extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.G);
public NyleasDisciple(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{G}");
this.subtype.add(SubType.CENTAUR);
@ -31,12 +25,12 @@ public final class NyleasDisciple extends CardImpl {
this.toughness = new MageInt(3);
// When Nylea's Disciple enters the battlefield, you gain life equal to your devotion to green.
Effect effect = new GainLifeEffect(xValue);
effect.setText("you gain life equal to your devotion to green");
this.addAbility(new EntersBattlefieldTriggeredAbility(effect).addHint(new ValueHint("Devotion to green", xValue)));
this.addAbility(new EntersBattlefieldTriggeredAbility(
new GainLifeEffect(DevotionCount.G).setText("you gain life equal to your devotion to green")
).addHint(DevotionCount.G.getHint()));
}
public NyleasDisciple(final NyleasDisciple card) {
private NyleasDisciple(final NyleasDisciple card) {
super(card);
}

View file

@ -5,12 +5,9 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -20,7 +17,6 @@ import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.game.permanent.token.PharikaSnakeToken;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCardInGraveyard;
import java.util.UUID;
@ -30,7 +26,7 @@ import java.util.UUID;
*/
public final class PharikaGodOfAffliction extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.B, ColoredManaSymbol.G);
private static final FilterCreatureCard filter = new FilterCreatureCard("a creature card from a graveyard");
public PharikaGodOfAffliction(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{1}{B}{G}");
@ -44,14 +40,12 @@ public final class PharikaGodOfAffliction extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to black and green is less than seven, Pharika isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 7);
effect.setText("As long as your devotion to black and green is less than seven, Pharika isn't a creature");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to black and green", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.BG, 7))
.addHint(DevotionCount.BG.getHint()));
// {B}{G}: Exile target creature card from a graveyard. It's owner creates a 1/1 black and green Snake enchantment creature token with deathtouch.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PharikaExileEffect(), new ManaCostsImpl("{B}{G}"));
Target target = new TargetCardInGraveyard(new FilterCreatureCard("a creature card from a graveyard"));
ability.addTarget(target);
Ability ability = new SimpleActivatedAbility(new PharikaExileEffect(), new ManaCostsImpl("{B}{G}"));
ability.addTarget(new TargetCardInGraveyard(filter));
this.addAbility(ability);
}
@ -68,31 +62,33 @@ public final class PharikaGodOfAffliction extends CardImpl {
class PharikaExileEffect extends OneShotEffect {
public PharikaExileEffect() {
PharikaExileEffect() {
super(Outcome.PutCreatureInPlay);
staticText = "Exile target creature card from a graveyard. Its owner creates a 1/1 black and green Snake enchantment creature token with deathtouch";
}
public PharikaExileEffect(final PharikaExileEffect effect) {
private PharikaExileEffect(final PharikaExileEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card targetCard = game.getCard(source.getFirstTarget());
if (targetCard != null) {
if (game.getState().getZone(source.getFirstTarget()) == Zone.GRAVEYARD) {
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true);
}
Player tokenController = game.getPlayer(targetCard.getOwnerId());
if (tokenController != null) {
return new PharikaSnakeToken().putOntoBattlefield(1, game, source.getSourceId(), tokenController.getId());
}
}
if (controller == null) {
return false;
}
return false;
Card targetCard = game.getCard(source.getFirstTarget());
if (targetCard == null) {
return false;
}
if (game.getState().getZone(source.getFirstTarget()) == Zone.GRAVEYARD) {
controller.moveCards(targetCard, Zone.EXILED, source, game);
}
Player tokenController = game.getPlayer(targetCard.getOwnerId());
if (tokenController == null) {
return false;
}
return new PharikaSnakeToken().putOntoBattlefield(1, game, source.getSourceId(), tokenController.getId());
}
@Override

View file

@ -5,18 +5,18 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.dynamicvalue.common.SourcePermanentToughnessValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.PutTopCardOfLibraryIntoGraveTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.StaticFilters;
import mage.target.TargetPlayer;
@ -27,8 +27,6 @@ import java.util.UUID;
*/
public final class PhenaxGodOfDeception extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.U, ColoredManaSymbol.B);
public PhenaxGodOfDeception(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{3}{U}{B}");
addSuperType(SuperType.LEGENDARY);
@ -41,21 +39,24 @@ public final class PhenaxGodOfDeception extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to blue and black is less than seven, Phenax isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 7);
effect.setText("As long as your devotion to blue and black is less than seven, Phenax isn't a creature");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to blue and black", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.UB, 7))
.addHint(DevotionCount.UB.getHint()));
// Creatures you control have "{T}: Target player puts the top X cards of their library into their graveyard, where X is this creature's toughness."
effect = new PutTopCardOfLibraryIntoGraveTargetEffect(SourcePermanentToughnessValue.getInstance());
effect.setText("Target player puts the top X cards of their library into their graveyard, where X is this creature's toughness");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new TapSourceCost());
Ability ability = new SimpleActivatedAbility(
new PutTopCardOfLibraryIntoGraveTargetEffect(SourcePermanentToughnessValue.getInstance())
.setText("Target player puts the top X cards of their library into their graveyard, " +
"where X is this creature's toughness"), new TapSourceCost());
ability.addTarget(new TargetPlayer());
effect = new GainAbilityControlledEffect(ability, Duration.WhileOnBattlefield, StaticFilters.FILTER_PERMANENT_CREATURES, false);
effect.setText("Creatures you control have \"{T}: Target player puts the top X cards of their library into their graveyard, where X is this creature's toughness.\"");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(
new GainAbilityControlledEffect(
ability, Duration.WhileOnBattlefield, StaticFilters.FILTER_PERMANENT_CREATURES, false
).setText("Creatures you control have \"{T}: Target player puts the top X cards of their library " +
"into their graveyard, where X is this creature's toughness.\"")
));
}
public PhenaxGodOfDeception(final PhenaxGodOfDeception card) {
private PhenaxGodOfDeception(final PhenaxGodOfDeception card) {
super(card);
}

View file

@ -5,17 +5,15 @@ import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamagePlayersEffect;
import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
@ -26,14 +24,12 @@ import java.util.UUID;
*/
public final class PurphorosGodOfTheForge extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature");
private static final FilterPermanent filter = new FilterCreaturePermanent("another creature");
static {
filter.add(AnotherPredicate.instance);
}
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.R);
public PurphorosGodOfTheForge(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{3}{R}");
@ -47,18 +43,21 @@ public final class PurphorosGodOfTheForge extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to red is less than five, Purphoros isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 5);
effect.setText("As long as your devotion to red is less than five, Purphoros isn't a creature.<i>(Each {R} in the mana costs of permanents you control counts towards your devotion to red.)</i>");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to red", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.R, 5))
.addHint(DevotionCount.R.getHint()));
// Whenever another creature enters the battlefield under your control, Purphoros deals 2 damage to each opponent.
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(new DamagePlayersEffect(2, TargetController.OPPONENT), filter));
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(
new DamagePlayersEffect(2, TargetController.OPPONENT), filter
));
// {2}{R}: Creatures you control get +1/+0 until end of turn.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl("{2}{R}")));
this.addAbility(new SimpleActivatedAbility(
new BoostControlledEffect(1, 0, Duration.EndOfTurn), new ManaCostsImpl("{2}{R}")
));
}
public PurphorosGodOfTheForge(final PurphorosGodOfTheForge card) {
private PurphorosGodOfTheForge(final PurphorosGodOfTheForge card) {
super(card);
}

View file

@ -2,14 +2,11 @@ package mage.cards.r;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.SubType;
import mage.counters.CounterType;
@ -20,8 +17,6 @@ import java.util.UUID;
*/
public final class ReverentHunter extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.G);
public ReverentHunter(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}");
this.subtype.add(SubType.HUMAN);
@ -31,14 +26,12 @@ public final class ReverentHunter extends CardImpl {
this.toughness = new MageInt(1);
// When Reverent Hunter enters the battlefield, put a number of +1/+1 counters on it equal to your devotion to green.
this.addAbility(
new EntersBattlefieldTriggeredAbility(
new AddCountersSourceEffect(CounterType.P1P1.createInstance(0), xValue, true)
).addHint(new ValueHint("Devotion to green", xValue))
);
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(
CounterType.P1P1.createInstance(0), DevotionCount.G, true
)).addHint(DevotionCount.G.getHint()));
}
public ReverentHunter(final ReverentHunter card) {
private ReverentHunter(final ReverentHunter card) {
super(card);
}

View file

@ -1,15 +1,12 @@
package mage.cards.s;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import java.util.UUID;
@ -18,19 +15,17 @@ import java.util.UUID;
*/
public final class Sanguimancy extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.B);
public Sanguimancy(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{B}");
// You draw X cards and you lose X life, where X is your devotion to black.
Effect effect = new DrawCardSourceControllerEffect(xValue);
Effect effect = new DrawCardSourceControllerEffect(DevotionCount.B);
effect.setText("You draw X cards");
this.getSpellAbility().addEffect(effect);
effect = new LoseLifeSourceControllerEffect(xValue);
effect = new LoseLifeSourceControllerEffect(DevotionCount.B);
effect.setText("and you lose X life, where X is your devotion to black");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addHint(new ValueHint("Devotion to black", xValue));
this.getSpellAbility().addHint(DevotionCount.B.getHint());
}
public Sanguimancy(final Sanguimancy card) {

View file

@ -1,15 +1,12 @@
package mage.cards.s;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageAllEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AbilityPredicate;
@ -26,17 +23,14 @@ public final class Skyreaping extends CardImpl {
filter.add(new AbilityPredicate(FlyingAbility.class));
}
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.G);
public Skyreaping(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{G}");
// Skyreaping deals damage to each creature with flying equal to your devotion to green.
Effect effect = new DamageAllEffect(xValue, filter);
Effect effect = new DamageAllEffect(DevotionCount.G, filter);
effect.setText("{this} deals damage to each creature with flying equal to your devotion to green <i>(Each {G} in the mana costs of permanents you control counts toward your devotion to green.)</i>");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addHint(new ValueHint("Devotion to green", xValue));
this.getSpellAbility().addHint(DevotionCount.G.getHint());
}
public Skyreaping(final Skyreaping card) {

View file

@ -6,13 +6,10 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.combat.CantBeBlockedTargetEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.effects.keyword.ScryEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -27,8 +24,6 @@ import java.util.UUID;
public final class ThassaGodOfTheSea extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.U);
public ThassaGodOfTheSea(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{2}{U}");
addSuperType(SuperType.LEGENDARY);
@ -40,21 +35,24 @@ public final class ThassaGodOfTheSea extends CardImpl {
// Indestructible
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to white is less than five, Thassa isn't a creature.<i>(Each {U} in the mana costs of permanents you control counts towards your devotion to white.)</i>
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 5);
effect.setText("As long as your devotion to blue is less than five, Thassa isn't a creature.<i>(Each {U} in the mana costs of permanents you control counts towards your devotion to blue.)</i>");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to blue", xValue)));
// As long as your devotion to blue is less than five, Thassa isn't a creature.<i>(Each {U} in the mana costs of permanents you control counts towards your devotion to white.)</i>
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.U, 5))
.addHint(DevotionCount.U.getHint()));
// At the beginning of your upkeep, scry 1.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new ScryEffect(1), TargetController.YOU, false));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
new ScryEffect(1), TargetController.YOU, false
));
// {1}{U}: Target creature you control can't be blocked this turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CantBeBlockedTargetEffect(Duration.EndOfTurn), new ManaCostsImpl("{1}{U}"));
Ability ability = new SimpleActivatedAbility(
new CantBeBlockedTargetEffect(Duration.EndOfTurn), new ManaCostsImpl("{1}{U}")
);
ability.addTarget(new TargetControlledCreaturePermanent());
this.addAbility(ability);
}
public ThassaGodOfTheSea(final ThassaGodOfTheSea card) {
private ThassaGodOfTheSea(final ThassaGodOfTheSea card) {
super(card);
}

View file

@ -1,13 +1,10 @@
package mage.cards.t;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.common.CounterUnlessPaysEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.target.TargetSpell;
import java.util.UUID;
@ -17,18 +14,16 @@ import java.util.UUID;
*/
public final class ThassasRebuff extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.U);
public ThassasRebuff(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// Counter target spell unless its controller pays {X}, where X is your devotion to blue.
this.getSpellAbility().addEffect(new CounterUnlessPaysEffect(xValue));
this.getSpellAbility().addEffect(new CounterUnlessPaysEffect(DevotionCount.U));
this.getSpellAbility().addTarget(new TargetSpell());
this.getSpellAbility().addHint(new ValueHint("Devotion to blue", xValue));
this.getSpellAbility().addHint(DevotionCount.U.getHint());
}
public ThassasRebuff(final ThassasRebuff card) {
private ThassasRebuff(final ThassasRebuff card) {
super(card);
}

View file

@ -2,12 +2,10 @@ package mage.cards.t;
import mage.abilities.Ability;
import mage.abilities.common.AttacksAttachedTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -22,8 +20,6 @@ import java.util.UUID;
*/
public final class ThunderousMight extends CardImpl {
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.R);
public ThunderousMight(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}");
this.subtype.add(SubType.AURA);
@ -36,14 +32,14 @@ public final class ThunderousMight extends CardImpl {
this.addAbility(ability);
// Whenever enchanted creature attacks, it gets +X/+0 until end of turn, where X is your devotion to red.
BoostEnchantedEffect effect = new BoostEnchantedEffect(xValue, new StaticValue(0), Duration.EndOfTurn);
BoostEnchantedEffect effect = new BoostEnchantedEffect(DevotionCount.R, new StaticValue(0), Duration.EndOfTurn);
effect.setText("it gets +X/+0 until end of turn, where X is your devotion to red");
effect.setLockedIn(true);
this.addAbility(new AttacksAttachedTriggeredAbility(effect, AttachmentType.AURA, false)
.addHint(new ValueHint("Devotion to red", xValue)));
.addHint(DevotionCount.R.getHint()));
}
public ThunderousMight(final ThunderousMight card) {
private ThunderousMight(final ThunderousMight card) {
super(card);
}

View file

@ -4,25 +4,22 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfCombatTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.DevotionCount;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.effects.common.continuous.LoseCreatureTypeSourceEffect;
import mage.abilities.hint.ValueHint;
import mage.abilities.keyword.HasteAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.TargetPermanent;
import java.util.UUID;
@ -31,14 +28,13 @@ import java.util.UUID;
*/
public final class XenagosGodOfRevels extends CardImpl {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("another target creature you control");
private static final FilterPermanent filter
= new FilterControlledCreaturePermanent("another target creature you control");
static {
filter.add(AnotherPredicate.instance);
}
private static final DynamicValue xValue = new DevotionCount(ColoredManaSymbol.R, ColoredManaSymbol.G);
public XenagosGodOfRevels(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{3}{R}{G}");
addSuperType(SuperType.LEGENDARY);
@ -51,20 +47,23 @@ public final class XenagosGodOfRevels extends CardImpl {
this.addAbility(IndestructibleAbility.getInstance());
// As long as your devotion to red and green is less than seven, Xenagos isn't a creature.
Effect effect = new LoseCreatureTypeSourceEffect(xValue, 7);
effect.setText("As long as your devotion to red and green is less than seven, Xenagos isn't a creature");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect).addHint(new ValueHint("Devotion to red and green", xValue)));
this.addAbility(new SimpleStaticAbility(new LoseCreatureTypeSourceEffect(DevotionCount.RG, 7))
.addHint(DevotionCount.RG.getHint()));
// At the beginning of combat on your turn, another target creature you control gains haste and gets +X/+X until end of turn, where X is that creature's power.
effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setText("another target creature you control gains haste");
Ability ability = new BeginningOfCombatTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.YOU, false, false);
Ability ability = new BeginningOfCombatTriggeredAbility(
Zone.BATTLEFIELD,
new GainAbilityTargetEffect(
HasteAbility.getInstance(), Duration.EndOfTurn
).setText("another target creature you control gains haste"),
TargetController.YOU, false, false
);
ability.addEffect(new XenagosGodOfRevelsEffect());
ability.addTarget(new TargetControlledCreaturePermanent(1, 1, filter, false));
ability.addTarget(new TargetPermanent(filter));
this.addAbility(ability);
}
public XenagosGodOfRevels(final XenagosGodOfRevels card) {
private XenagosGodOfRevels(final XenagosGodOfRevels card) {
super(card);
}
@ -76,12 +75,12 @@ public final class XenagosGodOfRevels extends CardImpl {
class XenagosGodOfRevelsEffect extends OneShotEffect {
public XenagosGodOfRevelsEffect() {
XenagosGodOfRevelsEffect() {
super(Outcome.BoostCreature);
this.staticText = "and gets +X/+X until end of turn, where X is that creature's power";
}
public XenagosGodOfRevelsEffect(final XenagosGodOfRevelsEffect effect) {
private XenagosGodOfRevelsEffect(final XenagosGodOfRevelsEffect effect) {
super(effect);
}
@ -93,11 +92,13 @@ class XenagosGodOfRevelsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
ContinuousEffect effect = new BoostTargetEffect(targetCreature.getPower().getValue(), targetCreature.getPower().getValue(), Duration.EndOfTurn);
effect.setTargetPointer(this.getTargetPointer());
game.addEffect(effect, source);
if (targetCreature == null) {
return false;
}
int power = targetCreature.getPower().getValue();
game.addEffect(new BoostTargetEffect(
power, power, Duration.EndOfTurn
).setTargetPointer(this.getTargetPointer()), source);
return false;
}
}

View file

@ -1,18 +1,18 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.dynamicvalue.common;
import java.util.ArrayList;
import java.util.Arrays;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.constants.ColoredManaSymbol;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
/**
* Each colored mana symbol (e.g. {U}) in the mana costs of permanents you
@ -20,37 +20,49 @@ import mage.game.permanent.Permanent;
*
* @author LevelX2
*/
public class DevotionCount implements DynamicValue {
public enum DevotionCount implements DynamicValue {
W(ColoredManaSymbol.W),
U(ColoredManaSymbol.U),
B(ColoredManaSymbol.B),
R(ColoredManaSymbol.R),
G(ColoredManaSymbol.G),
WU(ColoredManaSymbol.W, ColoredManaSymbol.U),
WB(ColoredManaSymbol.W, ColoredManaSymbol.B),
UB(ColoredManaSymbol.U, ColoredManaSymbol.B),
UR(ColoredManaSymbol.U, ColoredManaSymbol.R),
BR(ColoredManaSymbol.B, ColoredManaSymbol.R),
BG(ColoredManaSymbol.B, ColoredManaSymbol.G),
RG(ColoredManaSymbol.R, ColoredManaSymbol.G),
RW(ColoredManaSymbol.R, ColoredManaSymbol.W),
GW(ColoredManaSymbol.G, ColoredManaSymbol.W),
GU(ColoredManaSymbol.G, ColoredManaSymbol.U);
private ArrayList<ColoredManaSymbol> devotionColors = new ArrayList<>();
private final ArrayList<ColoredManaSymbol> devotionColors = new ArrayList<>();
private final Hint hint;
public DevotionCount(ColoredManaSymbol... devotionColor) {
DevotionCount(ColoredManaSymbol... devotionColor) {
this.devotionColors.addAll(Arrays.asList(devotionColor));
}
public DevotionCount(final DevotionCount dynamicValue) {
this.devotionColors = dynamicValue.devotionColors;
this.hint = new ValueHint(this.getMessage().replace("your d", "D"), this);
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int devotion = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(sourceAbility.getControllerId())) {
for (ManaCost manaCost : permanent.getManaCost()) {
for (ColoredManaSymbol coloredManaSymbol : devotionColors) {
if (manaCost.containsColor(coloredManaSymbol)) {
devotion++;
break; // count each manaCost maximum of one time (Hybrid don't count for multiple colors of devotion)
}
}
}
}
return devotion;
return game.getBattlefield()
.getAllActivePermanents(sourceAbility.getControllerId())
.stream()
.map(MageObject::getManaCost)
.flatMap(Collection::stream)
.mapToInt(this::checkCost)
.sum();
}
private int checkCost(ManaCost manaCost) {
return devotionColors.stream().anyMatch(manaCost::containsColor) ? 1 : 0;
}
@Override
public DevotionCount copy() {
return new DevotionCount(this);
return this;
}
@Override
@ -71,4 +83,8 @@ public class DevotionCount implements DynamicValue {
}
return sb.toString();
}
public Hint getHint() {
return hint;
}
}