Page 1 of 1

[not quite fix]Curse of Echoes not countering correct spell

PostPosted: 09 Jul 2020, 21:43
by gnomefry
Describe the Bug:

Curse of Echoes isn't copying the other player's instants and sorceries.wrong

The enchantment lights up and allows you to activate it as the opponent casts an instant or sorcery, but without any resulting effect.

Savegame attached.

Which card behaved improperly?

Curse of Echoes

Which update are you using? (date, name)Which type? (duel, gauntlet, sealed deck)
version 6-2020 v3 a8bbff706 - gauntlet

What exactly should be the correct behavior/interaction?

Whenever enchanted player casts an instant or sorcery spell each other player may copy that spell and choose new targets for the copy they control.

Are any other cards possibly affected by this bug?

No.

Re: Curse of Echoes not copying

PostPosted: 10 Jul 2020, 05:31
by drool66
Counterspells don't work well with Hive Mind either, yet they do with Twincast which uses the same copy_spell_from_stack()

Re: Curse of Echoes not copying

PostPosted: 11 Jul 2020, 10:00
by Aswan jaguar
I am quite certain that in this case at least the issue is that you don't get to choose/change target and so while Curse of Echoes does copy Force of Will or any other counterspell, but still targets the same target the original spell did so it seems to not have an effect while it counters the original spell instead of countering like usual the last spell on stack.

Re: [confirmed]Curse of Echoes not countering correct spell

PostPosted: 12 Jul 2020, 06:56
by drool66
Ok! Took me a couple of days but I solved it.

Fixed, uncommitted.

Re: [not quite fix]Curse of Echoes not countering correct sp

PostPosted: 14 Jul 2020, 22:25
by drool66
Moving this back to bugs because I'm realizing it was working but for all the wrong reasons. Fixing the code to work for the "right" reasons breaks it. For reference, here's my code:
Code: Select all
int card_curse_of_echoes(int player, int card, event_t event){
/* CARD_ID_CURSE_OF_ECHOES   12157
Curse of Echoes   |4|U
Enchantment - Aura Curse
Enchant player
Whenever enchanted player casts an instant or sorcery spell, each other player may copy that spell and may choose new targets for the copy he or she controls.*/

   card_instance_t *instance = get_card_instance( player, card );
   int cursed_player = instance->targets[4].player;
   test_definition_t test;
   default_test_definition(&test, TYPE_SPELL);

   if( new_specific_spell_played(player, card, event, cursed_player, RESOLVE_TRIGGER_AI(player), &test) ){
      instance->targets[0].player = card_on_stack_controller;
      instance->targets[0].card = card_on_stack;

      if( in_play(player, card) && ! is_humiliated(player, card) ){
         target_definition_t td;
         counterspell_target_definition(player, card, &td, TYPE_SPELL);
         td.illegal_abilities = 0;
         if (counterspell_validate(player, card, &td, 0)){
            copy_spell_from_stack(player, instance->targets[0].player, instance->targets[0].card);
         }
         else{
            copy_spell_from_stack(player, trigger_cause_controller, trigger_cause);
         }
      }
   }
   if( !IS_GS_EVENT(player, card, event) && event != EVENT_SHOULD_AI_PLAY)
      return 0;

   return curse(player, card, event);
}