Page 1 of 1

[fixed/closed]Overlaid Terrain,Joraga Treespeaker

PostPosted: 25 Aug 2013, 19:17
by Korath
Describe the Bug:
Overlaid Terrain destroys all your permanents, including itself, when it comes into play. (Plus, when that's fixed, it taps creatures instead of lands for mana when activated, and ignores their summoning sickness; and it lets you pick two different colors.)

Which card did behave improperly ?
Overlaid Terrain, nemesis.c.

Which update are you using?(date,name)Which type(Duel,Gauntlet,Sealed Deck)
Kind-of sort-of OtIv2.

What exactly should be the correct behavior/interaction ?
It should sac only your lands at cip, and activate to tap one of your (untapped, not animated-and-summoning-sick) lands to produce 2 mana of a single color.

Are any other cards possibly affected by this bug ?

I'm largely rewriting this card anyway so it works properly with Mana Flare and Mana Reflection, but that won't be ready in time for the next release. Might as well put in the two one-line fixes for the old implementation in the meantime.

Most of these sort of cards don't check for animation/sickness either, though that's unusual enough that I've just been fixing them as I find them; they can wait till I merge. Joraga Treespeaker (at level 5) is probably worth fixing now, though, since it works directly on creatures.

Re: Overlaid Terrain

PostPosted: 25 Aug 2013, 23:05
by Gargaroz
Fixed, here's the code now :
Code: Select all
int card_overlaid_terrain(int player, int card, event_t event){

    target_definition_t td;
    default_target_definition(player, card, &td, TYPE_CREATURE);
    td.allowed_controller = player;
    td.preferred_controller = player;
    td.illegal_abilities = 0;
   td.illegal_state = TARGET_STATE_TAPPED;

   card_instance_t *instance = get_card_instance(player, card);
   
   if( event == EVENT_RESOLVE_SPELL ){
      test_definition_t this_test;
      default_test_definition(&this_test, TYPE_LAND);
      new_manipulate_all(player, card, player, &this_test, KILL_SACRIFICE);
   }

    if( event == EVENT_CAN_ACTIVATE ){
        return can_target(&td);
    }
    if( event == EVENT_ACTIVATE ){
        if( pick_target(&td, "TARGET_LAND") ){
         instance->number_of_targets = 1;
         if( ! is_animated_and_sick(instance->targets[0].player, instance->targets[0].card) ){
            tap_card(instance->targets[0].player, instance->targets[0].card);
            mana_producer(player, card, event);
            mana_producer(player, card, event);
         }
         else{
            spell_fizzled = 1;
         }
      }
    }
    if( event == EVENT_COUNT_MANA && affect_me(player, card) ){
      if( can_target(&td) ){
         mana_producer(player, card, event);
         mana_producer(player, card, event);
      }
    }
   return global_enchantment(player, card, event);
}

Re: Overlaid Terrain

PostPosted: 25 Aug 2013, 23:22
by Gargaroz
Also, here's the new code for Joraga Treespeaker.
Code: Select all
int card_joraga_treespeaker(int player, int card, event_t event){

    target_definition_t td;
    default_target_definition(player, card, &td, TYPE_CREATURE);
    td.required_subtype = SUBTYPE_ELF;
    td.allowed_controller = player;
    td.preferred_controller = player;
    td.illegal_abilities = 0;
    td.illegal_state = TARGET_STATE_TAPPED | TARGET_STATE_SUMMONING_SICK;
   
    card_instance_t *instance = get_card_instance(player, card);
   
   generic_leveler(player, card, event, 1, 0, 0, 1, 0, 0, 1);

    int level = count_ccounters(player, card);
    if( affect_me(player, card) ){
        if( level > 4 ){
            if( event == EVENT_TOUGHNESS ){
                event_result += 3;
            }
        }
        else if( level > 0 ){
            if( event == EVENT_TOUGHNESS ){
                event_result += 1;
            }
        }
    }

    if( event == EVENT_CAN_ACTIVATE ){
      if( level < 1 && ! get_forbid_activation_flag(player, card)  && has_mana_for_activated_ability(player, card, 1, 0, 0, 1, 0, 0) &&
         can_sorcery_be_played(player)
        ){
         return 1;
      }
      if( level > 1 && ! is_tapped(player, card) && ! is_sick(player, card) && can_produce_mana(player, card) ){
         return 1;
      }
      if( level > 4 && can_target(&td) && can_produce_mana(player, card) ){
         return 1;
      }
    }
    if( event == EVENT_ACTIVATE ){
        int choice = 0;
      int ai_choice = 0;
      char buffer[500];
      int pos = 0;
      int mode = (1<<3);
        if( ! paying_mana() && ! get_forbid_activation_flag(player, card) && has_mana_for_activated_ability(player, card, 1, 0, 0, 1, 0, 0) &&
         can_sorcery_be_played(player)
        ){
         if( level < 1 ){
            ai_modifier+=500;
         }
         pos += scnprintf(buffer + pos, 500-pos, " Level up\n", buffer);
         mode+=(1<<0);
      }
      if( level > 1 && ! is_tapped(player, card) && ! is_sick(player, card) && can_produce_mana(player, card) ){
         ai_choice = 1;
         pos += scnprintf(buffer + pos, 500-pos, " Tap for GG\n", buffer);
         mode+=(1<<1);
      }
      if( level > 4 && can_target(&td) && can_produce_mana(player, card) ){
         ai_choice = 2;
         pos += scnprintf(buffer + pos, 500-pos, " Tap an Elf for GG\n", buffer);
         mode+=(1<<2);
      }
      pos += scnprintf(buffer + pos, 500-pos, " Cancel", buffer);
      choice = do_dialog(player, player, card, -1, -1, buffer, ai_choice);
      while( !( (1<<choice) & mode) ){
            choice++;
      }
      if( choice == 0 ){
         if( charge_mana_for_activated_ability(player, card, 1, 0, 0, 1, 0, 0) ){
            instance->info_slot = 66;
         }
        }
      else if( choice == 1 ){
            tap_card(player, card);
            produce_mana(player, COLOR_GREEN, 2);
        }
      else if( choice == 2 ){
            if( select_target(player, card, &td, "Choose an Elf to tap for GG.", NULL) ){
               instance->number_of_targets = 1;
               tap_card( player, instance->targets[0].card);
               produce_mana(player, COLOR_GREEN, 2);
            }
            else{
               spell_fizzled = 1;
            }
        }
        else{
         spell_fizzled = 1;
        }
    }
    if( event == EVENT_RESOLVE_ACTIVATION ){
      if( instance->info_slot == 66 ){
         add_ccounters(instance->parent_controller, instance->parent_card, 1);
         card_instance_t *parent = get_card_instance(instance->parent_controller, instance->parent_card);
         parent->info_slot = 0;
      }
    }
       
    if( level > 0 && event == EVENT_COUNT_MANA && affect_me(player, card) ){
      if( ! is_tapped(player, card) && ! is_sick(player, card) ){
         declare_mana_available(player, COLOR_GREEN, 2);     
      }
      if( level > 4 && can_target(&td) ){
         declare_mana_available(player, COLOR_GREEN, 2);     
      }
    }
    return 0;
}