reimplement Conqueror's Pledge

This commit is contained in:
Loki 2011-09-15 23:25:23 +03:00
parent 8dfd3bfc9d
commit 8c98938aa7
2 changed files with 20 additions and 7 deletions

View file

@ -32,7 +32,10 @@ import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.costs.mana.KickerManaCost;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.keyword.KickerAbility;
import mage.cards.CardImpl;
@ -48,10 +51,10 @@ public class ConquerorsPledge extends CardImpl<ConquerorsPledge> {
super(ownerId, 8, "Conqueror's Pledge", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{W}{W}{W}");
this.expansionSetCode = "ZEN";
this.color.setWhite(true);
this.getSpellAbility().addEffect(new CreateTokenEffect(new KorSoldierToken(), 6));
KickerAbility ability = new KickerAbility(new CreateTokenEffect(new KorSoldierToken(), 12), true);
ability.addManaCost(new GenericManaCost(6));
this.addAbility(ability);
this.getSpellAbility().addOptionalCost(new KickerManaCost("{6}"));
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(new CreateTokenEffect(new KorSoldierToken(), 12),
new CreateTokenEffect(new KorSoldierToken(), 6), KickedCondition.getInstance(),
"Put six 1/1 white Kor Soldier creature tokens onto the battlefield. If Conqueror's Pledge was kicked, put twelve of those tokens onto the battlefield instead"));
}
public ConquerorsPledge(final ConquerorsPledge card) {

View file

@ -28,6 +28,7 @@
package mage.abilities.decorator;
import com.sun.istack.internal.Nullable;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.effects.OneShotEffect;
@ -41,18 +42,25 @@ import mage.game.Game;
public class ConditionalOneShotEffect extends OneShotEffect<ConditionalOneShotEffect> {
private OneShotEffect effect;
private OneShotEffect otherwiseEffect;
private Condition condition;
public ConditionalOneShotEffect ( OneShotEffect effect, Condition condition, String text ) {
public ConditionalOneShotEffect ( OneShotEffect effect, Condition condition, String text ) {
this(effect, null, condition, text);
}
public ConditionalOneShotEffect ( OneShotEffect effect, OneShotEffect otherwiseEffect, Condition condition, String text ) {
super(effect.getOutcome());
this.effect = effect;
this.otherwiseEffect = otherwiseEffect;
this.condition = condition;
this.staticText = text;
}
public ConditionalOneShotEffect ( ConditionalOneShotEffect effect ) {
super(effect);
this.effect = effect.effect;
this.effect = (OneShotEffect) effect.effect.copy();
this.otherwiseEffect = (OneShotEffect) effect.otherwiseEffect.copy();
this.condition = effect.condition;
}
@ -60,7 +68,9 @@ public class ConditionalOneShotEffect extends OneShotEffect<ConditionalOneShotEf
public boolean apply ( Game game, Ability source ) {
if ( condition.apply(game, source) ) {
return effect.apply(game, source);
}
} else if (otherwiseEffect != null) {
return otherwiseEffect.apply(game, source);
}
return false;
}