foul-magics/Mage/src/main/java/mage/abilities/condition/common/CardsInControllerGraveyardCondition.java
Evan Kranzler 80e11b2052
(WIP) Replacing blocking/blocked by predicates (#8729)
* replaced blocking/blocked by predicates

* added test for knight of dusk (currently fails)

* added source parameter to filters and everything else that needs it

* some changes to various predicates

* test fix

* small changes to filter code

* merge fix

* fixed a test failure

* small change to Karn, Scion of Urza

* removed sourceId from filter methods and other similar places

* added new getobject method to fix some test failures

* a few more fixes

* fixed merge conflicts

* merge fix
2022-03-23 18:45:02 -04:00

45 lines
1.3 KiB
Java

package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
/**
* Condition for - Controller has X or more cards in their graveyard
*
* @author LevelX2
*/
public class CardsInControllerGraveyardCondition implements Condition {
private final int value;
private final FilterCard filter;
public CardsInControllerGraveyardCondition(int value) {
this(value, null);
}
public CardsInControllerGraveyardCondition(int value, FilterCard filter) {
this.value = value;
this.filter = filter;
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (filter != null) {
return player != null && player.getGraveyard().count(filter, source.getControllerId(), source, game) >= value;
}
return player != null && player.getGraveyard().size() >= value;
}
@Override
public String toString() {
return "there are " + CardUtil.numberToText(value, "one") + " or more "
+ (filter == null ? "cards" : filter.getMessage())
+ " in your graveyard";
}
}