* Propaganda, Windborn Muse, Ghostly Prison, Elephant Grass - Fixed bug that the attacker was wrongly forced to pay cost also if he attacked a planeswalker.

This commit is contained in:
LevelX2 2014-06-13 15:10:37 +02:00
parent 48f149c549
commit 86995cde87
4 changed files with 44 additions and 23 deletions

View file

@ -50,6 +50,8 @@ public class GhostlyPrison extends CardImpl {
super(ownerId, 10, "Ghostly Prison", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
this.expansionSetCode = "CHK";
this.color.setWhite(true);
// Creatures can't attack you unless their controller pays {2} for each creature he or she controls that's attacking you
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GhostlyPrisonReplacementEffect()));
}
@ -87,10 +89,10 @@ class GhostlyPrisonReplacementEffect extends ReplacementEffectImpl {
if ( event.getType() == GameEvent.EventType.DECLARE_ATTACKER) {
Player player = game.getPlayer(event.getPlayerId());
if ( player != null && event.getTargetId().equals(source.getControllerId())) {
ManaCostsImpl propagandaTax = new ManaCostsImpl("{2}");
if ( propagandaTax.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Outcome.Benefit, "Pay {2} to declare attacker?", game) ) {
if (propagandaTax.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
ManaCostsImpl attackTax = new ManaCostsImpl("{2}");
if ( attackTax.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Outcome.Benefit, "Pay {2} to attack player?", game) ) {
if (attackTax.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
return false;
}
}
@ -103,7 +105,11 @@ class GhostlyPrisonReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if ( event.getType() == GameEvent.EventType.DECLARE_ATTACKER && event.getTargetId().equals(source.getControllerId()) ) {
return true;
Player attackedPlayer = game.getPlayer(event.getTargetId());
if (attackedPlayer != null) {
// only if a player is attacked. Attacking a planeswalker is free
return true;
}
}
return false;
}

View file

@ -89,11 +89,11 @@ class PropagandaReplacementEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(event.getPlayerId());
if ( player != null ) {
ManaCostsImpl propagandaTax = new ManaCostsImpl("{2}");
if ( propagandaTax.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Outcome.Neutral, "Pay {2} to declare attacker?", game) )
ManaCostsImpl attackTax = new ManaCostsImpl("{2}");
if ( attackTax.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Outcome.Neutral, "Pay {2} to attack player?", game) )
{
if (propagandaTax.payOrRollback(source, game, source.getSourceId(), event.getPlayerId()) ) {
if (attackTax.payOrRollback(source, game, source.getSourceId(), event.getPlayerId()) ) {
return false;
}
}
@ -105,7 +105,11 @@ class PropagandaReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if ( event.getType() == GameEvent.EventType.DECLARE_ATTACKER && event.getTargetId().equals(source.getControllerId())) {
return true;
Player attackedPlayer = game.getPlayer(event.getTargetId());
if (attackedPlayer != null) {
// only if a player is attacked. Attacking a planeswalker is free
return true;
}
}
return false;
}

View file

@ -54,9 +54,12 @@ public class WindbornMuse extends CardImpl {
this.color.setWhite(true);
this.power = new MageInt(2);
this.toughness = new MageInt(3);
// Flying
this.addAbility(FlyingAbility.getInstance());
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new WindbornMuseReplacementEffect()));
// Creatures can't attack you unless their controller pays {2} for each creature he or she controls that's attacking you.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new WindbornMuseReplacementEffect()));
}
public WindbornMuse(final WindbornMuse card) {
@ -92,11 +95,11 @@ class WindbornMuseReplacementEffect extends ReplacementEffectImpl {
if ( event.getType() == GameEvent.EventType.DECLARE_ATTACKER) {
Player player = game.getPlayer(event.getPlayerId());
if ( player != null && event.getTargetId().equals(source.getControllerId())) {
ManaCostsImpl propagandaTax = new ManaCostsImpl("{2}");
if ( propagandaTax.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Outcome.Benefit, "Pay {2} to declare attacker?", game) )
ManaCostsImpl attackTax = new ManaCostsImpl("{2}");
if ( attackTax.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Outcome.Benefit, "Pay {2} to attack player?", game) )
{
if (propagandaTax.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
if (attackTax.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
return false;
}
}
@ -109,7 +112,11 @@ class WindbornMuseReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if ( event.getType() == GameEvent.EventType.DECLARE_ATTACKER && event.getTargetId().equals(source.getControllerId()) ) {
return true;
Player attackedPlayer = game.getPlayer(event.getTargetId());
if (attackedPlayer != null) {
// only if a player is attacked. Attacking a planeswalker is free
return true;
}
}
return false;
}

View file

@ -133,10 +133,10 @@ class ElephantGrassReplacementEffect2 extends ReplacementEffectImpl {
if ( event.getType() == GameEvent.EventType.DECLARE_ATTACKER) {
Player player = game.getPlayer(event.getPlayerId());
if ( player != null && event.getTargetId().equals(source.getControllerId())) {
ManaCostsImpl cost = new ManaCostsImpl("{2}");
if ( cost.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Outcome.Benefit, "Pay {2} to declare attacker?", game) ) {
if (cost.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
ManaCostsImpl attackCost = new ManaCostsImpl("{2}");
if ( attackCost.canPay(source.getSourceId(), event.getPlayerId(), game) &&
player.chooseUse(Outcome.Benefit, "Pay {2} to attack player?", game) ) {
if (attackCost.payOrRollback(source, game, this.getId(), event.getPlayerId())) {
return false;
}
}
@ -150,8 +150,12 @@ class ElephantGrassReplacementEffect2 extends ReplacementEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) {
if ( event.getType() == GameEvent.EventType.DECLARE_ATTACKER && event.getTargetId().equals(source.getControllerId()) ) {
Permanent creature = game.getPermanent(event.getSourceId());
if(creature != null && !creature.getColor().isBlack()){
return true;
if (creature != null && !creature.getColor().isBlack()) {
Player attackedPlayer = game.getPlayer(event.getTargetId());
if (attackedPlayer != null) {
// only if a player is attacked. Attacking a planeswalker is free
return true;
}
}
}
return false;
@ -162,4 +166,4 @@ class ElephantGrassReplacementEffect2 extends ReplacementEffectImpl {
return new ElephantGrassReplacementEffect2(this);
}
}
}