[DOM] Added Shield of the Realm.

This commit is contained in:
LevelX2 2018-04-18 15:18:23 +02:00
parent 3daa66f396
commit 26ce05b42d
5 changed files with 115 additions and 29 deletions

View file

@ -25,13 +25,12 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.cards.g;
import java.util.UUID;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.PreventAllDamageToAttachedEffect;
import mage.abilities.effects.common.PreventDamageToAttachedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.abilities.keyword.ShroudAbility;
@ -45,21 +44,21 @@ import mage.constants.*;
*/
public class GeneralsKabuto extends CardImpl {
public GeneralsKabuto (UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
public GeneralsKabuto(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
this.subtype.add(SubType.EQUIPMENT);
// Equipped creature has shroud. (It can't be the target of spells or abilities.)
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(ShroudAbility.getInstance(), AttachmentType.EQUIPMENT)));
// Prevent all combat damage that would be dealt to equipped creature
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventAllDamageToAttachedEffect(Duration.WhileOnBattlefield, "equipped creature", true)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventDamageToAttachedEffect(Duration.WhileOnBattlefield, AttachmentType.EQUIPMENT, true)));
// Equip {2}
this.addAbility(new EquipAbility(Outcome.PreventDamage, new GenericManaCost(2)));
}
public GeneralsKabuto (final GeneralsKabuto card) {
public GeneralsKabuto(final GeneralsKabuto card) {
super(card);
}

View file

@ -30,14 +30,15 @@ package mage.cards.i;
import java.util.UUID;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.PreventAllDamageToAttachedEffect;
import mage.abilities.effects.common.PreventDamageToAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -49,7 +50,7 @@ import mage.target.common.TargetCreaturePermanent;
public class Inviolability extends CardImpl {
public Inviolability(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}");
this.subtype.add(SubType.AURA);
// Enchant creature
@ -57,9 +58,9 @@ public class Inviolability extends CardImpl {
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Benefit));
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Prevent all damage that would be dealt to enchanted creature.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventAllDamageToAttachedEffect(Duration.WhileOnBattlefield, "enchanted creature", false)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventDamageToAttachedEffect(Duration.WhileOnBattlefield, AttachmentType.EQUIPMENT, false)));
}
public Inviolability(final Inviolability card) {

View file

@ -0,0 +1,69 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.cards.s;
import java.util.UUID;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.PreventDamageToAttachedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
/**
*
* @author LevelX2
*/
public class ShieldOfTheRealm extends CardImpl {
public ShieldOfTheRealm(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
this.subtype.add(SubType.EQUIPMENT);
// If a source would deal damage to equipped creature, prevent 2 of that damage.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventDamageToAttachedEffect(Duration.WhileOnBattlefield, AttachmentType.EQUIPMENT, 2, false)));
// Equip {1}
this.addAbility(new EquipAbility(Outcome.PreventDamage, new GenericManaCost(1)));
}
public ShieldOfTheRealm(final ShieldOfTheRealm card) {
super(card);
}
@Override
public ShieldOfTheRealm copy() {
return new ShieldOfTheRealm(this);
}
}

View file

@ -243,6 +243,7 @@ public class Dominaria extends ExpansionSet {
cards.add(new SetCardInfo("Settle the Score", 103, Rarity.UNCOMMON, mage.cards.s.SettleTheScore.class));
cards.add(new SetCardInfo("Shalai, Voice of Plenty", 35, Rarity.RARE, mage.cards.s.ShalaiVoiceOfPlenty.class));
cards.add(new SetCardInfo("Shanna, Sisay's Legacy", 204, Rarity.UNCOMMON, mage.cards.s.ShannaSisaysLegacy.class));
cards.add(new SetCardInfo("Shield of the Realm", 228, Rarity.UNCOMMON, mage.cards.s.ShieldOfTheRealm.class));
cards.add(new SetCardInfo("Shivan Fire", 142, Rarity.COMMON, mage.cards.s.ShivanFire.class));
cards.add(new SetCardInfo("Short Sword", 229, Rarity.COMMON, mage.cards.s.ShortSword.class));
cards.add(new SetCardInfo("Siege-Gang Commander", 143, Rarity.RARE, mage.cards.s.SiegeGangCommander.class));

View file

@ -25,11 +25,11 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.PreventionEffectImpl;
import mage.constants.AttachmentType;
import mage.constants.Duration;
import mage.game.Game;
import mage.game.events.DamageEvent;
@ -40,49 +40,65 @@ import mage.game.permanent.Permanent;
*
* @author LevelX2
*/
public class PreventAllDamageToAttachedEffect extends PreventionEffectImpl {
public class PreventDamageToAttachedEffect extends PreventionEffectImpl {
private final String attachedDescription;
protected AttachmentType attachmentType;
public PreventAllDamageToAttachedEffect(Duration duration, String attachedDescription, boolean combatOnly) {
super(duration, Integer.MAX_VALUE, false);
this.attachedDescription = attachedDescription;
public PreventDamageToAttachedEffect(Duration duration, AttachmentType attachmentType, boolean combatOnly) {
this(duration, attachmentType, Integer.MAX_VALUE, combatOnly);
}
public PreventDamageToAttachedEffect(Duration duration, AttachmentType attachmentType, int amountToPrevent, boolean combatOnly) {
super(duration, Integer.MAX_VALUE, false, false);
this.attachmentType = attachmentType;
staticText = setText();
}
public PreventAllDamageToAttachedEffect(final PreventAllDamageToAttachedEffect effect) {
public PreventDamageToAttachedEffect(final PreventDamageToAttachedEffect effect) {
super(effect);
this.attachedDescription = effect.attachedDescription;
this.attachmentType = effect.attachmentType;
}
@Override
public PreventAllDamageToAttachedEffect copy() {
return new PreventAllDamageToAttachedEffect(this);
public PreventDamageToAttachedEffect copy() {
return new PreventDamageToAttachedEffect(this);
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (super.applies(event, source, game)) {
if (!onlyCombat || ((DamageEvent)event).isCombatDamage()) {
if (!onlyCombat || ((DamageEvent) event).isCombatDamage()) {
Permanent attachment = game.getPermanent(source.getSourceId());
if (attachment != null
if (attachment != null
&& attachment.getAttachedTo() != null) {
if (event.getTargetId().equals(attachment.getAttachedTo())) {
return true;
}
}
}
}
}
return false;
}
private String setText() {
StringBuilder sb = new StringBuilder("Prevent all ");
if (onlyCombat) {
sb.append("combat ");
StringBuilder sb = new StringBuilder();
if (amountToPrevent == Integer.MAX_VALUE) {
sb.append("prevent all ");
if (onlyCombat) {
sb.append("combat ");
}
sb.append("damage that would be dealt to ");
sb.append(attachmentType.toString()).append(" creature");
} else {
sb.append("If a source would deal ");
if (onlyCombat) {
sb.append("combat ");
}
sb.append("damage to ");
sb.append(attachmentType.toString());
sb.append("creature, prevent ").append(amountToPrevent);;
sb.append("of that damage");
}
sb.append("damage that would be dealt to ");
sb.append(attachedDescription);
return sb.toString();
}
}