diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/CombatGroupSimulator.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/CombatGroupSimulator.java index 115fa0c7751..026f7dac5b7 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/CombatGroupSimulator.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/simulators/CombatGroupSimulator.java @@ -86,7 +86,7 @@ public class CombatGroupSimulator implements Serializable { } private void assignDamage(boolean first) { - if (blockers.size() == 0) { + if (blockers.isEmpty()) { if (canDamage(attacker, first)) unblockedDamage += attacker.power; } diff --git a/Mage.Sets/src/mage/sets/mirrodin/SculptingSteel.java b/Mage.Sets/src/mage/sets/mirrodin/SculptingSteel.java new file mode 100644 index 00000000000..1b8e4c568d4 --- /dev/null +++ b/Mage.Sets/src/mage/sets/mirrodin/SculptingSteel.java @@ -0,0 +1,52 @@ +/* + * 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.sets.mirrodin; + +import java.util.UUID; + +/** + * + * @author jeffwadsworth + */ +public class SculptingSteel extends mage.sets.tenth.SculptingSteel { + + public SculptingSteel(UUID ownerId) { + super(ownerId); + this.cardNumber = 238; + this.expansionSetCode = "MRD"; + } + + public SculptingSteel(final SculptingSteel card) { + super(card); + } + + @Override + public SculptingSteel copy() { + return new SculptingSteel(this); + } +} diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/Smite.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/Smite.java index 7ceb4c8a3f8..980687a5efa 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/Smite.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/Smite.java @@ -32,7 +32,9 @@ import mage.Constants.CardType; import mage.Constants.Rarity; import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; -import mage.target.common.TargetBlockingCreature; +import mage.filter.common.FilterBlockedCreature; +import mage.filter.common.FilterCreaturePermanent; +import mage.target.common.TargetCreaturePermanent; /** * @@ -40,6 +42,8 @@ import mage.target.common.TargetBlockingCreature; */ public class Smite extends CardImpl { + private static final FilterCreaturePermanent filter = new FilterBlockedCreature(); + public Smite(UUID ownerId) { super(ownerId, 43, "Smite", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{W}"); this.expansionSetCode = "ROE"; @@ -47,8 +51,8 @@ public class Smite extends CardImpl { this.color.setWhite(true); // Destroy target blocked creature. - this.getSpellAbility().addTarget(new TargetBlockingCreature()); - this.getSpellAbility().addEffect(new DestroyTargetEffect(false)); + this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); + this.getSpellAbility().addEffect(new DestroyTargetEffect(false)); } public Smite(final Smite card) { diff --git a/Mage.Sets/src/mage/sets/shadowmoor/KithkinShielddare.java b/Mage.Sets/src/mage/sets/shadowmoor/KithkinShielddare.java index 8dce1dde94c..10253acd045 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/KithkinShielddare.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/KithkinShielddare.java @@ -38,6 +38,7 @@ import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.continious.BoostTargetEffect; import mage.cards.CardImpl; +import mage.filter.common.FilterBlockingCreature; import mage.filter.common.FilterCreaturePermanent; import mage.target.common.TargetCreaturePermanent; @@ -47,12 +48,7 @@ import mage.target.common.TargetCreaturePermanent; */ public class KithkinShielddare extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("blocking creature"); - - static { - filter.setBlocking(true); - filter.setUseBlocking(true); - } + private static final FilterCreaturePermanent filter = new FilterBlockingCreature("blocking creature"); public KithkinShielddare(UUID ownerId) { super(ownerId, 10, "Kithkin Shielddare", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{W}"); diff --git a/Mage.Sets/src/mage/sets/tempest/AltarOfDementia.java b/Mage.Sets/src/mage/sets/tempest/AltarOfDementia.java new file mode 100644 index 00000000000..f8ea0999f8e --- /dev/null +++ b/Mage.Sets/src/mage/sets/tempest/AltarOfDementia.java @@ -0,0 +1,121 @@ +/* + * 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.sets.tempest; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.SacrificeTargetCost; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.filter.common.FilterControlledPermanent; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetPlayer; +import mage.target.common.TargetControlledPermanent; + +/** + * + * @author jeffwadsworth + */ +public class AltarOfDementia extends CardImpl { + + private static final FilterControlledPermanent filter = new FilterControlledPermanent("creature"); + + static { + filter.getCardType().add(CardType.CREATURE); + } + + public AltarOfDementia(UUID ownerId) { + super(ownerId, 266, "Altar of Dementia", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{2}"); + this.expansionSetCode = "TMP"; + + // Sacrifice a creature: Target player puts a number of cards equal to the sacrificed creature's power from the top of his or her library into his or her graveyard. + Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new AltarOfDementiaEffect(), new SacrificeTargetCost(new TargetControlledPermanent(filter))); + ability.addTarget(new TargetPlayer()); + this.addAbility(ability); + + } + + public AltarOfDementia(final AltarOfDementia card) { + super(card); + } + + @Override + public AltarOfDementia copy() { + return new AltarOfDementia(this); + } +} + +class AltarOfDementiaEffect extends OneShotEffect { + + public AltarOfDementiaEffect() { + super(Constants.Outcome.Damage); + staticText = "Target player puts a number of cards equal to the sacrificed creature's power from the top of his or her library into his or her graveyard"; + } + + public AltarOfDementiaEffect(final AltarOfDementiaEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + int amount = 0; + for (Cost cost: source.getCosts()) { + if (cost instanceof SacrificeTargetCost && ((SacrificeTargetCost)cost).getPermanents().size() > 0) { + amount = ((SacrificeTargetCost)cost).getPermanents().get(0).getPower().getValue(); + break; + } + } + if (amount > 0) { + Player player = game.getPlayer(source.getFirstTarget()); + if (player != null) { + for (int i = 0; i { - private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("blocking creature"); - - static { - filter.setUseBlocking(true); - filter.setBlocking(true); - } + private final static FilterCreaturePermanent filter = new FilterBlockingCreature("blocking creature"); public Gallantry(UUID ownerId) { super(ownerId, 232, "Gallantry", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{1}{W}"); this.expansionSetCode = "TMP"; this.color.setWhite(true); - this.getSpellAbility().addEffect(new BoostTargetEffect(4, 4, Constants.Duration.EndOfTurn)); + + // Target blocking creature gets +4/+4 until end of turn. + this.getSpellAbility().addEffect(new BoostTargetEffect(4, 4, Duration.EndOfTurn)); this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); + // Draw a card. this.getSpellAbility().addEffect(new DrawCardControllerEffect(1)); } diff --git a/Mage.Sets/src/mage/sets/tenth/Righteousness.java b/Mage.Sets/src/mage/sets/tenth/Righteousness.java index af4af7af12e..bd8441f4afa 100644 --- a/Mage.Sets/src/mage/sets/tenth/Righteousness.java +++ b/Mage.Sets/src/mage/sets/tenth/Righteousness.java @@ -33,6 +33,7 @@ import mage.Constants.Duration; import mage.Constants.Rarity; import mage.abilities.effects.common.continious.BoostTargetEffect; import mage.cards.CardImpl; +import mage.filter.common.FilterBlockingCreature; import mage.filter.common.FilterCreaturePermanent; import mage.target.common.TargetCreaturePermanent; @@ -42,12 +43,7 @@ import mage.target.common.TargetCreaturePermanent; */ public class Righteousness extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("blocking creature"); - - static { - filter.setBlocking(true); - filter.setUseBlocking(true); - } + private static final FilterCreaturePermanent filter = new FilterBlockingCreature("blocking creature"); public Righteousness(UUID ownerId) { super(ownerId, 36, "Righteousness", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{W}"); diff --git a/Mage.Sets/src/mage/sets/tenth/SculptingSteel.java b/Mage.Sets/src/mage/sets/tenth/SculptingSteel.java new file mode 100644 index 00000000000..f4dc251a619 --- /dev/null +++ b/Mage.Sets/src/mage/sets/tenth/SculptingSteel.java @@ -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.sets.tenth; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.effects.EntersBattlefieldEffect; +import mage.abilities.effects.common.CopyPermanentEffect; +import mage.cards.CardImpl; +import mage.filter.FilterPermanent; + +/** + * + * @author jeffwadsworth + */ +public class SculptingSteel extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent("artifact"); + + static { + filter.getCardType().add(CardType.ARTIFACT); + } + + public SculptingSteel(UUID ownerId) { + super(ownerId, 342, "Sculpting Steel", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{3}"); + this.expansionSetCode = "10E"; + + // You may have Sculpting Steel enter the battlefield as a copy of any artifact on the battlefield. + Ability ability = new EntersBattlefieldAbility(new EntersBattlefieldEffect(new CopyPermanentEffect(filter)), "You may have {this} enter the battlefield as a copy of any artifact on the battlefield"); + this.addAbility(ability); + } + + public SculptingSteel(final SculptingSteel card) { + super(card); + } + + @Override + public SculptingSteel copy() { + return new SculptingSteel(this); + } +} diff --git a/Mage.Sets/src/mage/sets/tenth/SteelGolem.java b/Mage.Sets/src/mage/sets/tenth/SteelGolem.java new file mode 100644 index 00000000000..bad51fe4d35 --- /dev/null +++ b/Mage.Sets/src/mage/sets/tenth/SteelGolem.java @@ -0,0 +1,109 @@ +/* + * 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.sets.tenth; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.GameEvent; + +/** + * + * @author jeffwadsworth + */ +public class SteelGolem extends CardImpl { + + public SteelGolem(UUID ownerId) { + super(ownerId, 344, "Steel Golem", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}"); + this.expansionSetCode = "10E"; + this.subtype.add("Golem"); + + this.power = new MageInt(3); + this.toughness = new MageInt(4); + + // You can't cast creature spells. + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new SteelGolemEffect())); + } + + public SteelGolem(final SteelGolem card) { + super(card); + } + + @Override + public SteelGolem copy() { + return new SteelGolem(this); + } +} + +class SteelGolemEffect extends ReplacementEffectImpl { + + public SteelGolemEffect() { + super(Constants.Duration.WhileOnBattlefield, Constants.Outcome.Detriment); + staticText = "You can't cast creature spells."; + } + + public SteelGolemEffect(final SteelGolemEffect effect) { + super(effect); + } + + @Override + public SteelGolemEffect copy() { + return new SteelGolemEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + return true; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getType() == GameEvent.EventType.CAST_SPELL && event.getPlayerId().equals(source.getControllerId())) { + MageObject object = game.getObject(event.getSourceId()); + if (object.getCardType().contains(CardType.CREATURE)) { + return true; + } + } + return false; + } + +} + diff --git a/Mage.Sets/src/mage/sets/weatherlight/SteelGolem.java b/Mage.Sets/src/mage/sets/weatherlight/SteelGolem.java new file mode 100644 index 00000000000..21e14ffbc71 --- /dev/null +++ b/Mage.Sets/src/mage/sets/weatherlight/SteelGolem.java @@ -0,0 +1,52 @@ +/* + * 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.sets.weatherlight; + +import java.util.UUID; + +/** + * + * @author jeffwadsworth + */ +public class SteelGolem extends mage.sets.tenth.SteelGolem { + + public SteelGolem(UUID ownerId) { + super(ownerId); + this.cardNumber = 157; + this.expansionSetCode = "WTH"; + } + + public SteelGolem(final SteelGolem card) { + super(card); + } + + @Override + public SteelGolem copy() { + return new SteelGolem(this); + } +} diff --git a/Mage/src/mage/filter/common/FilterBlockedCreature.java b/Mage/src/mage/filter/common/FilterBlockedCreature.java new file mode 100644 index 00000000000..750bd252416 --- /dev/null +++ b/Mage/src/mage/filter/common/FilterBlockedCreature.java @@ -0,0 +1,71 @@ +/* + * 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.filter.common; + +import mage.game.Game; +import mage.game.combat.CombatGroup; +import mage.game.permanent.Permanent; + +/** + * + * @author North + */ +public class FilterBlockedCreature extends FilterCreaturePermanent { + + public FilterBlockedCreature() { + this("blocked creature"); + } + + public FilterBlockedCreature(String name) { + super(name); + } + + public FilterBlockedCreature(final FilterBlockedCreature filter) { + super(filter); + } + + @Override + public FilterBlockedCreature copy() { + return new FilterBlockedCreature(this); + } + + @Override + public boolean match(Permanent permanent, Game game) { + if (!super.match(permanent, game)) { + return notFilter; + } + + for (CombatGroup combatGroup : game.getCombat().getGroups()) { + if (!combatGroup.getBlockers().isEmpty() && combatGroup.getAttackers().contains(permanent.getId())) { + return !notFilter; + } + } + + return notFilter; + } +} diff --git a/Mage/src/mage/filter/common/FilterCreaturePermanent.java b/Mage/src/mage/filter/common/FilterCreaturePermanent.java index 6ce0c9ef327..eb6622e0e65 100644 --- a/Mage/src/mage/filter/common/FilterCreaturePermanent.java +++ b/Mage/src/mage/filter/common/FilterCreaturePermanent.java @@ -43,8 +43,8 @@ public class FilterCreaturePermanent> exten protected boolean attacking; protected boolean useBlocking; protected boolean blocking; - protected boolean useDamageDealt; - protected boolean damageDealt; + protected boolean useDamageDealt; + protected boolean damageDealt; public FilterCreaturePermanent() { this("creature"); @@ -61,8 +61,8 @@ public class FilterCreaturePermanent> exten this.attacking = filter.attacking; this.useBlocking = filter.useBlocking; this.blocking = filter.blocking; - this.useDamageDealt = filter.useDamageDealt; - this.damageDealt = filter.damageDealt; + this.useDamageDealt = filter.useDamageDealt; + this.damageDealt = filter.damageDealt; this.useTapped = filter.useTapped; this.tapped = filter.tapped; } @@ -85,17 +85,18 @@ public class FilterCreaturePermanent> exten return notFilter; } } - return !notFilter; - } + return !notFilter; + } if (useBlocking && (permanent.getBlocking() > 0) != blocking) return notFilter; - if (useDamageDealt) { - // use this instead of getDamage() because damage is reset in case of regeneration - if (permanent.getDealtDamageByThisTurn().isEmpty()) - return notFilter; - } + if (useDamageDealt) { + // use this instead of getDamage() because damage is reset in case of regeneration + if (permanent.getDealtDamageByThisTurn().isEmpty()) { + return notFilter; + } + } return !notFilter; } @@ -114,21 +115,23 @@ public class FilterCreaturePermanent> exten public void setBlocking ( boolean blocking ) { this.blocking = blocking; } - /** - * Select creatures dependant if they already got damage - * during the current turn. Works also if the creature - * was meanwhile regenerated during the turn. - * - * @param useDamageDealt - */ - public void setUseDamageDealt ( boolean useDamageDealt ) { + + /** + * Select creatures dependant if they already got damage during the current turn. Works also if the creature was + * meanwhile regenerated during the turn. + * + * @param useDamageDealt + */ + public void setUseDamageDealt(boolean useDamageDealt) { this.useDamageDealt = useDamageDealt; } - /** - * Select creatures that got damage dealt to this turn. - * @param damageDealt - */ - public void setDamageDealt ( boolean damageDealt ) { + + /** + * Select creatures that got damage dealt to this turn. + * + * @param damageDealt + */ + public void setDamageDealt(boolean damageDealt) { this.damageDealt = damageDealt; } diff --git a/Mage/src/mage/target/common/TargetBlockingCreature.java b/Mage/src/mage/target/common/TargetBlockingCreature.java deleted file mode 100644 index d5025762072..00000000000 --- a/Mage/src/mage/target/common/TargetBlockingCreature.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -* 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.target.common; - -import mage.filter.common.FilterBlockingCreature; - -/** - * - * @author jeff - */ - -public class TargetBlockingCreature extends TargetCreaturePermanent { - - public TargetBlockingCreature() { - this(1, 1, new FilterBlockingCreature(), false); - } - - public TargetBlockingCreature(int numTargets) { - this(numTargets, numTargets, new FilterBlockingCreature(), false); - } - - public TargetBlockingCreature(int minNumTargets, int maxNumTargets, FilterBlockingCreature filter, boolean notTarget) { - super(minNumTargets, maxNumTargets, filter, notTarget); - this.targetName = filter.getMessage(); - } - - public TargetBlockingCreature(final TargetBlockingCreature target) { - super(target); - } - - @Override - public TargetBlockingCreature copy() { - return new TargetBlockingCreature(this); - } - -}