forked from External/mage
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:
parent
d5187fc7a3
commit
f036bc75fb
89 changed files with 1062 additions and 1276 deletions
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue