[SNC] Implemented Graveyard Shift

This commit is contained in:
Evan Kranzler 2022-04-10 09:52:12 -04:00
parent c451ae88c7
commit b658d60bfd
5 changed files with 135 additions and 56 deletions

View file

@ -0,0 +1,38 @@
package mage.abilities.condition.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
/**
* @author TheElk801
*/
public enum DifferentManaValuesInGraveCondition implements Condition {
FIVE(5);
private final int amount;
DifferentManaValuesInGraveCondition(int amount) {
this.amount = amount;
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
return player != null
&& player
.getGraveyard()
.getCards(game)
.stream()
.mapToInt(MageObject::getManaValue)
.distinct()
.count() >= amount;
}
@Override
public String toString() {
return "there are " + CardUtil.numberToText(amount) + " or more mana values among cards in your graveyard";
}
}

View file

@ -0,0 +1,40 @@
package mage.abilities.hint.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.hint.Hint;
import mage.game.Game;
import mage.players.Player;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author TheElk801
*/
public enum DifferentManaValuesInGraveHint implements Hint {
instance;
public String getText(Game game, Ability ability) {
Player player = game.getPlayer(ability.getControllerId());
if (player == null) {
return null;
}
List<String> values = player
.getGraveyard()
.getCards(game)
.stream()
.mapToInt(MageObject::getManaValue)
.distinct()
.sorted()
.mapToObj(String::valueOf)
.collect(Collectors.toList());
return "Different mana values among cards in your graveyard: " + values.size()
+ (values.size() > 0 ? " (" + String.join(", ", values) + ')' : "");
}
@Override
public DifferentManaValuesInGraveHint copy() {
return this;
}
}