Page 1 of 1

Wormwood Treefolk menu/ai choice no honor Magical Hack

PostPosted: 24 Jun 2019, 20:24
by travolter
Describe the Bug:
You cannot activate the ability that requires GG. Only the BB one.

Which card did behave improperly?
Wormwood Treefolk

Which update are you using? (date, name)Which type? (duel, gauntlet, sealed deck)
Manalink dev version 250c78bd updated 11-5-19

Re: Wormwood Treefolk

PostPosted: 26 Jun 2019, 12:38
by Aswan jaguar
Fixed in commit 51c47843. As I try to keep the card's code as close as to how it was coded it has a minor bug that in menu to choose ability from both abilities will highlight as activate-able. Also in this form I can't figure out how to make it use alternate_legacy_text.
code | Open
Code: Select all
int card_wormwood_treefolk(int player, int card, event_t event){
   /*
     Wormwood Treefolk English |3|G|G
     Creature - Treefolk 4/4
     {G}{G}: Wormwood Treefolk gains forestwalk until end of turn and deals 2 damage to you.
     {B}{B}: Wormwood Treefolk gains swampwalk until end of turn and deals 2 damage to you.
   */


   if( event == EVENT_CAN_ACTIVATE ){
      if( generic_activated_ability(player, card, event, 0, MANACOST0, 0, NULL, NULL) ){
         return has_mana_for_activated_ability(player, card, MANACOST_B(2)) || has_mana_for_activated_ability(player, card, MANACOST_G(2)) ;
      }
   }

   if( event == EVENT_ACTIVATE ){
      card_instance_t *instance = get_card_instance(player, card);
      int choice = 0;
      if(has_mana_for_activated_ability(player, card, MANACOST_B(2)) || has_mana_for_activated_ability(player, card, MANACOST_G(2)) ){
         choice = do_dialog(player, player, card, -1, -1, " Give Forestwalk\n Give Swampwalk\n Cancel",
                                                       check_battlefield_for_subtype(1-player, TYPE_LAND, SUBTYPE_SWAMP || SUBTYPE_FOREST));
      }
      else{
         choice = 1;
      }
      if( choice == 2 ){
         spell_fizzled = 1;
         return 0;
      }
      if( charge_mana_for_activated_ability(player, card, 0, (choice == 1 ? 2 : 0), 0, (choice == 0 ? 2 : 0), 0, 0) ){
         instance->info_slot = 66+choice;
      }
   }

   if( event == EVENT_RESOLVE_ACTIVATION ){
      card_instance_t *instance = get_card_instance(player, card);
      int kw = instance->info_slot == 66 ? get_hacked_walk(instance->parent_controller, instance->parent_card, KEYWORD_FORESTWALK) :
                                 get_hacked_walk(instance->parent_controller, instance->parent_card, KEYWORD_SWAMPWALK);
      pump_ability_until_eot(instance->parent_controller, instance->parent_card, instance->parent_controller, instance->parent_card, 0, 0, kw, 0);
      damage_player(instance->parent_controller, 2, instance->parent_controller, instance->parent_card);
   }

   return 0;
}

Re: Wormwood Treefolk doesn't use different legacy cards/abi

PostPosted: 26 Jun 2019, 16:34
by Korath
Neither the menu nor the AI's choice honor Magical Hack, either (though the created effect should), and that "SUBTYPE_SWAMP || SUBTYPE_FOREST" doesn't do anything at all like what you're intending - it looks for a land with SUBTYPE_ALLY. Setting that aside, you'd want something similar to
Code: Select all
int choice = 0;
int has_BB = has_mana_for_activated_ability(player, card, MANACOST_B(2));
int has_GG = has_mana_for_activated_ability(player, card, MANACOST_G(2));
if (has_BB && has_GG)
  choice = do_dialog(player, player,card, -1,-1, " Forestwalk\n Swampwalk\n Cancel",
                     check_battlefield_for_subtype(1-player, TYPE_LAND, SUBTYPE_SWAMP));
else if (has_BB)
  choice = 0;
else if (has_GG)
  choice = 1;
else
  choice = 2;
Always displaying both options even if only one is pickable (and disabling the other) is a better interface, of course, and DIALOG()'s the most convenient way to do that.

pump_ability_until_eot() returns the card index of the effect card it creates, just like most other effect-creating functions in Manalink.

Re: Wormwood Treefolk doesn't use different legacy cards/abi

PostPosted: 27 Jun 2019, 14:49
by Aswan jaguar
I gave it alternate effect for abilities and used above code to fix the other bug in commit 5360d68e.
I tried but seems impossible for me to make menu honor Magical Hack without changing the whole card using DIALOG() which is a nice touch. I left untouched also AI's choice which doesn't honor Magical Hack which seems easy but I don't know what it does and how it will affect AI's choice.