[CMM] Implement Nyxborn Behemoth (#10670)

* [CMM] Implement Nyxborn Behemoth

Regroup the different dynamic values for "total mana value of [FILTER]" under a shared class.

* refactor hints inside TotalPermanentsManaValue

* apply review on TotalPermanentsManaValue->copy
This commit is contained in:
Susucre 2023-07-27 18:50:47 +02:00 committed by GitHub
parent 9eb7e2870e
commit c4f13be87f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 197 additions and 152 deletions

View file

@ -0,0 +1,64 @@
package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.List;
public class TotalPermanentsManaValue implements DynamicValue {
private final String message;
private final ValueHint hint;
private final FilterPermanent filter;
public TotalPermanentsManaValue(FilterPermanent filter) {
this.filter = filter.copy();
this.message = "the total mana value of " + filter.getMessage();
this.hint = new ValueHint("Total mana value of " + filter.getMessage(), this);
}
private TotalPermanentsManaValue(final TotalPermanentsManaValue value) {
this.filter = value.filter.copy();
this.message = value.message;
this.hint = value.hint.copy();
}
@Override
public TotalPermanentsManaValue copy() {
return new TotalPermanentsManaValue(this);
}
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
int totalCMC = 0;
List<Permanent> permanents = game.getBattlefield().getActivePermanents(
filter,
sourceAbility.getControllerId(),
sourceAbility,
game);
for (Permanent permanent : permanents) {
totalCMC += permanent.getManaValue();
}
return totalCMC;
}
@Override
public String getMessage() {
return message;
}
@Override
public String toString() {
return "X";
}
public Hint getHint() {
return hint;
}
}

View file

@ -28,7 +28,7 @@ public class ValueHint implements Hint {
}
@Override
public Hint copy() {
public ValueHint copy() {
return new ValueHint(this);
}
}

View file

@ -483,6 +483,14 @@ public final class StaticFilters {
FILTER_CONTROLLED_PERMANENT_ENCHANTMENT.setLockedFilter(true);
}
public static final FilterControlledPermanent FILTER_CONTROLLED_ANOTHER_ENCHANTMENT_SHORT_TEXT = new FilterControlledPermanent("another enchantment");
static {
FILTER_CONTROLLED_ANOTHER_ENCHANTMENT_SHORT_TEXT.add(AnotherPredicate.instance);
FILTER_CONTROLLED_ANOTHER_ENCHANTMENT_SHORT_TEXT.add(CardType.ENCHANTMENT.getPredicate());
FILTER_CONTROLLED_ANOTHER_ENCHANTMENT_SHORT_TEXT.setLockedFilter(true);
}
public static final FilterControlledPermanent FILTER_CONTROLLED_PERMANENT_LAND = new FilterControlledLandPermanent();
static {
@ -625,6 +633,14 @@ public final class StaticFilters {
FILTER_CONTROLLED_CREATURES.setLockedFilter(true);
}
public static final FilterControlledCreaturePermanent FILTER_OTHER_CONTROLLED_CREATURES = new FilterControlledCreaturePermanent("other creatures you control");
static {
FILTER_OTHER_CONTROLLED_CREATURES.add(AnotherPredicate.instance);
FILTER_OTHER_CONTROLLED_CREATURES.setLockedFilter(true);
}
public static final FilterControlledCreaturePermanent FILTER_CONTROLLED_A_CREATURE = new FilterControlledCreaturePermanent("a creature you control");
static {