diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/WhiteSunsZenith.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/WhiteSunsZenith.java new file mode 100644 index 00000000000..3b48e1e0a00 --- /dev/null +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/WhiteSunsZenith.java @@ -0,0 +1,77 @@ +/* + * 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.mirrodinbesieged; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.ShuffleSpellEffect; +import mage.cards.CardImpl; +import mage.game.permanent.token.EldraziSpawnToken; +import mage.game.permanent.token.Token; + +/** + * + * @author Loki + */ +public class WhiteSunsZenith extends CardImpl { + + public WhiteSunsZenith (UUID ownerId) { + super(ownerId, 19, "White Sun's Zenith", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{X}{W}{W}{W}"); + this.expansionSetCode = "MBS"; + this.color.setWhite(true); + this.getSpellAbility().addEffect(new CreateTokenEffect(new CatToken(), new ManacostVariableValue())); + this.getSpellAbility().addEffect(ShuffleSpellEffect.getInstance()); + } + + public WhiteSunsZenith (final WhiteSunsZenith card) { + super(card); + } + + @Override + public WhiteSunsZenith copy() { + return new WhiteSunsZenith(this); + } +} + +class CatToken extends Token { + public CatToken() { + super("Cat", "2/2 white Cat creature token"); + cardType.add(CardType.CREATURE); + color = ObjectColor.WHITE; + subtype.add("Cat"); + power = new MageInt(2); + toughness = new MageInt(2); + } +} \ No newline at end of file diff --git a/Mage/src/mage/abilities/dynamicvalue/common/ManacostVariableValue.java b/Mage/src/mage/abilities/dynamicvalue/common/ManacostVariableValue.java new file mode 100644 index 00000000000..8b43648ef8c --- /dev/null +++ b/Mage/src/mage/abilities/dynamicvalue/common/ManacostVariableValue.java @@ -0,0 +1,22 @@ +package mage.abilities.dynamicvalue.common; + +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.game.Game; + +public class ManacostVariableValue implements DynamicValue { + @Override + public int calculate(Game game, Ability sourceAbility) { + return sourceAbility.getManaCostsToPay().getVariableCosts().get(0).getAmount(); + } + + @Override + public DynamicValue clone() { + return new ManacostVariableValue(); + } + + @Override + public String toString() { + return "X"; + } +} diff --git a/Mage/src/mage/abilities/effects/common/CreateTokenEffect.java b/Mage/src/mage/abilities/effects/common/CreateTokenEffect.java index 807cd098c4b..b832bda75e9 100644 --- a/Mage/src/mage/abilities/effects/common/CreateTokenEffect.java +++ b/Mage/src/mage/abilities/effects/common/CreateTokenEffect.java @@ -30,6 +30,8 @@ package mage.abilities.effects.common; import mage.Constants.Outcome; import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.OneShotEffect; import mage.game.Game; import mage.game.permanent.token.Token; @@ -41,18 +43,22 @@ import mage.game.permanent.token.Token; public class CreateTokenEffect extends OneShotEffect { private Token token; - private int amount; + private DynamicValue amount; public CreateTokenEffect(Token token) { - this(token, 1); + this(token, new StaticValue(1)); } public CreateTokenEffect(Token token, int amount) { - super(Outcome.PutCreatureInPlay); - this.token = token; - this.amount = amount; + this(token, new StaticValue(amount)); } + public CreateTokenEffect(Token token, DynamicValue amount) { + super(Outcome.PutCreatureInPlay); + this.token = token; + this.amount = amount.clone(); + } + public CreateTokenEffect(final CreateTokenEffect effect) { super(effect); this.amount = effect.amount; @@ -66,19 +72,23 @@ public class CreateTokenEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (int i = 0; i < amount; i++) { + for (int i = 0; i < amount.calculate(game, source); i++) { token.putOntoBattlefield(game, source.getId(), source.getControllerId()); } return true; } @Override - public String getText(Ability source) { + public String getDynamicText(Ability source) { StringBuilder sb = new StringBuilder(); - if (amount == 1) - sb.append("put a"); - else - sb.append("put ").append(Integer.toString(amount)); + if (amount instanceof StaticValue) { + int count = amount.calculate(null, null); + if (count == 1) + sb.append("put a"); + else sb.append("put ").append(Integer.toString(count)); + } else { + sb.append("put ").append(amount); + } sb.append(" ").append(token.getDescription()).append(" onto the battlefield"); return sb.toString(); } diff --git a/Mage/src/mage/abilities/effects/common/ShuffleSpellEffect.java b/Mage/src/mage/abilities/effects/common/ShuffleSpellEffect.java index 86aa71a7eea..c4c7b7d7a1e 100644 --- a/Mage/src/mage/abilities/effects/common/ShuffleSpellEffect.java +++ b/Mage/src/mage/abilities/effects/common/ShuffleSpellEffect.java @@ -63,7 +63,7 @@ public class ShuffleSpellEffect extends OneShotEffect { @Override public String getText(Ability source) { - return "Shuffle {this} into its owner's library."; + return "Shuffle {this} into its owner's library"; } @Override