[CLB] Implemented Majestic Genesis

This commit is contained in:
Evan Kranzler 2022-06-04 09:57:47 -04:00
parent 9497f8b6c3
commit 23ed717c8c
10 changed files with 159 additions and 66 deletions

View file

@ -1,18 +1,13 @@
package mage.cards.c;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.dynamicvalue.common.GreatestCommanderManaValue;
import mage.abilities.dynamicvalue.common.SignInversionDynamicValue;
import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.CommanderCardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
@ -21,13 +16,14 @@ import java.util.UUID;
*/
public final class Cloudkill extends CardImpl {
private static final DynamicValue xValue = new SignInversionDynamicValue(GreatestCommanderManaValue.instance);
public Cloudkill(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{B}{B}");
// All creatures gets -X/-X until end of turn, where X is the greatest mana value of a commander you own on the battlefield or in the command zone.
this.getSpellAbility().addEffect(new BoostAllEffect(
CloudkillValue.instance, CloudkillValue.instance, Duration.EndOfTurn
));
this.getSpellAbility().addEffect(new BoostAllEffect(xValue, xValue, Duration.EndOfTurn));
this.getSpellAbility().addHint(GreatestCommanderManaValue.getHint());
}
private Cloudkill(final Cloudkill card) {
@ -39,36 +35,3 @@ public final class Cloudkill extends CardImpl {
return new Cloudkill(this);
}
}
enum CloudkillValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Player player = game.getPlayer(sourceAbility.getControllerId());
return player != null ? -game
.getCommanderCardsFromAnyZones(
player, CommanderCardType.ANY,
Zone.BATTLEFIELD, Zone.COMMAND
)
.stream()
.mapToInt(MageObject::getManaValue)
.max()
.orElse(0) : 0;
}
@Override
public CloudkillValue copy() {
return this;
}
@Override
public String getMessage() {
return "the greatest mana value of a commander you own on the battlefield or in the command zone";
}
@Override
public String toString() {
return "-X";
}
}

View file

@ -0,0 +1,81 @@
package mage.cards.m;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.GreatestCommanderManaValue;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class MajesticGenesis extends CardImpl {
public MajesticGenesis(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{6}{G}{G}");
// Reveal the top X cards of your library, where X is the highest mana value of a commander you own on the battlefield or in the command zone. You may put any number of a permanent cards from among them onto the battlefield. Put the rest on the bottom of your library in a random order.
this.getSpellAbility().addEffect(new MajesticGenesisEffect());
this.getSpellAbility().addHint(GreatestCommanderManaValue.getHint());
}
private MajesticGenesis(final MajesticGenesis card) {
super(card);
}
@Override
public MajesticGenesis copy() {
return new MajesticGenesis(this);
}
}
class MajesticGenesisEffect extends OneShotEffect {
MajesticGenesisEffect() {
super(Outcome.Benefit);
staticText = "reveal the top X cards of your library, where X is the highest mana value of a commander " +
"you own on the battlefield or in the command zone. You may put any number of a permanent cards " +
"from among them onto the battlefield. Put the rest on the bottom of your library in a random order";
}
private MajesticGenesisEffect(final MajesticGenesisEffect effect) {
super(effect);
}
@Override
public MajesticGenesisEffect copy() {
return new MajesticGenesisEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
int xValue = GreatestCommanderManaValue.instance.calculate(game, source, this);
if (player == null || xValue < 1) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, xValue));
player.revealCards(source, cards, game);
TargetCard target = new TargetCardInLibrary(
0, Integer.MAX_VALUE,
StaticFilters.FILTER_CARD_PERMANENT
);
player.choose(outcome, cards, target, game);
player.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game);
cards.retainZone(Zone.LIBRARY, game);
player.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
}

View file

@ -3,6 +3,7 @@ package mage.cards.v;
import mage.abilities.Ability;
import mage.abilities.costs.costadjusters.CommanderManaValueAdjuster;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.GreatestCommanderManaValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl;
@ -32,7 +33,8 @@ public final class VisionsOfDominance extends CardImpl {
this.addAbility(new FlashbackAbility(this, new ManaCostsImpl<>("{8}{G}{G}"))
.setAbilityName("This spell costs {X} less to cast this way, where X is the greatest mana value " +
"of a commander you own on the battlefield or in the command zone.")
.setCostAdjuster(CommanderManaValueAdjuster.instance));
.setCostAdjuster(CommanderManaValueAdjuster.instance)
.addHint(GreatestCommanderManaValue.getHint()));
}
private VisionsOfDominance(final VisionsOfDominance card) {

View file

@ -3,6 +3,7 @@ package mage.cards.v;
import mage.abilities.Ability;
import mage.abilities.costs.costadjusters.CommanderManaValueAdjuster;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.GreatestCommanderManaValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl;
@ -34,7 +35,8 @@ public final class VisionsOfDread extends CardImpl {
this.addAbility(new FlashbackAbility(this, new ManaCostsImpl<>("{8}{B}{B}"))
.setAbilityName("This spell costs {X} less to cast this way, where X is the greatest mana value " +
"of a commander you own on the battlefield or in the command zone.")
.setCostAdjuster(CommanderManaValueAdjuster.instance));
.setCostAdjuster(CommanderManaValueAdjuster.instance)
.addHint(GreatestCommanderManaValue.getHint()));
}
private VisionsOfDread(final VisionsOfDread card) {

View file

@ -2,6 +2,7 @@ package mage.cards.v;
import mage.abilities.costs.costadjusters.CommanderManaValueAdjuster;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.GreatestCommanderManaValue;
import mage.abilities.effects.common.continuous.ExchangeControlTargetEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl;
@ -33,7 +34,8 @@ public final class VisionsOfDuplicity extends CardImpl {
this.addAbility(new FlashbackAbility(this, new ManaCostsImpl<>("{8}{U}{U}"))
.setAbilityName("This spell costs {X} less to cast this way, where X is the greatest mana value " +
"of a commander you own on the battlefield or in the command zone.")
.setCostAdjuster(CommanderManaValueAdjuster.instance));
.setCostAdjuster(CommanderManaValueAdjuster.instance)
.addHint(GreatestCommanderManaValue.getHint()));
}
private VisionsOfDuplicity(final VisionsOfDuplicity card) {

View file

@ -3,6 +3,7 @@ package mage.cards.v;
import mage.abilities.costs.costadjusters.CommanderManaValueAdjuster;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.CreaturesYouControlCount;
import mage.abilities.dynamicvalue.common.GreatestCommanderManaValue;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl;
@ -29,7 +30,8 @@ public final class VisionsOfGlory extends CardImpl {
this.addAbility(new FlashbackAbility(this, new ManaCostsImpl<>("{8}{W}{W}"))
.setAbilityName("This spell costs {X} less to cast this way, where X is the greatest mana value " +
"of a commander you own on the battlefield or in the command zone.")
.setCostAdjuster(CommanderManaValueAdjuster.instance));
.setCostAdjuster(CommanderManaValueAdjuster.instance)
.addHint(GreatestCommanderManaValue.getHint()));
}
private VisionsOfGlory(final VisionsOfGlory card) {

View file

@ -3,6 +3,7 @@ package mage.cards.v;
import mage.abilities.Ability;
import mage.abilities.costs.costadjusters.CommanderManaValueAdjuster;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.common.GreatestCommanderManaValue;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl;
@ -35,7 +36,8 @@ public final class VisionsOfRuin extends CardImpl {
this.addAbility(new FlashbackAbility(this, new ManaCostsImpl<>("{8}{R}{R}"))
.setAbilityName("This spell costs {X} less to cast this way, where X is the greatest mana value " +
"of a commander you own on the battlefield or in the command zone.")
.setCostAdjuster(CommanderManaValueAdjuster.instance));
.setCostAdjuster(CommanderManaValueAdjuster.instance)
.addHint(GreatestCommanderManaValue.getHint()));
}
private VisionsOfRuin(final VisionsOfRuin card) {

View file

@ -336,6 +336,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet {
cards.add(new SetCardInfo("Mage's Attendant", 698, Rarity.UNCOMMON, mage.cards.m.MagesAttendant.class));
cards.add(new SetCardInfo("Magus of the Balance", 699, Rarity.RARE, mage.cards.m.MagusOfTheBalance.class));
cards.add(new SetCardInfo("Mahadi, Emporium Master", 282, Rarity.UNCOMMON, mage.cards.m.MahadiEmporiumMaster.class));
cards.add(new SetCardInfo("Majestic Genesis", 240, Rarity.MYTHIC, mage.cards.m.MajesticGenesis.class));
cards.add(new SetCardInfo("Malakir Blood-Priest", 760, Rarity.COMMON, mage.cards.m.MalakirBloodPriest.class));
cards.add(new SetCardInfo("Managorger Hydra", 828, Rarity.RARE, mage.cards.m.ManagorgerHydra.class));
cards.add(new SetCardInfo("Manifold Key", 319, Rarity.UNCOMMON, mage.cards.m.ManifoldKey.class));

View file

@ -1,12 +1,9 @@
package mage.abilities.costs.costadjusters;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.costs.CostAdjuster;
import mage.constants.CommanderCardType;
import mage.constants.Zone;
import mage.abilities.dynamicvalue.common.GreatestCommanderManaValue;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
/**
@ -17,19 +14,6 @@ public enum CommanderManaValueAdjuster implements CostAdjuster {
@Override
public void adjustCosts(Ability ability, Game game) {
Player player = game.getPlayer(ability.getControllerId());
if (player == null) {
return;
}
int maxValue = game
.getCommanderCardsFromAnyZones(
player, CommanderCardType.ANY,
Zone.BATTLEFIELD, Zone.COMMAND
)
.stream()
.mapToInt(MageObject::getManaValue)
.max()
.orElse(0);
CardUtil.reduceCost(ability, maxValue);
CardUtil.reduceCost(ability, GreatestCommanderManaValue.instance.calculate(game, ability, null));
}
}

View file

@ -0,0 +1,54 @@
package mage.abilities.dynamicvalue.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.constants.CommanderCardType;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
/**
* @author TheElk801
*/
public enum GreatestCommanderManaValue implements DynamicValue {
instance;
private static final Hint hint = new ValueHint("Greatest mana value of a commander you own", instance);
public static Hint getHint() {
return hint;
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Player player = game.getPlayer(sourceAbility.getControllerId());
return player != null ? game
.getCommanderCardsFromAnyZones(
player, CommanderCardType.ANY,
Zone.BATTLEFIELD, Zone.COMMAND
)
.stream()
.mapToInt(MageObject::getManaValue)
.max()
.orElse(0) : 0;
}
@Override
public GreatestCommanderManaValue copy() {
return this;
}
@Override
public String getMessage() {
return "the greatest mana value of a commander you own on the battlefield or in the command zone";
}
@Override
public String toString() {
return "X";
}
}