Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
How to get upkeep availability working?
Moderator: CCGHQ Admins
How to get upkeep availability working?
by 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.
So far this is the code I have for the card, it seems to work fine with the exception of the upkeep rule.
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?
by Xander9009 » 21 Oct 2015, 04:25
The last three lines on their own should do the trick.
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:
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 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.
- Code: Select all
<AVAILABILITY>
return MTG():GetStep() == STEP_UPKEEP
</AVAILABILITY>
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>
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 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
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
-
Xander9009 - Programmer
- Posts: 2905
- Joined: 29 Jun 2013, 07:44
- Location: Indiana, United States
- Has thanked: 121 times
- Been thanked: 445 times
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 9 guests