diff --git a/Mage/src/mage/abilities/effects/common/AddConditionalManaOfAnyColorEffect.java b/Mage/src/mage/abilities/effects/common/AddConditionalManaOfAnyColorEffect.java new file mode 100644 index 00000000000..e87d310f121 --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/AddConditionalManaOfAnyColorEffect.java @@ -0,0 +1,98 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.abilities.effects.common; + +import mage.ConditionalMana; +import mage.Mana; +import mage.abilities.Ability; +import mage.abilities.mana.builder.ConditionalManaBuilder; +import mage.choices.ChoiceColor; +import mage.game.Game; +import mage.players.Player; + +/** + * @author noxx + */ +public class AddConditionalManaOfAnyColorEffect extends ManaEffect { + + private int amount; + private ConditionalMana conditionalMana; + private ConditionalManaBuilder manaBuilder; + + public AddConditionalManaOfAnyColorEffect(int amount, ConditionalManaBuilder manaBuilder) { + super(); + this.amount = amount; + this.manaBuilder = manaBuilder; + staticText = "Add " + amount + " mana of any one color to your mana pool."; + } + + public AddConditionalManaOfAnyColorEffect(final AddConditionalManaOfAnyColorEffect effect) { + super(effect); + this.amount = effect.amount; + this.manaBuilder = effect.manaBuilder; + } + + @Override + public AddConditionalManaOfAnyColorEffect copy() { + return new AddConditionalManaOfAnyColorEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + + if (player != null) { + for (int i = 0; i < amount; i++) { + addMana(game, player, source, (ChoiceColor) source.getChoices().get(i)); + } + } + + return false; + } + + private boolean addMana(Game game, Player player, Ability source, ChoiceColor choice) { + if (choice.getColor().isBlack()) { + player.getManaPool().addMana(manaBuilder.setMana(Mana.BlackMana(1)).build(), game, source); + return true; + } else if (choice.getColor().isBlue()) { + player.getManaPool().addMana(manaBuilder.setMana(Mana.BlueMana(1)).build(), game, source); + return true; + } else if (choice.getColor().isRed()) { + player.getManaPool().addMana(manaBuilder.setMana(Mana.RedMana(1)).build(), game, source); + return true; + } else if (choice.getColor().isGreen()) { + player.getManaPool().addMana(manaBuilder.setMana(Mana.GreenMana(1)).build(), game, source); + return true; + } else if (choice.getColor().isWhite()) { + player.getManaPool().addMana(manaBuilder.setMana(Mana.WhiteMana(1)).build(), game, source); + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/Mage/src/mage/abilities/mana/AnyColorManaAbility.java b/Mage/src/mage/abilities/mana/AnyColorManaAbility.java index cf5695952d8..8b01f515d98 100644 --- a/Mage/src/mage/abilities/mana/AnyColorManaAbility.java +++ b/Mage/src/mage/abilities/mana/AnyColorManaAbility.java @@ -1,3 +1,30 @@ +/* +* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are +* permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright notice, this list of +* conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright notice, this list +* of conditions and the following disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR +* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The views and conclusions contained in the software and documentation are those of the +* authors and should not be interpreted as representing official policies, either expressed +* or implied, of BetaSteward_at_googlemail.com. +*/ package mage.abilities.mana; import mage.Constants; diff --git a/Mage/src/mage/abilities/mana/ConditionalAnyColorManaAbility.java b/Mage/src/mage/abilities/mana/ConditionalAnyColorManaAbility.java new file mode 100644 index 00000000000..d21f4e2fa68 --- /dev/null +++ b/Mage/src/mage/abilities/mana/ConditionalAnyColorManaAbility.java @@ -0,0 +1,65 @@ +/* +* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are +* permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright notice, this list of +* conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright notice, this list +* of conditions and the following disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR +* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The views and conclusions contained in the software and documentation are those of the +* authors and should not be interpreted as representing official policies, either expressed +* or implied, of BetaSteward_at_googlemail.com. +*/ +package mage.abilities.mana; + +import mage.Constants; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.common.AddConditionalManaOfAnyColorEffect; +import mage.abilities.mana.builder.ConditionalManaBuilder; +import mage.choices.ChoiceColor; + +/** + * For cards like: + * {tap}: Add three mana of any one color to your mana pool. Spend this mana only to cast creature spells. + * + * @author + */ +public class ConditionalAnyColorManaAbility extends ManaAbility { + + public ConditionalAnyColorManaAbility(int amount, ConditionalManaBuilder manaBuilder) { + this(new TapSourceCost(), amount, manaBuilder); + } + + public ConditionalAnyColorManaAbility(Cost cost, int amount, ConditionalManaBuilder manaBuilder) { + super(Constants.Zone.BATTLEFIELD, new AddConditionalManaOfAnyColorEffect(amount, manaBuilder), cost); + for (int i = 0; i < amount; i++) { + this.addChoice(new ChoiceColor()); + } + } + + public ConditionalAnyColorManaAbility(final ConditionalAnyColorManaAbility ability) { + super(ability); + } + + @Override + public ConditionalAnyColorManaAbility copy() { + return new ConditionalAnyColorManaAbility(this); + } +} + diff --git a/Mage/src/mage/abilities/mana/builder/Builder.java b/Mage/src/mage/abilities/mana/builder/Builder.java new file mode 100644 index 00000000000..d841367e606 --- /dev/null +++ b/Mage/src/mage/abilities/mana/builder/Builder.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.abilities.mana.builder; + +/** + * @author noxx + */ +public interface Builder { + public T build(Object... options); +} diff --git a/Mage/src/mage/abilities/mana/builder/ConditionalManaBuilder.java b/Mage/src/mage/abilities/mana/builder/ConditionalManaBuilder.java new file mode 100644 index 00000000000..8a9c8d395aa --- /dev/null +++ b/Mage/src/mage/abilities/mana/builder/ConditionalManaBuilder.java @@ -0,0 +1,44 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.abilities.mana.builder; + +import mage.ConditionalMana; +import mage.Mana; + +/** + * @author noxx + */ +public abstract class ConditionalManaBuilder implements Builder { + + private Mana mana; + + public ConditionalManaBuilder setMana(Mana mana) { + this.mana = mana; + return this; + } +} diff --git a/Mage/src/mage/abilities/mana/conditional/CreatureCastConditionalMana.java b/Mage/src/mage/abilities/mana/conditional/CreatureCastConditionalMana.java new file mode 100644 index 00000000000..14451cf6af0 --- /dev/null +++ b/Mage/src/mage/abilities/mana/conditional/CreatureCastConditionalMana.java @@ -0,0 +1,43 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.abilities.mana.conditional; + +import mage.ConditionalMana; +import mage.Mana; + +/** + * @author noxx + */ +public class CreatureCastConditionalMana extends ConditionalMana { + + public CreatureCastConditionalMana(Mana mana) { + super(mana); + staticText = "Spend this mana only to cast creature spells"; + addCondition(new CreatureCastManaCondition()); + } +} \ No newline at end of file diff --git a/Mage/src/mage/abilities/mana/conditional/CreatureCastManaCondition.java b/Mage/src/mage/abilities/mana/conditional/CreatureCastManaCondition.java new file mode 100644 index 00000000000..6fac5fdbe9c --- /dev/null +++ b/Mage/src/mage/abilities/mana/conditional/CreatureCastManaCondition.java @@ -0,0 +1,51 @@ +/* +* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are +* permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright notice, this list of +* conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright notice, this list +* of conditions and the following disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR +* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The views and conclusions contained in the software and documentation are those of the +* authors and should not be interpreted as representing official policies, either expressed +* or implied, of BetaSteward_at_googlemail.com. +*/ +package mage.abilities.mana.conditional; + +import mage.Constants; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.condition.Condition; +import mage.game.Game; + +/** + * @author noxx + */ +class CreatureCastManaCondition implements Condition { + @Override + public boolean apply(Game game, Ability source) { + if (source instanceof SpellAbility) { + MageObject object = game.getObject(source.getSourceId()); + if (object != null && object.getCardType().contains(Constants.CardType.CREATURE)) { + return true; + } + } + return false; + } +} \ No newline at end of file