[KHM] Implemented Draugr's Helm (#7393)

* [KHM] Implemented Draugr's Helm

* Implemented CreateTokenAttachSourceEffect and refactored existing cards to use it
This commit is contained in:
Daniel Bomar 2021-01-15 08:07:25 -06:00 committed by GitHub
parent 3c8ad2a664
commit 9165cab00a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 108 additions and 156 deletions

View file

@ -1,19 +1,15 @@
package mage.cards.a;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.CreateTokenAttachSourceEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
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 mage.game.permanent.Permanent;
import mage.game.permanent.token.SoldierToken;
import mage.players.Player;
import java.util.UUID;
@ -28,7 +24,7 @@ public final class AncestralBlade extends CardImpl {
this.subtype.add(SubType.EQUIPMENT);
// When Ancestral Blade enters the battlefield, create a 1/1 white Soldier creature token, then attach Ancestral Blade to it.
this.addAbility(new EntersBattlefieldTriggeredAbility(new AncestralBladeEffect()));
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenAttachSourceEffect(new SoldierToken())));
// Equipped creature get +1/+1
this.addAbility(new SimpleStaticAbility(new BoostEquippedEffect(1, 1)));
@ -46,34 +42,3 @@ public final class AncestralBlade extends CardImpl {
return new AncestralBlade(this);
}
}
class AncestralBladeEffect extends CreateTokenEffect {
AncestralBladeEffect() {
super(new SoldierToken());
staticText = "create a 1/1 white Soldier creature token, then attach {this} to it.";
}
private AncestralBladeEffect(final AncestralBladeEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || !super.apply(game, source)) {
return false;
}
Permanent p = game.getPermanent(this.getLastAddedTokenId());
if (p == null) {
return false;
}
p.addAttachment(source.getSourceId(), source, game);
return true;
}
@Override
public AncestralBladeEffect copy() {
return new AncestralBladeEffect(this);
}
}

View file

@ -0,0 +1,56 @@
package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.CreateTokenAttachSourceEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.abilities.keyword.MenaceAbility;
import mage.constants.AttachmentType;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.game.permanent.token.ZombieBerserkerToken;
/**
*
* @author weirddan455
*/
public final class DraugrsHelm extends CardImpl {
public DraugrsHelm(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}{B}");
this.subtype.add(SubType.EQUIPMENT);
// When Draugr's Helm enters the battlefield, you may pay {2}{B}.
// If you do, create a 2/2 black Zombie Berserker creature token, then attach Draugr's Helm to it.
this.addAbility(new EntersBattlefieldTriggeredAbility(new DoIfCostPaid(
new CreateTokenAttachSourceEffect(new ZombieBerserkerToken()), new ManaCostsImpl<>("{2}{B}")
)));
// Equipped creature gets +2/+2 and has menace.
Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(2, 2));
ability.addEffect(new GainAbilityAttachedEffect(new MenaceAbility(), AttachmentType.EQUIPMENT).setText("and has menace"));
this.addAbility(ability);
// Equip {4}
this.addAbility(new EquipAbility(4));
}
private DraugrsHelm(final DraugrsHelm card) {
super(card);
}
@Override
public DraugrsHelm copy() {
return new DraugrsHelm(this);
}
}

View file

@ -5,12 +5,11 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.InvertCondition;
import mage.abilities.condition.common.SourceTappedCondition;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.CreateTokenAttachSourceEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
@ -19,10 +18,7 @@ import mage.abilities.keyword.HexproofAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.GiantsAmuletToken;
import mage.players.Player;
import java.util.UUID;
@ -37,7 +33,9 @@ public final class GiantsAmulet extends CardImpl {
this.subtype.add(SubType.EQUIPMENT);
// When Giant's Amulet enters the battlefield, you may pay {3}{U}. If you do, create a 4/4 blue Giant Wizard creature token, then attach Giant's Amulet to it.
this.addAbility(new EntersBattlefieldTriggeredAbility(new GiantsAmuletEffect()));
this.addAbility(new EntersBattlefieldTriggeredAbility(new DoIfCostPaid(
new CreateTokenAttachSourceEffect(new GiantsAmuletToken()), new ManaCostsImpl<>("{3}{U}")
)));
// Equipped creature gets +0/+1 and has "This creature has hexproof as long as it's untapped."
Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(0, 1));
@ -64,42 +62,3 @@ public final class GiantsAmulet extends CardImpl {
return new GiantsAmulet(this);
}
}
class GiantsAmuletEffect extends OneShotEffect {
GiantsAmuletEffect() {
super(Outcome.Benefit);
this.staticText = "you may pay {3}{U}. If you do, create a 4/4 blue Giant Wizard creature token, then attach Giant's Amulet to it.";
}
GiantsAmuletEffect(final GiantsAmuletEffect effect) {
super(effect);
}
@Override
public GiantsAmuletEffect copy() {
return new GiantsAmuletEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
if (player.chooseUse(Outcome.BoostCreature, "Do you want to pay {3}{U}?", source, game)) {
Cost cost = new ManaCostsImpl<>("{3}{U}");
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
CreateTokenEffect effect = new CreateTokenEffect(new GiantsAmuletToken());
if (effect.apply(game, source)) {
Permanent p = game.getPermanent(effect.getLastAddedTokenId());
if (p != null) {
p.addAttachment(source.getSourceId(), source, game);
return true;
}
}
}
}
}
return false;
}
}

View file

@ -5,7 +5,7 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.CreateTokenAttachSourceEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EquipAbility;
@ -14,10 +14,7 @@ import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.RedElementalToken;
import mage.players.Player;
import mage.target.common.TargetAnyTarget;
import java.util.UUID;
@ -33,7 +30,7 @@ public final class MaskOfImmolation extends CardImpl {
this.subtype.add(SubType.EQUIPMENT);
// When Mask of Immolation enters the battlefield, create a 1/1 red Elemental creature token, then attach Mask of Immolation to it.
this.addAbility(new EntersBattlefieldTriggeredAbility(new MaskOfImmolationEffect()));
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenAttachSourceEffect(new RedElementalToken())));
// Equipped creature has "Sacrifice this creature: It deals 1 damage to any target."
Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(1), new SacrificeSourceCost());
@ -55,34 +52,3 @@ public final class MaskOfImmolation extends CardImpl {
return new MaskOfImmolation(this);
}
}
class MaskOfImmolationEffect extends CreateTokenEffect {
MaskOfImmolationEffect() {
super(new RedElementalToken());
staticText = "create a 1/1 red Elemental creature token, then attach {this} to it.";
}
private MaskOfImmolationEffect(final MaskOfImmolationEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || !super.apply(game, source)) {
return false;
}
Permanent p = game.getPermanent(this.getLastAddedTokenId());
if (p == null) {
return false;
}
p.addAttachment(source.getSourceId(), source, game);
return true;
}
@Override
public MaskOfImmolationEffect copy() {
return new MaskOfImmolationEffect(this);
}
}

View file

@ -3,7 +3,7 @@ package mage.cards.w;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.CreateTokenAttachSourceEffect;
import mage.abilities.effects.common.combat.CantBeBlockedByMoreThanOneSourceEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
@ -13,10 +13,7 @@ import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.WolfToken;
import mage.players.Player;
import java.util.UUID;
@ -31,7 +28,7 @@ public final class WolfridersSaddle extends CardImpl {
this.subtype.add(SubType.EQUIPMENT);
// When Wolfrider's Saddle enters the battlefield, create a 2/2 green Wolf creature token, then attach Wolfrider's Saddle to it.
this.addAbility(new EntersBattlefieldTriggeredAbility(new WolfridersSaddleEffect()));
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenAttachSourceEffect(new WolfToken())));
// Equipped creature gets +1/+1 and can't be blocked by more than one creature.
Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(1, 1));
@ -53,34 +50,3 @@ public final class WolfridersSaddle extends CardImpl {
return new WolfridersSaddle(this);
}
}
class WolfridersSaddleEffect extends CreateTokenEffect {
WolfridersSaddleEffect() {
super(new WolfToken());
staticText = "create a 2/2 green Wolf creature token, then attach {this} to it.";
}
private WolfridersSaddleEffect(final WolfridersSaddleEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || !super.apply(game, source)) {
return false;
}
Permanent p = game.getPermanent(this.getLastAddedTokenId());
if (p == null) {
return false;
}
p.addAttachment(source.getSourceId(), source, game);
return true;
}
@Override
public WolfridersSaddleEffect copy() {
return new WolfridersSaddleEffect(this);
}
}

View file

@ -94,6 +94,7 @@ public final class Kaldheim extends ExpansionSet {
cards.add(new SetCardInfo("Divine Gambit", 8, Rarity.UNCOMMON, mage.cards.d.DivineGambit.class));
cards.add(new SetCardInfo("Dogged Pursuit", 85, Rarity.COMMON, mage.cards.d.DoggedPursuit.class));
cards.add(new SetCardInfo("Doomskar Oracle", 10, Rarity.COMMON, mage.cards.d.DoomskarOracle.class));
cards.add(new SetCardInfo("Draugr's Helm", 88, Rarity.UNCOMMON, mage.cards.d.DraugrsHelm.class));
cards.add(new SetCardInfo("Duskwielder", 91, Rarity.COMMON, mage.cards.d.Duskwielder.class));
cards.add(new SetCardInfo("Dwarven Reinforcements", 134, Rarity.COMMON, mage.cards.d.DwarvenReinforcements.class));
cards.add(new SetCardInfo("Egon, God of Death", 92, Rarity.RARE, mage.cards.e.EgonGodOfDeath.class));

View file

@ -0,0 +1,39 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
/**
*
* @author weirddan455
*/
public class CreateTokenAttachSourceEffect extends CreateTokenEffect {
public CreateTokenAttachSourceEffect(Token token) {
super(token);
setText();
staticText = staticText.concat(", then attach {this} to it");
}
private CreateTokenAttachSourceEffect(final CreateTokenAttachSourceEffect effect) {
super(effect);
}
@Override
public CreateTokenAttachSourceEffect copy() {
return new CreateTokenAttachSourceEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
super.apply(game, source);
Permanent token = game.getPermanent(this.getLastAddedTokenId());
if (token != null) {
token.addAttachment(source.getSourceId(), source, game);
return true;
}
return false;
}
}

View file

@ -111,7 +111,7 @@ public class CreateTokenEffect extends OneShotEffect {
}
}
private void setText() {
void setText() {
StringBuilder sb = new StringBuilder("create ");
if (amount.toString().equals("1")) {
sb.append("a ");