[OTC] Implement Cactus Preserve

This commit is contained in:
Susucre 2024-04-06 13:41:08 +02:00
parent 24e3a5b7ac
commit b5d0943b9d
4 changed files with 126 additions and 36 deletions

View file

@ -0,0 +1,41 @@
package mage.abilities.dynamicvalue.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.CommanderCardType;
import mage.constants.Zone;
import mage.game.Game;
/**
* @author PurpleCrowbar
*/
public enum CommanderGreatestManaValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return game.getCommanderCardsFromAnyZones(
game.getPlayer(sourceAbility.getControllerId()), CommanderCardType.ANY, Zone.ALL)
.stream()
.mapToInt(MageObject::getManaValue)
.max()
.orElse(0);
}
@Override
public CommanderGreatestManaValue copy() {
return this;
}
@Override
public String toString() {
return "X";
}
@Override
public String getMessage() {
return "the greatest mana value among your commanders";
}
}