mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 04:42:07 -08:00
added hints for Happily Ever After (#7050)
This commit is contained in:
parent
c2a5a6bb9c
commit
967968a98f
1 changed files with 87 additions and 5 deletions
|
|
@ -8,6 +8,7 @@ import mage.abilities.condition.Condition;
|
|||
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.WinGameSourceControllerEffect;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
|
|
@ -18,10 +19,7 @@ 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;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
|
@ -42,7 +40,7 @@ public final class HappilyEverAfter extends CardImpl {
|
|||
"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."
|
||||
));
|
||||
).addHint(HappilyEverAfterColorHint.instance).addHint(HappilyEverAfterCardTypeHint.instance));
|
||||
}
|
||||
|
||||
private HappilyEverAfter(final HappilyEverAfter card) {
|
||||
|
|
@ -123,3 +121,87 @@ enum HappilyEverAfterCondition implements Condition {
|
|||
return cardTypeEnumSet.size() >= 6;
|
||||
}
|
||||
}
|
||||
|
||||
enum HappilyEverAfterColorHint implements Hint {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public String getText(Game game, Ability ability) {
|
||||
Player player = game.getPlayer(ability.getControllerId());
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
ObjectColor color = new ObjectColor("");
|
||||
game.getBattlefield()
|
||||
.getAllActivePermanents(ability.getControllerId())
|
||||
.stream()
|
||||
.map(permanent -> permanent.getColor(game))
|
||||
.forEach(color::addColor);
|
||||
if (color.isColorless()) {
|
||||
return "Colors of permanents you control: None";
|
||||
}
|
||||
List<String> colors = new ArrayList<>();
|
||||
if (color.isWhite()) {
|
||||
colors.add("white");
|
||||
}
|
||||
if (color.isBlue()) {
|
||||
colors.add("blue");
|
||||
}
|
||||
if (color.isBlack()) {
|
||||
colors.add("black");
|
||||
}
|
||||
if (color.isRed()) {
|
||||
colors.add("red");
|
||||
}
|
||||
if (color.isGreen()) {
|
||||
colors.add("green");
|
||||
}
|
||||
return "Colors of permanents you control: " + color.getColorCount() + " (" + colors.stream().reduce((a, b) -> a + ", " + b) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public HappilyEverAfterColorHint copy() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
enum HappilyEverAfterCardTypeHint implements Hint {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public String getText(Game game, Ability ability) {
|
||||
Player player = game.getPlayer(ability.getControllerId());
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
Set<CardType> cardTypeSet = EnumSet.noneOf(CardType.class);
|
||||
game.getBattlefield()
|
||||
.getAllActivePermanents(ability.getControllerId())
|
||||
.stream()
|
||||
.map(Permanent::getCardType)
|
||||
.flatMap(Collection::stream)
|
||||
.forEach(cardTypeSet::add);
|
||||
player.getGraveyard()
|
||||
.getCards(game)
|
||||
.stream()
|
||||
.map(Card::getCardType)
|
||||
.flatMap(Collection::stream)
|
||||
.forEach(cardTypeSet::add);
|
||||
if (cardTypeSet.isEmpty()) {
|
||||
return "Card types on battlefield and in graveyard: None";
|
||||
}
|
||||
String message = cardTypeSet
|
||||
.stream()
|
||||
.distinct()
|
||||
.sorted()
|
||||
.map(CardType::toString)
|
||||
.reduce((a, b) -> a + ", " + b)
|
||||
.get();
|
||||
return "Card types on battlefield and in graveyard: " + cardTypeSet.size() + " (" + message + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public HappilyEverAfterCardTypeHint copy() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue