Board index
Programs with AI or Rules Enforcement
Magic: The Gathering - Duels of the Planeswalkers
Programming Talk



[Request Help] Filter: Converted Mana Cost?
Moderator: CCGHQ Admins
6 posts
• Page 1 of 1
[Request Help] Filter: Converted Mana Cost?
by kevorz » 06 Aug 2012, 19:32
Hey guys,
I'm currently trying to recreate AEther Vial, but i have stumbled (once again) upon a problem.
I need to add a filter so i only can choose creatures in my hand that equal the converted mana cost equal to the charge counters on AEther Vial
Here is my current code:
ÆTHER_VIAL
Kevorz
I'm currently trying to recreate AEther Vial, but i have stumbled (once again) upon a problem.
I need to add a filter so i only can choose creatures in my hand that equal the converted mana cost equal to the charge counters on AEther Vial
Here is my current code:
ÆTHER_VIAL
- Code: Select all
<?xml version='1.0'?>
<CARD_V2>
<FILENAME text="ÆTHER_VIAL_48146" />
<CARDNAME text="ÆTHER_VIAL" />
<TITLE>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Æther Vial]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Æther Vial]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Æther Vial]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Æther Vial]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Æther Vial]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Æther Vial]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Æther Vial]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Æther Vial]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Æther Vial]]></LOCALISED_TEXT>
</TITLE>
<MULTIVERSEID value="48146" />
<ARTID value="48146" />
<ARTIST name="Greg Hildebrandt" />
<CASTING_COST cost="{1}" />
<TYPE metaname="Artifact" />
<EXPANSION value="DPG" />
<RARITY metaname="U" />
<TRIGGERED_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[At the beginning of your upkeep, you may put a charge counter on Æther Vial.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[At the beginning of your upkeep, you may put a charge counter on Æther Vial.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[At the beginning of your upkeep, you may put a charge counter on Æther Vial.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[At the beginning of your upkeep, you may put a charge counter on Æther Vial.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[At the beginning of your upkeep, you may put a charge counter on Æther Vial.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[At the beginning of your upkeep, you may put a charge counter on Æther Vial.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[At the beginning of your upkeep, you may put a charge counter on Æther Vial.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[At the beginning of your upkeep, you may put a charge counter on Æther Vial.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[At the beginning of your upkeep, you may put a charge counter on Æther Vial.]]></LOCALISED_TEXT>
<TRIGGER value="BEGINNING_OF_STEP" simple_qualifier="controller">
return ( EffectController():MyTurn() ~= 0 ) and ( MTG():GetStep() == STEP_UPKEEP )
</TRIGGER>
<RESOLUTION_TIME_ACTION>
--PlaceholderChoiceQuery
if EffectController():IsAI() == 0 then
EffectController():BeginNewMultipleChoice()
EffectController():AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_YES" )
EffectController():AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_NO" )
EffectController():AskMultipleChoiceQuestion( "CARD_QUERY_DRAW_A_CARD" )
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
if EffectController():IsAI() == 0 then
local decision = Object():GetMultipleChoiceResult()
if decision == 0 then
Object():AddCounters( MTG():ChargeCounters(), 1 )
end
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<ACTIVATED_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{T}: You may put a creature card with converted mana cost equal to the number of charge counters on Æther Vial from your hand onto the battlefield.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[{T}: You may put a creature card with converted mana cost equal to the number of charge counters on Æther Vial from your hand onto the battlefield.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[{T}: You may put a creature card with converted mana cost equal to the number of charge counters on Æther Vial from your hand onto the battlefield.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[{T}: You may put a creature card with converted mana cost equal to the number of charge counters on Æther Vial from your hand onto the battlefield.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[{T}: You may put a creature card with converted mana cost equal to the number of charge counters on Æther Vial from your hand onto the battlefield.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[{T}: You may put a creature card with converted mana cost equal to the number of charge counters on Æther Vial from your hand onto the battlefield.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[{T}: You may put a creature card with converted mana cost equal to the number of charge counters on Æther Vial from your hand onto the battlefield.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[{T}: You may put a creature card with converted mana cost equal to the number of charge counters on Æther Vial from your hand onto the battlefield.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[{T}: You may put a creature card with converted mana cost equal to the number of charge counters on Æther Vial from your hand onto the battlefield.]]></LOCALISED_TEXT>
<COST type="TapSelf" />
<RESOLUTION_TIME_ACTION>
--Declare variable(int?) equal to ChargeCounters?
local vial = Object():CountCounters( MTG():ChargeCounters() )
local player = EffectController()
local filter = Object():GetFilter()
filter:Clear()
filter:NotTargetted()
filter:May()
filter:SetPlayer( player )
filter:SetZone( ZONE_HAND )
filter:AddCardType( CARD_TYPE_CREATURE )
--No clue how to get this filter going (or even the syntax)
filter:GetConvertedManaCost( vial )
player:ChooseTarget(NO_VALIDATION, "CARD_QUERY_CHOOSE_CREATURE_TO_PUT_ONTO_BATTLEFIELD", EffectDC():Make_Targets(0))
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local player = EffectController()
local target = EffectDC():Get_Targets(0)
if player ~= nil then
if target ~= nil then
local card = target:Get_CardPtr(0)
if (card ~= nil and card:GetZone() == ZONE_HAND) then
card:PutIntoPlay( player )
end
end
end
</RESOLUTION_TIME_ACTION>
<AI_AVAILABILITY step="end_of_turn" turn="their_turn" />
<AI_AVAILABILITY step="declare_attackers" turn="their_turn" />
<AI_AVAILABILITY type="in_response_dangerous" />
<AI_AVAILABILITY step="declare_blockers" blocking_or_blocked="1" />
</ACTIVATED_ABILITY>
<AI_BASE_SCORE score="450" zone="ZONE_IN_PLAY" />
</CARD_V2>
Kevorz
Re: [Request Help] Filter: Converted Mana Cost?
by thefiremind » 06 Aug 2012, 19:35
As you can see on Panoptic Mirror:
filter:SetConvertedCostValue( value )
There are also:
SetConvertedCostMax for cost "less or equal to" the one specified
SetConvertedCostMin for cost "more or equal to" the one specified
In general, most filter functions start with "Set" when they are mutually exclusive, or "Add" if they are cumulative.
EDIT: Just thought I haven't been precise enough: with "mutually exclusive" I meant that each call of the same filter function cancels the previous ones, so for example if I write:
filter:SetConvertedCostValue( 2 )
filter:SetConvertedCostValue( 4 )
only CMC=4 will be considered, while if I write
filter:AddColour( COLOUR_WHITE )
filter:AddColour( COLOUR_BLUE )
I'll search for white or blue cards. Too bad we don't have a choice: for each function there's only one version, you can't substitute Add with Set (or vice versa) if you need to.
filter:SetConvertedCostValue( value )
There are also:
SetConvertedCostMax for cost "less or equal to" the one specified
SetConvertedCostMin for cost "more or equal to" the one specified
In general, most filter functions start with "Set" when they are mutually exclusive, or "Add" if they are cumulative.
EDIT: Just thought I haven't been precise enough: with "mutually exclusive" I meant that each call of the same filter function cancels the previous ones, so for example if I write:
filter:SetConvertedCostValue( 2 )
filter:SetConvertedCostValue( 4 )
only CMC=4 will be considered, while if I write
filter:AddColour( COLOUR_WHITE )
filter:AddColour( COLOUR_BLUE )
I'll search for white or blue cards. Too bad we don't have a choice: for each function there's only one version, you can't substitute Add with Set (or vice versa) if you need to.
Last edited by thefiremind on 06 Aug 2012, 19:53, edited 1 time in total.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 722 times
Re: [Request Help] Filter: Converted Mana Cost?
by kevorz » 06 Aug 2012, 19:44
Oh thank you so much, hadn't thought of Panoptic Mirror at all, must have a brain meltdown 
I really appreciate all the help you have given me already!
Greetings,
Kevorz

I really appreciate all the help you have given me already!
Greetings,
Kevorz
Re: [Request Help] Filter: Converted Mana Cost?
by thefiremind » 06 Aug 2012, 19:57
If you need a good way to browse through the existing cards, search on Google for "Depeche View" (there's a freeware version). It's a software that opens all the files inside a directory and lets you search through them all at once. I find it really useful when I need to search for existing code to take example from.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 722 times
Re: [Request Help] Filter: Converted Mana Cost?
by RiiakShiNal » 06 Aug 2012, 20:51
Or if you have Visual Studio doing a "Find in Files" (Shortcut: Ctrl+Shift+F) can be great if you want to see if anything in a directory (or set of directories) uses a particular search phrase. I find it wonderfully useful for looking up function usages or if I'm trying to find a specific keyword or phrase. (Visual Studio 2010 Professional is available for free to students [basically people with an .edu e-mail address] at DreamSpark.com.)
Though, if you don't have Visual Studio already and don't need it for programming then it's a bit overkill just for searching through a bunch of files.
Though, if you don't have Visual Studio already and don't need it for programming then it's a bit overkill just for searching through a bunch of files.
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2188
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
Re: [Request Help] Filter: Converted Mana Cost?
by Xana » 06 Aug 2012, 21:00
You can also use Notepad++ to search through multiple files, and it is a decent xml editor too 
What i have done is extract all cards from almost every download i could, and saved all the cards to their own folder, that way i can quickly search for example code in them.

What i have done is extract all cards from almost every download i could, and saved all the cards to their own folder, that way i can quickly search for example code in them.
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 12 guests