diff --git a/Mage.Sets/src/mage/sets/conspiracy/TravelersCloak.java b/Mage.Sets/src/mage/sets/conspiracy/TravelersCloak.java new file mode 100644 index 00000000000..ad8ac3724a5 --- /dev/null +++ b/Mage.Sets/src/mage/sets/conspiracy/TravelersCloak.java @@ -0,0 +1,94 @@ +/* + * 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.conspiracy; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.AsEntersBattlefieldAbility; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.ChooseLandTypeEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.abilities.keyword.LandwalkAbility; +import mage.cards.CardImpl; +import mage.constants.AttachmentType; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.common.FilterLandPermanent; +import mage.filter.predicate.mageobject.ChosenSubtypePredicate; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author emerald000 + */ +public class TravelersCloak extends CardImpl { + + public TravelersCloak(UUID ownerId) { + super(ownerId, 109, "Traveler's Cloak", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}"); + this.expansionSetCode = "CNS"; + this.subtype.add("Aura"); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // As Traveler's Cloak enters the battlefield, choose a land type. + this.addAbility(new AsEntersBattlefieldAbility(new ChooseLandTypeEffect(Outcome.AddAbility))); + + // When Traveler's Cloak enters the battlefield, draw a card. + this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1), false)); + + // Enchanted creature has landwalk of the chosen type. + FilterLandPermanent filter = new FilterLandPermanent("Landwalk of the chosen type"); + filter.add(new ChosenSubtypePredicate(this.getId())); + Ability landwalkAbility = new LandwalkAbility(filter); + Effect effect = new GainAbilityAttachedEffect(landwalkAbility, AttachmentType.AURA); + effect.setText("Enchanted creature has landwalk of the chosen type"); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); + } + + public TravelersCloak(final TravelersCloak card) { + super(card); + } + + @Override + public TravelersCloak copy() { + return new TravelersCloak(this); + } +} diff --git a/Mage.Sets/src/mage/sets/guildpact/NivixAerieOfTheFiremind.java b/Mage.Sets/src/mage/sets/guildpact/NivixAerieOfTheFiremind.java new file mode 100644 index 00000000000..d1a35ddeee7 --- /dev/null +++ b/Mage.Sets/src/mage/sets/guildpact/NivixAerieOfTheFiremind.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.guildpact; + +import java.util.UUID; + +/** + * + * @author emerald000 + */ +public class NivixAerieOfTheFiremind extends mage.sets.izzetvsgolgari.NivixAerieOfTheFiremind { + + public NivixAerieOfTheFiremind(UUID ownerId) { + super(ownerId); + this.cardNumber = 160; + this.expansionSetCode = "GPT"; + } + + public NivixAerieOfTheFiremind(final NivixAerieOfTheFiremind card) { + super(card); + } + + @Override + public NivixAerieOfTheFiremind copy() { + return new NivixAerieOfTheFiremind(this); + } +} diff --git a/Mage.Sets/src/mage/sets/invasion/TravelersCloak.java b/Mage.Sets/src/mage/sets/invasion/TravelersCloak.java new file mode 100644 index 00000000000..6a748bdb5a6 --- /dev/null +++ b/Mage.Sets/src/mage/sets/invasion/TravelersCloak.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.invasion; + +import java.util.UUID; + +/** + * + * @author emerald000 + */ +public class TravelersCloak extends mage.sets.conspiracy.TravelersCloak { + + public TravelersCloak(UUID ownerId) { + super(ownerId); + this.cardNumber = 83; + this.expansionSetCode = "INV"; + } + + public TravelersCloak(final TravelersCloak card) { + super(card); + } + + @Override + public TravelersCloak copy() { + return new TravelersCloak(this); + } +} diff --git a/Mage.Sets/src/mage/sets/izzetvsgolgari/NivixAerieOfTheFiremind.java b/Mage.Sets/src/mage/sets/izzetvsgolgari/NivixAerieOfTheFiremind.java new file mode 100644 index 00000000000..ba37bcea266 --- /dev/null +++ b/Mage.Sets/src/mage/sets/izzetvsgolgari/NivixAerieOfTheFiremind.java @@ -0,0 +1,146 @@ +/* + * 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.izzetvsgolgari; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.mana.ColorlessManaAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.constants.AsThoughEffectType; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Library; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author emerald000 + */ +public class NivixAerieOfTheFiremind extends CardImpl { + + public NivixAerieOfTheFiremind(UUID ownerId) { + super(ownerId, 36, "Nivix, Aerie of the Firemind", Rarity.UNCOMMON, new CardType[]{CardType.LAND}, ""); + this.expansionSetCode = "DDJ"; + + // {tap}: Add {1} to your mana pool. + this.addAbility(new ColorlessManaAbility()); + + // {2}{U}{R}, {tap}: Exile the top card of your library. Until your next turn, you may cast that card if it's an instant or sorcery. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new NivixAerieOfTheFiremindEffect(), new ManaCostsImpl<>("{2}{U}{R}")); + ability.addCost(new TapSourceCost()); + this.addAbility(ability); + } + + public NivixAerieOfTheFiremind(final NivixAerieOfTheFiremind card) { + super(card); + } + + @Override + public NivixAerieOfTheFiremind copy() { + return new NivixAerieOfTheFiremind(this); + } +} + +class NivixAerieOfTheFiremindEffect extends OneShotEffect { + + NivixAerieOfTheFiremindEffect() { + super(Outcome.Benefit); + this.staticText = "Exile the top card of your library. Until your next turn, you may cast that card if it's an instant or sorcery"; + } + + NivixAerieOfTheFiremindEffect(final NivixAerieOfTheFiremindEffect effect) { + super(effect); + } + + @Override + public NivixAerieOfTheFiremindEffect copy() { + return new NivixAerieOfTheFiremindEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Library library = controller.getLibrary(); + if (library.size() > 0) { + Card card = library.removeFromTop(game); + if (card != null + && controller.moveCardsToExile(card, source, game, true, source.getSourceId(), "Nivix, Aerie of the Firemind") + && (card.getCardType().contains(CardType.INSTANT) || card.getCardType().contains(CardType.SORCERY))) { + ContinuousEffect effect = new NivixAerieOfTheFiremindCanCastEffect(); + effect.setTargetPointer(new FixedTarget(card.getId())); + game.addEffect(effect, source); + } + } + return true; + } + return false; + } +} + +class NivixAerieOfTheFiremindCanCastEffect extends AsThoughEffectImpl { + + NivixAerieOfTheFiremindCanCastEffect() { + super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.UntilYourNextTurn, Outcome.Benefit); + staticText = "Until your next turn, you may cast that card"; + } + + NivixAerieOfTheFiremindCanCastEffect(final NivixAerieOfTheFiremindCanCastEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public NivixAerieOfTheFiremindCanCastEffect copy() { + return new NivixAerieOfTheFiremindCanCastEffect(this); + } + + @Override + public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { + return this.getTargetPointer().getFirst(game, source) != null + && this.getTargetPointer().getFirst(game, source).equals(sourceId) + && source.getControllerId().equals(affectedControllerId) + && game.getState().getZone(sourceId).equals(Zone.EXILED); + } +} diff --git a/Mage/pom.xml b/Mage/pom.xml index 457b1f8d257..b164c1d678e 100644 --- a/Mage/pom.xml +++ b/Mage/pom.xml @@ -39,9 +39,6 @@ - - src - org.apache.maven.plugins diff --git a/Mage/src/main/java/mage/counters/Counter.java b/Mage/src/main/java/mage/counters/Counter.java index f3a125ec283..7a9c16e5b5f 100644 --- a/Mage/src/main/java/mage/counters/Counter.java +++ b/Mage/src/main/java/mage/counters/Counter.java @@ -28,64 +28,145 @@ package mage.counters; +import org.apache.log4j.Logger; + import java.io.Serializable; /** - * * @author BetaSteward_at_googlemail.com */ public class Counter implements Serializable { - protected String name; + private static final Logger logger = Logger.getLogger(Counter.class); + + protected final String name; protected int count; - public Counter(String name) { + + /** + * Creates a {@link Counter} with the provided {@code name} and a default value of 1 + * + * @param name the name of this counter. + */ + public Counter(final String name) { this.name = name; this.count = 1; } - public Counter(String name, int count) { + + /** + * Creates a {@link Counter} with the provided {@code name} and {@code count} + * + * @param name the name of this counter. + * @param count the value of this counter. + */ + public Counter(final String name, final int count) { this.name = name; this.count = count; } + + /** + * Creates a {@link Counter} from an existing {@link Counter} object. + * + * @param counter the {@link Counter} to create a copy from. + */ public Counter(final Counter counter) { this.name = counter.name; this.count = counter.count; } - public void add() { + /** + * Increases the {@code count} by 1 + */ + public void increase() { count++; } + /** + * Adds the passed in {@code amount} to the {@code count} + * + * @param amount the value to add to the {@code count} + */ public void add(int amount) { count += amount; } - public void remove() { + + /** + * Decreases the {@code count} by one. Will not allow the count to be less than 0. + * If an attempt is made to make the count be less than zero, the call will be logged. + */ + public void decrease() { if (count > 0) { count--; + } else { + logger.warn("An attempt was made to set the counter '" + name + + "' to less than 0. Setting to 0."); } } + + /** + * Decreases the {@code count} by tne passed in {@code amount}. Will not allow the count + * to be less than 0. If an attempt is made to make the count be less than zero, the call will be logged. + */ public void remove(int amount) { if (count > amount) { count -= amount; - } - else { + } else { + logger.warn("An attempt was made to set the counter '" + name + + "' to less than 0. Setting to 0."); count = 0; } } + + /** + * Returns the name of this {@link Counter} + * + * @return the name of this {@link Counter} + */ public String getName() { return name; } + /** + * Returns the count of this {@link Counter} + * + * @return the count of this {@link Counter} + */ public int getCount() { return count; } + /** + * Returns a deep copy of this object. + * + * @return a deep copy of this object. + */ public Counter copy() { return new Counter(this); } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Counter counter = (Counter) o; + + if (count != counter.count) return false; + return !(name != null ? !name.equals(counter.name) : counter.name != null); + + } + + + @Override + public int hashCode() { + int result = name != null ? name.hashCode() : 0; + result = 31 * result + count; + return result; + } } diff --git a/Mage/src/main/java/mage/counters/Counters.java b/Mage/src/main/java/mage/counters/Counters.java index 473106f081f..21842e59783 100644 --- a/Mage/src/main/java/mage/counters/Counters.java +++ b/Mage/src/main/java/mage/counters/Counters.java @@ -56,7 +56,7 @@ public class Counters extends HashMap implements Serializable { if (!this.containsKey(name)) { this.put(name, new Counter(name)); } - this.get(name).add(); + this.get(name).increase(); } public void addCounter(String name, int amount) { diff --git a/Mage/src/test/java/mage/ManaTest.java b/Mage/src/test/java/mage/ManaTest.java index 49f7cab20e2..796c3c55d79 100644 --- a/Mage/src/test/java/mage/ManaTest.java +++ b/Mage/src/test/java/mage/ManaTest.java @@ -1,16 +1,15 @@ package mage; +import static junit.framework.TestCase.assertFalse; import mage.constants.ColoredManaSymbol; import mage.constants.ManaType; import mage.filter.FilterMana; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import static junit.framework.Assert.assertTrue; -import static junit.framework.TestCase.assertFalse; -import static org.junit.Assert.*; - /** * Custom unit tests for {link Mana}. * @@ -21,7 +20,6 @@ public class ManaTest { @Rule public ExpectedException expectedException = ExpectedException.none(); - @Test public void shouldNotAllowNullCopyConstructor() { // given @@ -33,7 +31,6 @@ public class ManaTest { new Mana(nullMana); } - @Test public void shouldCreateManaFromCopy() { // given @@ -51,7 +48,6 @@ public class ManaTest { assertEquals(0, copy.getWhite()); } - @Test public void shouldCreateManaFromGreenColoredManaSymbol() { // given @@ -68,7 +64,6 @@ public class ManaTest { assertEquals(0, mana.getWhite()); } - @Test public void shouldCreateManaFromRedColoredManaSymbol() { // given @@ -85,7 +80,6 @@ public class ManaTest { assertEquals(0, mana.getWhite()); } - @Test public void shouldCreateManaFromBlackColoredManaSymbol() { // given @@ -102,7 +96,6 @@ public class ManaTest { assertEquals(0, mana.getWhite()); } - @Test public void shouldCreateManaFromBlueColoredManaSymbol() { // given @@ -119,7 +112,6 @@ public class ManaTest { assertEquals(0, mana.getWhite()); } - @Test public void shouldCreateManaFromWhiteColoredManaSymbol() { // given @@ -136,7 +128,6 @@ public class ManaTest { assertEquals(1, mana.getWhite()); } - @Test public void shouldNotCreateManaFromNullColoredManaSymbol() { // given @@ -149,7 +140,6 @@ public class ManaTest { new Mana(nullSymbol); } - @Test public void shouldCreateManaFromIntegers() { @@ -166,7 +156,6 @@ public class ManaTest { assertEquals(7, mana.getAny()); } - @Test public void shouldNotAllowNegativeIntegers() { // given @@ -178,7 +167,6 @@ public class ManaTest { assertEquals(0, mana.getRed()); } - @Test public void shouldCreateRedMana() { @@ -189,7 +177,6 @@ public class ManaTest { assertEquals(1, mana.getRed()); } - @Test public void shouldCreateGreenMana() { @@ -200,7 +187,6 @@ public class ManaTest { assertEquals(1, mana.getGreen()); } - @Test public void shouldCreateBlueMana() { @@ -211,7 +197,6 @@ public class ManaTest { assertEquals(1, mana.getBlue()); } - @Test public void shouldCreateWhiteMana() { @@ -222,7 +207,6 @@ public class ManaTest { assertEquals(1, mana.getWhite()); } - @Test public void shouldCreateBlackMana() { @@ -233,7 +217,6 @@ public class ManaTest { assertEquals(1, mana.getBlack()); } - @Test public void shouldCreateColorlessMana() { @@ -244,7 +227,6 @@ public class ManaTest { assertEquals(1, mana.getColorless()); } - @Test public void shouldNotAllowNegativeRedMana() { // given @@ -256,7 +238,6 @@ public class ManaTest { assertEquals(0, mana.getRed()); } - @Test public void shouldNotAllowNegativeGreenMana() { // given @@ -268,7 +249,6 @@ public class ManaTest { assertEquals(0, mana.getGreen()); } - @Test public void shouldNotAllowNegativeBlueMana() { // given @@ -280,7 +260,6 @@ public class ManaTest { assertEquals(0, mana.getBlue()); } - @Test public void shouldNotAllowNegativeWhiteMana() { // given @@ -292,7 +271,6 @@ public class ManaTest { assertEquals(0, mana.getWhite()); } - @Test public void shouldNotAllowNegativeBlackMana() { // given @@ -304,7 +282,6 @@ public class ManaTest { assertEquals(0, mana.getBlack()); } - @Test public void shouldNotAllowNegativeColorlessMana() { // given @@ -316,14 +293,12 @@ public class ManaTest { assertEquals(0, mana.getColorless()); } - @Test public void shouldAddMana() { // given Mana thisMana = new Mana(1, 2, 3, 4, 5, 6, 7); Mana thatMana = new Mana(1, 2, 3, 4, 5, 6, 7); - // when thisMana.add(thatMana); @@ -337,7 +312,6 @@ public class ManaTest { assertEquals(14, thisMana.getAny()); } - @Test public void shouldIncreaseRedMana() { // given @@ -350,7 +324,6 @@ public class ManaTest { assertEquals(1, mana.getRed()); } - @Test public void shouldIncreaseGreenMana() { // given @@ -430,7 +403,6 @@ public class ManaTest { assertEquals(1, thisMana.getAny()); } - @Test public void shouldSubtractCost() { // given @@ -450,7 +422,6 @@ public class ManaTest { assertEquals(1, thisMana.getAny()); } - @Test public void shouldUseExistingManaToPayColorless() { // given @@ -468,7 +439,6 @@ public class ManaTest { assertEquals(1, available.getRed()); } - @Test public void shouldThrowExceptionOnUnavailableColorless() { // given @@ -485,7 +455,6 @@ public class ManaTest { available.subtractCost(cost); } - @Test public void shouldReturnCount() { // given @@ -504,7 +473,6 @@ public class ManaTest { assertEquals(5, filteredMana); } - @Test public void shouldReturnString() { // given @@ -535,7 +503,6 @@ public class ManaTest { assertEquals(0, mana.getAny()); } - @Test public void shouldReturnCopy() { // given @@ -569,7 +536,6 @@ public class ManaTest { assertEquals(1, whiteMana); } - @Test public void shouldGetColorByManaType() { // given @@ -592,7 +558,6 @@ public class ManaTest { assertEquals(1, colorlessMana); } - @Test public void shouldSetManaFromType() { // given @@ -629,7 +594,6 @@ public class ManaTest { assertFalse(mana == newMana); } - @Test public void shouldHaveEqualManaValue() { // given @@ -643,7 +607,6 @@ public class ManaTest { assertTrue(equalMana); } - @Test public void shouldGetDifferentColors() { // given @@ -658,7 +621,6 @@ public class ManaTest { assertEquals(2, colors); } - @Test public void shouldNotSetManaLessThanZero() { // given diff --git a/Mage/src/test/java/mage/counters/CounterTest.java b/Mage/src/test/java/mage/counters/CounterTest.java new file mode 100644 index 00000000000..77bb39cf010 --- /dev/null +++ b/Mage/src/test/java/mage/counters/CounterTest.java @@ -0,0 +1,135 @@ +package mage.counters; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Custom unit tests for {@link Counter} + */ +public class CounterTest { + + private Counter counter; + + @Before + public void setUp() { + counter = new Counter("test", 1); + } + + + @Test + public void shouldIncreaseCounter() { + // given + + // when + counter.increase(); + + // then + assertEquals(2, counter.getCount()); + assertEquals("test", counter.getName()); + } + + + @Test + public void shouldAddMana() { + // given + + // when + counter.add(5); + + // then + assertEquals(6, counter.getCount()); + } + + + @Test + public void shouldDecreaseCounter() { + // given + + + // when + counter.decrease(); + + // then + assertEquals(0, counter.getCount()); + } + + + @Test + public void shouldNotDecreaseToLessThanZero() { + // given + + // when + counter.decrease(); + counter.decrease(); + + // then + assertEquals(0, counter.getCount()); + } + + + @Test + public void shouldRemoveCounters() { + // given + + + // when + counter.remove(1); + + // then + assertEquals(0, counter.getCount()); + } + + + @Test + public void shouldNotRemoveMoreCountersThanAvailable() { + // given + + // when + counter.remove(10); + + // then + assertEquals(0, counter.getCount()); + } + + + @Test + public void shouldReturnCopy() { + // given + + // when + Counter copy = counter.copy(); + + // then + assertEquals(copy, counter); + assertFalse(copy == counter); + } + + + @Test + public void shouldCreateCounterFromCounter() { + // given + + // when + Counter copy = new Counter(counter); + + // then + assertEquals(1, copy.getCount()); + assertEquals("test", copy.getName()); + } + + + @Test + public void shouldCreatDefaultCounter() { + // given + + + // when + Counter defaultCounter = new Counter("default"); + + // then + assertEquals(1, defaultCounter.getCount()); + assertEquals("default", defaultCounter.getName()); + } +} \ No newline at end of file