Page 1 of 1

[fixed]Avatar of Discord bad selection

PostPosted: 25 Aug 2016, 08:39
by Aswan jaguar
Describe the Bug:
I cast Avatar of Discord I discarded a card but then in hand (in panel to choose from not actual hand as the cards were in actual hand)there were missing 2 cards instead of the the 1 I discarded.Another time after the first card I discarded 3 were missing.This doesn't happen all the time as I cast it without a problem other times.

Which card did behave improperly ?
Avatar of Discord

Which update are you using?(date,name)Which type(Duel,Gauntlet,Sealed Deck)
Manalink 2016/08/07: Eldritch Moon, duel

What exactly should be the correct behavior/interaction ?
Avatar of Discord when you discard a card only that card gets removed from hand prompt window.

Are any other cards possibly affected by this bug ?
-

Re: [confirmed]Avatar of Discord bad selection

PostPosted: 25 Aug 2016, 09:26
by BAgate
To state more clearly, after you select a card to discard more than one disappear from the selection box. The correct cards are discarded.

Re: [confirmed]Avatar of Discord bad selection

PostPosted: 19 Sep 2016, 17:28
by Gargaroz
The new implementation of 'discard_card' was a bit buggy, it was recently fixed so consider also this fixed until further notice.

Re: [still bug]Avatar of Discord bad selection

PostPosted: 20 Apr 2018, 13:46
by Aswan jaguar
Still the same bug. I have some more info to help this time. It seems that the 1st card you choose to be discarded, together with the 2 cards with the biggest in game ids will be removed from the selection panel when you get to choose a 2nd card to be discarded. If there is only 1 card or none card with bigger in game id then only the 1 card will be missing or none will be missing retrospectively.
The discarded cards are correct they are ones you have chosen to discard.

Re: [still bug]Avatar of Discord bad selection

PostPosted: 10 Aug 2020, 16:24
by FastEddie
Simple issue once you got the hang of it... which took me 2 hours. The counter for player's cards was decremented inside the loop shifting the hand back one card to overwrite the removed card, effectively halving your hand after the removed card. I removed one loop shifting the hand as it is only needed after choosing the first card.

The diff looks worse than it is as I also fixed the formatting.

Code: Select all
   if( event == EVENT_ETB_ABILITY ){
      int kill_me = 1;
      if( hand_count[player] > 1 ){
         int p_hand[2][hand_count[player]];
         int pc = 0; // player cards
         int discarded[2];
         int dc = 0; // cards to discard
         int count = 0;
         while( count < active_cards_count[player] ){
            if( in_hand(player, count) ){
               p_hand[0][pc] = get_original_internal_card_id(player, count);
               p_hand[1][pc] = count;
               pc++;
            }
            count++;
         }
      
         test_definition_t this_test;
         new_default_test_definition(&this_test, TYPE_ANY, "Select a card to discard.");
         while( dc < 2 ){
            int selected = select_card_from_zone(player, player, p_hand[0], pc, 0, AI_MIN_VALUE, -1, &this_test);
            if( selected != -1 ){
               discarded[dc] = p_hand[1][selected];
               dc++;               
               // Need this only once, hand is not shown after second choice
               if (dc == 1 ) {
                  for(count = selected; count < pc; count++){
                     p_hand[0][count] = p_hand[0][count+1];
                     p_hand[1][count] = p_hand[1][count+1];
                  }
                  pc--; // <-- this was inside the loop
               }
            }
            else{
               break;
            }
         }
         if( dc == 2 ){
            discard_card(player, discarded[0]);
            discard_card(player, discarded[1]);
            kill_me = 0;
         }
      }
      if( kill_me ){
         kill_card(player, card, KILL_SACRIFICE );
      }
   }

Re: [still bug]Avatar of Discord bad selection

PostPosted: 10 Aug 2020, 17:40
by Aswan jaguar
Inserted above fix in commit 3c07db2. Thanks, FastEddie. =D>
FastEddie wrote:Simple issue once you got the hang of it... which took me 2 hours.
I totally feel you. I can't even estimate you how much time and frustration such bugs have cost me. :(