mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 02:52:02 -08:00
[BLB] fix implementation of Clement, the Worrywort
This commit is contained in:
parent
8633a100fb
commit
d4f1d42c3e
1 changed files with 27 additions and 38 deletions
|
|
@ -15,27 +15,35 @@ import mage.abilities.mana.builder.ConditionalManaBuilder;
|
||||||
import mage.abilities.mana.conditional.CreatureCastManaCondition;
|
import mage.abilities.mana.conditional.CreatureCastManaCondition;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.SubType;
|
||||||
|
import mage.constants.SuperType;
|
||||||
import mage.filter.Filter;
|
import mage.filter.Filter;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.StaticFilters;
|
||||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.predicate.mageobject.ManaValuePredicate;
|
import mage.filter.predicate.ObjectSourcePlayer;
|
||||||
|
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
|
import mage.util.CardUtil;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author earchip94
|
* @author earchip94
|
||||||
*/
|
*/
|
||||||
public final class ClementTheWorrywort extends CardImpl {
|
public final class ClementTheWorrywort extends CardImpl {
|
||||||
|
|
||||||
|
private static final FilterPermanent filter = new FilterControlledCreaturePermanent("creature you control with lesser mana value");
|
||||||
private static final FilterPermanent frogFilter = new FilterPermanent(SubType.FROG, "Frogs");
|
private static final FilterPermanent frogFilter = new FilterPermanent(SubType.FROG, "Frogs");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filter.add(ClementTheWorrywortPredicate.instance);
|
||||||
|
}
|
||||||
|
|
||||||
public ClementTheWorrywort(UUID ownerId, CardSetInfo setInfo) {
|
public ClementTheWorrywort(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{U}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{U}");
|
||||||
|
|
||||||
|
|
@ -49,12 +57,16 @@ public final class ClementTheWorrywort extends CardImpl {
|
||||||
this.addAbility(VigilanceAbility.getInstance());
|
this.addAbility(VigilanceAbility.getInstance());
|
||||||
|
|
||||||
// Whenever Clement, the Worrywort or another creature you control enters, return up to one target creature you control with lesser mana value to its owner's hand.
|
// Whenever Clement, the Worrywort or another creature you control enters, return up to one target creature you control with lesser mana value to its owner's hand.
|
||||||
this.addAbility(new ClementTheWorrywortTriggeredAbility());
|
Ability ability = new EntersBattlefieldThisOrAnotherTriggeredAbility(
|
||||||
|
new ReturnToHandTargetEffect(), StaticFilters.FILTER_CONTROLLED_CREATURE, false, false
|
||||||
|
);
|
||||||
|
ability.addTarget(new TargetPermanent(0, 1, filter));
|
||||||
|
this.addAbility(ability);
|
||||||
|
|
||||||
// Frogs you control have "{T}: Add {G} or {U}. Spend this mana only to cast a creature spell."
|
// Frogs you control have "{T}: Add {G} or {U}. Spend this mana only to cast a creature spell."
|
||||||
Ability gMana = new ConditionalColoredManaAbility(new TapSourceCost(), Mana.GreenMana(1), new ClementTheWorrywortManaBuilder());
|
Ability gMana = new ConditionalColoredManaAbility(new TapSourceCost(), Mana.GreenMana(1), new ClementTheWorrywortManaBuilder());
|
||||||
Ability bMana = new ConditionalColoredManaAbility(new TapSourceCost(), Mana.BlueMana(1), new ClementTheWorrywortManaBuilder());
|
Ability bMana = new ConditionalColoredManaAbility(new TapSourceCost(), Mana.BlueMana(1), new ClementTheWorrywortManaBuilder());
|
||||||
Ability ability = new SimpleStaticAbility(
|
ability = new SimpleStaticAbility(
|
||||||
new GainAbilityControlledEffect(gMana, Duration.WhileOnBattlefield, frogFilter, false)
|
new GainAbilityControlledEffect(gMana, Duration.WhileOnBattlefield, frogFilter, false)
|
||||||
.setText("Frogs you control have \"{T}: Add {G} or {U}.")
|
.setText("Frogs you control have \"{T}: Add {G} or {U}.")
|
||||||
);
|
);
|
||||||
|
|
@ -75,40 +87,17 @@ public final class ClementTheWorrywort extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClementTheWorrywortTriggeredAbility extends EntersBattlefieldThisOrAnotherTriggeredAbility {
|
enum ClementTheWorrywortPredicate implements ObjectSourcePlayerPredicate<Permanent> {
|
||||||
|
instance;
|
||||||
ClementTheWorrywortTriggeredAbility() {
|
|
||||||
super(new ReturnToHandTargetEffect().setText("return up to one target creature you control with lesser mana value to its owner's hand"),
|
|
||||||
StaticFilters.FILTER_PERMANENT_CREATURE, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
ClementTheWorrywortTriggeredAbility(final ClementTheWorrywortTriggeredAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClementTheWorrywortTriggeredAbility copy() {
|
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
|
||||||
return new ClementTheWorrywortTriggeredAbility(this);
|
return CardUtil.getEffectValueFromAbility(
|
||||||
|
input.getSource(), "permanentEnteringBattlefield", Permanent.class
|
||||||
|
)
|
||||||
|
.filter(permanent -> input.getObject().getManaValue() < permanent.getManaValue())
|
||||||
|
.isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
if (super.checkTrigger(event, game)) {
|
|
||||||
this.getTargets().clear();
|
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
|
||||||
if (permanent == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int mv = permanent.getManaValue();
|
|
||||||
FilterControlledCreaturePermanent filter =
|
|
||||||
new FilterControlledCreaturePermanent("creature you control with mana value " + (mv - 1) + " or less");
|
|
||||||
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, mv));
|
|
||||||
this.addTarget(new TargetPermanent(0,1, filter));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClementTheWorrywortConditionalMana extends ConditionalMana {
|
class ClementTheWorrywortConditionalMana extends ConditionalMana {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue