[EOE] Implement The Dominion Bracelet

This commit is contained in:
theelk801 2025-07-12 10:51:17 -04:00
parent 0c5654a7fe
commit 06cdd63b10
4 changed files with 165 additions and 1 deletions

View file

@ -0,0 +1,83 @@
package mage.cards.t;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.CostAdjuster;
import mage.abilities.costs.common.ExileAttachmentCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effects;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.effects.common.continuous.GainAbilityWithAttachmentEffect;
import mage.abilities.effects.common.turn.ControlTargetPlayerNextTurnEffect;
import mage.abilities.keyword.EquipAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.TimingRule;
import mage.game.Game;
import mage.target.Targets;
import mage.target.common.TargetOpponent;
import mage.util.CardUtil;
import java.util.Optional;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class TheDominionBracelet extends CardImpl {
public TheDominionBracelet(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.EQUIPMENT);
// Equipped creature gets +1/+1 and has "{15}, Exile The Dominion Bracelet: You control target opponent during their next turn. This ability costs {X} less to activate, where X is this creature's power. Activate only as a sorcery."
Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(1, 1));
ability.addEffect(new GainAbilityWithAttachmentEffect(
"and has \"{15}, Exile {this}: You control target opponent during their next turn. This ability " +
"costs {X} less to activate, where X is this creature's power. Activate only as a sorcery.\"",
new Effects(
new ControlTargetPlayerNextTurnEffect(), new InfoEffect("This ability costs {X} " +
"less to activate, where X is this creature's power. Activate only as a sorcery")
), new Targets(new TargetOpponent()), new ExileAttachmentCost(),
activatedAbility -> {
activatedAbility.setCostAdjuster(TheDominionBraceletAdjuster.instance);
activatedAbility.setTiming(TimingRule.SORCERY);
},
new GenericManaCost(15)
));
this.addAbility(ability);
// Equip {1}
this.addAbility(new EquipAbility(1));
}
private TheDominionBracelet(final TheDominionBracelet card) {
super(card);
}
@Override
public TheDominionBracelet copy() {
return new TheDominionBracelet(this);
}
}
enum TheDominionBraceletAdjuster implements CostAdjuster {
instance;
@Override
public void reduceCost(Ability ability, Game game) {
Optional.ofNullable(ability.getSourcePermanentIfItStillExists(game))
.map(MageObject::getPower)
.map(MageInt::getValue)
.filter(x -> x > 0)
.ifPresent(x -> CardUtil.reduceCost(ability, x));
}
}

View file

@ -211,6 +211,10 @@ public final class EdgeOfEternities extends ExpansionSet {
cards.add(new SetCardInfo("Terrasymbiosis", 312, Rarity.RARE, mage.cards.t.Terrasymbiosis.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Tezzeret, Cruel Captain", 2, Rarity.MYTHIC, mage.cards.t.TezzeretCruelCaptain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Tezzeret, Cruel Captain", 287, Rarity.MYTHIC, mage.cards.t.TezzeretCruelCaptain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Dominion Bracelet", 239, Rarity.MYTHIC, mage.cards.t.TheDominionBracelet.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Dominion Bracelet", 352, Rarity.MYTHIC, mage.cards.t.TheDominionBracelet.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Dominion Bracelet", 364, Rarity.MYTHIC, mage.cards.t.TheDominionBracelet.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Dominion Bracelet", 390, Rarity.MYTHIC, mage.cards.t.TheDominionBracelet.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Endstone", 240, Rarity.MYTHIC, mage.cards.t.TheEndstone.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Endstone", 353, Rarity.MYTHIC, mage.cards.t.TheEndstone.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("The Endstone", 365, Rarity.MYTHIC, mage.cards.t.TheEndstone.class, NON_FULL_USE_VARIOUS));

View file

@ -0,0 +1,65 @@
package mage.abilities.costs.common;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.SacrificeCost;
import mage.abilities.costs.UseAttachedCost;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.Optional;
import java.util.UUID;
/**
* @author TheElk801
*/
public class ExileAttachmentCost extends UseAttachedCost implements SacrificeCost {
public ExileAttachmentCost() {
super();
}
protected ExileAttachmentCost(final ExileAttachmentCost cost) {
super(cost);
}
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
if (mageObjectReference == null) {
return false;
}
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null) {
return paid;
}
for (UUID attachmentId : permanent.getAttachments()) {
if (!this.mageObjectReference.refersTo(attachmentId, game)) {
continue;
}
Permanent attachment = game.getPermanent(attachmentId);
paid = attachment != null
&& Optional
.ofNullable(controllerId)
.map(game::getPlayer)
.filter(player -> player.moveCards(attachment, Zone.EXILED, source, game))
.isPresent();
if (paid) {
break;
}
}
return paid;
}
@Override
public ExileAttachmentCost copy() {
return new ExileAttachmentCost(this);
}
@Override
public String getText() {
return "exile " + this.name;
}
}

View file

@ -1,6 +1,7 @@
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.Costs;
@ -20,6 +21,7 @@ import mage.target.Targets;
import mage.target.targetpointer.FixedTarget;
import java.util.Collections;
import java.util.function.Consumer;
/**
* @author TheElk801
@ -30,18 +32,24 @@ public class GainAbilityWithAttachmentEffect extends ContinuousEffectImpl {
private final Targets targets = new Targets();
private final Costs<Cost> costs = new CostsImpl<>();
protected final UseAttachedCost useAttachedCost;
private final Consumer<ActivatedAbility> consumer;
public GainAbilityWithAttachmentEffect(String rule, Effect effect, Target target, UseAttachedCost attachedCost, Cost... costs) {
this(rule, new Effects(effect), new Targets(target), attachedCost, costs);
}
public GainAbilityWithAttachmentEffect(String rule, Effects effects, Targets targets, UseAttachedCost attachedCost, Cost... costs) {
this(rule, effects, targets, attachedCost, null, costs);
}
public GainAbilityWithAttachmentEffect(String rule, Effects effects, Targets targets, UseAttachedCost attachedCost, Consumer<ActivatedAbility> consumer, Cost... costs) {
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
this.staticText = rule;
this.effects.addAll(effects);
this.targets.addAll(targets);
Collections.addAll(this.costs, costs);
this.useAttachedCost = attachedCost;
this.consumer = consumer;
this.generateGainAbilityDependencies(makeAbility(null, null), null);
}
@ -51,6 +59,7 @@ public class GainAbilityWithAttachmentEffect extends ContinuousEffectImpl {
this.targets.addAll(effect.targets);
this.costs.addAll(effect.costs);
this.useAttachedCost = effect.useAttachedCost == null ? null : effect.useAttachedCost.copy();
this.consumer = effect.consumer;
}
@Override
@ -94,7 +103,7 @@ public class GainAbilityWithAttachmentEffect extends ContinuousEffectImpl {
}
protected Ability makeAbility(Game game, Ability source) {
Ability ability = new SimpleActivatedAbility(null, null);
ActivatedAbility ability = new SimpleActivatedAbility(null, null);
for (Effect effect : effects) {
if (effect == null) {
continue;
@ -116,6 +125,9 @@ public class GainAbilityWithAttachmentEffect extends ContinuousEffectImpl {
if (source != null && game != null) {
ability.addCost(useAttachedCost.copy().setMageObjectReference(source, game));
}
if (consumer != null) {
consumer.accept(ability);
}
return ability;
}
}