From 1961965e8ee3f2a4a964291241fa9f1487131cec Mon Sep 17 00:00:00 2001 From: myersn024 Date: Tue, 10 Mar 2015 15:41:57 -0500 Subject: [PATCH 1/2] Implemented PowerArtifact.java --- .../mage/sets/antiquities/PowerArtifact.java | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/antiquities/PowerArtifact.java diff --git a/Mage.Sets/src/mage/sets/antiquities/PowerArtifact.java b/Mage.Sets/src/mage/sets/antiquities/PowerArtifact.java new file mode 100644 index 0000000000..c4b5bc3ba0 --- /dev/null +++ b/Mage.Sets/src/mage/sets/antiquities/PowerArtifact.java @@ -0,0 +1,111 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.sets.antiquities; + +import java.util.UUID; +import mage.Mana; +import mage.abilities.Ability; +import mage.abilities.ActivatedAbility; +import mage.abilities.SpellAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.cost.CostModificationEffectImpl; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.CostModificationType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetArtifactPermanent; +import mage.util.CardUtil; + +/** + * + * @author nick.myers + */ +public class PowerArtifact extends CardImpl { + + public PowerArtifact(UUID ownerId) { + super(ownerId, 55, "Power Artifact", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{U}{U}"); + this.expansionSetCode = "ATQ"; + this.subtype.add("Aura"); + + // Enchant artifact + TargetPermanent auraTarget = new TargetArtifactPermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Benefit)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // The activation cost of target artifact is reduced by {2}. If this would reduce target + // artifact's activation cost below {1}, target artifact's activation cost becomes {1}. + // Power Artifact has no effect on artifacts that have no activation cost or whose activation + // cost is {0}. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PowerArtifactCostModificationEffect())); + } + + public PowerArtifact(final PowerArtifact card) { + super(card); + } + + @Override + public PowerArtifact copy() { + return new PowerArtifact(this); + } +} + +class PowerArtifactCostModificationEffect extends CostModificationEffectImpl { + + PowerArtifactCostModificationEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); + staticText = "The activation cost of target artifact is reduced by {2}. If this would reduce target artifact's activation cost below {1}, target artifact's activation cost becomes {1}. Power artifact has no effect on artifacts that have no activation cost or whose activation cost is {0}."; + + } + + PowerArtifactCostModificationEffect(PowerArtifactCostModificationEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + Player controller = game.getPlayer(abilityToModify.getControllerId()); + if (controller != null) { + Mana mana = abilityToModify.getManaCostsToPay().getMana(); + int reduce = mana.getColorless(); + if (reduce > 0 && mana.count() == mana.getColorless()) { + reduce--; + } + if (reduce > 2) { + reduce = 2; + } + CardUtil.reduceCost(abilityToModify, reduce); + } + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + Permanent artifact = game.getPermanent(abilityToModify.getSourceId()); + if (artifact != null && artifact.getAttachments().contains(source.getSourceId())) { + if (abilityToModify instanceof ActivatedAbility && !(abilityToModify instanceof SpellAbility)) { + return true; + } + } + return false; + } + + @Override + public PowerArtifactCostModificationEffect copy() { + return new PowerArtifactCostModificationEffect(this); + } + +} From 7c16b2ff591bd862eb86c5ae4326486530310e95 Mon Sep 17 00:00:00 2001 From: myersn024 Date: Wed, 11 Mar 2015 08:04:51 -0500 Subject: [PATCH 2/2] Changed type check in applies() --- Mage.Sets/src/mage/sets/antiquities/PowerArtifact.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/sets/antiquities/PowerArtifact.java b/Mage.Sets/src/mage/sets/antiquities/PowerArtifact.java index c4b5bc3ba0..e4791acea2 100644 --- a/Mage.Sets/src/mage/sets/antiquities/PowerArtifact.java +++ b/Mage.Sets/src/mage/sets/antiquities/PowerArtifact.java @@ -96,7 +96,7 @@ class PowerArtifactCostModificationEffect extends CostModificationEffectImpl { public boolean applies(Ability abilityToModify, Ability source, Game game) { Permanent artifact = game.getPermanent(abilityToModify.getSourceId()); if (artifact != null && artifact.getAttachments().contains(source.getSourceId())) { - if (abilityToModify instanceof ActivatedAbility && !(abilityToModify instanceof SpellAbility)) { + if (abilityToModify.getAbilityType().equals(AbilityType.ACTIVATED)) { return true; } }