mirror of
https://github.com/correl/mage.git
synced 2024-12-27 11:07:39 +00:00
Merge pull request #789 from myersn024/master
Implemented PowerArtifact.java
This commit is contained in:
commit
3f0a235471
1 changed files with 111 additions and 0 deletions
111
Mage.Sets/src/mage/sets/antiquities/PowerArtifact.java
Normal file
111
Mage.Sets/src/mage/sets/antiquities/PowerArtifact.java
Normal file
|
@ -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.getAbilityType().equals(AbilityType.ACTIVATED)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PowerArtifactCostModificationEffect copy() {
|
||||||
|
return new PowerArtifactCostModificationEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue