Page 1 of 1

[fixed]Demonic consultation -> game hangs (plz confirm)

PostPosted: 21 May 2019, 20:42
by travolter
Im trying to cast Demonic Consultation and game hangs (seem to be waiting but nothing occur)

Re: [confirmed]Demonic consultation -> game hangs (plz confi

PostPosted: 22 May 2019, 17:21
by Aswan jaguar
code | Open
Code: Select all
int card_demonic_consultation(int player, int card, event_t event){
/* Demonic Consultation   |B   0x20016C3
 * Instant
 * Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card.
 * Put that card into your hand and exile all other cards revealed this way. */

   if( event == EVENT_RESOLVE_SPELL ){
      test_definition_t test;
      default_test_definition(&test, TYPE_LAND);
      if( count_subtype(player, TYPE_LAND, -1) >= 4 ){
         test.type_flag = DOESNT_MATCH;
         test.cmc = count_subtype(player, TYPE_LAND, -1)+1;
         test.cmc_flag = F5_CMC_LESSER_THAN_VALUE;
      }
      int choice = ai_name_a_random_csvid( player, card, player, 0, &test);
      if( player == HUMAN ){
         if( ai_is_speculating != 1 ){
            choice = card_from_list(player, 3, TYPE_ANY, 0, 0, 0, 0, 0, 0, 0, -1, 0);
         }
      }

      // remove the top 6
      int i=0;
      for(i=0;i<6;i++){
         rfg_top_card_of_deck(player);
      }

      default_test_definition(&test, TYPE_ANY);
      test.id = choice;
      reveal_card_until_you_reveal_test(player, player, &test, RCUYRT_EXILE_REST | RCUYRT_ADD_TEST_TO_HAND);

      kill_card(player, card, KILL_DESTROY);
   }

   return generic_spell(player, card, event, 0, NULL, NULL, 0, NULL);
}

Re: [confirmed]Demonic consultation -> game hangs (plz confi

PostPosted: 19 Sep 2019, 16:01
by Aswan jaguar
Fixed in commit 220eb269. I had to disable AI code as it went on a loop if AI had 4 =< lands. If it had less lands then AI correctly searched for land. Despite my efforts I wasn't able to make it work correctly and not go on a loop but instead search for non-land cards if AI already had 4 or more.
Current code:
Code: Select all
int card_demonic_consultation(int player, int card, event_t event){
/* Demonic Consultation   |B   0x20016C3
 * Instant
 * Name a card. Exile the top six cards of your library, then reveal cards from the top of your library until you reveal the named card.
 * Put that card into your hand and exile all other cards revealed this way. */

   if( event == EVENT_RESOLVE_SPELL ){
      // remove the top 6
      int i=0;
      for(i=0;i<6;i++){
         rfg_top_card_of_deck(player);
      }

      test_definition_t test;
      default_test_definition(&test, TYPE_ANY);
      int choice = -1;

      if( IS_AI(player) ){// AI code crashed if lands >= 4 so I disabled it.
           /*if( count_subtype(player, TYPE_LAND, -1) >= 4 ){
                test.type_flag = DOESNT_MATCH;
               test.cmc = count_subtype(player, TYPE_LAND, -1)+1;
               test.cmc_flag = F5_CMC_LESSER_THAN_VALUE;
          } */
           choice = ai_name_a_random_csvid( player, card, player, 0, &test);
      }
         else{
           choice = card_from_list(player, 3, TYPE_ANY, 0, 0, 0, 0, 0, 0, 0, -1, 0);
      }

        test_definition_t test1;
      default_test_definition(&test1, TYPE_ANY);
      test1.id = choice;
      reveal_card_until_you_reveal_test(player, player, &test1, RCUYRT_EXILE_REST | RCUYRT_ADD_TEST_TO_HAND);

      kill_card(player, card, KILL_DESTROY);
   }

   return generic_spell(player, card, event, 0, NULL, NULL, 0, NULL);
}