It is currently 05 Sep 2025, 18:57
   
Text Size

Unmark marked cards

Moderator: CCGHQ Admins

Unmark marked cards

Postby Zarroc » 07 Aug 2013, 15:11

Is there a way to unmark cards which were marked for a filter by using card:MarkForFilter() ?
User avatar
Zarroc
 
Posts: 16
Joined: 28 Jun 2013, 13:06
Has thanked: 1 time
Been thanked: 3 times

Re: Unmark marked cards

Postby thefiremind » 07 Aug 2013, 15:34

I don't think there's a way to unmark single cards, you can only clear all marks with MTG():ClearFilterMark(), but I'm pretty sure that there's a workaround that lets you do what you need without having to unmark single cards. What card are you trying to code?
< 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: 722 times

Re: Unmark marked cards

Postby Zarroc » 07 Aug 2013, 16:17

Thank you thats exactly what i needed.

I'm trying to code Epic Experiment and i'm marking each spell which can be cast for free and has a converted mana cost <= X. I put the top x cards in the grave because i ran into the same problem you discribed here: http://www.slightlymagic.net/forum/viewtopic.php?f=63&t=11380. I know it's not 100% rule compliant but the difference is not that big most of the time because the cards would end up in the grave anyway.

The problem with the marking was: when i cast a second epic experiment the cards which were marked by the first experiment were still marked and i could've cast them again.

Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2 ExportVersion="1">
  <FILENAME text="EPIC_EXPERIMENT_500253552" />
  <CARDNAME text="EPIC_EXPERIMENT" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Epic Experiment]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Expérience épique]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Experimento épico]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Episches Experiment]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Esperimento Epico]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[世紀の実験]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[위대한 실험]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Великий Эксперимент]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Experimento Épico]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="500253552" />
  <ARTID value="500253552" />
  <ARTIST name="Dan Scott" />
  <CASTING_COST cost="{X}{U}{R}" />
  <TYPE metaname="Sorcery" />
  <EXPANSION value="M13" />
  <RARITY metaname="R" />
  <SPELL_ABILITY>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Exile the top X cards of your library. For each instant and sorcery card with converted mana cost X or less among them, you may cast that card without paying its mana cost. Then put all cards exiled this way that weren’t cast into your graveyard.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Exilez les X cartes du dessus de votre bibliothèque. Pour chaque carte d’éphémère et de rituel ayant un coût converti de mana inférieur ou égal à X parmi elles, vous pouvez lancer cette carte sans payer son coût de mana. Mettez ensuite toutes les cartes exilées de cette manière qui n’ont pas été lancées dans votre cimetière.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Exilia las primeras X cartas de tu biblioteca. Por cada carta de instantáneo y de conjuro con coste de maná convertido de X o menos que se encuentre entre ellas, puedes lanzar esa carta sin pagar su coste de maná. Luego pon en tu cementerio todas las cartas exiliadas de esta manera que no fueron lanzadas.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Schicke die obersten X Karten deiner Bibliothek ins Exil. Du kannst davon jede Spontanzauber- und Hexereikarte mit umgewandelten Manakosten von X oder weniger wirken, ohne ihre Manakosten zu bezahlen. Lege dann alle Karten, die auf diese Weise ins Exil geschickt und nicht gewirkt wurden, auf deinen Friedhof.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Esilia le prime X carte del tuo grimorio. Per ogni carta istantaneo e stregoneria con costo di mana convertito pari o inferiore a X tra esse, puoi lanciare quella carta senza pagarne il costo di mana. Poi metti nel tuo cimitero tutte le carte esiliate in questo modo che non sono state lanciate.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[あなたのライブラリーの一番上からX枚のカードを追放する。あなたは、その中にある点数で見たマナ・コストがX以下の各インスタント・カードと各ソーサリー・カードをそれらのマナ・コストを支払うことなく唱えてもよい。その後、これにより追放されたうちで唱えられなかったすべてのカードをあなたの墓地に置く。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[당신의 서고 맨 위의 카드 X장을 추방한다. 당신은 그 중에서 전환마나비용이 X 이하인 각 순간마법 및 집중마법 카드를 마나비용의 지불 없이 발동할 수 있다. 그러고 나서 이렇게 추방된 카드 중 발동하지 않은 모든 카드를 당신의 무덤에 넣는다.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Изгоните X верхних карт вашей библиотеки. Для каждой находящейся среди них карты мгновенного заклинания и волшебства с конвертированной мана-стоимостью Х или меньше вы можете разыграть ту карту без уплаты ее мана-стоимости. Затем положите все изгнанные таким образом карты, которые не были разыграны, на ваше кладбище.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Exile os primeiros X cards do topo de seu grimório. Para cada card de mágica instantânea e feitiço com custo de mana convertido menor ou igual a X entre eles, você pode conjurá-lo sem pagar seu custo de mana. Depois, coloque em seu cemitério todos os cards exilados dessa maneira que não tenham sido conjurados.]]></LOCALISED_TEXT>
    <RESOLUTION_TIME_ACTION>
      local number = EffectSource():GetPaidX()
      for i = 0, (number-1) do
        local card = EffectController():Library_GetTop()
        if card ~= nil then
           EffectDC():Set_CardPtr(i, card)
           card:PutInGraveyard()
        end
      end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
      local number = EffectSource():GetPaidX()
      ClearFilter()
      for i = 0, (number-1) do
        local card = EffectDC():Get_CardPtr(i)
        if card ~= nil then
            EffectDC():Protect_CardPtr(i)
          if ((EffectController():CanCastSpellForFree( card )) and (card:GetConvertedManaCost() &lt; number+1)) then
                card:MarkForFilter()
             end
        end
      end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
      local number = EffectSource():GetPaidX()
      local efc = EffectController()
      local filter = EffectSource():GetFilter()
      filter:Set_Or()
      filter:Add( FE_TYPE, OP_IS, CARD_TYPE_INSTANT )
      filter:Add( FE_TYPE, OP_IS, CARD_TYPE_SORCERY )
      filter:SetMarkedObjectsOnly()
      filter:SetZone(ZONE_GRAVEYARD, efc)
      efc:SetItemCount(number)
      for i = 0, (number-1) do
        efc:SetItemPrompt( i, "CARD_QUERY_CHOOSE_A_CARD_TO_CAST_FOR_FREE" )
      end
      efc:ChooseItems( EffectDC():Make_Targets(0), QUERY_FLAG_UP_TO)
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
      local number = EffectSource():GetPaidX()
      for i = 0, (number-1) do
        local card = EffectDC():Get_Targets(0):Get_CardPtr(i)
        if card ~= nil then
           if EffectController():CanCastSpellForFree( card ) then
              EffectController():CastSpellForFree( card )
           
           end
        end
      end
    </RESOLUTION_TIME_ACTION>
  </SPELL_ABILITY>
</CARD_V2>
EDIT: I tried to fix it with MTG():ClearFilterMark() but if i use it i cant seem to mark anything even if i call MTG():ClearFilterMark() after marking and using the marks in my filter.
Code: Select all
<RESOLUTION_TIME_ACTION>
      local number = EffectSource():GetPaidX()
      for i = 0, (number-1) do
        local card = EffectController():Library_GetTop()
        if card ~= nil then
           EffectDC():Set_CardPtr(i, card)
           card:PutInGraveyard()
        end
      end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
      local number = EffectSource():GetPaidX()
      ClearFilter()
      for i = 0, (number-1) do
        local card = EffectDC():Get_CardPtr(i)
        if card ~= nil then
            EffectDC():Protect_CardPtr(i)
          if ((EffectController():CanCastSpellForFree( card )) and (card:GetConvertedManaCost() &lt; number+1)) then
                card:MarkForFilter()
             end
        end
      end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
      local number = EffectSource():GetPaidX()
      local efc = EffectController()
      local filter = EffectSource():GetFilter()
      filter:Set_Or()
      filter:Add( FE_TYPE, OP_IS, CARD_TYPE_INSTANT )
      filter:Add( FE_TYPE, OP_IS, CARD_TYPE_SORCERY )
      filter:SetMarkedObjectsOnly()
      filter:SetZone(ZONE_GRAVEYARD, efc)
      efc:SetItemCount(number)
      for i = 0, (number-1) do
        efc:SetItemPrompt( i, "CARD_QUERY_CHOOSE_A_CARD_TO_CAST_FOR_FREE" )
      end
      efc:ChooseItems( EffectDC():Make_Targets(0), QUERY_FLAG_UP_TO)
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
      local number = EffectSource():GetPaidX()
      for i = 0, (number-1) do
        local card = EffectDC():Get_Targets(0):Get_CardPtr(i)
        if card ~= nil then
           if EffectController():CanCastSpellForFree( card ) then
              EffectController():CastSpellForFree( card )
           end
        end
      end
      MTG():ClearFilterMark()
    </RESOLUTION_TIME_ACTION>
  </SPELL_ABILITY>
User avatar
Zarroc
 
Posts: 16
Joined: 28 Jun 2013, 13:06
Has thanked: 1 time
Been thanked: 3 times

Re: Unmark marked cards

Postby RiiakShiNal » 07 Aug 2013, 17:53

Instead of marking the cards why don't you add them to a data chest then use:
Code: Select all
efc:ChooseItemsFromDC( EffectDC():Get_Chest(10), EffectDC():Make_Targets(0), QUERY_FLAG_UP_TO )
Instead of doing MarkForFilter() you would do something along the lines of:
Code: Select all
local nCount = EffectDC():Int_Get( 9 )
local oDC = EffectDC():Get_Chest( 10 )
if (oDC == nil) then
  oDC = EffectDC():Make_Chest( 10 )
end
oDC:Set_CardPtr( nCount, card )
EffectDC():Int_Inc( 9 )
RiiakShiNal
Programmer
 
Posts: 2188
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Unmark marked cards

Postby thefiremind » 07 Aug 2013, 18:40

Yeah, marking is useful only if you need to let the player choose something from an entire zone. For Epic Experiment I'd suggest to do something along the lines of Jace's Mindseeker: you save the X cards into a chest, protect their pointers, exile them, then use QueryUnselect_CardPtr on the cards that you cannot cast, and let the player choose any number of them to cast.

My problem of targetting cards in the exile zone has nothing to do with this: Epic Experiment doesn't target anything.
< 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: 722 times

Re: Unmark marked cards

Postby Zarroc » 07 Aug 2013, 21:03

I managed to get it to work finally :D
Thanks for all your help!
User avatar
Zarroc
 
Posts: 16
Joined: 28 Jun 2013, 13:06
Has thanked: 1 time
Been thanked: 3 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 21 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 21 users online :: 0 registered, 0 hidden and 21 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 21 guests

Login Form