Some rule text changes and some improvements to BeginningOfCombatTriggeredAbility. Use it for Desecration Demon.

This commit is contained in:
LevelX2 2013-01-09 15:25:23 +01:00
parent 9fb66bd065
commit efccd682b6
3 changed files with 17 additions and 45 deletions

View file

@ -32,10 +32,9 @@ import mage.Constants;
import mage.Constants.CardType; import mage.Constants.CardType;
import mage.Constants.Outcome; import mage.Constants.Outcome;
import mage.Constants.Rarity; import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.BeginningOfCombatTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -44,7 +43,6 @@ import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate; import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetControlledPermanent;
@ -68,8 +66,7 @@ public class DesecrationDemon extends CardImpl<DesecrationDemon> {
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
// At the beginning of each combat, any opponent may sacrifice a creature. If a player does, tap Desecration Demon and put a +1/+1 counter on it. // At the beginning of each combat, any opponent may sacrifice a creature. If a player does, tap Desecration Demon and put a +1/+1 counter on it.
this.addAbility(new DesecrationDemonTriggeredAbility()); this.addAbility(new BeginningOfCombatTriggeredAbility(new DesecrationDemonEffect(), Constants.TargetController.ANY, false));
} }
public DesecrationDemon(final DesecrationDemon card) { public DesecrationDemon(final DesecrationDemon card) {
@ -82,39 +79,10 @@ public class DesecrationDemon extends CardImpl<DesecrationDemon> {
} }
} }
class DesecrationDemonTriggeredAbility extends TriggeredAbilityImpl<DesecrationDemonTriggeredAbility> {
public DesecrationDemonTriggeredAbility() {
super(Zone.BATTLEFIELD, new DesecrationDemonEffect());
}
public DesecrationDemonTriggeredAbility(final DesecrationDemonTriggeredAbility ability) {
super(ability);
}
@Override
public DesecrationDemonTriggeredAbility copy() {
return new DesecrationDemonTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.COMBAT_PHASE_PRE) {
return true;
}
return false;
}
@Override
public String getRule() {
return "At the beginning of each combat, any opponent may sacrifice a creature. If a player does, tap Desecration Demon and put a +1/+1 counter on it";
}
}
class DesecrationDemonEffect extends OneShotEffect<DesecrationDemonEffect> { class DesecrationDemonEffect extends OneShotEffect<DesecrationDemonEffect> {
DesecrationDemonEffect() { DesecrationDemonEffect() {
super(Constants.Outcome.BoostCreature); super(Constants.Outcome.BoostCreature);
staticText = "any opponent may sacrifice a creature. If a player does, tap {this} and put a +1/+1 counter on it";
} }
DesecrationDemonEffect(final DesecrationDemonEffect effect) { DesecrationDemonEffect(final DesecrationDemonEffect effect) {
@ -134,13 +102,13 @@ class DesecrationDemonEffect extends OneShotEffect<DesecrationDemonEffect> {
filter.add(new ControllerPredicate(Constants.TargetController.YOU)); filter.add(new ControllerPredicate(Constants.TargetController.YOU));
TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false); TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, false);
if (target.canChoose(opponent.getId(), game)) { if (target.canChoose(opponent.getId(), game)) {
if (opponent.chooseUse(Outcome.Detriment, "Sacrifice a creature to tap Desecration Demon and put a +1/+1 counter on it?", game)) if (opponent.chooseUse(Outcome.Detriment, new StringBuilder("Sacrifice a creature to tap ").append(descrationDemon.getName()).append("and put a +1/+1 counter on it?").toString(), game))
{ {
opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game); opponent.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget()); Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) { if (permanent != null) {
permanent.sacrifice(source.getId(), game); permanent.sacrifice(source.getId(), game);
game.informPlayers(opponent.getName() + " sacrifices " + permanent.getName() + " to tap Desecration Demon and put a +1/+1 counter on it"); game.informPlayers(new StringBuilder(opponent.getName()).append(" sacrifices ").append(permanent.getName()).append(" to tap ").append(descrationDemon.getName()).append(". A +1/+1 counter was put on it").toString());
if (descrationDemon != null) { if (descrationDemon != null) {
descrationDemon.tap(game); descrationDemon.tap(game);
descrationDemon.addCounters(CounterType.P1P1.createInstance(), game); descrationDemon.addCounters(CounterType.P1P1.createInstance(), game);
@ -159,4 +127,4 @@ class DesecrationDemonEffect extends OneShotEffect<DesecrationDemonEffect> {
public DesecrationDemonEffect copy() { public DesecrationDemonEffect copy() {
return new DesecrationDemonEffect(this); return new DesecrationDemonEffect(this);
} }
} }

View file

@ -55,7 +55,7 @@ public class BattleRattleShaman extends CardImpl<BattleRattleShaman> {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// At the beginning of combat on your turn, you may have target creature get +2/+0 until end of turn. // At the beginning of combat on your turn, you may have target creature get +2/+0 until end of turn.
Ability ability = new BeginningOfCombatTriggeredAbility(Constants.Zone.BATTLEFIELD, new BoostTargetEffect(2, 0, Constants.Duration.EndOfTurn), Constants.TargetController.YOU, true); Ability ability = new BeginningOfCombatTriggeredAbility(Constants.Zone.BATTLEFIELD, new BoostTargetEffect(2, 0, Constants.Duration.EndOfTurn), Constants.TargetController.YOU, true, false);
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability); this.addAbility(ability);

View file

@ -8,20 +8,24 @@ import mage.game.events.GameEvent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl<BeginningOfCombatTriggeredAbility> { public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl<BeginningOfCombatTriggeredAbility> {
private Constants.TargetController targetController; private Constants.TargetController targetController;
private boolean setTargetPointer;
public BeginningOfCombatTriggeredAbility(Effect effect, Constants.TargetController targetController, boolean isOptional) { public BeginningOfCombatTriggeredAbility(Effect effect, Constants.TargetController targetController, boolean isOptional) {
this(Constants.Zone.BATTLEFIELD, effect, targetController, isOptional); this(Constants.Zone.BATTLEFIELD, effect, targetController, isOptional, false);
} }
public BeginningOfCombatTriggeredAbility(Constants.Zone zone, Effect effect, Constants.TargetController targetController, boolean isOptional) { public BeginningOfCombatTriggeredAbility(Constants.Zone zone, Effect effect, Constants.TargetController targetController, boolean isOptional, boolean setTargetPointer) {
super(zone, effect, isOptional); super(zone, effect, isOptional);
this.targetController = targetController; this.targetController = targetController;
this.setTargetPointer = setTargetPointer;
} }
public BeginningOfCombatTriggeredAbility(final BeginningOfCombatTriggeredAbility ability) { public BeginningOfCombatTriggeredAbility(final BeginningOfCombatTriggeredAbility ability) {
super(ability); super(ability);
this.targetController = ability.targetController; this.targetController = ability.targetController;
this.setTargetPointer = ability.setTargetPointer;
} }
@Override @Override
@ -35,7 +39,7 @@ public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl<Begi
switch (targetController) { switch (targetController) {
case YOU: case YOU:
boolean yours = event.getPlayerId().equals(this.controllerId); boolean yours = event.getPlayerId().equals(this.controllerId);
if (yours) { if (yours && setTargetPointer) {
if (getTargets().size() == 0) { if (getTargets().size() == 0) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
@ -45,7 +49,7 @@ public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl<Begi
return yours; return yours;
case OPPONENT: case OPPONENT:
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) { if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
if (getTargets().size() == 0) { if (setTargetPointer) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }
@ -54,7 +58,7 @@ public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl<Begi
} }
break; break;
case ANY: case ANY:
if (getTargets().size() == 0) { if (setTargetPointer) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }
@ -73,7 +77,7 @@ public class BeginningOfCombatTriggeredAbility extends TriggeredAbilityImpl<Begi
case OPPONENT: case OPPONENT:
return "At the beginning of each opponent's combat step, " + generateZoneString() + getEffects().getText(modes.getMode()); return "At the beginning of each opponent's combat step, " + generateZoneString() + getEffects().getText(modes.getMode());
case ANY: case ANY:
return "At the beginning of each player's combat step, " + generateZoneString() + getEffects().getText(modes.getMode()); return "At the beginning of each combat, " + generateZoneString() + getEffects().getText(modes.getMode());
} }
return ""; return "";
} }