mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 22:12:03 -08:00
[ZNR] Implemented Mind Carver
This commit is contained in:
parent
da65fa2cc1
commit
b54c9449ef
6 changed files with 113 additions and 59 deletions
|
|
@ -2,33 +2,57 @@ package mage.abilities.condition.common;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.hint.ConditionHint;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.game.Game;
|
||||
import mage.game.Graveyard;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Condition for -
|
||||
* Any opponent has X or more cards in their graveyard
|
||||
* @author Loki
|
||||
* Any opponent has X or more cards in their graveyard
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class CardsInOpponentGraveCondition implements Condition {
|
||||
private final int value;
|
||||
public enum CardsInOpponentGraveCondition implements Condition {
|
||||
SEVEN(7),
|
||||
EIGHT(8),
|
||||
TEN(10);
|
||||
|
||||
public CardsInOpponentGraveCondition(int value) {
|
||||
private final int value;
|
||||
private final Hint hint;
|
||||
|
||||
CardsInOpponentGraveCondition(int value) {
|
||||
this.value = value;
|
||||
this.hint = new ConditionHint(this, "O" + this.makeStem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
for (UUID playerId : game.getOpponents(source.getControllerId())) {
|
||||
Player opponent = game.getPlayer(playerId);
|
||||
if (opponent != null && opponent.getGraveyard().size() >= value)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return game
|
||||
.getOpponents(source.getControllerId())
|
||||
.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.map(Player::getGraveyard)
|
||||
.mapToInt(Graveyard::size)
|
||||
.anyMatch(i -> i >= this.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "an o" + this.makeStem();
|
||||
}
|
||||
|
||||
private String makeStem() {
|
||||
return "pponent has " + CardUtil.numberToText(value) + " or more cards in their graveyard";
|
||||
}
|
||||
|
||||
public Hint getHint() {
|
||||
return hint;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue