It is currently 18 Apr 2024, 05:05
   
Text Size

How to get upkeep availability working?

Moderator: CCGHQ Admins

How to get upkeep availability working?

Postby Rockenchick » 21 Oct 2015, 02:33

I've got Dwarven Armory to do most of what it's supposed to do, but I can't figure out how have it be activated only during any upkeep stage.

I've yet to find a coded card that even has such a condition to work out how to go about it. I've come across triggered abilities using the STEP_UPKEEP condition but this ability isn't triggered, is it? There's only 1 card I found with an upkeep availability condition that's coded, Infinite Hourglass. I tried using this part of its code (even though it grants the ability to opponents as well and I realise this card is just for the controller) to test the functioning of any upkeep and it rendered the card useless.
Code: Select all
<AVAILABILITY any_player="1" />
      <AVAILABILITY>
         return MTG():GetStep() == STEP_UPKEEP
      </AVAILABILITY>


So far this is the code I have for the card, it seems to work fine with the exception of the upkeep rule.

Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2 ExportVersion="1">
  <FILENAME text="DWARVEN_ARMORY_2618" />
  <CARDNAME text="DWARVEN_ARMORY" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Dwarven Armory]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Dwarven Armory]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Dwarven Armory]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Dwarven Armory]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Dwarven Armory]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Dwarven Armory]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Dwarven Armory]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Dwarven Armory]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Dwarven Armory]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="2618" />
  <ARTID value="2618" />
  <ARTIST name="Richard Thomas" />
  <CASTING_COST cost="{2}{R}{R}" />
  <TYPE metaname="Enchantment" />
  <EXPANSION value="IA" />
  <RARITY metaname="R" />
  <ACTIVATED_ABILITY>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{2}, Sacrifice a land: Put a +2/+2 counter on target creature. Activate this ability only during any upkeep step.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[{2}, Sacrifice a land: Put a +2/+2 counter on target creature. Activate this ability only during any upkeep step.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[{2}, Sacrifice a land: Put a +2/+2 counter on target creature. Activate this ability only during any upkeep step.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[{2}, Sacrifice a land: Put a +2/+2 counter on target creature. Activate this ability only during any upkeep step.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[{2}, Sacrifica una terra: Metti un segnalino +2/+2 su una creatura bersaglio. Attiva questa abilità solo durante una qualsiasi sottofase di mantenimento.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[{2}, Sacrifice a land: Put a +2/+2 counter on target creature. Activate this ability only during any upkeep step.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[{2}, Sacrifice a land: Put a +2/+2 counter on target creature. Activate this ability only during any upkeep step.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[{2}, Sacrifice a land: Put a +2/+2 counter on target creature. Activate this ability only during any upkeep step.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[{2}, Sacrifice a land: Put a +2/+2 counter on target creature. Activate this ability only during any upkeep step.]]></LOCALISED_TEXT>
                <COST mana_cost="{2}" type="Mana" />
      <COST type="Sacrifice" definition="0" compartment="1" query_tag="CARD_QUERY_CHOOSE_LAND_TO_SACRIFICE" item_count="1" />
      <COST_DEFINITION id="0">
         local filter = ClearFilter()
         filter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
      </COST_DEFINITION>
      <TARGET tag="CHOOSE_CREATURE_TO_GET +2_+2" definition="0" compartment="0" count="1" />
      <TARGET_DEFINITION id="0">
         local filter = ClearFilter()
         filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
         </TARGET_DEFINITION>
      <RESOLUTION_TIME_ACTION>
         local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
         if target ~= nil then
            target:AddCounters( MTG():PlusOnePlusOneCounters(), 2)
         end
      </RESOLUTION_TIME_ACTION>
                </ACTIVATED_ABILITY>
</CARD_V2>
Rockenchick
 
Posts: 21
Joined: 16 Oct 2015, 05:05
Has thanked: 4 times
Been thanked: 2 times

Re: How to get upkeep availability working?

Postby Xander9009 » 21 Oct 2015, 04:25

The last three lines on their own should do the trick.

Code: Select all
      <AVAILABILITY>
         return MTG():GetStep() == STEP_UPKEEP
      </AVAILABILITY>
An AVAILABILITY block simply limits the ability to activate an ability. If it returns true, then the player can activate it. If it returns false, they can't. So, returning true if and only if the current step is STEP_UPKEEP should make it work. However, the reason it made the card useless is probably because there's nothing happening during the upkeep, so you don't get a chance to activate abilities. To fix this, we made an Upkeep Time Manager a long time ago which gives the player a chance to activate abilities during the upkeep, but only does so once, no matter how many cards on the battlefield might need it (they can USE any of those cards, but they don't have to wait through 15 timers if they have 15 Dwarven Armory cards).

To make use of it, you'll need to register and create the Upkeep Time Manager, whose filename (like any other manager in the CW) starts with "_MANAGER_". So, looking at the managers, you'll find "_MANAGER_UPKEEP_TIME" is the actual card's filename, so search for cards containing that filename. One I found was Braid of Fire (the original card it was made for).

The code on Braid of Fire related to the Upkeep Time Manager is this:
Code: Select all
   <!--Make the tokens at the beginning of the game at the rate of one per player.-->
   <TRIGGERED_ABILITY replacement_effect="1" active_zone="ZONE_ANY" >
      <TRIGGER value="BEGINNING_OF_STEP" pre_trigger="1" >
         return MTG():GetStep() == STEP_UPKEEP and MTG():GetTurnNumber() == 0
      </TRIGGER>
      <RESOLUTION_TIME_ACTION>
         RSN_Characteristics_CreateManagers("_UPKEEP_TIME_MANAGER")
      </RESOLUTION_TIME_ACTION>
   </TRIGGERED_ABILITY>
   <TOKEN_REGISTRATION reservation="1" type="_MANAGER_UPKEEP_TIME" />
   <TOKEN_REGISTRATION reservation="1" type="_MANAGER_CHARACTERISTICS" />
   <!--Turn the token off, then on if needed.-->
   <STATIC_ABILITY>
      <CONTINUOUS_ACTION layer="6"> <!--Here, put the requirements for the upkeep time window to appear for this card. Braid of Fire has none.-->
         EffectController():PlayerDataChest():Set_Int(CW_UPKEEP_TIME, 1)
      </CONTINUOUS_ACTION>
   </STATIC_ABILITY>
The triggered ability at the beginning of the game will automatically create the manager token. (Riiak's manager creation function will automatically make one for each player, and will also automatically create the manager it was made for, "_MANAGER_CHARACTERISTICS".)

If you want, you can make the upkeep time window not appear (by that, I mean there won't be a timer and the player won't get a chance to use the card) if they can't afford {2} or if they don't control a land. However, since they could potentially put a land out (via an instant or ability) and/or use Manual Mana, I wouldn't advise this. So, just stick that code at the end of the card and use the availability in the activated ability and it should be good to go.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 25 guests


Who is online

In total there are 25 users online :: 0 registered, 0 hidden and 25 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 25 guests

Login Form