It is currently 03 Sep 2025, 14:12
   
Text Size

Help with Stitcher Geralf

Moderator: CCGHQ Admins

Help with Stitcher Geralf

Postby volrathxp » 08 Nov 2014, 02:47

Having some issues with Geralf. Am I on the right track here, or is there a better way to do this?

Stitcher Geralf | Open
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2 ExportVersion="1">
  <FILENAME text="STITCHER_GERALF_1000389694" />
  <CARDNAME text="STITCHER_GERALF" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Stitcher Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Geralf, raccommodeur]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Suturador Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Geralf der Leichenflicker]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Cucitore Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[縫い師、ゲラルフ]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Stitcher Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Stitcher Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Stitcher Geralf]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="1000389694" />
  <ARTID value="1000389694" />
  <ARTIST name="Karla Ortiz" />
  <CASTING_COST cost="{3}{U}{U}" />
  <SUPERTYPE metaname="Legendary" />
  <TYPE metaname="Creature" />
  <SUB_TYPE metaname="Human" />
  <SUB_TYPE metaname="Wizard" />
  <EXPANSION value="C14" />
  <RARITY metaname="M" />
  <POWER value="3" />
  <TOUGHNESS value="4" />
  <ACTIVATED_ABILITY>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{2}{U}, {T}: Each player puts the top three cards of his or her library into his or her graveyard. Exile up to two creature cards put into graveyards this way. Put an X/X blue Zombie creature token onto the battlefield, where X is the total power of the cards exiled this way.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[{2}{U}, {T} : Chaque joueur met les trois cartes du dessus de sa bibliothèque dans son cimetière. Exilez jusqu’à deux cartes de créature mises dans des cimetières de cette manière. Mettez sur le champ de bataille un jeton de créature X/X bleue Zombie, X étant la force totale des cartes exilées de cette manière.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[{2}{U}, {T}: Cada jugador pone las tres primeras cartas de su biblioteca en su cementerio. Exilia hasta dos cartas de criatura puestas en los cementerios de esta manera. Pon en el campo de batalla una ficha de criatura Zombie azul X/X, donde X es igual a la fuerza total de las cartas exiliadas de esta manera.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[{2}{U}, {T}: Jeder Spieler legt die obersten drei Karten seiner Bibliothek auf seinen Friedhof. Schicke bis zu zwei Kreaturenkarten, die auf diese Weise auf den Friedhof gelegt wurden, ins Exil. Bringe einen X/X blauen Zombie-Kreaturenspielstein ins Spiel, wobei X der Gesamtstärke der Karten entspricht, die auf diese Weise ins Exil geschickt wurden.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[{2}{U}, {T}: Ogni giocatore mette nel proprio cimitero le prime tre carte del proprio grimorio. Esilia fino a due carte creatura messe nei cimiteri in questo modo. Metti sul campo di battaglia una pedina creatura Zombie X/X blu, dove X è la forza totale delle carte esiliate in questo modo.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[{2}{U}, {T}:各プレイヤーはそれぞれ、自分のライブラリーの一番上から3枚のカードを自分の墓地に置く。これにより墓地に置かれたクリーチャー・カードを最大2体まで追放する。青のX/Xのゾンビ・クリーチャー・トークンを1体戦場に出す。Xはこれにより追放されたカードのパワーの合計に等しい。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[{2}{U}, {T}: Each player puts the top three cards of his or her library into his or her graveyard. Exile up to two creature cards put into graveyards this way. Put an X/X blue Zombie creature token onto the battlefield, where X is the total power of the cards exiled this way.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[{2}{U}, {T}: Each player puts the top three cards of his or her library into his or her graveyard. Exile up to two creature cards put into graveyards this way. Put an X/X blue Zombie creature token onto the battlefield, where X is the total power of the cards exiled this way.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[{2}{U}, {T}: Each player puts the top three cards of his or her library into his or her graveyard. Exile up to two creature cards put into graveyards this way. Put an X/X blue Zombie creature token onto the battlefield, where X is the total power of the cards exiled this way.]]></LOCALISED_TEXT>
<COST mana_cost="{2}{U}" type="Mana" />
<COST type="TapSelf" />
<RESOLUTION_TIME_ACTION>
    local answerDC = EffectDC():Make_Targets(0)
    local queryDC = EffectDC():Make_Chest(1)
    for i=0,MTG():GetNumberOfPlayers()-1 do
       local player = MTG():GetNthPlayer(i)
       if player ~= nil then
      for i=0,(3-1) do
         local card = player:Library_GetNth(i)
         if card ~= nil then
            queryDC:Set_CardPtr(i, card)
            queryDC:Protect_CardPtr(i)
            if card:GetCardType():Test(CARD_TYPE_CREATURE) == false then
               queryDC:QueryUnselect_CardPtr(i)
            end
            card:PutInGraveyard()
         else
            break
         end
      end
       end
    end
    EffectController():SetItemCount(2)
    for n=0,(2-1) do
      EffectController():SetItemPrompt(n, "CARD_QUERY_CHOOSE_CREATURE_TO_EXILE")
    end
    EffectController():ChooseItemsFromDC( queryDC, answerDC )
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
   local answerDC = EffectDC():Get_Targets(0)
   local num_cards = answerDC():Count()
   local max_power = 0
   for i=0,num_cards-1 do
      local card = answerDC:Get_CardPtr(i)
      if card ~= nil then
         local card_power = card:GetCurrentCharacteristics():Power_Get()
         max_power = max_power + card_power
         card:Exile()
      end
   end
   MTG():PutPTTokensOntoBattlefield( "TOKEN_ZOMBIE_X_X_U_100038969", 1, EffectController(), max_power, max_power )
</RESOLUTION_TIME_ACTION>
  </ACTIVATED_ABILITY>
  <SFX text="COMBAT_BLUNT_LARGE_ATTACK" power_boundary_min="4" power_boundary_max="-1" />
  <SFX text="COMBAT_BLUNT_SMALL_ATTACK" power_boundary_min="1" power_boundary_max="3" />
<TOKEN_REGISTRATION reservation="1" type="TOKEN_ZOMBIE_X_X_U_100038969" />
</CARD_V2>
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Help with Stitcher Geralf

Postby thefiremind » 08 Nov 2014, 10:02

I like the idea, but I see 2 problems:
  1. You aren't considering the "up to" clause, you should add it as an argument in the query where you choose the 2 creatures.
  2. You are nesting "for" loops with the same iteration variable, I don't even know exactly what's the result of that.
    Code: Select all
    for i=0,10 do
        ...
        for j=1,5 do
            ...
            for k=6,100 do
                ...
            end
        end
    end
    That's how you should do (this is just an example, the numbers are random and of course you can use any name you want, using i,j,k is just a convention).
< 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: Help with Stitcher Geralf

Postby volrathxp » 08 Nov 2014, 13:00

thefiremind wrote:I like the idea, but I see 2 problems:
  1. You aren't considering the "up to" clause, you should add it as an argument in the query where you choose the 2 creatures.
  2. You are nesting "for" loops with the same iteration variable, I don't even know exactly what's the result of that.
    Code: Select all
    for i=0,10 do
        ...
        for j=1,5 do
            ...
            for k=6,100 do
                ...
            end
        end
    end
    That's how you should do (this is just an example, the numbers are random and of course you can use any name you want, using i,j,k is just a convention).
Oh, good catches, that completely slipped my mind. Thanks :)
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Help with Stitcher Geralf

Postby NeoAnderson » 08 Nov 2014, 13:56

thefiremind wrote:I like the idea, but I see 2 problems:
  1. You aren't considering the "up to" clause, you should add it as an argument in the query where you choose the 2 creatures.
  2. You are nesting "for" loops with the same iteration variable, I don't even know exactly what's the result of that.
    Code: Select all
    for i=0,10 do
        ...
        for j=1,5 do
            ...
            for k=6,100 do
                ...
            end
        end
    end
    That's how you should do (this is just an example, the numbers are random and of course you can use any name you want, using i,j,k is just a convention).
If i am not wrong you could also use the same variable name, because the Lua should see them as local variables so each for should refer to a different value, but i am not sure.
NeoAnderson
 
Posts: 914
Joined: 10 Sep 2013, 07:49
Has thanked: 18 times
Been thanked: 139 times

Re: Help with Stitcher Geralf

Postby thefiremind » 08 Nov 2014, 14:06

NeoAnderson wrote:If i am not wrong you could also use the same variable name, because the Lua should see them as local variables so each for should refer to a different value, but i am not sure.
I don't think it's like that, because then how could you distinguish which variable you are referring to if you need to address the variable of an outer loop in the current one? For a multi-dimensional table you should be able to do this:
Code: Select all
for i=0,10 do
    for j=0,10 do
        some_function(some_table[i][j])
    end
end
If you use "i" again instead of "j", this would make no sense. :)
< 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: Help with Stitcher Geralf

Postby volrathxp » 08 Nov 2014, 14:28

Okay, so this is what it looks like now. And now I'm getting the following script error:

Code: Select all
[lua] [string "STITCHER_GERALF_1000389694_TITLE (RESOLUTION_TIME_ACTION)~0x00000749"]:3: attempt to call local 'answerDC' (a table value)
Stitcher Geralf | Open
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2 ExportVersion="1">
  <FILENAME text="STITCHER_GERALF_1000389694" />
  <CARDNAME text="STITCHER_GERALF" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Stitcher Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Geralf, raccommodeur]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Suturador Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Geralf der Leichenflicker]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Cucitore Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[縫い師、ゲラルフ]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Stitcher Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Stitcher Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Stitcher Geralf]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="1000389694" />
  <ARTID value="1000389694" />
  <ARTIST name="Karla Ortiz" />
  <CASTING_COST cost="{3}{U}{U}" />
  <SUPERTYPE metaname="Legendary" />
  <TYPE metaname="Creature" />
  <SUB_TYPE metaname="Human" />
  <SUB_TYPE metaname="Wizard" />
  <EXPANSION value="C14" />
  <RARITY metaname="M" />
  <POWER value="3" />
  <TOUGHNESS value="4" />
  <ACTIVATED_ABILITY>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{2}{U}, {T}: Each player puts the top three cards of his or her library into his or her graveyard. Exile up to two creature cards put into graveyards this way. Put an X/X blue Zombie creature token onto the battlefield, where X is the total power of the cards exiled this way.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[{2}{U}, {T} : Chaque joueur met les trois cartes du dessus de sa bibliothèque dans son cimetière. Exilez jusqu’à deux cartes de créature mises dans des cimetières de cette manière. Mettez sur le champ de bataille un jeton de créature X/X bleue Zombie, X étant la force totale des cartes exilées de cette manière.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[{2}{U}, {T}: Cada jugador pone las tres primeras cartas de su biblioteca en su cementerio. Exilia hasta dos cartas de criatura puestas en los cementerios de esta manera. Pon en el campo de batalla una ficha de criatura Zombie azul X/X, donde X es igual a la fuerza total de las cartas exiliadas de esta manera.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[{2}{U}, {T}: Jeder Spieler legt die obersten drei Karten seiner Bibliothek auf seinen Friedhof. Schicke bis zu zwei Kreaturenkarten, die auf diese Weise auf den Friedhof gelegt wurden, ins Exil. Bringe einen X/X blauen Zombie-Kreaturenspielstein ins Spiel, wobei X der Gesamtstärke der Karten entspricht, die auf diese Weise ins Exil geschickt wurden.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[{2}{U}, {T}: Ogni giocatore mette nel proprio cimitero le prime tre carte del proprio grimorio. Esilia fino a due carte creatura messe nei cimiteri in questo modo. Metti sul campo di battaglia una pedina creatura Zombie X/X blu, dove X è la forza totale delle carte esiliate in questo modo.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[{2}{U}, {T}:各プレイヤーはそれぞれ、自分のライブラリーの一番上から3枚のカードを自分の墓地に置く。これにより墓地に置かれたクリーチャー・カードを最大2体まで追放する。青のX/Xのゾンビ・クリーチャー・トークンを1体戦場に出す。Xはこれにより追放されたカードのパワーの合計に等しい。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[{2}{U}, {T}: Each player puts the top three cards of his or her library into his or her graveyard. Exile up to two creature cards put into graveyards this way. Put an X/X blue Zombie creature token onto the battlefield, where X is the total power of the cards exiled this way.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[{2}{U}, {T}: Each player puts the top three cards of his or her library into his or her graveyard. Exile up to two creature cards put into graveyards this way. Put an X/X blue Zombie creature token onto the battlefield, where X is the total power of the cards exiled this way.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[{2}{U}, {T}: Each player puts the top three cards of his or her library into his or her graveyard. Exile up to two creature cards put into graveyards this way. Put an X/X blue Zombie creature token onto the battlefield, where X is the total power of the cards exiled this way.]]></LOCALISED_TEXT>
<COST mana_cost="{2}{U}" type="Mana" />
<COST type="TapSelf" />
<RESOLUTION_TIME_ACTION>
    local answerDC = EffectDC():Make_Targets(0)
    local queryDC = EffectDC():Make_Chest(1)
    for i=0,MTG():GetNumberOfPlayers()-1 do
       local player = MTG():GetNthPlayer(i)
       if player ~= nil then
      for j=0,(3-1) do
         local card = player:Library_GetNth(j)
         if card ~= nil then
            queryDC:Set_CardPtr(j, card)
            queryDC:Protect_CardPtr(j)
            if card:GetCardType():Test(CARD_TYPE_CREATURE) == false then
               queryDC:QueryUnselect_CardPtr(j)
            end
            card:PutInGraveyard()
         else
            break
         end
      end
       end
    end
    EffectController():SetItemCount(2)
    for n=0,(2-1) do
      EffectController():SetItemPrompt(n, "CARD_QUERY_CHOOSE_CREATURE_TO_EXILE")
    end
    EffectController():ChooseItemsFromDC( queryDC, answerDC, QUERY_FLAG_UP_TO )
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
   local answerDC = EffectDC():Get_Targets(0)
   local num_cards = answerDC():Count()
   local max_power = 0
   for i=0,num_cards-1 do
      local card = answerDC:Get_CardPtr(i)
      if card ~= nil then
         local card_power = card:GetCurrentCharacteristics():Power_Get()
         max_power = max_power + card_power
         card:Exile()
      end
   end
   MTG():PutPTTokensOntoBattlefield( "TOKEN_ZOMBIE_X_X_U_100038969", 1, EffectController(), max_power, max_power )
</RESOLUTION_TIME_ACTION>
  </ACTIVATED_ABILITY>
  <SFX text="COMBAT_BLUNT_LARGE_ATTACK" power_boundary_min="4" power_boundary_max="-1" />
  <SFX text="COMBAT_BLUNT_SMALL_ATTACK" power_boundary_min="1" power_boundary_max="3" />
<TOKEN_REGISTRATION reservation="1" type="TOKEN_ZOMBIE_X_X_U_100038969" />
</CARD_V2>
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Help with Stitcher Geralf

Postby thefiremind » 08 Nov 2014, 16:11

Here:
Code: Select all
local num_cards = answerDC():Count()
you are using answerDC as a function, but it's not, so it doesn't want parentheses.
< 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: Help with Stitcher Geralf

Postby volrathxp » 08 Nov 2014, 16:22

thefiremind wrote:Here:
Code: Select all
local num_cards = answerDC():Count()
you are using answerDC as a function, but it's not, so it doesn't want parentheses.
Oops! Can't believe I did that.
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Help with Stitcher Geralf

Postby NeoAnderson » 08 Nov 2014, 17:06

thefiremind wrote:
NeoAnderson wrote:If i am not wrong you could also use the same variable name, because the Lua should see them as local variables so each for should refer to a different value, but i am not sure.
I don't think it's like that, because then how could you distinguish which variable you are referring to if you need to address the variable of an outer loop in the current one? For a multi-dimensional table you should be able to do this:
Code: Select all
for i=0,10 do
    for j=0,10 do
        some_function(some_table[i][j])
    end
end
If you use "i" again instead of "j", this would make no sense. :)
You're right Fire i made a bit confusion with the follow situation :
Unlike global variables, local variables have their scope limited to the block where they are declared. A block is the body of a control structure, the body of a function, or a chunk (the file or string with the code where the variable is declared).
Code: Select all
 x = 10
    local i = 1        -- local to the chunk
    while i<=x do
      local x = i*2    -- local to the while body
      print(x)         --> 2, 4, 6, 8, ...
      i = i + 1
    end
    if i > 20 then
      local x          -- local to the "then" body
      x = 20
      print(x + 2)
    else
      print(x)         --> 10  (the global one)
    end
    print(x)           --> 10  (the global one)
NeoAnderson
 
Posts: 914
Joined: 10 Sep 2013, 07:49
Has thanked: 18 times
Been thanked: 139 times

Re: Help with Stitcher Geralf

Postby thefiremind » 08 Nov 2014, 18:58

NeoAnderson wrote:Unlike global variables, local variables have their scope limited to the block where they are declared. A block is the body of a control structure, the body of a function, or a chunk (the file or string with the code where the variable is declared).
That is nice to know, but don't even try to ask help to anyone if you start naming variables like in that example. :lol: :lol: :lol:
< 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: Help with Stitcher Geralf

Postby volrathxp » 08 Nov 2014, 23:55

Well. In my testing, I no longer get the script error, but when I activate Geralf, I only ever get the opponents cards come up and even if I have creatures in my yard, they don't come up for selection.

I'm not sure what I'm doing wrong here.
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Help with Stitcher Geralf

Postby volrathxp » 09 Nov 2014, 01:01

Nevermind! I figured out what I'm doing slightly. I was overwriting the card pointer with each player iteration, so instead of storing the card pointer in j for each player, i'm figuring out how to store it so that they don't overlap. I had it set to j+i (for player 0 it would store 1, 2, 3), but I realize for player 1 it would overlap some.

Anyone have any thoughts?

Edit: for the record here is the current code. I only get 4 cards out of this, whereas before I only got the opponent's cards. I haven't tried with more than 2 players, but I'm pretty sure the results will be the same. How do I get all 6?

Stitcher Geralf | Open
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2 ExportVersion="1">
  <FILENAME text="STITCHER_GERALF_1000389694" />
  <CARDNAME text="STITCHER_GERALF" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Stitcher Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Geralf, raccommodeur]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Suturador Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Geralf der Leichenflicker]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Cucitore Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[縫い師、ゲラルフ]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Stitcher Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Stitcher Geralf]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Stitcher Geralf]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="1000389694" />
  <ARTID value="1000389694" />
  <ARTIST name="Karla Ortiz" />
  <CASTING_COST cost="{3}{U}{U}" />
  <SUPERTYPE metaname="Legendary" />
  <TYPE metaname="Creature" />
  <SUB_TYPE metaname="Human" />
  <SUB_TYPE metaname="Wizard" />
  <EXPANSION value="C14" />
  <RARITY metaname="M" />
  <POWER value="3" />
  <TOUGHNESS value="4" />
  <ACTIVATED_ABILITY>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{2}{U}, {T}: Each player puts the top three cards of his or her library into his or her graveyard. Exile up to two creature cards put into graveyards this way. Put an X/X blue Zombie creature token onto the battlefield, where X is the total power of the cards exiled this way.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[{2}{U}, {T} : Chaque joueur met les trois cartes du dessus de sa bibliothèque dans son cimetière. Exilez jusqu’à deux cartes de créature mises dans des cimetières de cette manière. Mettez sur le champ de bataille un jeton de créature X/X bleue Zombie, X étant la force totale des cartes exilées de cette manière.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[{2}{U}, {T}: Cada jugador pone las tres primeras cartas de su biblioteca en su cementerio. Exilia hasta dos cartas de criatura puestas en los cementerios de esta manera. Pon en el campo de batalla una ficha de criatura Zombie azul X/X, donde X es igual a la fuerza total de las cartas exiliadas de esta manera.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[{2}{U}, {T}: Jeder Spieler legt die obersten drei Karten seiner Bibliothek auf seinen Friedhof. Schicke bis zu zwei Kreaturenkarten, die auf diese Weise auf den Friedhof gelegt wurden, ins Exil. Bringe einen X/X blauen Zombie-Kreaturenspielstein ins Spiel, wobei X der Gesamtstärke der Karten entspricht, die auf diese Weise ins Exil geschickt wurden.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[{2}{U}, {T}: Ogni giocatore mette nel proprio cimitero le prime tre carte del proprio grimorio. Esilia fino a due carte creatura messe nei cimiteri in questo modo. Metti sul campo di battaglia una pedina creatura Zombie X/X blu, dove X è la forza totale delle carte esiliate in questo modo.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[{2}{U}, {T}:各プレイヤーはそれぞれ、自分のライブラリーの一番上から3枚のカードを自分の墓地に置く。これにより墓地に置かれたクリーチャー・カードを最大2体まで追放する。青のX/Xのゾンビ・クリーチャー・トークンを1体戦場に出す。Xはこれにより追放されたカードのパワーの合計に等しい。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[{2}{U}, {T}: Each player puts the top three cards of his or her library into his or her graveyard. Exile up to two creature cards put into graveyards this way. Put an X/X blue Zombie creature token onto the battlefield, where X is the total power of the cards exiled this way.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[{2}{U}, {T}: Each player puts the top three cards of his or her library into his or her graveyard. Exile up to two creature cards put into graveyards this way. Put an X/X blue Zombie creature token onto the battlefield, where X is the total power of the cards exiled this way.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[{2}{U}, {T}: Each player puts the top three cards of his or her library into his or her graveyard. Exile up to two creature cards put into graveyards this way. Put an X/X blue Zombie creature token onto the battlefield, where X is the total power of the cards exiled this way.]]></LOCALISED_TEXT>
<COST mana_cost="{2}{U}" type="Mana" />
<COST type="TapSelf" />
<RESOLUTION_TIME_ACTION>
    local answerDC = EffectDC():Make_Targets(0)
    local queryDC = EffectDC():Make_Chest(1)
    for i=0,MTG():GetNumberOfPlayers()-1 do
       local player = MTG():GetNthPlayer(i)
       if player ~= nil then
      for j=0,(3-1) do
         local card = player:Library_GetNth(j)
         if card ~= nil then
            queryDC:Set_CardPtr(j+i, card)
            queryDC:Protect_CardPtr(j+i)
            if card:GetCardType():Test(CARD_TYPE_CREATURE) == false then
               queryDC:QueryUnselect_CardPtr(j+i)
            end
            card:PutInGraveyard()
         else
            break
         end
      end
       end
    end
    EffectController():SetItemCount(2)
    for n=0,(2-1) do
      EffectController():SetItemPrompt(n, "CARD_QUERY_CHOOSE_CREATURE_TO_EXILE")
    end
    EffectController():ChooseItemsFromDC( queryDC, answerDC, QUERY_FLAG_UP_TO )
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
   local answerDC = EffectDC():Get_Targets(0)
   local num_cards = answerDC:Count()
   local max_power = 0
   for i=0,num_cards-1 do
      local card = answerDC:Get_CardPtr(i)
      if card ~= nil then
         local card_power = card:GetCurrentCharacteristics():Power_Get()
         max_power = max_power + card_power
         card:Exile()
      end
   end
   MTG():PutPTTokensOntoBattlefield( "TOKEN_ZOMBIE_X_X_U_100038969", 1, EffectController(), max_power, max_power )
</RESOLUTION_TIME_ACTION>
  </ACTIVATED_ABILITY>
  <SFX text="COMBAT_BLUNT_LARGE_ATTACK" power_boundary_min="4" power_boundary_max="-1" />
  <SFX text="COMBAT_BLUNT_SMALL_ATTACK" power_boundary_min="1" power_boundary_max="3" />
<TOKEN_REGISTRATION reservation="1" type="TOKEN_ZOMBIE_X_X_U_100038969" />
</CARD_V2>
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Help with Stitcher Geralf

Postby RiiakShiNal » 09 Nov 2014, 13:58

Instead of using "j+i" you should use "(i * 3) + j". When you are using nested loops to fill a single dimensional array or list the other loop index needs to be multiplied by the inner loop max count to avoid overlap. So in your example for player 0 you would get (0*3)+j or indices 0, 1, 2 while for player 1 you would get (1*3)+j or indices 3, 4, 5, etc....

Now if you need to eliminate nil entries then you will need to maintain a separate index variable to keep track of the current index and whenever you add to the single dimensional array or list you add one to the index variable to prevent overlap. This is probably the approach you will need to take since you are not always guaranteed to find 3 cards (for example a player only has 2 cards left in his/her library due to mill effects).
RiiakShiNal
Programmer
 
Posts: 2188
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Help with Stitcher Geralf

Postby volrathxp » 09 Nov 2014, 14:28

RiiakShiNal wrote:Instead of using "j+i" you should use "(i * 3) + j". When you are using nested loops to fill a single dimensional array or list the other loop index needs to be multiplied by the inner loop max count to avoid overlap. So in your example for player 0 you would get (0*3)+j or indices 0, 1, 2 while for player 1 you would get (1*3)+j or indices 3, 4, 5, etc....

Now if you need to eliminate nil entries then you will need to maintain a separate index variable to keep track of the current index and whenever you add to the single dimensional array or list you add one to the index variable to prevent overlap. This is probably the approach you will need to take since you are not always guaranteed to find 3 cards (for example a player only has 2 cards left in his/her library due to mill effects).
That makes sense. How do I deal with the separate index variable? I'm not sure how to do that part. The i*3+j thing I get.
volrathxp
User avatar
volrathxp
 
Posts: 362
Joined: 23 Jul 2014, 17:34
Has thanked: 9 times
Been thanked: 17 times

Re: Help with Stitcher Geralf

Postby RiiakShiNal » 09 Nov 2014, 18:59

The separate index variable would just be a local you define outside of the loops then when you add a card to the chest you would use that variable then increment by 1. For example:
Code: Select all
local myIndex = 0
for i=0, MTG():GetNumberOfPlayers()-1 do
  local oPlayer = MTG():GetNthPlayer(i)
  for j=0, 2 do
    local oCard = oPlayer:Library_GetNth(j)
    if (oCard ~= nil) then
      EffectDC():Set_CardPtr(myIndex, oCard)
      myIndex = myIndex + 1
    end
  end
end
RiiakShiNal
Programmer
 
Posts: 2188
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Next

Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 20 guests

Main Menu

User Menu

Our Partners


Who is online

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

Login Form