Page 1 of 1

Starlit Sanctum sac abilities not correct amount resolution

PostPosted: 24 Jan 2019, 09:07
by Aswan jaguar
Describe the Bug:
Starlit Sanctum all abilities can't be activated. Never highlights as active-able.

Which card did behave improperly?
Starlit Sanctum

Which update are you using? (date, name)Which type? (duel, gauntlet, sealed deck)
A based on Manalink dev 778ccb5 version - duel

What exactly should be the correct behavior/interaction?


Are any other cards possibly affected by this bug?
-

Re: Starlit Sanctum all abilities can't be activated

PostPosted: 27 Aug 2019, 12:35
by Aswan jaguar
Fixed abilities can't be activated in commit b44337ca. It has another issue that both non mana abilities don't have any effect on resolution when SARV_REPORT_TOUGHNESS and SARV_REPORT_POWER are used. I tried a lot of different approaches with and without SARV_REPORT_TOUGHNESS and SARV_REPORT_POWER but none gave a correct result(like the emnv2 version does). It seems to me that most approaches I tried tracked the number of abilities instead of toughness for gain life ability (2 life gained in my approaches) and power for lose life (3 life lost in my approaches) ability.
I removed checks for power or toughness to check if my assumption is correct and it seems correct.
Current code that has no checks to track power or toughness:
Code: Select all
int card_starlit_sanctum(int player, int card, event_t event){
   /* Starlit Sanctum   ""
    * Land
    * |T: Add |C to your mana pool.
    * |W, |T, Sacrifice a Cleric creature: You gain life equal to the sacrificed creature's toughness.
    * |B, |T, Sacrifice a Cleric creature: Target player loses life equal to the sacrificed creature's power. */

   if( ! IS_GAA_EVENT(event) || event == EVENT_CAN_ACTIVATE ){
      return mana_producer(player, card, event);
   }

   target_definition_t td;
   default_target_definition(player, card, &td, 0);
   td.zone = TARGET_ZONE_PLAYERS;

   test_definition_t test;
   new_default_test_definition(&test, TYPE_CREATURE, "Select a Cleric creature to sacrifice.");
   test.subtype = SUBTYPE_CLERIC;

   card_instance_t *instance = get_card_instance( player, card );

   enum{
      CHOICE_MANA = 1,
      CHOICE_SAC_GAIN,
      CHOICE_SAC_LOSE
   };

   if( event == EVENT_ACTIVATE ){
      int abils[4] = {
                     0,
                  1,
                  generic_activated_ability_with_sacrifice_as_cost(player, card, EVENT_CAN_ACTIVATE, GAA_UNTAPPED, MANACOST_W(1), 0,
                                                       NULL, NULL, 0, &test, 0),
                  generic_activated_ability_with_sacrifice_as_cost(player, card, EVENT_CAN_ACTIVATE, GAA_UNTAPPED | GAA_CAN_TARGET,
                                                       MANACOST_B(1), 0, &td, NULL, 0, &test, 0)
      };
      int choice = instance->info_slot =  CHOICE_MANA;
      if( ! paying_mana() ){
         if( (abils[2] && life[player] < 6) || (abils[3] && life[1-player] < 6) ){
            ai_modifier += 48;
         }
         choice = DIALOG(player, card, event, DLG_RANDOM,
                     "Get mana", abils[1], 5,
                     "Sac Cleric & gain life", abils[2], life[player] < 6 ? 10 : 1,
                     "Sac Cleric & weaken opp", abils[3], life[1-player] < 6 ? 10 : 1);
         if( ! choice ){
            spell_fizzled = 1;
            return 0;
         }
      }

      if( choice == CHOICE_MANA){
         return mana_producer(player, card, event);
      }

      if( choice == CHOICE_SAC_GAIN ){
         add_state(player, card, STATE_TAPPED);
         generic_activated_ability_with_sacrifice_as_cost(player, card, event, GAA_UNTAPPED, MANACOST_W(1), 0, NULL, NULL, 0,
                                                          &test, 0);
                                 
         if( spell_fizzled == 1 ){
            remove_state(player, card, STATE_TAPPED);
         }
      }
      if( choice == CHOICE_SAC_LOSE ){
         add_state(player, card, STATE_TAPPED);
         generic_activated_ability_with_sacrifice_as_cost(player, card, event, GAA_UNTAPPED | GAA_CAN_TARGET, MANACOST_B(1), 0,
                                                          &td, "TARGET_PLAYER", 0, &test, 0);            
         if( spell_fizzled == 1 ){
            remove_state(player, card, STATE_TAPPED);
         }
      }
   }

   if( event == EVENT_RESOLVE_ACTIVATION ){
      if( instance->info_slot == CHOICE_SAC_GAIN ){
      gain_life(player, instance->info_slot);
      }
      if( instance->info_slot == CHOICE_SAC_LOSE ){
         if( valid_target(&td) ){
            lose_life(instance->targets[0].player, instance->info_slot);
         }
      }
   }

   return 0;
}