mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Implemented Happily Ever After
This commit is contained in:
parent
0ead44c156
commit
dd93f29e46
2 changed files with 126 additions and 0 deletions
125
Mage.Sets/src/mage/cards/h/HappilyEverAfter.java
Normal file
125
Mage.Sets/src/mage/cards/h/HappilyEverAfter.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
package mage.cards.h;
|
||||
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.WinGameSourceControllerEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class HappilyEverAfter extends CardImpl {
|
||||
|
||||
public HappilyEverAfter(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
|
||||
|
||||
// When Happily Ever After enters the battlefield, each player gains 5 life and draws a card.
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new HappilyEverAfterEffect()));
|
||||
|
||||
// At the beginning of your upkeep, if there are five colors among permanents you control, there are six or more card types among permanents you control and/or cards in your graveyard, and your life total is greater than or equal to your starting life total, you win the game.
|
||||
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
|
||||
new BeginningOfUpkeepTriggeredAbility(
|
||||
new WinGameSourceControllerEffect(), TargetController.YOU, false
|
||||
), HappilyEverAfterCondition.instance, "At the beginning of your upkeep, " +
|
||||
"if there are five colors among permanents you control, there are six or more card types " +
|
||||
"among permanents you control and/or cards in your graveyard, and your life total is " +
|
||||
"greater than or equal to your starting life total, you win the game."
|
||||
));
|
||||
}
|
||||
|
||||
private HappilyEverAfter(final HappilyEverAfter card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HappilyEverAfter copy() {
|
||||
return new HappilyEverAfter(this);
|
||||
}
|
||||
}
|
||||
|
||||
class HappilyEverAfterEffect extends OneShotEffect {
|
||||
|
||||
HappilyEverAfterEffect() {
|
||||
super(Outcome.GainLife);
|
||||
staticText = "each player gains 5 life and draws a card";
|
||||
}
|
||||
|
||||
private HappilyEverAfterEffect(final HappilyEverAfterEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HappilyEverAfterEffect copy() {
|
||||
return new HappilyEverAfterEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
game.getState()
|
||||
.getPlayersInRange(source.getControllerId(), game)
|
||||
.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.forEachOrdered(player -> {
|
||||
player.gainLife(5, game, source);
|
||||
player.drawCards(1, game);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
enum HappilyEverAfterCondition implements Condition {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null || player.getLife() < game.getLife()) {
|
||||
return false;
|
||||
}
|
||||
ObjectColor color = new ObjectColor("");
|
||||
game.getBattlefield()
|
||||
.getAllActivePermanents(source.getControllerId())
|
||||
.stream()
|
||||
.map(permanent -> permanent.getColor(game))
|
||||
.forEach(color::addColor);
|
||||
if (color.getColorCount() < 5) {
|
||||
return false;
|
||||
}
|
||||
EnumSet<CardType> cardTypeEnumSet = EnumSet.noneOf(CardType.class);
|
||||
game.getBattlefield()
|
||||
.getAllActivePermanents(source.getControllerId())
|
||||
.stream()
|
||||
.map(Permanent::getCardType)
|
||||
.flatMap(Collection::stream)
|
||||
.forEach(cardTypeEnumSet::add);
|
||||
if (cardTypeEnumSet.size() >= 6) {
|
||||
return true;
|
||||
}
|
||||
player.getGraveyard()
|
||||
.getCards(game)
|
||||
.stream()
|
||||
.map(Card::getCardType)
|
||||
.flatMap(Collection::stream)
|
||||
.forEach(cardTypeEnumSet::add);
|
||||
return cardTypeEnumSet.size() >= 6;
|
||||
}
|
||||
}
|
|
@ -118,6 +118,7 @@ public final class ThroneOfEldraine extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Gluttonous Troll", 327, Rarity.RARE, mage.cards.g.GluttonousTroll.class));
|
||||
cards.add(new SetCardInfo("Golden Egg", 220, Rarity.COMMON, mage.cards.g.GoldenEgg.class));
|
||||
cards.add(new SetCardInfo("Grumgully, the Generous", 192, Rarity.UNCOMMON, mage.cards.g.GrumgullyTheGenerous.class));
|
||||
cards.add(new SetCardInfo("Happily Ever After", 16, Rarity.RARE, mage.cards.h.HappilyEverAfter.class));
|
||||
cards.add(new SetCardInfo("Harmonious Archon", 17, Rarity.MYTHIC, mage.cards.h.HarmoniousArchon.class));
|
||||
cards.add(new SetCardInfo("Henge Walker", 221, Rarity.COMMON, mage.cards.h.HengeWalker.class));
|
||||
cards.add(new SetCardInfo("Heraldic Banner", 222, Rarity.UNCOMMON, mage.cards.h.HeraldicBanner.class));
|
||||
|
|
Loading…
Reference in a new issue