Small fixes to "Domain" cards Draco, Fettergeist and Samite Pilgrim.

This commit is contained in:
Simown 2015-07-22 22:01:02 +01:00
parent f8063ae064
commit 0f6fab5248
3 changed files with 5 additions and 48 deletions

View file

@ -102,10 +102,7 @@ class FettergeistUnlessPaysEffect extends OneShotEffect {
if (player != null && permanent != null) { if (player != null && permanent != null) {
PermanentsOnBattlefieldCount amount = new PermanentsOnBattlefieldCount(filter, 1); PermanentsOnBattlefieldCount amount = new PermanentsOnBattlefieldCount(filter, 1);
int count = amount.calculate(game, source, this); int count = amount.calculate(game, source, this);
if (count == 0) { if (player.chooseUse(Outcome.Benefit, "Pay " + count + "? Or " + permanent.getName() + " will be sacrificed.", source, game)) {
return true;
}
if (player.chooseUse(Outcome.Benefit, "Pay " + count + "?", source, game)) {
GenericManaCost cost = new GenericManaCost(count); GenericManaCost cost = new GenericManaCost(count);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) { if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
return true; return true;

View file

@ -124,11 +124,7 @@ class DracoSacrificeUnlessPaysEffect extends OneShotEffect {
if (player != null && permanent != null) { if (player != null && permanent != null) {
// The cost is reduced by {2} for each basic land type. // The cost is reduced by {2} for each basic land type.
int domainValueReduction = new DomainValue(2).calculate(game, source, this); int domainValueReduction = new DomainValue(2).calculate(game, source, this);
// Nothing to pay int count = MAX_DOMAIN_VALUE - domainValueReduction;
if (domainValueReduction >= MAX_DOMAIN_VALUE) {
return true;
}
int count = (MAX_DOMAIN_VALUE-domainValueReduction );
if (player.chooseUse(Outcome.Benefit, "Pay {" + count + "}? Or " + permanent.getName() + " will be sacrificed.", source, game)) { if (player.chooseUse(Outcome.Benefit, "Pay {" + count + "}? Or " + permanent.getName() + " will be sacrificed.", source, game)) {
GenericManaCost cost = new GenericManaCost(count); GenericManaCost cost = new GenericManaCost(count);
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) { if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {

View file

@ -55,7 +55,7 @@ public class SamitePilgrim extends CardImpl {
this.power = new MageInt(1); this.power = new MageInt(1);
this.toughness = new MageInt(1); this.toughness = new MageInt(1);
// Domain - {tap}: Prevent the next X damage that would be dealt to target creature this turn, where X is the number of basic land types among lands you control. // Domain - {T}: Prevent the next X damage that would be dealt to target creature this turn, where X is the number of basic land types among lands you control.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SamitePilgrimPreventDamageToTargetEffect(), new TapSourceCost()); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SamitePilgrimPreventDamageToTargetEffect(), new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability); this.addAbility(ability);
@ -73,16 +73,14 @@ public class SamitePilgrim extends CardImpl {
class SamitePilgrimPreventDamageToTargetEffect extends PreventionEffectImpl { class SamitePilgrimPreventDamageToTargetEffect extends PreventionEffectImpl {
protected int amount = 0;
public SamitePilgrimPreventDamageToTargetEffect() { public SamitePilgrimPreventDamageToTargetEffect() {
super(Duration.EndOfTurn); super(Duration.EndOfTurn, Integer.MAX_VALUE, false, true);
staticText = "Prevent the next X damage that would be dealt to target creature this turn, where X is the number of basic land types among lands you control."; staticText = "Prevent the next X damage that would be dealt to target creature this turn, where X is the number of basic land types among lands you control.";
} }
public SamitePilgrimPreventDamageToTargetEffect(final SamitePilgrimPreventDamageToTargetEffect effect) { public SamitePilgrimPreventDamageToTargetEffect(final SamitePilgrimPreventDamageToTargetEffect effect) {
super(effect); super(effect);
this.amount = effect.amount;
} }
@Override @Override
@ -93,7 +91,7 @@ class SamitePilgrimPreventDamageToTargetEffect extends PreventionEffectImpl {
@Override @Override
public void init(Ability source, Game game) { public void init(Ability source, Game game) {
super.init(source, game); super.init(source, game);
amount = new DomainValue().calculate(game, source, this); amountToPrevent = new DomainValue().calculate(game, source, this);
} }
@Override @Override
@ -101,40 +99,6 @@ class SamitePilgrimPreventDamageToTargetEffect extends PreventionEffectImpl {
return true; return true;
} }
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
boolean result = false;
int toPrevent = amount;
if (event.getAmount() < this.amount) {
toPrevent = event.getAmount();
amount -= event.getAmount();
} else {
amount = 0;
}
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent, false);
if (!game.replaceEvent(preventEvent)) {
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
if (targetCreature != null) {
if (amount == 0) {
this.used = true;
this.discard();
}
if (event.getAmount() >= toPrevent) {
event.setAmount(event.getAmount() - toPrevent);
} else {
event.setAmount(0);
result = true;
}
if (toPrevent > 0) {
game.informPlayers(new StringBuilder("Samite Pilgrim ").append("prevented ").append(toPrevent).append(" to ").append(targetCreature.getName()).toString());
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent));
}
}
}
return result;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
return !this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getFirstTarget()); return !this.used && super.applies(event, source, game) && event.getTargetId().equals(source.getFirstTarget());