From 08f48b41648107b45321280a905afdfdd1bf29a6 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 15 Mar 2015 16:42:53 +0100 Subject: [PATCH] Some minor changes and added framework functions. --- .../sets/commander/ChorusOfTheConclave.java | 8 +- .../sets/darkascension/PyreheartWolf.java | 55 ++++-------- .../sets/dragonsoftarkir/CraterElemental.java | 2 +- .../mage/sets/dragonsoftarkir/IreShaman.java | 2 +- .../common/RevealTargetFromHandCost.java | 2 +- .../combat/CantBeBlockedByOneAllEffect.java | 7 +- .../CantBeBlockedByOneTargetEffect.java | 89 +++++++++++++++++++ 7 files changed, 120 insertions(+), 45 deletions(-) create mode 100644 Mage/src/mage/abilities/effects/common/combat/CantBeBlockedByOneTargetEffect.java diff --git a/Mage.Sets/src/mage/sets/commander/ChorusOfTheConclave.java b/Mage.Sets/src/mage/sets/commander/ChorusOfTheConclave.java index cd43c80ee8..8d3c8c2984 100644 --- a/Mage.Sets/src/mage/sets/commander/ChorusOfTheConclave.java +++ b/Mage.Sets/src/mage/sets/commander/ChorusOfTheConclave.java @@ -129,10 +129,14 @@ class ChorusOfTheConclaveReplacementEffect extends ReplacementEffectImpl { return false; } + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.CAST_SPELL; + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { - if ((event.getType() == GameEvent.EventType.CAST_SPELL) - && event.getPlayerId() == source.getControllerId()) { + if (event.getPlayerId() == source.getControllerId()) { MageObject spellObject = game.getObject(event.getSourceId()); if (spellObject != null) { return spellObject.getCardType().contains(CardType.CREATURE); diff --git a/Mage.Sets/src/mage/sets/darkascension/PyreheartWolf.java b/Mage.Sets/src/mage/sets/darkascension/PyreheartWolf.java index 348c37b8fd..b7bad59029 100644 --- a/Mage.Sets/src/mage/sets/darkascension/PyreheartWolf.java +++ b/Mage.Sets/src/mage/sets/darkascension/PyreheartWolf.java @@ -28,19 +28,17 @@ package mage.sets.darkascension; import java.util.UUID; - -import mage.constants.*; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.AttacksTriggeredAbility; -import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.combat.CantBeBlockedByOneEffect; +import mage.abilities.effects.common.combat.CantBeBlockedByOneAllEffect; import mage.abilities.keyword.UndyingAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.TargetController; import mage.filter.common.FilterCreaturePermanent; -import mage.game.Game; -import mage.game.permanent.Permanent; +import mage.filter.predicate.permanent.ControllerPredicate; /** * @@ -48,18 +46,26 @@ import mage.game.permanent.Permanent; */ public class PyreheartWolf extends CardImpl { + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control"); + + static { + filter.add(new ControllerPredicate(TargetController.YOU)); + } + public PyreheartWolf(UUID ownerId) { super(ownerId, 101, "Pyreheart Wolf", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{2}{R}"); this.expansionSetCode = "DKA"; this.subtype.add("Wolf"); - this.color.setRed(true); this.power = new MageInt(1); this.toughness = new MageInt(1); // Whenever Pyreheart Wolf attacks, each creature you control can't be blocked this turn except by two or more creatures. + this.addAbility(new AttacksTriggeredAbility(new CantBeBlockedByOneAllEffect(2, filter, Duration.EndOfTurn), false)); + + // Undying (When this creature dies, if it had no +1/+1 counters on it, return it to the battlefield under its owner's control with a +1/+1 counter on it.) this.addAbility(new UndyingAbility()); - this.addAbility(new AttacksTriggeredAbility(new PyreheartWolfEffect(), false)); + } public PyreheartWolf(final PyreheartWolf card) { @@ -71,32 +77,3 @@ public class PyreheartWolf extends CardImpl { return new PyreheartWolf(this); } } - -class PyreheartWolfEffect extends OneShotEffect { - - public PyreheartWolfEffect() { - super(Outcome.Benefit); - this.staticText = "creatures you control can't be blocked except by two or more creatures until end of turn"; - } - - public PyreheartWolfEffect(final PyreheartWolfEffect effect) { - super(effect); - } - - @Override - public PyreheartWolfEffect copy() { - return new PyreheartWolfEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - - FilterCreaturePermanent filter = new FilterCreaturePermanent(); - for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { - CantBeBlockedByOneEffect effect = new CantBeBlockedByOneEffect(2, Duration.EndOfTurn); - SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, effect); - perm.addAbility(ability, game); - } - return false; - } -} diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/CraterElemental.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/CraterElemental.java index 642794ddda..9227ad538f 100644 --- a/Mage.Sets/src/mage/sets/dragonsoftarkir/CraterElemental.java +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/CraterElemental.java @@ -71,7 +71,7 @@ public class CraterElemental extends CardImpl { ability = new ActivateIfConditionActivatedAbility( Zone.BATTLEFIELD, new SetPowerSourceEffect(new StaticValue(8), Duration.EndOfTurn), - new ManaCostsImpl("{4}{R}{R}"), + new ManaCostsImpl("{2}{R}"), FormidableCondition.getInstance()); ability.setAbilityWord(AbilityWord.FORMIDABLE); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/IreShaman.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/IreShaman.java index c78e54933a..14cfeeed6d 100644 --- a/Mage.Sets/src/mage/sets/dragonsoftarkir/IreShaman.java +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/IreShaman.java @@ -90,7 +90,7 @@ class IreShamanExileEffect extends OneShotEffect { public IreShamanExileEffect() { super(Outcome.Detriment); - this.staticText = "Exile the top card of your library. Until end of turn, you may play that card"; + this.staticText = "exile the top card of your library. Until end of turn, you may play that card"; } public IreShamanExileEffect(final IreShamanExileEffect effect) { diff --git a/Mage/src/mage/abilities/costs/common/RevealTargetFromHandCost.java b/Mage/src/mage/abilities/costs/common/RevealTargetFromHandCost.java index e97ad38c71..f5b131fa78 100644 --- a/Mage/src/mage/abilities/costs/common/RevealTargetFromHandCost.java +++ b/Mage/src/mage/abilities/costs/common/RevealTargetFromHandCost.java @@ -46,7 +46,7 @@ public class RevealTargetFromHandCost extends CostImpl { public RevealTargetFromHandCost(TargetCardInHand target) { this.addTarget(target); - this.text = "reveal " + target.getTargetName(); + this.text = (target.getNumberOfTargets() == 0 ?"you may ":"") + "reveal " + target.getTargetName(); } public RevealTargetFromHandCost(RevealTargetFromHandCost cost) { diff --git a/Mage/src/mage/abilities/effects/common/combat/CantBeBlockedByOneAllEffect.java b/Mage/src/mage/abilities/effects/common/combat/CantBeBlockedByOneAllEffect.java index 54ef2188b8..6ace98f33f 100644 --- a/Mage/src/mage/abilities/effects/common/combat/CantBeBlockedByOneAllEffect.java +++ b/Mage/src/mage/abilities/effects/common/combat/CantBeBlockedByOneAllEffect.java @@ -55,7 +55,12 @@ public class CantBeBlockedByOneAllEffect extends ContinuousEffectImpl { super(duration, Outcome.Benefit); this.amount = amount; this.filter = filter; - staticText = new StringBuilder("Each ").append(filter.getMessage()).append(" can't be blocked except by ").append(CardUtil.numberToText(amount)).append(" or more creatures").toString(); + StringBuilder sb = new StringBuilder("Each ").append(filter.getMessage()).append(" can't be blocked "); + if (duration.equals(Duration.EndOfTurn)) { + sb.append("this turn "); + } + sb.append("except by ").append(CardUtil.numberToText(amount)).append(" or more creatures").toString(); + staticText = sb.toString(); } public CantBeBlockedByOneAllEffect(final CantBeBlockedByOneAllEffect effect) { diff --git a/Mage/src/mage/abilities/effects/common/combat/CantBeBlockedByOneTargetEffect.java b/Mage/src/mage/abilities/effects/common/combat/CantBeBlockedByOneTargetEffect.java new file mode 100644 index 0000000000..5d42e187ae --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/combat/CantBeBlockedByOneTargetEffect.java @@ -0,0 +1,89 @@ +/* + * 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.abilities.effects.common.combat; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.SubLayer; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author LevelX2 + */ + +public class CantBeBlockedByOneTargetEffect extends ContinuousEffectImpl { + + protected int amount; + + public CantBeBlockedByOneTargetEffect(int amount) { + this(amount, Duration.WhileOnBattlefield); + } + + public CantBeBlockedByOneTargetEffect(int amount, Duration duration) { + super(duration, Outcome.Benefit); + this.amount = amount; + staticText = "Target creature can't be blocked except by " + amount + " or more creatures"; + } + + public CantBeBlockedByOneTargetEffect(final CantBeBlockedByOneTargetEffect effect) { + super(effect); + this.amount = effect.amount; + } + + @Override + public CantBeBlockedByOneTargetEffect copy() { + return new CantBeBlockedByOneTargetEffect(this); + } + + @Override + public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { + for(UUID targetId: getTargetPointer().getTargets(game, source)) { + Permanent perm = game.getPermanent(targetId); + if (perm != null) { + perm.setMinBlockedBy(amount); + } + } + return true; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean hasLayer(Layer layer) { + return layer == Layer.RulesEffects; + } +} \ No newline at end of file