diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/PlasmCapture.java b/Mage.Sets/src/mage/sets/dragonsmaze/PlasmCapture.java index ae7f5f64f05..cf82ebbf9e1 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/PlasmCapture.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/PlasmCapture.java @@ -141,15 +141,15 @@ class PlasmCaptureManaEffect extends ManaEffect { } if (choiceColor.getColor().isBlack()) { - mana.increaseBlack(); + mana.addBlack(); } else if (choiceColor.getColor().isBlue()) { - mana.increaseBlue(); + mana.addBlue(); } else if (choiceColor.getColor().isRed()) { - mana.increaseRed(); + mana.addRed(); } else if (choiceColor.getColor().isGreen()) { - mana.increaseGreen(); + mana.addGreen(); } else if (choiceColor.getColor().isWhite()) { - mana.increaseWhite(); + mana.addWhite(); } } diff --git a/Mage.Sets/src/mage/sets/dragonsoftarkir/SarkhanUnbroken.java b/Mage.Sets/src/mage/sets/dragonsoftarkir/SarkhanUnbroken.java index daf2b769358..ccd28a1c476 100644 --- a/Mage.Sets/src/mage/sets/dragonsoftarkir/SarkhanUnbroken.java +++ b/Mage.Sets/src/mage/sets/dragonsoftarkir/SarkhanUnbroken.java @@ -132,19 +132,19 @@ class SarkhanUnbrokenAbility1 extends OneShotEffect { switch (manaChoice.getChoice()) { case "White": - mana.increaseWhite(); + mana.addWhite(); break; case "Blue": - mana.increaseBlue(); + mana.addBlue(); break; case "Black": - mana.increaseBlack(); + mana.addBlack(); break; case "Red": - mana.increaseRed(); + mana.addRed(); break; case "Green": - mana.increaseGreen(); + mana.addGreen(); break; } diff --git a/Mage.Sets/src/mage/sets/eventide/BloomTender.java b/Mage.Sets/src/mage/sets/eventide/BloomTender.java index ecadab68f71..f4544ddc232 100644 --- a/Mage.Sets/src/mage/sets/eventide/BloomTender.java +++ b/Mage.Sets/src/mage/sets/eventide/BloomTender.java @@ -107,19 +107,19 @@ class BloomTenderEffect extends ManaEffect { Mana mana = new Mana(); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(controller.getId())) { if (mana.getBlack() == 0 && permanent.getColor(game).isBlack()) { - mana.increaseBlack(); + mana.addBlack(); } if (mana.getBlue() == 0 && permanent.getColor(game).isBlue()) { - mana.increaseBlue(); + mana.addBlue(); } if (mana.getRed() == 0 && permanent.getColor(game).isRed()) { - mana.increaseRed(); + mana.addRed(); } if (mana.getGreen() == 0 && permanent.getColor(game).isGreen()) { - mana.increaseGreen(); + mana.addGreen(); } if (mana.getWhite() == 0 && permanent.getColor(game).isWhite()) { - mana.increaseWhite(); + mana.addWhite(); } } return mana; diff --git a/Mage.Sets/src/mage/sets/fifthdawn/DawnsReflection.java b/Mage.Sets/src/mage/sets/fifthdawn/DawnsReflection.java index e511ed55865..417381b270e 100644 --- a/Mage.Sets/src/mage/sets/fifthdawn/DawnsReflection.java +++ b/Mage.Sets/src/mage/sets/fifthdawn/DawnsReflection.java @@ -142,15 +142,15 @@ class DawnsReflectionManaEffect extends ManaEffect { } if (choiceColor.getColor().isBlack()) { - mana.increaseBlack(); + mana.addBlack(); } else if (choiceColor.getColor().isBlue()) { - mana.increaseBlue(); + mana.addBlue(); } else if (choiceColor.getColor().isRed()) { - mana.increaseRed(); + mana.addRed(); } else if (choiceColor.getColor().isGreen()) { - mana.increaseGreen(); + mana.addGreen(); } else if (choiceColor.getColor().isWhite()) { - mana.increaseWhite(); + mana.addWhite(); } } diff --git a/Mage.Sets/src/mage/sets/futuresight/CoalitionRelic.java b/Mage.Sets/src/mage/sets/futuresight/CoalitionRelic.java index 3c2b480ecbe..1c7ec71523c 100644 --- a/Mage.Sets/src/mage/sets/futuresight/CoalitionRelic.java +++ b/Mage.Sets/src/mage/sets/futuresight/CoalitionRelic.java @@ -109,15 +109,15 @@ class CoalitionRelicEffect extends OneShotEffect { player.choose(outcome, choice, game); } if (choice.getColor().isBlack()) { - mana.increaseBlack(); + mana.addBlack(); } else if (choice.getColor().isBlue()) { - mana.increaseBlue(); + mana.addBlue(); } else if (choice.getColor().isRed()) { - mana.increaseRed(); + mana.addRed(); } else if (choice.getColor().isGreen()) { - mana.increaseGreen(); + mana.addGreen(); } else if (choice.getColor().isWhite()) { - mana.increaseWhite(); + mana.addWhite(); } choice.clearChoice(); } diff --git a/Mage.Sets/src/mage/sets/heroesvsmonsters/OrcishLumberjack.java b/Mage.Sets/src/mage/sets/heroesvsmonsters/OrcishLumberjack.java index 3a06eafc05a..93277aa22f2 100644 --- a/Mage.Sets/src/mage/sets/heroesvsmonsters/OrcishLumberjack.java +++ b/Mage.Sets/src/mage/sets/heroesvsmonsters/OrcishLumberjack.java @@ -123,10 +123,10 @@ class OrcishLumberjackManaEffect extends ManaEffect { } switch (manaChoice.getChoice()) { case "Green": - mana.increaseGreen(); + mana.addGreen(); break; case "Red": - mana.increaseRed(); + mana.addRed(); break; } diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/MarketFestival.java b/Mage.Sets/src/mage/sets/journeyintonyx/MarketFestival.java index daa67c13978..affa7e15e95 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/MarketFestival.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/MarketFestival.java @@ -154,15 +154,15 @@ class MarketFestivalManaEffect extends ManaEffect { } if (choiceColor.getColor().isBlack()) { - mana.increaseBlack(); + mana.addBlack(); } else if (choiceColor.getColor().isBlue()) { - mana.increaseBlue(); + mana.addBlue(); } else if (choiceColor.getColor().isRed()) { - mana.increaseRed(); + mana.addRed(); } else if (choiceColor.getColor().isGreen()) { - mana.increaseGreen(); + mana.addGreen(); } else if (choiceColor.getColor().isWhite()) { - mana.increaseWhite(); + mana.addWhite(); } } checkToFirePossibleEvents(mana, game, source); diff --git a/Mage.Sets/src/mage/sets/legions/GoblinClearcutter.java b/Mage.Sets/src/mage/sets/legions/GoblinClearcutter.java index bce8de73085..20a5279fbb7 100644 --- a/Mage.Sets/src/mage/sets/legions/GoblinClearcutter.java +++ b/Mage.Sets/src/mage/sets/legions/GoblinClearcutter.java @@ -32,11 +32,15 @@ import java.util.Set; import java.util.UUID; import mage.MageInt; import mage.Mana; +import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DamageTargetEffect; import mage.cards.CardImpl; import mage.choices.Choice; import mage.choices.ChoiceImpl; @@ -44,11 +48,14 @@ import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; +import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; import mage.players.Player; import mage.target.common.TargetControlledPermanent; +import mage.target.common.TargetCreatureOrPlayer; /** * @author BursegSardaukar @@ -125,10 +132,10 @@ class GoblinClearCutterEffect extends OneShotEffect { } switch (manaChoice.getChoice()) { case "Green": - mana.increaseGreen(); + mana.addGreen(); break; case "Red": - mana.increaseRed(); + mana.addRed(); break; } player.getManaPool().addMana(mana, game, source); diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/SasayaOrochiAscendant.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/SasayaOrochiAscendant.java index 3804d61c11c..3bc2a38c378 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/SasayaOrochiAscendant.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/SasayaOrochiAscendant.java @@ -202,22 +202,22 @@ class SasayasEssenceManaEffectEffect extends ManaEffect { } switch (choice.getChoice()) { case "Black": - newMana.increaseBlack(); + newMana.addBlack(); break; case "Blue": - newMana.increaseBlue(); + newMana.addBlue(); break; case "Red": - newMana.increaseRed(); + newMana.addRed(); break; case "Green": - newMana.increaseGreen(); + newMana.addGreen(); break; case "White": - newMana.increaseWhite(); + newMana.addWhite(); break; case "Colorless": - newMana.increaseColorless(); + newMana.addColorless(); break; } } diff --git a/Mage.Sets/src/mage/sets/shadowmoor/ManaforgeCinder.java b/Mage.Sets/src/mage/sets/shadowmoor/ManaforgeCinder.java index 5501ab9aded..c650a49008d 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/ManaforgeCinder.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/ManaforgeCinder.java @@ -114,10 +114,10 @@ class ManaforgeCinderManaEffect extends OneShotEffect { } switch (manaChoice.getChoice()) { case "Black": - mana.increaseBlack(); + mana.addBlack(); break; case "Red": - mana.increaseRed(); + mana.addRed(); break; } controller.getManaPool().addMana(mana, game, source); diff --git a/Mage.Sets/src/mage/sets/theros/XenagosTheReveler.java b/Mage.Sets/src/mage/sets/theros/XenagosTheReveler.java index 781fe57fdb0..8dca6413956 100644 --- a/Mage.Sets/src/mage/sets/theros/XenagosTheReveler.java +++ b/Mage.Sets/src/mage/sets/theros/XenagosTheReveler.java @@ -130,10 +130,10 @@ class XenagosManaEffect extends OneShotEffect { } switch (manaChoice.getChoice()) { case "Green": - mana.increaseGreen(); + mana.addGreen(); break; case "Red": - mana.increaseRed(); + mana.addRed(); break; } player.getManaPool().addMana(mana, game, source); diff --git a/Mage.Tests/src/test/java/org/mage/test/mana/ManaTest.java b/Mage.Tests/src/test/java/org/mage/test/mana/ManaTest.java deleted file mode 100644 index 7cfa5a88571..00000000000 --- a/Mage.Tests/src/test/java/org/mage/test/mana/ManaTest.java +++ /dev/null @@ -1,650 +0,0 @@ -package org.mage.test.mana; - -import mage.Mana; -import mage.constants.ColoredManaSymbol; -import mage.constants.ManaType; -import mage.filter.FilterMana; -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.assertEquals; - -/** - * Custom unit tests for {link Mana}. - * - * @author githubpoixen@github.com - */ -public class ManaTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - - @Test - public void shouldNotAllowNullCopyConstructor() { - // given - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("The passed in Mana can not be null"); - - // when - Mana nullMana = null; - new Mana(nullMana); - } - - - @Test - public void shouldCreateManaFromCopy() { - // given - Mana original = new Mana(); - original.increaseBlack(); - - // when - Mana copy = new Mana(original); - - // then - assertEquals(0, copy.getGreen()); - assertEquals(0, copy.getRed()); - assertEquals(1, copy.getBlack()); - assertEquals(0, copy.getBlue()); - assertEquals(0, copy.getWhite()); - } - - - @Test - public void shouldCreateManaFromGreenColoredManaSymbol() { - // given - ColoredManaSymbol symbol = ColoredManaSymbol.G; - - // when - Mana mana = new Mana(symbol); - - // then - assertEquals(1, mana.getGreen()); - assertEquals(0, mana.getRed()); - assertEquals(0, mana.getBlack()); - assertEquals(0, mana.getBlue()); - assertEquals(0, mana.getWhite()); - } - - - @Test - public void shouldCreateManaFromRedColoredManaSymbol() { - // given - ColoredManaSymbol symbol = ColoredManaSymbol.R; - - // when - Mana mana = new Mana(symbol); - - // then - assertEquals(0, mana.getGreen()); - assertEquals(1, mana.getRed()); - assertEquals(0, mana.getBlack()); - assertEquals(0, mana.getBlue()); - assertEquals(0, mana.getWhite()); - } - - - @Test - public void shouldCreateManaFromBlackColoredManaSymbol() { - // given - ColoredManaSymbol symbol = ColoredManaSymbol.B; - - // when - Mana mana = new Mana(symbol); - - // then - assertEquals(0, mana.getGreen()); - assertEquals(0, mana.getRed()); - assertEquals(1, mana.getBlack()); - assertEquals(0, mana.getBlue()); - assertEquals(0, mana.getWhite()); - } - - - @Test - public void shouldCreateManaFromBlueColoredManaSymbol() { - // given - ColoredManaSymbol symbol = ColoredManaSymbol.U; - - // when - Mana mana = new Mana(symbol); - - // then - assertEquals(0, mana.getGreen()); - assertEquals(0, mana.getRed()); - assertEquals(0, mana.getBlack()); - assertEquals(1, mana.getBlue()); - assertEquals(0, mana.getWhite()); - } - - - @Test - public void shouldCreateManaFromWhiteColoredManaSymbol() { - // given - ColoredManaSymbol symbol = ColoredManaSymbol.W; - - // when - Mana mana = new Mana(symbol); - - // then - assertEquals(0, mana.getGreen()); - assertEquals(0, mana.getRed()); - assertEquals(0, mana.getBlack()); - assertEquals(0, mana.getBlue()); - assertEquals(1, mana.getWhite()); - } - - - @Test - public void shouldNotCreateManaFromNullColoredManaSymbol() { - // given - ColoredManaSymbol nullSymbol = null; - - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("The passed in ColoredManaSymbol can not be null"); - - // when - new Mana(nullSymbol); - } - - - @Test - public void shouldCreateManaFromIntegers() { - - // when - Mana mana = new Mana(1, 2, 3, 4, 5, 6, 7); - - // then - assertEquals(1, mana.getRed()); - assertEquals(2, mana.getGreen()); - assertEquals(3, mana.getBlue()); - assertEquals(4, mana.getWhite()); - assertEquals(5, mana.getBlack()); - assertEquals(6, mana.getColorless()); - assertEquals(7, mana.getAny()); - } - - - @Test - public void shouldNotAllowNegativeIntegers() { - // given - - // when - Mana mana = new Mana(-1, 2, 3, 4, 5, 6, 7); - - // then - assertEquals(0, mana.getRed()); - } - - - @Test - public void shouldCreateRedMana() { - - // when - Mana mana = Mana.RedMana(1); - - // then - assertEquals(1, mana.getRed()); - } - - - @Test - public void shouldCreateGreenMana() { - - // when - Mana mana = Mana.GreenMana(1); - - // then - assertEquals(1, mana.getGreen()); - } - - - @Test - public void shouldCreateBlueMana() { - - // when - Mana mana = Mana.BlueMana(1); - - // then - assertEquals(1, mana.getBlue()); - } - - - @Test - public void shouldCreateWhiteMana() { - - // when - Mana mana = Mana.WhiteMana(1); - - // then - assertEquals(1, mana.getWhite()); - } - - - @Test - public void shouldCreateBlackMana() { - - // when - Mana mana = Mana.BlackMana(1); - - // then - assertEquals(1, mana.getBlack()); - } - - - @Test - public void shouldCreateColorlessMana() { - - // when - Mana mana = Mana.ColorlessMana(1); - - // then - assertEquals(1, mana.getColorless()); - } - - - @Test - public void shouldNotAllowNegativeRedMana() { - // given - - // when - Mana mana = Mana.RedMana(-1); - - //then - assertEquals(0, mana.getRed()); - } - - - @Test - public void shouldNotAllowNegativeGreenMana() { - // given - - // when - Mana mana = Mana.GreenMana(-1); - - //then - assertEquals(0, mana.getGreen()); - } - - - @Test - public void shouldNotAllowNegativeBlueMana() { - // given - - // when - Mana mana = Mana.BlueMana(-1); - - //then - assertEquals(0, mana.getBlue()); - } - - - @Test - public void shouldNotAllowNegativeWhiteMana() { - // given - - // when - Mana mana = Mana.WhiteMana(-1); - - //then - assertEquals(0, mana.getWhite()); - } - - - @Test - public void shouldNotAllowNegativeBlackMana() { - // given - - // when - Mana mana = Mana.BlackMana(-1); - - //then - assertEquals(0, mana.getBlack()); - } - - - @Test - public void shouldNotAllowNegativeColorlessMana() { - // given - - // when - Mana mana = Mana.ColorlessMana(-1); - - //then - 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); - - // then - assertEquals(2, thisMana.getRed()); - assertEquals(4, thisMana.getGreen()); - assertEquals(6, thisMana.getBlue()); - assertEquals(8, thisMana.getWhite()); - assertEquals(10, thisMana.getBlack()); - assertEquals(12, thisMana.getColorless()); - assertEquals(14, thisMana.getAny()); - } - - - @Test - public void shouldIncreaseRedMana() { - // given - Mana mana = new Mana(); - - // when - mana.increaseRed(); - - // then - assertEquals(1, mana.getRed()); - } - - - @Test - public void shouldIncreaseGreenMana() { - // given - Mana mana = new Mana(); - - // when - mana.increaseGreen(); - - // then - assertEquals(1, mana.getGreen()); - } - - @Test - public void shouldIncreaseBlueMana() { - // given - Mana mana = new Mana(); - - // when - mana.increaseBlue(); - - // then - assertEquals(1, mana.getBlue()); - } - - @Test - public void shouldIncreaseWhiteMana() { - // given - Mana mana = new Mana(); - - // when - mana.increaseWhite(); - - // then - assertEquals(1, mana.getWhite()); - } - - @Test - public void shouldIncreaseBlackMana() { - // given - Mana mana = new Mana(); - - // when - mana.increaseBlack(); - - // then - assertEquals(1, mana.getBlack()); - } - - @Test - public void shouldIncreaseColorlessMana() { - // given - Mana mana = new Mana(); - - // when - mana.increaseColorless(); - - // then - assertEquals(1, mana.getColorless()); - } - - @Test - public void shouldSubtractMana() { - // given - Mana thisMana = new Mana(2, 2, 2, 2, 2, 2, 2); - Mana thatMana = new Mana(1, 1, 1, 1, 1, 1, 1); - - // when - thisMana.subtract(thatMana); - - // then - assertEquals(1, thisMana.getRed()); - assertEquals(1, thisMana.getGreen()); - assertEquals(1, thisMana.getBlue()); - assertEquals(1, thisMana.getWhite()); - assertEquals(1, thisMana.getBlack()); - assertEquals(1, thisMana.getColorless()); - assertEquals(1, thisMana.getAny()); - } - - @Test - public void shouldNotSubtractLessThan0() { - // given - Mana thisMana = new Mana(2, 2, 2, 2, 2, 2, 2); - Mana thatMana = new Mana(10, 1, 1, 1, 10, 1, 1); - - // when - thisMana.subtract(thatMana); - - // then - assertEquals(-8, thisMana.getRed()); - assertEquals(1, thisMana.getGreen()); - assertEquals(1, thisMana.getBlue()); - assertEquals(1, thisMana.getWhite()); - assertEquals(-8, thisMana.getBlack()); - assertEquals(1, thisMana.getColorless()); - assertEquals(1, thisMana.getAny()); - } - - - @Test - public void shouldReturnCount() { - // given - Mana mana = new Mana(1, 2, 3, 4, 5, 6, 7); - FilterMana filter = new FilterMana(); - filter.setBlack(true); - - // when - int totalCount = mana.count(); - int coloredCount = mana.countColored(); - int filteredMana = mana.count(filter); - - // then - assertEquals(28, totalCount); - assertEquals(22, coloredCount); - assertEquals(5, filteredMana); - } - - - @Test - public void shouldReturnString() { - // given - Mana mana = new Mana(1, 2, 3, 0, 3, 6, 2); - - // when - String ret = mana.toString(); - - // then - assertEquals("{6}{R}{G}{G}{U}{U}{U}{B}{B}{B}{Any}{Any}", ret); - } - - @Test - public void shouldClearMana() { - // given - Mana mana = new Mana(1, 2, 3, 4, 5, 6, 7); - - // when - mana.clear(); - - // then - assertEquals(0, mana.getRed()); - assertEquals(0, mana.getGreen()); - assertEquals(0, mana.getBlue()); - assertEquals(0, mana.getWhite()); - assertEquals(0, mana.getBlack()); - assertEquals(0, mana.getColorless()); - assertEquals(0, mana.getAny()); - } - - - @Test - public void shouldReturnCopy() { - // given - Mana mana = new Mana(1, 2, 3, 4, 5, 6, 7); - - // when - Mana copy = mana.copy(); - - // then - assertEquals(mana, copy); // are equal - assertFalse(mana == copy); // are not the same object - } - - @Test - public void shouldGetColorByColoredManaSymbol() { - // given - Mana mana = new Mana(1, 1, 1, 1, 1, 1, 1); - - // when - int redMana = mana.getColor(ColoredManaSymbol.R); - int greenMana = mana.getColor(ColoredManaSymbol.G); - int blueMana = mana.getColor(ColoredManaSymbol.U); - int blackMana = mana.getColor(ColoredManaSymbol.B); - int whiteMana = mana.getColor(ColoredManaSymbol.W); - - // then - assertEquals(1, redMana); - assertEquals(1, greenMana); - assertEquals(1, blueMana); - assertEquals(1, blackMana); - assertEquals(1, whiteMana); - } - - - @Test - public void shouldGetColorByManaType() { - // given - Mana mana = new Mana(1, 1, 1, 1, 1, 1, 1); - - // when - int redMana = mana.get(ManaType.RED); - int greenMana = mana.get(ManaType.GREEN); - int blueMana = mana.get(ManaType.BLUE); - int blackMana = mana.get(ManaType.BLACK); - int whiteMana = mana.get(ManaType.WHITE); - int colorlessMana = mana.get(ManaType.COLORLESS); - - // then - assertEquals(1, redMana); - assertEquals(1, greenMana); - assertEquals(1, blueMana); - assertEquals(1, blackMana); - assertEquals(1, whiteMana); - assertEquals(1, colorlessMana); - } - - - @Test - public void shouldSetManaFromType() { - // given - Mana mana = new Mana(); - - // when - mana.set(ManaType.BLACK, 3); - mana.set(ManaType.BLUE, 4); - mana.set(ManaType.RED, 5); - mana.set(ManaType.GREEN, 6); - mana.set(ManaType.WHITE, 7); - mana.set(ManaType.COLORLESS, 8); - - // then - assertEquals(3, mana.getBlack()); - assertEquals(4, mana.getBlue()); - assertEquals(5, mana.getRed()); - assertEquals(6, mana.getGreen()); - assertEquals(7, mana.getWhite()); - assertEquals(8, mana.getColorless()); - } - - @Test - public void shouldSetToMana() { - // given - Mana mana = new Mana(); - Mana newMana = new Mana(1, 2, 3, 4, 5, 6, 7); - - // when - mana.setToMana(newMana); - - // then - assertEquals(mana, newMana); - assertFalse(mana == newMana); - } - - - @Test - public void shouldHaveEqualManaValue() { - // given - Mana mana = new Mana(1, 2, 3, 4, 5, 6, 7); - Mana newMana = new Mana(1, 2, 3, 4, 5, 6, 7); - - // when - boolean equalMana = mana.equalManaValue(newMana); - - // then - assertTrue(equalMana); - } - - - @Test - public void shouldGetDifferentColors() { - // given - Mana mana = new Mana(); - mana.setRed(3); - mana.setGreen(2); - - // when - int colors = mana.getDifferentColors(); - - // then - assertEquals(2, colors); - } - - - @Test - public void shouldNotSetManaLessThanZero() { - // given - Mana mana = new Mana(); - - // when - mana.setRed(-4); - mana.setGreen(-4); - mana.setBlue(-4); - mana.setWhite(-4); - mana.setBlack(-4); - mana.setColorless(-4); - mana.setAny(-4); - - // then - assertEquals(0, mana.getRed()); - assertEquals(0, mana.getGreen()); - assertEquals(0, mana.getBlue()); - assertEquals(0, mana.getWhite()); - assertEquals(0, mana.getBlack()); - assertEquals(0, mana.getColorless()); - assertEquals(0, mana.getAny()); - } -} diff --git a/Mage/src/mage/Mana.java b/Mage/src/mage/Mana.java index 0038727309b..e5dace32df1 100644 --- a/Mage/src/mage/Mana.java +++ b/Mage/src/mage/Mana.java @@ -28,32 +28,19 @@ package mage; import java.io.Serializable; -import java.util.Objects; -import java.util.logging.Logger; - import mage.constants.ColoredManaSymbol; import mage.constants.ManaType; +import static mage.constants.ManaType.COLORLESS; import mage.filter.FilterMana; import mage.util.Copyable; -import mage.util.Logging; +import mage.util.ThreadLocalStringBuilder; /** - * Representation of a mana pool. Can contain colored and colorless mana. * * @author BetaSteward_at_googlemail.com */ public class Mana implements Comparable, Serializable, Copyable { - private static Logger logger = Logging.getLogger(Mana.class.getName()); - - public static final String RED = "RED"; - public static final String GREEN = "GREEN"; - public static final String BLUE = "BLUE"; - public static final String WHITE = "WHITE"; - public static final String BLACK = "BLACK"; - public static final String COLORLESS = "COLORLESS"; - public static final String ANY = "ANY"; - protected int red; protected int green; protected int blue; @@ -63,7 +50,6 @@ public class Mana implements Comparable, Serializable, Copyable { protected int any; protected boolean flag = false; - //todo unsafe and mutable public static final Mana RedMana = RedMana(1); public static final Mana GreenMana = GreenMana(1); public static final Mana BlueMana = BlueMana(1); @@ -74,13 +60,7 @@ public class Mana implements Comparable, Serializable, Copyable { public Mana() { } - /** - * Copy constructor. - * - * @param mana The {@link Mana} to copy from. Can not be null. - */ public Mana(final Mana mana) { - Objects.requireNonNull(mana, "The passed in Mana can not be null"); this.red = mana.red; this.green = mana.green; this.blue = mana.blue; @@ -91,38 +71,7 @@ public class Mana implements Comparable, Serializable, Copyable { this.flag = mana.flag; } - - /** - * Creates a {@link Mana} object with the mana passed in. - * - * @param red Total red mana to add. - * @param green Total green mana to add. - * @param blue Total blue mana to add. - * @param white Total white mana to add. - * @param black Total black mana to add. - * @param colorless Total colorless mana to add. - * @param any Total any colored mana to add. - */ - public Mana(final int red, final int green, final int blue, final int white, - final int black, final int colorless, final int any) { - this.red = notNegative(red, RED); - this.green = notNegative(green, GREEN); - this.blue = notNegative(blue, BLUE); - this.white = notNegative(white, WHITE); - this.black = notNegative(black, BLACK); - this.colorless = notNegative(colorless, COLORLESS); - this.any = notNegative(any, ANY); - } - - - /** - * Creates a {@link Mana} object from the {@link ColoredManaSymbol} {@code color}. - * - * @param color The {@link ColoredManaSymbol} to create {@link Mana} from. - * Can not be null. - */ - public Mana(final ColoredManaSymbol color) { - Objects.requireNonNull(color, "The passed in ColoredManaSymbol can not be null"); + public Mana(ColoredManaSymbol color) { switch (color) { case G: green = 1; @@ -139,154 +88,95 @@ public class Mana implements Comparable, Serializable, Copyable { case W: white = 1; break; - default: - throw new IllegalArgumentException("Unknown color " + color.getColorName()); } } - /** - * Creates a {@link Mana} object with {@code num} Red mana. - * - * @param num The amount of Red mana to add. Can not be negative. - * @return {@link Mana} object with {@code num} Red mana. - */ - public static Mana RedMana(final int num) { - return new Mana(notNegative(num, RED), 0, 0, 0, 0, 0, 0); + public static Mana RedMana(int num) { + return new Mana(num, 0, 0, 0, 0, 0, 0); } - /** - * Creates a {@link Mana} object with {@code num} Green mana. - * - * @param num The amount of Green mana to add. Can not be negative. - * @return {@link Mana} object with {@code num} Green mana. - */ - public static Mana GreenMana(final int num) { - return new Mana(0, notNegative(num, GREEN), 0, 0, 0, 0, 0); + public static Mana GreenMana(int num) { + return new Mana(0, num, 0, 0, 0, 0, 0); } - /** - * Creates a {@link Mana} object with {@code num} Blue mana. - * - * @param num The amount of Blue mana to add. Can not be negative. - * @return {@link Mana} object with {@code num} Blue mana. - */ - public static Mana BlueMana(final int num) { - return new Mana(0, 0, notNegative(num, BLUE), 0, 0, 0, 0); + public static Mana BlueMana(int num) { + return new Mana(0, 0, num, 0, 0, 0, 0); } - /** - * Creates a {@link Mana} object with {@code num} White mana. - * - * @param num The amount of White mana to add. Can not be negative. - * @return {@link Mana} object with {@code num} White mana. - */ - public static Mana WhiteMana(final int num) { - return new Mana(0, 0, 0, notNegative(num, WHITE), 0, 0, 0); + public static Mana WhiteMana(int num) { + return new Mana(0, 0, 0, num, 0, 0, 0); } - /** - * Creates a {@link Mana} object with {@code num} Black mana. - * - * @param num The amount of Black mana to add. Can not be negative. - * @return {@link Mana} object with {@code num} Black mana. - */ - public static Mana BlackMana(final int num) { - return new Mana(0, 0, 0, 0, notNegative(num, BLACK), 0, 0); + public static Mana BlackMana(int num) { + return new Mana(0, 0, 0, 0, num, 0, 0); } - /** - * Creates a {@link Mana} object with {@code num} Colorless mana. - * - * @param num The amount of Colorless mana to add. Can not be negative. - * @return {@link Mana} object with {@code num} Colorless mana. - */ - public static Mana ColorlessMana(final int num) { - return new Mana(0, 0, 0, 0, 0, notNegative(num, COLORLESS), 0); + public static Mana ColorlessMana(int num) { + return new Mana(0, 0, 0, 0, 0, num, 0); } - - /** - * Increases the mana in this object by the relative mana in the passed in {@link Mana} object. - * - * @param mana {@link Mana} object to increase this mana by. - */ - public void add(final Mana mana) { - red += mana.red; - green += mana.green; - blue += mana.blue; - white += mana.white; - black += mana.black; - colorless += mana.colorless; - any += mana.any; + public Mana(int red, int green, int blue, int white, int black, int colorless, int any) { + this.red = red; + this.green = green; + this.blue = blue; + this.white = white; + this.black = black; + this.colorless = colorless; + this.any = any; } - /** - * Increases the Red mana by one. - */ - public void increaseRed() { + public void add(Mana mana) { + red += mana.getRed(); + green += mana.getGreen(); + blue += mana.getBlue(); + white += mana.getWhite(); + black += mana.getBlack(); + colorless += mana.getColorless(); + any += mana.getAny(); + } + + public void addRed() { red++; } - /** - * Increases the Green mana by one. - */ - public void increaseGreen() { + public void addGreen() { green++; } - /** - * Increases the Blue mana by one. - */ - public void increaseBlue() { + public void addBlue() { blue++; } - /** - * Increases the White mana by one. - */ - public void increaseWhite() { + public void addWhite() { white++; } - /** - * Increases the Black mana by one. - */ - public void increaseBlack() { + public void addBlack() { black++; } - /** - * Increases the Colorless mana by one. - */ - public void increaseColorless() { + public void addColorless() { colorless++; } - /** - * Subtracts the passed in mana values from this instance. Will not - * reduce this instances mana below 0. - * - * @param mana mana values to subtract - */ - public void subtract(final Mana mana) { - red -= mana.red; - green -= mana.green; - blue -= mana.blue; - white -= mana.white; - black -= mana.black; - colorless -= mana.colorless; - any -= mana.any; + public void subtract(Mana mana) { + red -= mana.getRed(); + green -= mana.getGreen(); + blue -= mana.getBlue(); + white -= mana.getWhite(); + black -= mana.getBlack(); + colorless -= mana.getColorless(); + any -= mana.getAny(); } public void subtractCost(Mana cost) { - red -= cost.red; - green -= cost.green; - blue -= cost.blue; - white -= cost.white; - black -= cost.black; - any -= cost.any; - colorless -= cost.colorless; - + red -= cost.getRed(); + green -= cost.getGreen(); + blue -= cost.getBlue(); + white -= cost.getWhite(); + black -= cost.getBlack(); + any -= cost.getAny(); + colorless -= cost.getColorless(); while (colorless < 0) { int oldColorless = colorless; if (red > 0) { @@ -323,72 +213,15 @@ public class Mana implements Comparable, Serializable, Copyable { } } - /** - * Sets this object's mana to be equal to the passed in {@code mana} - * - * @param mana the mana to copy from - */ - public void setToMana(final Mana mana) { - any = mana.any; - red = mana.red; - green = mana.green; - white = mana.white; - blue = mana.blue; - black = mana.black; - colorless = mana.colorless; - } - - /** - * Returns the total mana count. - * - * @return the total mana count. - */ public int count() { return red + green + blue + white + black + colorless + any; } - /** - * Returns the total colored mana count. - * - * @return the total colored mana count. - */ public int countColored() { return red + green + blue + white + black + any; } - - /** - * Returns how many colors are currently more than 0. - * - * @return how many colors are currently more than 0. - */ - public int getDifferentColors() { - int count = 0; - if (blue > 0) { - count++; - } - if (black > 0) { - count++; - } - if (green > 0) { - count++; - } - if (white > 0) { - count++; - } - if (red > 0) { - count++; - } - return count; - } - - /** - * Returns the total mana with a {@link FilterMana} applied. - * - * @param filter the filter to apply when counting mana - * @return the total mana after filtration. - */ - public int count(final FilterMana filter) { + public int count(FilterMana filter) { if (filter == null) { return count(); } @@ -414,9 +247,6 @@ public class Mana implements Comparable, Serializable, Copyable { return count; } - /** - * Resets all mana to 0 - */ public void clear() { red = 0; green = 0; @@ -427,11 +257,6 @@ public class Mana implements Comparable, Serializable, Copyable { any = 0; } - /** - * Returns {@link String} of internal state. - * - * @return text version of internal state. - */ @Override public String toString() { StringBuilder sbMana = new StringBuilder(); @@ -459,24 +284,14 @@ public class Mana implements Comparable, Serializable, Copyable { return sbMana.toString(); } + private static final transient ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(10); - /** - * Returns a deep copy of this object - * - * @return a deep copy of this object - */ @Override public Mana copy() { return new Mana(this); } - /** - * Returns if there is enough mana available compared to the passed in {@link Mana} - * - * @param avail value to compare with - * @return if there is enough mana in the mana pool compared to the passed in {@link Mana} - */ - public boolean enough(final Mana avail) { + public boolean enough(Mana avail) { Mana compare = avail.copy(); compare.subtract(this); if (compare.getRed() < 0) { @@ -523,13 +338,7 @@ public class Mana implements Comparable, Serializable, Copyable { return true; } - /** - * Returns how much mana is needed to meet the passed in cost - * - * @param avail mana cost to meet - * @return how much mana is needed to meet the passed in cost - */ - public Mana needed(final Mana avail) { + public Mana needed(Mana avail) { Mana compare = avail.copy(); compare.subtract(this); if (compare.getRed() < 0 && compare.getAny() > 0) { @@ -596,8 +405,8 @@ public class Mana implements Comparable, Serializable, Copyable { return red; } - public void setRed(final int red) { - this.red = notNegative(red, "Red"); + public void setRed(int red) { + this.red = red; } public int getGreen() { @@ -605,7 +414,7 @@ public class Mana implements Comparable, Serializable, Copyable { } public void setGreen(int green) { - this.green = notNegative(green, "Green"); + this.green = green; } public int getBlue() { @@ -613,7 +422,7 @@ public class Mana implements Comparable, Serializable, Copyable { } public void setBlue(int blue) { - this.blue = notNegative(blue, "Blue"); + this.blue = blue; } public int getWhite() { @@ -621,7 +430,7 @@ public class Mana implements Comparable, Serializable, Copyable { } public void setWhite(int white) { - this.white = notNegative(white, "White"); + this.white = white; } public int getBlack() { @@ -629,7 +438,7 @@ public class Mana implements Comparable, Serializable, Copyable { } public void setBlack(int black) { - this.black = notNegative(black, "Black"); + this.black = black; } public int getColorless() { @@ -637,7 +446,7 @@ public class Mana implements Comparable, Serializable, Copyable { } public void setColorless(int colorless) { - this.colorless = notNegative(colorless, "Colorless"); + this.colorless = colorless; } public int getAny() { @@ -645,51 +454,43 @@ public class Mana implements Comparable, Serializable, Copyable { } public void setAny(int any) { - this.any = notNegative(any, "Any"); + this.any = any; } - @Override - public int compareTo(final Mana o) { - return count() - o.count(); + public int compareTo(Mana o) { + return this.count() - o.count(); } /** + * * @param mana * @return true if this contains any values that mana has */ - // todo what purpose does this serve? - // todo what if you want to check for red, and you have black? public boolean contains(Mana mana) { - if (mana.black > 0 && black > 0) { + if (mana.black > 0 && this.black > 0) { return true; } - if (mana.blue > 0 && blue > 0) { + if (mana.blue > 0 && this.blue > 0) { return true; } - if (mana.red > 0 && red > 0) { + if (mana.red > 0 && this.red > 0) { return true; } - if (mana.white > 0 && white > 0) { + if (mana.white > 0 && this.white > 0) { return true; } - if (mana.green > 0 && green > 0) { + if (mana.green > 0 && this.green > 0) { return true; } - if (mana.colorless > 0 && count() > 0) { + if (mana.colorless > 0 && this.count() > 0) { return true; } return false; } - /** - * Returns the total color based on the {@link ColoredManaSymbol} passed in - * - * @param color the {@link ColoredManaSymbol} to get mana for - * @return the total color based on the {@link ColoredManaSymbol} passed in - */ - public int getColor(final ColoredManaSymbol color) { + public int getColor(ColoredManaSymbol color) { if (color.equals(ColoredManaSymbol.G)) { return getGreen(); } @@ -708,13 +509,7 @@ public class Mana implements Comparable, Serializable, Copyable { return 0; } - /** - * Returns the total color based on the {@link ManaType} passed in - * - * @param manaType the {@link ManaType} to return the color for - * @return the total color based on the {@link ManaType} passed in - */ - public int get(final ManaType manaType) { + public int get(ManaType manaType) { switch (manaType) { case BLACK: return black; @@ -732,14 +527,7 @@ public class Mana implements Comparable, Serializable, Copyable { return 0; } - /** - * Sets the total mana based on the passed int {@code manaType} and {@code amount} - * - * @param manaType the type of mana - * @param amount the amount to set the mana to, can not be negative - */ - public void set(final ManaType manaType, final int amount) { - notNegative(amount, manaType.toString()); + public void set(ManaType manaType, int amount) { switch (manaType) { case BLACK: black = amount; @@ -762,7 +550,6 @@ public class Mana implements Comparable, Serializable, Copyable { } } - //todo not sure what this does, should we add some documentation of what a flag is? public void setFlag(boolean flag) { this.flag = flag; } @@ -771,21 +558,24 @@ public class Mana implements Comparable, Serializable, Copyable { return flag; } + public void setToMana(Mana mana) { + this.any = mana.any; + this.red = mana.red; + this.green = mana.green; + this.white = mana.white; + this.blue = mana.blue; + this.black = mana.black; + this.colorless = mana.colorless; + } - /** - * Checks if this object has the same mana values as the passed in {@link Mana} - * - * @param mana the {@link Mana} to compare to - * @return if both {@link Mana} objects have the same mana values - */ - public boolean equalManaValue(final Mana mana) { - return any == mana.any - && red == mana.red - && green == mana.green - && white == mana.white - && blue == mana.blue - && black == mana.black - && colorless == mana.colorless; + public boolean equalManaValue(Mana mana) { + return this.any == mana.any + && this.red == mana.red + && this.green == mana.green + && this.white == mana.white + && this.blue == mana.blue + && this.black == mana.black + && this.colorless == mana.colorless; } /** @@ -796,13 +586,14 @@ public class Mana implements Comparable, Serializable, Copyable { * @return */ public boolean includesMana(Mana mana) { - return green >= mana.green - && blue >= mana.blue - && white >= mana.white - && black >= mana.black - && red >= mana.red - && (colorless >= mana.colorless - || countColored() >= mana.countColored() + mana.colorless); + return this.green >= mana.green + && this.blue >= mana.blue + && this.white >= mana.white + && this.black >= mana.black + && this.red >= mana.red + && (this.colorless >= mana.colorless + || this.countColored() >= mana.countColored() + mana.colorless); + } /** @@ -837,49 +628,23 @@ public class Mana implements Comparable, Serializable, Copyable { return moreMana; } - - /** - * Used to check if a passed in value is less than 0. Log if the value is. - * - * @param value The value to check - * @param valueName The name of the value - * @return 0 if less than 0, or the value if more than 0 - */ - private static int notNegative(int value, final String valueName) { - if (value < 0) { - logger.info(valueName + " can not be set to less than 0. Setting to 0"); - value = 0; + public int getDifferentColors() { + int count = 0; + if (blue > 0) { + count++; } - return value; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Mana mana = (Mana) o; - - if (red != mana.red) return false; - if (green != mana.green) return false; - if (blue != mana.blue) return false; - if (white != mana.white) return false; - if (black != mana.black) return false; - if (colorless != mana.colorless) return false; - if (any != mana.any) return false; - return flag == mana.flag; - } - - @Override - public int hashCode() { - int result = red; - result = 31 * result + green; - result = 31 * result + blue; - result = 31 * result + white; - result = 31 * result + black; - result = 31 * result + colorless; - result = 31 * result + any; - result = 31 * result + (flag ? 1 : 0); - return result; + if (black > 0) { + count++; + } + if (green > 0) { + count++; + } + if (white > 0) { + count++; + } + if (red > 0) { + count++; + } + return count; } } diff --git a/Mage/src/mage/abilities/costs/mana/ManaCostImpl.java b/Mage/src/mage/abilities/costs/mana/ManaCostImpl.java index 11c4a66e9aa..c33e0f5799b 100644 --- a/Mage/src/mage/abilities/costs/mana/ManaCostImpl.java +++ b/Mage/src/mage/abilities/costs/mana/ManaCostImpl.java @@ -118,31 +118,31 @@ public abstract class ManaCostImpl extends CostImpl implements ManaCost { switch (mana) { case B: if (pool.pay(ManaType.BLACK, ability, sourceFilter, game)) { - this.payment.increaseBlack(); + this.payment.addBlack(); return true; } break; case U: if (pool.pay(ManaType.BLUE, ability, sourceFilter, game)) { - this.payment.increaseBlue(); + this.payment.addBlue(); return true; } break; case W: if (pool.pay(ManaType.WHITE, ability, sourceFilter, game)) { - this.payment.increaseWhite(); + this.payment.addWhite(); return true; } break; case G: if (pool.pay(ManaType.GREEN, ability, sourceFilter, game)) { - this.payment.increaseGreen(); + this.payment.addGreen(); return true; } break; case R: if (pool.pay(ManaType.RED, ability, sourceFilter, game)) { - this.payment.increaseRed(); + this.payment.addRed(); return true; } break; @@ -154,27 +154,27 @@ public abstract class ManaCostImpl extends CostImpl implements ManaCost { int conditionalCount = pool.getConditionalCount(ability, game, null); while (mana > payment.count() && (pool.count() > 0 || conditionalCount > 0)) { if (pool.pay(ManaType.COLORLESS, ability, sourceFilter, game)) { - this.payment.increaseColorless(); + this.payment.addColorless(); continue; } if (pool.pay(ManaType.BLACK, ability, sourceFilter, game)) { - this.payment.increaseBlack(); + this.payment.addBlack(); continue; } if (pool.pay(ManaType.BLUE, ability, sourceFilter, game)) { - this.payment.increaseBlue(); + this.payment.addBlue(); continue; } if (pool.pay(ManaType.WHITE, ability, sourceFilter, game)) { - this.payment.increaseWhite(); + this.payment.addWhite(); continue; } if (pool.pay(ManaType.GREEN, ability, sourceFilter, game)) { - this.payment.increaseGreen(); + this.payment.addGreen(); continue; } if (pool.pay(ManaType.RED, ability, sourceFilter, game)) { - this.payment.increaseRed(); + this.payment.addRed(); continue; } break; diff --git a/Mage/src/mage/abilities/effects/common/DynamicManaEffect.java b/Mage/src/mage/abilities/effects/common/DynamicManaEffect.java index 6d6cc7597a7..d6f5cf01087 100644 --- a/Mage/src/mage/abilities/effects/common/DynamicManaEffect.java +++ b/Mage/src/mage/abilities/effects/common/DynamicManaEffect.java @@ -154,15 +154,15 @@ public class DynamicManaEffect extends BasicManaEffect { } } if (choiceColor.getColor().isBlack()) { - computedMana.increaseBlack(); + computedMana.addBlack(); } else if (choiceColor.getColor().isBlue()) { - computedMana.increaseBlue(); + computedMana.addBlue(); } else if (choiceColor.getColor().isRed()) { - computedMana.increaseRed(); + computedMana.addRed(); } else if (choiceColor.getColor().isGreen()) { - computedMana.increaseGreen(); + computedMana.addGreen(); } else if (choiceColor.getColor().isWhite()) { - computedMana.increaseWhite(); + computedMana.addWhite(); } if (!oneChoice) { choiceColor.clearChoice(); diff --git a/Mage/src/mage/abilities/effects/common/continuous/CommanderManaReplacementEffect.java b/Mage/src/mage/abilities/effects/common/continuous/CommanderManaReplacementEffect.java index b3e4e3de2c1..36ad215d042 100644 --- a/Mage/src/mage/abilities/effects/common/continuous/CommanderManaReplacementEffect.java +++ b/Mage/src/mage/abilities/effects/common/continuous/CommanderManaReplacementEffect.java @@ -81,31 +81,31 @@ public class CommanderManaReplacementEffect extends ReplacementEffectImpl { Mana mana = ((ManaEvent) event).getMana(); if (mana.getBlack() > 0 && !commanderMana.isBlack()) { for (int i = 0; i < mana.getBlack(); i++) { - mana.increaseColorless(); + mana.addColorless(); } mana.setBlack(0); } if (mana.getBlue() > 0 && !commanderMana.isBlue()) { for (int i = 0; i < mana.getBlue(); i++) { - mana.increaseColorless(); + mana.addColorless(); } mana.setBlue(0); } if (mana.getGreen() > 0 && !commanderMana.isGreen()) { for (int i = 0; i < mana.getGreen(); i++) { - mana.increaseColorless(); + mana.addColorless(); } mana.setGreen(0); } if (mana.getRed() > 0 && !commanderMana.isRed()) { for (int i = 0; i < mana.getRed(); i++) { - mana.increaseColorless(); + mana.addColorless(); } mana.setRed(0); } if (mana.getWhite() > 0 && !commanderMana.isWhite()) { for (int i = 0; i < mana.getWhite(); i++) { - mana.increaseColorless(); + mana.addColorless(); } mana.setWhite(0); }