diff --git a/Mage.Player.AI/src/mage/player/ai/ComputerPlayer.java b/Mage.Player.AI/src/mage/player/ai/ComputerPlayer.java index d96e56fe44..e3b13246fe 100644 --- a/Mage.Player.AI/src/mage/player/ai/ComputerPlayer.java +++ b/Mage.Player.AI/src/mage/player/ai/ComputerPlayer.java @@ -67,6 +67,7 @@ import mage.abilities.effects.ReplacementEffect; import mage.abilities.effects.common.BecomesCreatureSourceEOTEffect; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.keyword.DoubleStrikeAbility; +import mage.abilities.keyword.EquipAbility; import mage.abilities.keyword.FirstStrikeAbility; import mage.abilities.keyword.TrampleAbility; import mage.abilities.mana.ManaAbility; @@ -457,6 +458,8 @@ public class ComputerPlayer> extends PlayerImpl i for (Permanent permanent: game.getBattlefield().getAllActivePermanents(playerId)) { for (ActivatedAbility ability: permanent.getAbilities().getActivatedAbilities(Zone.BATTLEFIELD)) { if (!(ability instanceof ManaAbility) && ability.canActivate(playerId, game)) { + if (ability instanceof EquipAbility && permanent.getAttachedTo() != null) + continue; ManaOptions abilityOptions = ability.getManaCosts().getOptions(); if (ability.getManaCosts().getVariableCosts().size() > 0) { //don't use variable mana costs unless there is at least 3 extra mana for X @@ -479,6 +482,25 @@ public class ComputerPlayer> extends PlayerImpl i } } } + for (Card card: graveyard.getCards(game)) { + for (ActivatedAbility ability: card.getAbilities().getActivatedAbilities(Zone.GRAVEYARD)) { + if (ability.canActivate(playerId, game)) { + ManaOptions abilityOptions = ability.getManaCosts().getOptions(); + if (abilityOptions.size() == 0) { + playableAbilities.add(ability); + } + else { + for (Mana mana: abilityOptions) { + for (Mana avail: available) { + if (mana.enough(avail)) { + playableAbilities.add(ability); + } + } + } + } + } + } + } if (logger.isLoggable(Level.FINE)) logger.fine("findPlayables: " + playableInstant.toString() + "---" + playableNonInstant.toString() + "---" + playableAbilities.toString() ); } @@ -911,7 +933,7 @@ public class ComputerPlayer> extends PlayerImpl i for (Card card: this.playableInstant) { if (card.getSpellAbility().canActivate(playerId, game)) { for (Effect effect: card.getSpellAbility().getEffects()) { - if (effect.getOutcome().equals(Outcome.DestroyPermanent)) { + if (effect.getOutcome().equals(Outcome.DestroyPermanent) || effect.getOutcome().equals(Outcome.ReturnToHand)) { if (card.getSpellAbility().getTargets().get(0).canTarget(creatureId, card.getSpellAbility(), game)) { if (this.activateAbility(card.getSpellAbility(), game)) return; diff --git a/Mage.Sets/src/mage/sets/magic2010/ElvishArchdruid.java b/Mage.Sets/src/mage/sets/magic2010/ElvishArchdruid.java index 37ff2c5c3a..086e020ab4 100644 --- a/Mage.Sets/src/mage/sets/magic2010/ElvishArchdruid.java +++ b/Mage.Sets/src/mage/sets/magic2010/ElvishArchdruid.java @@ -36,11 +36,11 @@ import mage.Constants.Zone; import mage.MageInt; import mage.Mana; import mage.abilities.Ability; -import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.effects.common.BoostControlledEffect; import mage.abilities.effects.common.ManaEffect; +import mage.abilities.mana.ManaAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; @@ -67,8 +67,7 @@ public class ElvishArchdruid extends CardImpl { this.toughness = new MageInt(2); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter, true))); - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ElvishArchdruidEffect(), new TapSourceCost()); - this.addAbility(ability); + this.addAbility(new ElvishArchdruidAbility()); } public ElvishArchdruid(final ElvishArchdruid card) { @@ -85,40 +84,58 @@ public class ElvishArchdruid extends CardImpl { return "121692_typ_reg_sty_010.jpg"; } + class ElvishArchdruidAbility extends ManaAbility { + + public ElvishArchdruidAbility() { + super(Zone.BATTLEFIELD, new ElvishArchdruidEffect(), new TapSourceCost()); + } + + public ElvishArchdruidAbility(final ElvishArchdruidAbility ability) { + super(ability); + } + + @Override + public ElvishArchdruidAbility copy() { + return new ElvishArchdruidAbility(this); + } + + @Override + public Mana getNetMana(Game game) { + if (game == null) + return new Mana(); + return Mana.GreenMana(game.getBattlefield().countAll(filter, controllerId)); + } + + } + + class ElvishArchdruidEffect extends ManaEffect { + + public ElvishArchdruidEffect() { + super(new Mana()); + } + + public ElvishArchdruidEffect(final ElvishArchdruidEffect effect) { + super(effect); + } + + @Override + public ElvishArchdruidEffect copy() { + return new ElvishArchdruidEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + this.mana.clear(); + int amount = game.getBattlefield().countAll(filter, source.getControllerId()); + this.mana.setGreen(amount); + return super.apply(game, source); + } + + @Override + public String getText(Ability source) { + return "Add {G} to your mana pool for each Elf you control"; + } + + } } -class ElvishArchdruidEffect extends ManaEffect { - - private static FilterCreaturePermanent filter = new FilterCreaturePermanent("Elf creatures"); - - static { - filter.getSubtype().add("Elf"); - } - - public ElvishArchdruidEffect() { - super(new Mana()); - } - - public ElvishArchdruidEffect(final ElvishArchdruidEffect effect) { - super(effect); - } - - @Override - public ElvishArchdruidEffect copy() { - return new ElvishArchdruidEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - this.mana.clear(); - int amount = game.getBattlefield().countAll(filter, source.getControllerId()); - this.mana.setGreen(amount); - return super.apply(game, source); - } - - @Override - public String getText(Ability source) { - return "Add {G} to your mana pool for each Elf you control"; - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/magic2010/GlacialFortress.java b/Mage.Sets/src/mage/sets/magic2010/GlacialFortress.java index 4208f54c82..cb52319d27 100644 --- a/Mage.Sets/src/mage/sets/magic2010/GlacialFortress.java +++ b/Mage.Sets/src/mage/sets/magic2010/GlacialFortress.java @@ -32,8 +32,6 @@ import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.abilities.common.EntersBattlefieldAbility; -import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.EntersBattlefieldEffect; import mage.abilities.effects.common.TapSourceUnlessControlsEffect; import mage.abilities.mana.BlueManaAbility; import mage.abilities.mana.WhiteManaAbility; diff --git a/Mage.Sets/src/mage/sets/magic2010/SunpetalGrove.java b/Mage.Sets/src/mage/sets/magic2010/SunpetalGrove.java index 1b07757f63..8ebece3875 100644 --- a/Mage.Sets/src/mage/sets/magic2010/SunpetalGrove.java +++ b/Mage.Sets/src/mage/sets/magic2010/SunpetalGrove.java @@ -48,10 +48,10 @@ public class SunpetalGrove extends CardImpl { private static FilterLandPermanent filter = new FilterLandPermanent(); static { - filter.getSubtype().add("Swamp"); - filter.getSubtype().add("Mountain"); + filter.getSubtype().add("Forest"); + filter.getSubtype().add("Plains"); filter.setScopeSubtype(ComparisonScope.Any); - filter.setMessage("Swamp or a Mountain"); + filter.setMessage("Forest or a Plains"); } public SunpetalGrove(UUID ownerId) { diff --git a/Mage.Sets/src/mage/sets/tenth/Clone.java b/Mage.Sets/src/mage/sets/tenth/Clone.java index f630467cbe..3447b756ac 100644 --- a/Mage.Sets/src/mage/sets/tenth/Clone.java +++ b/Mage.Sets/src/mage/sets/tenth/Clone.java @@ -34,6 +34,7 @@ import mage.Constants.Rarity; import mage.Constants.Zone; import mage.MageInt; import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.CopyEffect; import mage.cards.CardImpl; @@ -53,7 +54,7 @@ public class Clone extends CardImpl { this.power = new MageInt(0); this.toughness = new MageInt(0); - Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new CopyEffect()); + Ability ability = new EntersBattlefieldAbility(new CopyEffect(), "You may have Clone enter the battlefield as a copy of any creature on the battlefield"); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/zendikar/AetherFigment.java b/Mage.Sets/src/mage/sets/zendikar/AetherFigment.java index 0b1312afae..9374fc6afb 100644 --- a/Mage.Sets/src/mage/sets/zendikar/AetherFigment.java +++ b/Mage.Sets/src/mage/sets/zendikar/AetherFigment.java @@ -30,11 +30,16 @@ package mage.sets.zendikar; import java.util.UUID; import mage.Constants.CardType; +import mage.Constants.Duration; import mage.Constants.Rarity; import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.common.AddPlusOneCountersSourceEffect; +import mage.abilities.effects.common.GainAbilitySourceEffect; import mage.abilities.keyword.KickerAbility; +import mage.abilities.keyword.UnblockableAbility; import mage.cards.CardImpl; /** @@ -44,16 +49,18 @@ import mage.cards.CardImpl; public class AetherFigment extends CardImpl { public AetherFigment(UUID ownerId) { - super(ownerId, 40, "Æther Figment", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{U}"); + super(ownerId, 40, "AEther Figment", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{U}"); this.expansionSetCode = "ZEN"; this.subtype.add("Illusion"); this.color.setBlue(true); this.power = new MageInt(1); this.toughness = new MageInt(1); - KickerAbility ability = new KickerAbility(new AddPlusOneCountersSourceEffect(2), false); - ability.addManaCost(new GenericManaCost(3)); - this.addAbility(ability); + this.addAbility(UnblockableAbility.getInstance()); + Ability ability1 = new EntersBattlefieldTriggeredAbility(new AddPlusOneCountersSourceEffect(2)); + KickerAbility ability2 = new KickerAbility(new GainAbilitySourceEffect(ability1, Duration.WhileOnBattlefield), false); + ability2.addManaCost(new GenericManaCost(3)); + this.addAbility(ability2); } public AetherFigment(final AetherFigment card) { diff --git a/Mage.Sets/src/mage/sets/zendikar/ConquerorsPledge.java b/Mage.Sets/src/mage/sets/zendikar/ConquerorsPledge.java index 360d844d7b..a9d232d784 100644 --- a/Mage.Sets/src/mage/sets/zendikar/ConquerorsPledge.java +++ b/Mage.Sets/src/mage/sets/zendikar/ConquerorsPledge.java @@ -45,7 +45,7 @@ import mage.game.permanent.token.Token; public class ConquerorsPledge extends CardImpl { public ConquerorsPledge(UUID ownerId) { - super(ownerId, 8, "Conquerors Pledge", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{W}{W}{W}"); + super(ownerId, 8, "Conqueror's Pledge", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{W}{W}{W}"); this.expansionSetCode = "ZEN"; this.color.setWhite(true); this.getSpellAbility().addEffect(new CreateTokenEffect(new KorSoldierToken(), 6)); diff --git a/Mage.Sets/src/mage/sets/zendikar/GoblinRuinblaster.java b/Mage.Sets/src/mage/sets/zendikar/GoblinRuinblaster.java index fabe96cd80..08294b64f9 100644 --- a/Mage.Sets/src/mage/sets/zendikar/GoblinRuinblaster.java +++ b/Mage.Sets/src/mage/sets/zendikar/GoblinRuinblaster.java @@ -64,7 +64,7 @@ public class GoblinRuinblaster extends CardImpl { ability1.addTarget(new TargetNonBasicLandPermanent()); KickerAbility ability2 = new KickerAbility(new GainAbilitySourceEffect(ability1, Duration.WhileOnBattlefield), false); ability2.addManaCost(new ColoredManaCost(ColoredManaSymbol.R)); - this.addAbility(ability1); + this.addAbility(ability2); } diff --git a/Mage/src/mage/abilities/common/EntersBattlefieldTappedAbility.java b/Mage/src/mage/abilities/common/EntersBattlefieldTappedAbility.java index 1463decb72..83b4d60789 100644 --- a/Mage/src/mage/abilities/common/EntersBattlefieldTappedAbility.java +++ b/Mage/src/mage/abilities/common/EntersBattlefieldTappedAbility.java @@ -28,7 +28,6 @@ package mage.abilities.common; -import java.io.ObjectStreamException; import mage.Constants.Zone; import mage.abilities.StaticAbility; import mage.abilities.effects.EntersBattlefieldEffect; diff --git a/Mage/src/mage/abilities/effects/EntersBattlefieldEffect.java b/Mage/src/mage/abilities/effects/EntersBattlefieldEffect.java index d15a97ec09..4af112aa6f 100644 --- a/Mage/src/mage/abilities/effects/EntersBattlefieldEffect.java +++ b/Mage/src/mage/abilities/effects/EntersBattlefieldEffect.java @@ -78,17 +78,17 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl> extends MageObjectImpl PermanentCard permanent = new PermanentCard(this, controllerId); game.getBattlefield().addPermanent(permanent); game.setZone(objectId, Zone.BATTLEFIELD); - permanent.entersBattlefield(sourceId, game); game.applyEffects(); + permanent.entersBattlefield(sourceId, game); game.fireEvent(new ZoneChangeEvent(permanent, controllerId, fromZone, Zone.BATTLEFIELD)); return true; } diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index 8df5e48d18..c7e3ca8fa0 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -106,8 +106,8 @@ public class Spell> implements StackObject, Card { return false; } else { - result = card.putOntoBattlefield(game, Zone.HAND, ability.getId(), controllerId); resolveKicker(game); + result = card.putOntoBattlefield(game, Zone.HAND, ability.getId(), controllerId); return result; } }