From 2c5083b85d114fab606218fbb72f90e199f54283 Mon Sep 17 00:00:00 2001 From: Fenhl Date: Thu, 14 Apr 2016 19:31:46 +0000 Subject: [PATCH] Implement Brand --- .../src/mage/sets/gatecrash/GruulCharm.java | 48 ++---------- Mage.Sets/src/mage/sets/urzassaga/Brand.java | 74 +++++++++++++++++++ .../continuous/GainControlAllEffect.java | 56 ++++++++++++++ 3 files changed, 135 insertions(+), 43 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/urzassaga/Brand.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlAllEffect.java diff --git a/Mage.Sets/src/mage/sets/gatecrash/GruulCharm.java b/Mage.Sets/src/mage/sets/gatecrash/GruulCharm.java index bd7158f5a9..0ac4c187e4 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/GruulCharm.java +++ b/Mage.Sets/src/mage/sets/gatecrash/GruulCharm.java @@ -32,10 +32,9 @@ import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; import mage.constants.*; -import mage.abilities.Ability; import mage.abilities.Mode; -import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.common.combat.CantBlockAllEffect; +import mage.abilities.effects.common.continuous.GainControlAllEffect; import mage.abilities.effects.common.DamageAllEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; @@ -44,19 +43,17 @@ import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.AbilityPredicate; import mage.filter.predicate.other.OwnerPredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; /** * * @author jeffwadsworth */ public class GruulCharm extends CardImpl { - + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Creatures without flying"); private static final FilterPermanent filter2 = new FilterPermanent("all permanents you own"); private static final FilterCreaturePermanent filter3 = new FilterCreaturePermanent("creature with flying"); - + static { filter.add(Predicates.not(new AbilityPredicate(FlyingAbility.class))); filter2.add(new OwnerPredicate(TargetController.YOU)); @@ -70,12 +67,12 @@ public class GruulCharm extends CardImpl { // Choose one - Creatures without flying can't block this turn; this.getSpellAbility().addEffect(new CantBlockAllEffect(filter, Duration.EndOfTurn)); - + // or gain control of all permanents you own; Mode mode = new Mode(); mode.getEffects().add(new GainControlAllEffect(Duration.EndOfGame, filter2)); this.getSpellAbility().addMode(mode); - + // or Gruul Charm deals 3 damage to each creature with flying. Mode mode2 = new Mode(); mode2.getEffects().add(new DamageAllEffect(3, filter3)); @@ -91,38 +88,3 @@ public class GruulCharm extends CardImpl { return new GruulCharm(this); } } - -class GainControlAllEffect extends ContinuousEffectImpl { - - final FilterPermanent filter; - - public GainControlAllEffect(Duration duration, FilterPermanent filter) { - super(duration, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl); - this.filter = filter; - } - - public GainControlAllEffect(final GainControlAllEffect effect) { - super(effect); - this.filter = effect.filter.copy(); - } - - @Override - public GainControlAllEffect copy() { - return new GainControlAllEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { - if (permanent != null) { - permanent.changeControllerId(source.getControllerId(), game); - } - } - return true; - } - - @Override - public String getText(Mode mode) { - return "Gain control of all permanents you own"; - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/urzassaga/Brand.java b/Mage.Sets/src/mage/sets/urzassaga/Brand.java new file mode 100644 index 0000000000..c73522ddaf --- /dev/null +++ b/Mage.Sets/src/mage/sets/urzassaga/Brand.java @@ -0,0 +1,74 @@ +/* + * 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.urzassaga; + +import java.util.UUID; + +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.common.continuous.GainControlAllEffect; +import mage.abilities.keyword.CyclingAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.TargetController; +import mage.filter.FilterPermanent; +import mage.filter.predicate.other.OwnerPredicate; + +/** + * + * @author fenhl + */ +public class Brand extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent("all permanents you own"); + + static { + filter.add(new OwnerPredicate(TargetController.YOU)); + } + + public Brand(UUID ownerId) { + super(ownerId, 176, "Brand", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{R}"); + this.expansionSetCode = "USG"; + + // Gain control of all permanents you own. (This effect lasts indefinitely.) + this.getSpellAbility().addEffect(new GainControlAllEffect(Duration.EndOfGame, filter)); + + // Cycling {2} + this.addAbility(new CyclingAbility(new GenericManaCost(2))); + } + + public Brand(final Brand card) { + super(card); + } + + @Override + public Brand copy() { + return new Brand(this); + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlAllEffect.java new file mode 100644 index 0000000000..c87dfdadae --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlAllEffect.java @@ -0,0 +1,56 @@ +/* + * 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.abilities.effects.common.continuous; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.SubLayer; +import mage.filter.FilterPermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author fenhl + */ +public class GainControlAllEffect extends ContinuousEffectImpl { + + final FilterPermanent filter; + + public GainControlAllEffect(Duration duration, FilterPermanent filter) { + super(duration, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl); + this.filter = filter; + } + + public GainControlAllEffect(final GainControlAllEffect effect) { + super(effect); + this.filter = effect.filter.copy(); + } + + @Override + public GainControlAllEffect copy() { + return new GainControlAllEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) { + if (permanent != null) { + permanent.changeControllerId(source.getControllerId(), game); + } + } + return true; + } + + @Override + public String getText(Mode mode) { + return "Gain control of " + filter; + } +}