refactor: dedicated condition for threshold (#12570)

* create threshold condition, refactor cards to use it

* fix threshold condition

* a couple more text fixes

---------

Co-authored-by: xenohedron <xenohedron@users.noreply.github.com>
This commit is contained in:
Evan Kranzler 2024-07-10 20:21:17 -04:00 committed by GitHub
parent d5187fc7a3
commit f036bc75fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
89 changed files with 1062 additions and 1276 deletions

View file

@ -0,0 +1,33 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.game.Controllable;
import mage.game.Game;
import mage.players.Player;
import java.util.HashSet;
import java.util.Optional;
/**
* @author TheElk801
*/
public enum ThresholdCondition implements Condition {
instance;
@Override
public boolean apply(Game game, Ability source) {
return Optional
.ofNullable(source)
.map(Controllable::getControllerId)
.map(game::getPlayer)
.map(Player::getGraveyard)
.map(HashSet::size)
.orElse(0) >= 7;
}
@Override
public String toString() {
return "seven or more cards are in your graveyard";
}
}