Page 1 of 1

[fixed]Attacking opponent with several Planeswalkers

PostPosted: 16 May 2020, 10:18
by FastEddie
Describe the Bug:
I attack an opponent with 4 Planeswalkers in play. I get asked whether to attack the opponent or a Planeswalker. If I want to attack the opponent I have to click/press Enter 4 times instead of once. This doesn't happen when attacking Planeswalkers.
The mechanics work. This is merely an issue of the user interface.

Which card behaved improperly?
All attacking creatures.

Which update are you using? (date, name)Which type? (duel, gauntlet, sealed deck)
Version 5-2020 10bda4ca0
Duel

What exactly should be the correct behavior/interaction?
When attacking an opponent with 4 Planeswalkers in play I should click/press Enter only once to attack the opponent.

Are any other cards possibly affected by this bug?
NA

Re: [confirmed]Attacking opponent with several Planeswalkers

PostPosted: 16 May 2020, 15:21
by Aswan jaguar
Yes, when choosing to attack a player it prompts as many times as the planeswalkers opponent has.

Re: [confirmed]Attacking opponent with several Planeswalkers

PostPosted: 14 Aug 2020, 17:57
by FastEddie
The issue is that every Planeswalker catches the message that the attack phase began and every Planeswalker reacts to that (i.e. letting the player choose whom to attack) without telling the other Planeswalkers about doing so. This fixes it, I used targets[8] as storage. It is set when a creature attacks and reset once the choice for the attacking creature is fixed. Then set again for the next attacking creature and so on.

This is the relevant code piece:

Code: Select all
   // when creatures attack, prompt for who they attack
   if( trigger_condition == TRIGGER_PAY_TO_ATTACK && current_phase == PHASE_DECLARE_ATTACKERS && current_turn == 1-player){
      if( affect_me( trigger_cause_controller, trigger_cause ) && reason_for_trigger_controller == affected_card_controller ){
         if( ! check_special_flags(trigger_cause_controller, trigger_cause, SF_ATTACKING_PWALKER) ){
            if(event == EVENT_TRIGGER ){
               event_result |= RESOLVE_TRIGGER_MANDATORY;
            }
            else if(event == EVENT_RESOLVE_TRIGGER){
// new code starts here
               if ( (instance->targets[8].player == -1) && (instance->targets[8].card == -1) ) {
                  // Inform other Planeswalkers that we chose the attacker
                  int count;
                  card_instance_t* otherPlaneswalker;
                  for (count = 0; count < active_cards_count[player]; ++count){
                     if( in_play(player, count) && is_planeswalker(player, count) ){
                        // Don't affect yourself
                        if (count != card) {
                           otherPlaneswalker = get_card_instance(player, count);
                           otherPlaneswalker->targets[8].player = player;
                           otherPlaneswalker->targets[8].card = card;
                        }
                     }
                  }
// original function call                  
                 choose_who_attack(affected_card_controller, affected_card);
               } else {
                  instance->targets[8].player = instance->targets[8].card = -1;
               }
// new code ends here
            }
         }
      }
   }

Re: [confirmed]Attacking opponent with several Planeswalkers

PostPosted: 15 Aug 2020, 11:21
by Aswan jaguar
I ran few tests and this seems fine. I will commit it in few hours. Nice job FastEddie. I looked if I could find a way so this piece of code can honor "can't attack you" effects like Propaganda paid costs and non paid ones:
viewtopic.php?f=86&t=18704&p=197646&hilit=planeswalker#p197645
This comment in defs.h seems related to make above work:
TRIGGER_ATTACKER_CHOSEN = 0xDE, // Triggers as each attacker is chosen. Infuriatingly, it's dispatched after PAY_TO_ATTACK when a human attacks, but before when the AI does.

Re: [confirmed]Attacking opponent with several Planeswalkers

PostPosted: 15 Aug 2020, 11:38
by FastEddie
I will have a look at this soon. There is also another piece of code that drew my attention, not a bug but still weird:

Code: Select all
      /* Change effect display to the planeswalker by brute force - legacy_name() doesn't get called if we just call
       * create_targeted_legacy_effect(1-player, planeswalkers[choice], &attacking_planeswalker, player, card) above and I'm not sure why yet. */
      leg->display_pic_csv_id = get_id(1 - player, planeswalkers[choice][0]);
      leg->display_pic_num = get_card_image_number(leg->display_pic_csv_id, 1 - player, planeswalkers[choice][0]);
Right now I am looking into why Three Dreams doesn't work properly whereas Gifts Ungiven does...

Re: [confirmed]Attacking opponent with several Planeswalkers

PostPosted: 16 Aug 2020, 12:14
by Aswan jaguar
Original bug fixed by FastEddie in commit b522cde.
For Propaganda bug there is already report and posts have to be posted there. I have already moved there previous post by FastEddie which belongs there:
viewtopic.php?f=86&t=18704