Added some parameters and improved rule text gerneration

This commit is contained in:
LevelX2 2013-04-05 15:11:39 +02:00
parent 36b4482367
commit 49f11cba8f
2 changed files with 40 additions and 7 deletions

View file

@ -38,6 +38,7 @@ import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID; import java.util.UUID;
import mage.Constants;
/** /**
* @author LevelX * @author LevelX
@ -45,15 +46,22 @@ import java.util.UUID;
public class PutOntoBattlefieldTargetEffect extends OneShotEffect<PutOntoBattlefieldTargetEffect> { public class PutOntoBattlefieldTargetEffect extends OneShotEffect<PutOntoBattlefieldTargetEffect> {
boolean tapped; boolean tapped;
boolean optional;
public PutOntoBattlefieldTargetEffect(boolean tapped) { public PutOntoBattlefieldTargetEffect(boolean tapped) {
this(tapped, false);
}
public PutOntoBattlefieldTargetEffect(boolean tapped, boolean optional) {
super(Outcome.PutCreatureInPlay); super(Outcome.PutCreatureInPlay);
this.tapped = tapped; this.tapped = tapped;
this.optional = optional;
} }
public PutOntoBattlefieldTargetEffect(final PutOntoBattlefieldTargetEffect effect) { public PutOntoBattlefieldTargetEffect(final PutOntoBattlefieldTargetEffect effect) {
super(effect); super(effect);
this.tapped = effect.tapped; this.tapped = effect.tapped;
this.optional = effect.optional;
} }
@Override @Override
@ -64,6 +72,15 @@ public class PutOntoBattlefieldTargetEffect extends OneShotEffect<PutOntoBattlef
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
boolean result = false; boolean result = false;
if (optional) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || !controller.chooseUse(Constants.Outcome.PutCreatureInPlay,
new StringBuilder("Put ")
.append(source.getTargets() != null ? source.getTargets().get(0).getTargetName():"target")
.append(" onto the battlefield?").toString(), game)) {
return false;
}
}
for (UUID targetId : targetPointer.getTargets(game, source)) { for (UUID targetId : targetPointer.getTargets(game, source)) {
Card card = game.getCard(targetId); Card card = game.getCard(targetId);
if (card != null) { if (card != null) {
@ -91,12 +108,20 @@ public class PutOntoBattlefieldTargetEffect extends OneShotEffect<PutOntoBattlef
@Override @Override
public String getText(Mode mode) { public String getText(Mode mode) {
// You may put an artifact card from your hand onto the battlefield.
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (optional) {
sb.append("You may put ");
} else {
sb.append("Put "); sb.append("Put ");
}
if (mode.getTargets().get(0).getMaxNumberOfTargets() == 0) { if (mode.getTargets().get(0).getMaxNumberOfTargets() == 0) {
sb.append("any number of "); sb.append("any number of ");
} }
if (mode.getTargets() != null) {
sb.append(mode.getTargets().get(0).getTargetName()); sb.append(mode.getTargets().get(0).getTargetName());
}
sb.append(tapped ? "tapped" : "").append(" onto the battlefield"); sb.append(tapped ? "tapped" : "").append(" onto the battlefield");
return sb.toString(); return sb.toString();

View file

@ -54,6 +54,14 @@ public class SetPowerToughnessAllEffect extends ContinuousEffectImpl<SetPowerTou
private DynamicValue toughness; private DynamicValue toughness;
private boolean lockedIn; private boolean lockedIn;
public SetPowerToughnessAllEffect(int power, int toughness, Duration duration) {
this(new StaticValue(power), new StaticValue(toughness), duration, new FilterCreaturePermanent("Creatures"), true);
}
public SetPowerToughnessAllEffect(int power, int toughness, Duration duration, FilterPermanent filter, boolean lockedIn) {
this(new StaticValue(power), new StaticValue(toughness), duration, filter, lockedIn);
}
public SetPowerToughnessAllEffect(DynamicValue power, DynamicValue toughness, Duration duration, FilterPermanent filter, boolean lockedIn) { public SetPowerToughnessAllEffect(DynamicValue power, DynamicValue toughness, Duration duration, FilterPermanent filter, boolean lockedIn) {
super(duration, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature); super(duration, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature);
this.power = power; this.power = power;
@ -62,10 +70,6 @@ public class SetPowerToughnessAllEffect extends ContinuousEffectImpl<SetPowerTou
this.lockedIn = lockedIn; this.lockedIn = lockedIn;
} }
public SetPowerToughnessAllEffect(int power, int toughness, Duration duration) {
this(new StaticValue(power), new StaticValue(toughness), duration, new FilterCreaturePermanent("Creatures"), true);
}
public SetPowerToughnessAllEffect(final SetPowerToughnessAllEffect effect) { public SetPowerToughnessAllEffect(final SetPowerToughnessAllEffect effect) {
super(effect); super(effect);
this.power = effect.power; this.power = effect.power;
@ -108,7 +112,11 @@ public class SetPowerToughnessAllEffect extends ContinuousEffectImpl<SetPowerTou
public String getText(Mode mode) { public String getText(Mode mode) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(filter.getMessage()); sb.append(filter.getMessage());
if (filter.getMessage().startsWith("Each ")) {
sb.append(" becomes ");
} else {
sb.append(" become "); sb.append(" become ");
}
sb.append(power).append("/").append(toughness); sb.append(power).append("/").append(toughness);
if (!duration.toString().isEmpty()) { if (!duration.toString().isEmpty()) {
sb.append(" ").append(duration.toString()); sb.append(" ").append(duration.toString());