mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
White Sun's Zenith
This commit is contained in:
parent
54adc043ec
commit
a9b4496ef3
4 changed files with 121 additions and 12 deletions
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue