It is currently 19 Apr 2024, 17:45
   
Text Size

Upkeep mana costs

Moderator: CCGHQ Admins

Upkeep mana costs

Postby Thran75 » 09 Mar 2013, 22:24

May someone help me? I do like know how implement the mana costs in upkeep and cumulative in cards like Junun Efreet for exemple or stasi
.
Thran75
 
Posts: 22
Joined: 24 Feb 2013, 11:38
Has thanked: 7 times
Been thanked: 0 time

Re: Upkeep mana costs

Postby thefiremind » 09 Mar 2013, 22:37

There are 2 ways: by using conditional mana costs, or by implementing the query manually. Conditional mana costs are asked to be paid before resolution, so I don't like to use them because it's not optimal rule-wise.

This is how I made the ability for Nicol Bolas:
Code: Select all
  <TRIGGERED_ABILITY>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[At the beginning of your upkeep, sacrifice Nicol Bolas unless you pay {U}{B}{R}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[All’inizio del tuo mantenimento, sacrifica Nicol Bolas a meno che non paghi {U}{B}{R}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Opfere Nicol Bolas zu Beginn deines Versorgungssegments, falls du nicht {U}{B}{R} bezahlst.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Au début de votre entretien, sacrifiez Nicol Bolas à moins que vous ne payiez {U}{B}{R}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Al comienzo de tu mantenimiento, sacrifica a Nicol Bolas a menos que pagues {U}{B}{R}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[あなたのアップキープの開始時に、あなたが{U}{B}{R}を支払わないかぎり、ニコル・ボーラスを生け贄に捧げる。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[At the beginning of your upkeep, sacrifice Nicol Bolas unless you pay {U}{B}{R}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[В начале вашего шага поддержки пожертвуйте Николя Боласа, если вы не заплатите {U}{B}{R}.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[No início de sua manutenção, sacrifique Nicol Bolas, a menos que você pague {U}{B}{R}.]]></LOCALISED_TEXT>
    <TRIGGER value="BEGINNING_OF_STEP" simple_qualifier="controller">
    return ( EffectController():MyTurn() ~= 0 ) and ( MTG():GetStep() == STEP_UPKEEP )
    </TRIGGER>
    <RESOLUTION_TIME_ACTION>
    local controller = EffectController()
    if controller ~= nil and controller:CanAfford("{U}{B}{R}") == 1 then
       controller:BeginNewMultipleChoice()
       controller:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_YES" )
       controller:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_NO" )
       controller:AskMultipleChoiceQuestion( "CONDITIONAL_QUESTION_BODY" )
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local controller = EffectController()
    if controller ~= nil then
       if controller:CanAfford("{U}{B}{R}") == 1 and Object():GetMultipleChoiceResult() == 0 then
          controller:TapLand("{U}{B}{R}")
       elseif EffectSource() ~= nil then
          EffectSource():Sacrifice(controller)
       end
    end
    </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
Change all the occurrences of "{U}{B}{R}" with the cost you need, and you can reuse this code for any similar card (Junun Efreet included).

Cumulative upkeeps would be a bit more complicated: the latest rulings for cumulative upkeep state that you must add one age counter to the card during each upkeep, and then pay the cost once for each age counter. I never tried to implement it, but I can come up with something if you need it, just write one of the cards with cumulative upkeep you need so I know where to start.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 721 times

Re: Upkeep mana costs

Postby RiiakShiNal » 10 Mar 2013, 14:00

Probably the easiest way to handle cumulative upkeep would be to create a function that generates a mana string based on the number of age counters on the object and the base mana cost for a single age counter, store the returned string in a local variable then use that variable in place of the hard coded mana strings then handle it much like thefiremind does regular upkeep above. Though it would only work properly for cumulative upkeeps that do not have multiple options of paying.

For those which you have the option of paying in multiple ways the easiest way would probably be looping the choice/payment until it has been paid X times where X is the number of age counters. Non-optimal, but it would work.
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 496 times

Re: Upkeep mana costs

Postby thefiremind » 10 Mar 2013, 14:09

RiiakShiNal wrote:For those which you have the option of paying in multiple ways the easiest way would probably be looping the choice/payment until it has been paid X times where X is the number of age counters. Non-optimal, but it would work.
Another solution would be to treat, for example, "Cumulative upkeep {B} or {R}" as "Cumulative upkeep {BR}".
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 721 times

Re: Upkeep mana costs

Postby RiiakShiNal » 11 Mar 2013, 13:35

thefiremind wrote:Another solution would be to treat, for example, "Cumulative upkeep {B} or {R}" as "Cumulative upkeep {BR}".
That would indeed work for alternate mana cumulative upkeeps, and using Phyrexian mana could even work for something that alternates between mana and 2 life.
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 496 times

Re: Upkeep mana costs

Postby Thran75 » 13 Mar 2013, 16:18

It worked very good now thanks
Thran75
 
Posts: 22
Joined: 24 Feb 2013, 11:38
Has thanked: 7 times
Been thanked: 0 time


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 30 guests


Who is online

In total there are 30 users online :: 0 registered, 0 hidden and 30 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 30 guests

Login Form