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

View file

@ -241,7 +241,7 @@ class SuspendExileEffect extends OneShotEffect<SuspendExileEffect> {
Card card = game.getCard(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
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 (!controller.chooseUse(outcome, new StringBuilder("Suspend ").append(card.getName()).append("?").toString(), game)) {
return false;
@ -322,7 +322,7 @@ class SuspendPlayCardEffect extends OneShotEffect<SuspendPlayCardEffect> {
Card card = game.getCard(source.getSourceId());
if (player != null && card != null) {
// 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()) {
if (ability instanceof SuspendAbility) {
if (((SuspendAbility)ability).isGainedTemporary()) {