- [KHM} - Added Alrund, God of the Cosmos

This commit is contained in:
Jeff 2021-01-23 21:25:37 -06:00
parent 227295ea41
commit 79a2815aef
3 changed files with 172 additions and 1 deletions

View file

@ -0,0 +1,170 @@
package mage.cards.a;
import java.util.Collection;
import java.util.Set;
import mage.MageInt;
import mage.cards.CardSetInfo;
import mage.cards.ModalDoubleFacesCard;
import mage.constants.*;
import mage.game.Game;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseCardTypeEffect;
import mage.abilities.effects.common.ReturnToHandSourceEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.effects.keyword.ScryEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.ForetellAbility;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.AbilityPredicate;
import mage.filter.predicate.other.OwnerIdPredicate;
import mage.game.ExileZone;
import mage.players.Player;
import mage.util.CardUtil;
/**
* @author jeffwadsworth
*/
public final class AlrundGodOfTheCosmos extends ModalDoubleFacesCard {
public AlrundGodOfTheCosmos(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo,
new CardType[]{CardType.CREATURE}, new SubType[]{SubType.GOD}, "{3}{U}{U}",
"Hakka, Whispering Raven", new CardType[]{CardType.CREATURE}, new SubType[]{}, "{1}{U}"
);
// 1.
// Alrund, God of the Cosmos
// Legendary Creature - God
this.getLeftHalfCard().addSuperType(SuperType.LEGENDARY);
this.getLeftHalfCard().setPT(new MageInt(1), new MageInt(1));
// Alrund gets +1/+1 for each card in your hand and each foretold card you own in exile.
Effect effect = new BoostSourceEffect(AlrundGodOfTheCosmosValue.instance, AlrundGodOfTheCosmosValue.instance, Duration.EndOfGame);
effect.setText("Alrund gets +1/+1 for each card in your hand and each foretold card you own in exile.");
Ability ability = new SimpleStaticAbility(effect);
this.getLeftHalfCard().addAbility(ability);
// At the beginning of your end step, choose a card type, then reveal the top two cards of your library. Put all cards of the chosen type into your hand and the rest on the bottom of your library in any order.
Ability ability2 = new BeginningOfYourEndStepTriggeredAbility(new ChooseCardTypeEffect(Outcome.Neutral), false);
ability2.addEffect(new AlrundGodOfTheCosmosEffect());
this.getLeftHalfCard().addAbility(ability2);
// 2.
// Hakka, Whispering Raven
// Legendary Creature Bird
this.getRightHalfCard().addSuperType(SuperType.LEGENDARY);
this.getRightHalfCard().setPT(new MageInt(2), new MageInt(3));
// Flying
this.getRightHalfCard().addAbility(FlyingAbility.getInstance());
// Whenever Hakka, Whispering Raven deals combat damage to a player, return it to its owners hand, then scry 2.
Ability ability3 = new DealsCombatDamageToAPlayerTriggeredAbility(new ReturnToHandSourceEffect(), false);
ability3.addEffect(new ScryEffect(2));
this.getRightHalfCard().addAbility(ability3);
}
private AlrundGodOfTheCosmos(final AlrundGodOfTheCosmos card) {
super(card);
}
@Override
public AlrundGodOfTheCosmos copy() {
return new AlrundGodOfTheCosmos(this);
}
}
class AlrundGodOfTheCosmosEffect extends OneShotEffect {
public AlrundGodOfTheCosmosEffect() {
super(Outcome.Neutral);
staticText = "then reveal the top two cards of your library. Put all cards of the chosen type into your hand and the rest on the bottom of your library in any order";
}
public AlrundGodOfTheCosmosEffect(final AlrundGodOfTheCosmosEffect effect) {
super(effect);
}
@Override
public AlrundGodOfTheCosmosEffect copy() {
return new AlrundGodOfTheCosmosEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
String chosenCardType = (String) game.getState().getValue(source.getSourceId() + "_type");
Cards cardsToHand = new CardsImpl();
Cards cardsToBottomOfLibrary = new CardsImpl();
if (controller != null) {
Set<Card> twoCardsFromTop = controller.getLibrary().getTopCards(game, 2);
Cards cards = new CardsImpl();
cards.addAll(twoCardsFromTop);
controller.revealCards(source, cards, game);
for (Card card : cards.getCards(game)) {
if (card.getCardType().toString().contains(chosenCardType)) {
cardsToHand.add(card);
} else {
cardsToBottomOfLibrary.add(card);
}
}
controller.moveCards(cardsToHand, Zone.HAND, source, game);
controller.putCardsOnBottomOfLibrary(cardsToBottomOfLibrary, game, source, true);
return true;
}
return false;
}
}
enum AlrundGodOfTheCosmosValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
Player controller = game.getPlayer(sourceAbility.getControllerId());
if (controller != null) {
Collection<ExileZone> exileZones = game.getState().getExile().getExileZones();
Cards cardsForetoldInExileZones = new CardsImpl();
FilterCard filter = new FilterCard();
filter.add(new OwnerIdPredicate(controller.getId()));
filter.add(new AbilityPredicate(ForetellAbility.class));
for (ExileZone exile : exileZones) {
for (Card card : exile.getCards(filter, game)) {
// verify that the card is actuall Foretold
UUID exileId = CardUtil.getExileZoneId(card.getId().toString() + "foretellAbility", game);
if (exileId != null) {
System.out.println("The exileId is " + exileId);
if (game.getState().getExile().getExileZone(exileId) != null) {
cardsForetoldInExileZones.add(card);
}
}
}
}
System.out.println("The cards with Foretell in Exile: " + cardsForetoldInExileZones.size());
System.out.println("The cards in controller's hand: " + controller.getHand().size());
return controller.getHand().size() + cardsForetoldInExileZones.size();
}
return 0;
}
@Override
public DynamicValue copy() {
return instance;
}
@Override
public String getMessage() {
return "test";
}
}

View file

@ -34,6 +34,7 @@ public final class Kaldheim extends ExpansionSet {
cards.add(new SetCardInfo("Absorb Identity", 383, Rarity.UNCOMMON, mage.cards.a.AbsorbIdentity.class));
cards.add(new SetCardInfo("Aegar, the Freezing Flame", 200, Rarity.UNCOMMON, mage.cards.a.AegarTheFreezingFlame.class));
cards.add(new SetCardInfo("Alpine Meadow", 248, Rarity.COMMON, mage.cards.a.AlpineMeadow.class));
cards.add(new SetCardInfo("Alrund, God of the Cosmos", 40, Rarity.MYTHIC, mage.cards.a.AlrundGodOfTheCosmos.class));
cards.add(new SetCardInfo("Alrund's Epiphany", 41, Rarity.MYTHIC, mage.cards.a.AlrundsEpiphany.class));
cards.add(new SetCardInfo("Annul", 42, Rarity.COMMON, mage.cards.a.Annul.class));
cards.add(new SetCardInfo("Arachnoform", 159, Rarity.COMMON, mage.cards.a.Arachnoform.class));

View file

@ -257,7 +257,7 @@ class ForetellCostAbility extends StaticAbility implements AlternativeSourceCost
public boolean isAvailable(Ability source, Game game) {
Card card = game.getCard(source.getSourceId());
if (card != null
&& game.getState().getValue(card.getId().toString()) != null) {
&& game.getState().getValue(card.getId().toString() + "Foretell Turn Number") != null) {
return Zone.STACK == game.getState().getZone(card.getId())
&& ((int) game.getState().getValue(card.getId().toString()
+ "Foretell Turn Number") != game.getTurnNum());