* Echo ability - Fixed that echo had not to be paid if permanent came into play by other abilities (e.g. Living End).

This commit is contained in:
LevelX2 2014-04-05 16:17:33 +02:00
parent a4f73a9fde
commit 6a827fcce8
2 changed files with 13 additions and 9 deletions

View file

@ -60,6 +60,7 @@ public class EchoAbility extends TriggeredAbilityImpl<EchoAbility> {
super(Zone.BATTLEFIELD, new EchoEffect(new ManaCostsImpl(manaString)), false); super(Zone.BATTLEFIELD, new EchoEffect(new ManaCostsImpl(manaString)), false);
this.echoPaid = false; this.echoPaid = false;
this.echoCosts.add(new ManaCostsImpl(manaString)); this.echoCosts.add(new ManaCostsImpl(manaString));
this.lastController = null;
} }
public EchoAbility(Cost echoCost) { public EchoAbility(Cost echoCost) {
@ -67,6 +68,7 @@ public class EchoAbility extends TriggeredAbilityImpl<EchoAbility> {
this.echoPaid = false; this.echoPaid = false;
this.echoCosts.add(echoCost); this.echoCosts.add(echoCost);
this.manaEcho = false; this.manaEcho = false;
this.lastController = null;
} }
public EchoAbility(final EchoAbility ability) { public EchoAbility(final EchoAbility ability) {
@ -74,6 +76,7 @@ public class EchoAbility extends TriggeredAbilityImpl<EchoAbility> {
this.echoPaid = ability.echoPaid; this.echoPaid = ability.echoPaid;
this.echoCosts = ability.echoCosts.copy(); this.echoCosts = ability.echoCosts.copy();
this.manaEcho = ability.manaEcho; this.manaEcho = ability.manaEcho;
this.lastController = ability.lastController;
} }
@Override @Override
@ -83,21 +86,22 @@ public class EchoAbility extends TriggeredAbilityImpl<EchoAbility> {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { // reset the echo paid state back, if creature enteres the battlefield
EntersTheBattlefieldEvent zEvent = (EntersTheBattlefieldEvent)event; if (event.getType().equals(GameEvent.EventType.ENTERS_THE_BATTLEFIELD)
if(zEvent.getFromZone() == null && this.echoPaid) { && event.getTargetId().equals(this.getSourceId())) {
this.echoPaid = false; this.echoPaid = false;
}
} }
if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE) { if (event.getType().equals(GameEvent.EventType.UPKEEP_STEP_PRE)) {
if(lastController != null){ if(lastController != null){
if(!lastController.equals(this.controllerId)){ if(!lastController.equals(this.controllerId)){
this.echoPaid = false; this.echoPaid = false;
} }
} }
// remember the last controller
lastController = this.getControllerId(); lastController = this.getControllerId();
} }
if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && // if echo not paid yet, controller has to pay
if (event.getType().equals(GameEvent.EventType.UPKEEP_STEP_PRE) &&
event.getPlayerId().equals(this.controllerId) && event.getPlayerId().equals(this.controllerId) &&
lastController.equals(this.controllerId) && !this.echoPaid){ lastController.equals(this.controllerId) && !this.echoPaid){
this.echoPaid = true; this.echoPaid = true;

View file

@ -241,7 +241,7 @@ class SuspendExileEffect extends OneShotEffect<SuspendExileEffect> {
Card card = game.getCard(source.getSourceId()); Card card = game.getCard(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (card != null && controller != null) { if (card != null && controller != null) {
// check if the user really wants to suspend the card (only if spell can't be casted because else the choose ability dialog appears) // check if the user really wants to suspend the card (only if the spell can't be casted because else the choose ability dialog appears)
if (!card.getSpellAbility().canActivate(source.getControllerId(), game)) { if (!card.getSpellAbility().canActivate(source.getControllerId(), game)) {
if (!controller.chooseUse(outcome, new StringBuilder("Suspend ").append(card.getName()).append("?").toString(), game)) { if (!controller.chooseUse(outcome, new StringBuilder("Suspend ").append(card.getName()).append("?").toString(), game)) {
return false; return false;
@ -322,7 +322,7 @@ class SuspendPlayCardEffect extends OneShotEffect<SuspendPlayCardEffect> {
Card card = game.getCard(source.getSourceId()); Card card = game.getCard(source.getSourceId());
if (player != null && card != null) { if (player != null && card != null) {
// remove temporary suspend ability (used e.g. for Epochrasite) // remove temporary suspend ability (used e.g. for Epochrasite)
List<Ability> abilitiesToRemove = new ArrayList<Ability>(); List<Ability> abilitiesToRemove = new ArrayList<>();
for (Ability ability : card.getAbilities()) { for (Ability ability : card.getAbilities()) {
if (ability instanceof SuspendAbility) { if (ability instanceof SuspendAbility) {
if (((SuspendAbility)ability).isGainedTemporary()) { if (((SuspendAbility)ability).isGainedTemporary()) {