Page 1 of 1

[fixed]Sleight of Mind target opponent spell then he chooses

PostPosted: 30 Sep 2018, 09:27
by Aswan jaguar
Describe the Bug:
1- Sleight of Mind can't target spells.
2- The prompt also doesn't mention spells only permanent.

3- If you target opponent's permanent then opponent chooses what to change.
Which card did behave improperly?
Sleight of Mind

Which update are you using? (date, name)Which type? (duel, gauntlet, sealed deck)
Manalink dev 778ccb5 version - duel

What exactly should be the correct behavior/interaction?
1- Sleight of Mind target spells & permanent.
2- The prompt should be "Select target spell or permanent".
3- No matter who player's permanent you choose it's always the caster that chooses what to change.

Are any other cards possibly affected by this bug?
-

Re: Sleight of Mind can't target spells & more

PostPosted: 09 Aug 2019, 17:03
by Aswan jaguar
Fixed the can't target spells in commit 94b1cf1b. The prompt is not needed in manalink way of spells in stack so that is also kind of "fixed".
I can't find a way to fix bug 3 above. Any help?
Code: Select all
int ai_can_sleight_card(int player, int card){
   int colors_to_sleight = cards_ptr[get_id(player, card)]->sleight_color;
   if( ! check_special_flags3(player, card, SF3_HARDCODED_SLEIGHT_WORDS_REPLACED) ){
      set_special_flags3(player, card, SF3_HARDCODED_SLEIGHT_WORDS_REPLACED);
      cards_ptr[get_id(player, card)]->sleight_color = colors_to_sleight = get_colors_to_sleight_from_text(get_id(player, card));
   }
   return colors_to_sleight;
}

int card_sleight_of_mind(int player, int card, event_t event){
/*
Sleight of Mind |U
Instant
Change the text of target spell or permanent by replacing all instances of one color word with another.
(For example, you may change "target black spell" to "target blue spell." This effect lasts indefinitely.)
*/
   if( ! IS_GS_EVENT(player, card, event) ){
      return 0;
   }

   target_definition_t td;
   default_target_definition(player, card, &td, TYPE_PERMANENT );

   card_instance_t *instance = get_card_instance( player, card);

   if( event == EVENT_CAN_CAST ){
      int result = counterspell(player, card, event, NULL, 0);
      if( result ){
         return result;
      }
      return generic_spell(player, card, event, GS_CAN_TARGET, &td, NULL, 1, NULL);
   }

   if( event == EVENT_CAST_SPELL && affect_me(player, card) ){
      instance->info_slot = 0;
      if( counterspell(player, card, EVENT_CAN_CAST, NULL, 0) ){
         if(! ai_can_sleight_card(card_on_stack_controller, card_on_stack) ){
            ai_modifier-=100;
         }
         counterspell(player, card, event, NULL, 0);
          SET_BYTE0(instance->info_slot) = 1;
         }
      else{
      generic_spell(player, card, event, GS_CAN_TARGET, &td, "TARGET_PERMANENT", 1, NULL);
      }
      if( spell_fizzled != 1 && ! ai_can_sleight_card(instance->targets[0].player, instance->targets[0].card) ){
         ai_modifier-=100;
      }
   }

   if( event == EVENT_RESOLVE_SPELL ){
      int t_player = -1;
      int t_card = -1;
      if( instance->info_slot == 1 ){
         if( counterspell_validate(player, card, NULL, 0) ){
            t_player = instance->targets[0].player;
            t_card = instance->targets[0].card;
         }
      }
      else{
         if( valid_target(&td) ){
            t_player = instance->targets[0].player;
            t_card = instance->targets[0].card;
         }
      }
      if( t_player != -1 ){
         replace_all_instances_of_one_color_word_with_another(t_player, t_card);
      }
      kill_card(player, card, KILL_DESTROY);
//      return card_sleight_of_mind_exe(player, card, event);
   }

   return 0;
}
Code: Select all
void replace_all_instances_of_one_basic_land_type_word_with_another(int player, int card){

   int options[6] = {0, 1, 1, 1, 1, 1};
   int i;
   if( player == AI ){
      for(i=COLOR_BLACK; i<=COLOR_WHITE; i++){
         options[i] = 0;
      }
      int colors_to_hack = cards_ptr[get_id(player, card)]->hack_colors;
      if( ! check_special_flags3(player, card, SF3_HARDCODED_HACK_WORDS_REPLACED) ){
         set_special_flags3(player, card, SF3_HARDCODED_HACK_WORDS_REPLACED);
         cards_ptr[get_id(player, card)]->hack_colors = colors_to_hack = get_colors_to_hack_from_csvid(get_id(player, card));
      }
      for(i=COLOR_BLACK; i<=COLOR_WHITE; i++){
         if( colors_to_hack & (1<<i) ){
            if( ! get_card_instance(player, card)->hack_mode[i] ){
               options[i] = 1;
            }
         }
      }
      for(i=COLOR_BLACK; i<=COLOR_WHITE; i++){
         if( get_card_instance(player, card)->hack_mode[i] ){
            options[i] = 1;
         }
      }
   }
   int orig_color = DIALOG(player, card, EVENT_RESOLVE_SPELL, DLG_NO_STORAGE, DLG_NO_CANCEL, DLG_OMIT_ILLEGAL,
                     "From Swamp...",    options[1], 1,
                     "From Island...",    options[2], 1,
                     "From Forest...",    options[3], 1,
                     "From Mountain...", options[4], 1,
                     "From Plain...",    options[5], 1);

   // 10/4/2004: It can't change a word to the same word. It must be a different word.
   for(i=COLOR_BLACK; i<=COLOR_WHITE; i++){
      options[i] = 0;
   }
   options[orig_color] = 1;

   int s_color = DIALOG(player, card, EVENT_RESOLVE_SPELL, DLG_NO_STORAGE, DLG_RANDOM, DLG_NO_CANCEL, DLG_OMIT_ILLEGAL,
                  "...to Swamp",       !options[1], ((orig_color == COLOR_WHITE || orig_color == COLOR_GREEN) ? 10 : 1),
                  "...to Island",    !options[2], ((orig_color == COLOR_RED || orig_color == COLOR_GREEN) ? 10 : 1),
                  "...to Forest",    !options[3], ((orig_color == COLOR_BLACK || orig_color == COLOR_BLUE) ? 10 : 1),
                  "...to Mountain",    !options[4], ((orig_color == COLOR_BLUE || orig_color == COLOR_WHITE) ? 10 : 1),
                  "...to Plain",       !options[5], ((orig_color == COLOR_RED || orig_color == COLOR_BLACK) ? 10 : 1));

   get_card_instance(player, card)->hack_mode[orig_color] = s_color;
}

Re: Sleight of Mind target opponent spell then he chooses

PostPosted: 05 Apr 2020, 14:05
by Aswan jaguar
Fixed last bug(3) in commit 9afbb72.