Reimplemented 2 cards with kicker.

This commit is contained in:
magenoxx 2011-09-14 23:12:15 +04:00
parent 4914e12d45
commit 1e172b0a45
4 changed files with 111 additions and 42 deletions

View file

@ -28,49 +28,57 @@
package mage.sets.zendikar;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.decorator.ConditionalStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
import mage.abilities.keyword.KickerAbility;
import mage.abilities.keyword.UnblockableAbility;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
* @author nantuko, BetaSteward_at_googlemail.com
*/
public class AetherFigment extends CardImpl<AetherFigment> {
public AetherFigment(UUID ownerId) {
super(ownerId, 40, "AEther Figment", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{U}");
this.expansionSetCode = "ZEN";
this.subtype.add("Illusion");
this.color.setBlue(true);
this.power = new MageInt(1);
this.toughness = new MageInt(1);
private final static String staticText = "If AEther Figment was kicked, it enters the battlefield with two +1/+1 counters on it";
this.addAbility(UnblockableAbility.getInstance());
Ability ability1 = new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2)));
KickerAbility ability2 = new KickerAbility(new GainAbilitySourceEffect(ability1, Duration.WhileOnBattlefield), false);
ability2.addManaCost(new GenericManaCost(3));
this.addAbility(ability2);
}
public AetherFigment(UUID ownerId) {
super(ownerId, 40, "AEther Figment", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{U}");
this.expansionSetCode = "ZEN";
this.subtype.add("Illusion");
this.color.setBlue(true);
this.power = new MageInt(1);
this.toughness = new MageInt(1);
public AetherFigment(final AetherFigment card) {
super(card);
}
// AEther Figment is unblockable.
this.addAbility(UnblockableAbility.getInstance());
@Override
public AetherFigment copy() {
return new AetherFigment(this);
}
// Kicker {3}
this.getSpellAbility().addOptionalCost(new GenericManaCost(3));
// If AEther Figment was kicked, it enters the battlefield with two +1/+1 counters on it
Ability ability = new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2)), KickedCondition.getInstance(), ""), staticText);
this.addAbility(ability);
}
public AetherFigment(final AetherFigment card) {
super(card);
}
@Override
public AetherFigment copy() {
return new AetherFigment(this);
}
}

View file

@ -27,35 +27,45 @@
*/
package mage.sets.zendikar;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.common.continious.BoostControlledEffect;
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.KickerAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import java.util.UUID;
/**
*
* @author Loki
* @author nantuko, Loki
*/
public class BoldDefense extends CardImpl<BoldDefense> {
private final String staticText = "If Bold Defense was kicked, instead creatures you control get +2/+2 and gain first strike until end of turn";
public BoldDefense(UUID ownerId) {
super(ownerId, 3, "Bold Defense", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{2}{W}");
this.expansionSetCode = "ZEN";
this.color.setWhite(true);
Ability kickedAbility = new KickerAbility(new BoostControlledEffect(2, 2, Constants.Duration.EndOfTurn), true);
kickedAbility.addCost(new ManaCostsImpl("{3}{W}"));
kickedAbility.addEffect(new GainAbilityControlledEffect(FirstStrikeAbility.getInstance(), Constants.Duration.EndOfTurn, FilterCreaturePermanent.getDefault(), false));
this.addAbility(kickedAbility);
this.getSpellAbility().addEffect(new BoostControlledEffect(1, 1, Constants.Duration.EndOfTurn));
DynamicValue dn = new BoldDefensePTCount();
this.getSpellAbility().addEffect(new BoostControlledEffect(dn, dn, Constants.Duration.EndOfTurn));
this.getSpellAbility().addOptionalCost(new ManaCostsImpl("{3}{W}"));
ContinuousEffect effect = new GainAbilityControlledEffect(FirstStrikeAbility.getInstance(), Constants.Duration.EndOfTurn, FilterCreaturePermanent.getDefault(), false);
this.getSpellAbility().addEffect(new ConditionalContinousEffect(effect, KickedCondition.getInstance(), staticText));
}
public BoldDefense(final BoldDefense card) {
@ -67,3 +77,28 @@ public class BoldDefense extends CardImpl<BoldDefense> {
return new BoldDefense(this);
}
}
class BoldDefensePTCount implements DynamicValue {
public BoldDefensePTCount() {
}
@Override
public int calculate(Game game, Ability sourceAbility) {
if (KickedCondition.getInstance().apply(game, sourceAbility)) {
return 2;
} else {
return 1;
}
}
@Override
public DynamicValue clone() {
return new BoldDefensePTCount();
}
@Override
public String getMessage() {
return "";
}
}

View file

@ -98,7 +98,7 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl<EntersBattlef
if (text.length() == 0)
return "When {this} enters the battlefield, " + baseEffects.getText(mode);
else
return "When {this} enters the battlefield, " + text;
return text;
}
@Override

View file

@ -33,6 +33,8 @@ import mage.Constants.Layer;
import mage.Constants.Outcome;
import mage.Constants.SubLayer;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
@ -44,8 +46,8 @@ import mage.game.permanent.Permanent;
*/
public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledEffect> {
protected int power;
protected int toughness;
private DynamicValue power;
private DynamicValue toughness;
protected boolean excludeSource;
protected FilterCreaturePermanent filter;
@ -53,11 +55,19 @@ public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledE
this(power, toughness, duration, FilterCreaturePermanent.getDefault(), false);
}
public BoostControlledEffect(DynamicValue power, DynamicValue toughness, Duration duration) {
this(power, toughness, duration, FilterCreaturePermanent.getDefault(), false);
}
public BoostControlledEffect(int power, int toughness, Duration duration, boolean excludeSource) {
this(power, toughness, duration, FilterCreaturePermanent.getDefault(), excludeSource);
}
public BoostControlledEffect(int power, int toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) {
this(new StaticValue(power), new StaticValue(toughness), duration, filter, excludeSource);
}
public BoostControlledEffect(DynamicValue power, DynamicValue toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) {
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
this.power = power;
this.toughness = toughness;
@ -96,8 +106,8 @@ public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledE
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) {
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
perm.addPower(power);
perm.addToughness(toughness);
perm.addPower(power.calculate(game, source));
perm.addToughness(toughness.calculate(game, source));
}
}
}
@ -109,7 +119,23 @@ public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledE
if (excludeSource)
sb.append("Other ");
sb.append(filter.getMessage());
sb.append(" you control get ").append(String.format("%1$+d/%2$+d", power, toughness));
sb.append(" you control get ");
String p = power.toString();
if(!p.startsWith("-")) {
sb.append("+");
}
sb.append(p).append("/");
String t = toughness.toString();
if(!t.startsWith("-")){
if(p.startsWith("-")) {
sb.append("-");
} else {
sb.append("+");
}
}
sb.append(t);
sb.append((duration==Duration.EndOfTurn?" until end of turn":""));
staticText = sb.toString();
}