mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
[AFR] Implemented Spare Dagger
This commit is contained in:
parent
f7319eb70a
commit
a47af7a5a9
3 changed files with 95 additions and 8 deletions
84
Mage.Sets/src/mage/cards/s/SpareDagger.java
Normal file
84
Mage.Sets/src/mage/cards/s/SpareDagger.java
Normal file
|
@ -0,0 +1,84 @@
|
|||
package mage.cards.s;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.common.delayed.ReflexiveTriggeredAbility;
|
||||
import mage.abilities.costs.common.SacrificeAttachmentCost;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.DoWhenCostPaid;
|
||||
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityWithAttachmentEffect;
|
||||
import mage.abilities.keyword.EquipAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class SpareDagger extends CardImpl {
|
||||
|
||||
public SpareDagger(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}");
|
||||
|
||||
this.subtype.add(SubType.EQUIPMENT);
|
||||
|
||||
// Equipped creature gets +1/+0 and has "Whenever this creature attacks, you may sacrifice Spare Dagger. When you do, this creature deals 1 damage to any target."
|
||||
Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(1, 0));
|
||||
ability.addEffect(new SpareDaggerEffect());
|
||||
this.addAbility(ability);
|
||||
|
||||
// Equip {1}
|
||||
this.addAbility(new EquipAbility(1));
|
||||
}
|
||||
|
||||
private SpareDagger(final SpareDagger card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpareDagger copy() {
|
||||
return new SpareDagger(this);
|
||||
}
|
||||
}
|
||||
|
||||
class SpareDaggerEffect extends GainAbilityWithAttachmentEffect {
|
||||
|
||||
SpareDaggerEffect() {
|
||||
super("and has \"Whenever this creature attacks, you may sacrifice {this}. " +
|
||||
"When you do, this creature deals 1 damage to any target.\"",
|
||||
(Effect) null, null, new SacrificeAttachmentCost(), null);
|
||||
}
|
||||
|
||||
private SpareDaggerEffect(final SpareDaggerEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpareDaggerEffect copy() {
|
||||
return new SpareDaggerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Ability makeAbility(Game game, Ability source) {
|
||||
if (source == null || game == null) {
|
||||
return null;
|
||||
}
|
||||
String sourceName = source.getSourcePermanentIfItStillExists(game).getName();
|
||||
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(
|
||||
new DamageTargetEffect(1), false,
|
||||
"This creature deals 1 damage to any target"
|
||||
);
|
||||
return new AttacksTriggeredAbility(new DoWhenCostPaid(
|
||||
ability, useAttachedCost.copy().setMageObjectReference(source, game),
|
||||
"Sacrifice " + sourceName + "?"
|
||||
), false, "Whenever this creature attacks, you may sacrifice "
|
||||
+ sourceName + ". When you do, this creature deals 1 damage to any target.");
|
||||
}
|
||||
}
|
|
@ -214,6 +214,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Skeletal Swarming", 232, Rarity.RARE, mage.cards.s.SkeletalSwarming.class));
|
||||
cards.add(new SetCardInfo("Skullport Merchant", 120, Rarity.UNCOMMON, mage.cards.s.SkullportMerchant.class));
|
||||
cards.add(new SetCardInfo("Soulknife Spy", 75, Rarity.COMMON, mage.cards.s.SoulknifeSpy.class));
|
||||
cards.add(new SetCardInfo("Spare Dagger", 250, Rarity.COMMON, mage.cards.s.SpareDagger.class));
|
||||
cards.add(new SetCardInfo("Sphere of Annihilation", 121, Rarity.RARE, mage.cards.s.SphereOfAnnihilation.class));
|
||||
cards.add(new SetCardInfo("Spiked Pit Trap", 251, Rarity.COMMON, mage.cards.s.SpikedPitTrap.class));
|
||||
cards.add(new SetCardInfo("Split the Party", 76, Rarity.UNCOMMON, mage.cards.s.SplitTheParty.class));
|
||||
|
|
|
@ -28,8 +28,8 @@ public class GainAbilityWithAttachmentEffect extends ContinuousEffectImpl {
|
|||
|
||||
private final Effects effects = new Effects();
|
||||
private final Targets targets = new Targets();
|
||||
private final Costs costs = new CostsImpl();
|
||||
private final UseAttachedCost useAttachedCost;
|
||||
private final Costs<Cost> costs = new CostsImpl<>();
|
||||
protected final UseAttachedCost useAttachedCost;
|
||||
|
||||
public GainAbilityWithAttachmentEffect(String rule, Effect effect, Target target, UseAttachedCost attachedCost, Cost... costs) {
|
||||
this(rule, new Effects(effect), new Targets(target), attachedCost, costs);
|
||||
|
@ -42,10 +42,10 @@ public class GainAbilityWithAttachmentEffect extends ContinuousEffectImpl {
|
|||
this.targets.addAll(targets);
|
||||
this.costs.addAll(Arrays.asList(costs));
|
||||
this.useAttachedCost = attachedCost;
|
||||
this.generateGainAbilityDependencies(makeAbility(this.effects, this.targets, this.costs), null);
|
||||
this.generateGainAbilityDependencies(makeAbility(null, null), null);
|
||||
}
|
||||
|
||||
public GainAbilityWithAttachmentEffect(final GainAbilityWithAttachmentEffect effect) {
|
||||
protected GainAbilityWithAttachmentEffect(final GainAbilityWithAttachmentEffect effect) {
|
||||
super(effect);
|
||||
this.effects.addAll(effect.effects);
|
||||
this.targets.addAll(effect.targets);
|
||||
|
@ -87,14 +87,13 @@ public class GainAbilityWithAttachmentEffect extends ContinuousEffectImpl {
|
|||
if (permanent == null) {
|
||||
return true;
|
||||
}
|
||||
Ability ability = makeAbility(this.effects, this.targets, this.costs);
|
||||
Ability ability = makeAbility(game, source);
|
||||
ability.getEffects().setValue("attachedPermanent", game.getPermanent(source.getSourceId()));
|
||||
ability.addCost(useAttachedCost.copy().setMageObjectReference(source, game));
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Ability makeAbility(Effects effects, Targets targets, Cost... costs) {
|
||||
protected Ability makeAbility(Game game, Ability source) {
|
||||
Ability ability = new SimpleActivatedAbility(null, null);
|
||||
for (Effect effect : effects) {
|
||||
if (effect == null) {
|
||||
|
@ -108,12 +107,15 @@ public class GainAbilityWithAttachmentEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
ability.addTarget(target);
|
||||
}
|
||||
for (Cost cost : costs) {
|
||||
for (Cost cost : this.costs) {
|
||||
if (cost == null) {
|
||||
continue;
|
||||
}
|
||||
ability.addCost(cost.copy());
|
||||
}
|
||||
if (source != null && game != null) {
|
||||
ability.addCost(useAttachedCost.copy().setMageObjectReference(source, game));
|
||||
}
|
||||
return ability;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue