White Sun's Zenith

This commit is contained in:
Loki 2011-05-13 23:40:30 +03:00
parent 54adc043ec
commit a9b4496ef3
4 changed files with 121 additions and 12 deletions

View file

@ -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<WhiteSunsZenith> {
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);
}
}

View file

@ -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";
}
}

View file

@ -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<CreateTokenEffect> {
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<CreateTokenEffect> {
@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();
}

View file

@ -63,7 +63,7 @@ public class ShuffleSpellEffect extends OneShotEffect<ShuffleSpellEffect> {
@Override
public String getText(Ability source) {
return "Shuffle {this} into its owner's library.";
return "Shuffle {this} into its owner's library";
}
@Override