It is currently 16 Jun 2019, 10:42
   
Text Size

Evolutionary Leap - A fitting first card

Moderators: Xander9009, CCGHQ Admins

Evolutionary Leap - A fitting first card

Postby killkong1211 » 25 Jul 2015, 17:00

So I'm trying to code Evolutionary Leap, but I'm still entirely a novice at this.

So far I've attemped to borrow code from Balustrade Spy, as he reveals from the top until a point.
All I managed to do with that though was change from milling till I hit a land to milling till I hit a creature.

I can't quite work out how to make the last revealed card go to hand. (Which is not to mention the second half of the ability to shuffle back in the remaining cards.)

If anyone can point ne in the right direction or hook me up to a glossary of syntactic commands I'd really appreciate it :)
killkong1211
 
Posts: 38
Joined: 24 Jul 2015, 16:06
Has thanked: 0 time
Been thanked: 0 time

Re: Evolutionary Leap - A fitting first card

Postby killkong1211 » 25 Jul 2015, 17:01

P.s. I have the cost of the ability working. It's just the activation I need a hand fixing
killkong1211
 
Posts: 38
Joined: 24 Jul 2015, 16:06
Has thanked: 0 time
Been thanked: 0 time

Re: Evolutionary Leap - A fitting first card

Postby Xander9009 » 25 Jul 2015, 17:31

You need to store all of the cards in a data chest as they're revealed rather than putting them directly into the graveyard or hand. Then, when you reveal the creature card, call Card:PutInHand(). Then, once you've done that, for each card in the datachest you made, put it on the bottom of the library. It won't be in a random order, but I don't think that will really matter. If anyone ever mentions it, I can make it random. But making it random can be a bit more difficult.

For reference, if you're not familiar with the terminology, a DataChest is usually abbreviated DC. So, when you see EffectDC(), that's EffectDataChest. LinkedDC and RSN_ObjectDC are all also datachests. EffectDC():Make_Targets(1) uses up EffectDC's first register (sort of, 0 is also a usable register) and makes a datachest of pointers considered targets. EffectDC():Make_Chest(2) uses up EffectDC's second register with a new, empty data chest. This is kind of thing you'll need to do.

Code: Select all
local TopCards = EffectDC():Make_Chest(0)  --Make a data chest to store the cards you find
local Count = EffectController():Library_Count()  --Count how many cards we MIGHT have to check
for i=0,Count-1 do  --For each card we may need to check, do the following
  local Card = EffectController():Library_GetNth(i)  --Get the next card from the top
  if Card ~= nil then  --If that card is valid...
    if Card:GetCardType():Test(CARD_TYPE_CREATURE) then  --Check if it's a creature
      Card:PutInHand()  --If it is, put it in your hand
      for j=0,i-1 do  --And then, for each card that we would have previously stored in the chest, do the following.
        local TopCard = TopCards:Get_CardPtr(j)  --Get the card
        if TopCard ~= nil then  --If it's not nil
          TopCard:PutOnBottomOfLibrary()  --Put it on the bottom of the library
        end
      end
      break  --When we're done with the chest and we've found the creature card, break the loop; we're done.
    else
      TopCards:Set_CardPtr(i, Card)  --If it's not a creature, store it in the chest for later.
    end
  end
end
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2880
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 116 times
Been thanked: 435 times

Re: Evolutionary Leap - A fitting first card

Postby killkong1211 » 25 Jul 2015, 17:47

Awesome, thanks for the breakdown and commented code Xander.
I'll give this a shot when I wake up.

I can already see I'd been calling PutInHand wrong, which I kind of suspected haha
killkong1211
 
Posts: 38
Joined: 24 Jul 2015, 16:06
Has thanked: 0 time
Been thanked: 0 time

Re: Evolutionary Leap - A fitting first card

Postby RiiakShiNal » 26 Jul 2015, 00:16

You can use Remove_RandomCardPtr() to get cards from the data chest in a random order to put on the bottom of the library. So still pretty easy to move cards randomly (function wasn't present in DotP 2013 so there things were more difficult).
Problems with base game cards: DotP 2014 Core Fixes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
RiiakShiNal
Programmer
 
Posts: 2115
Joined: 16 May 2011, 21:37
Has thanked: 73 times
Been thanked: 468 times

Re: Evolutionary Leap - A fitting first card

Postby killkong1211 » 26 Jul 2015, 02:46

Okay, so I used the code both of you suggested
Code: Select all
<RESOLUTION_TIME_ACTION>
      local TopCards = EffectDC():Make_Chest(0)
      local Count = EffectController():Library_Count()
      for i=0,Count-1 do
        local Card = EffectController():Library_GetNth(i)
        if Card ~= nil then
             Card:Reveal()
         if Card:GetCardType():Test(CARD_TYPE_CREATURE) then
           Card:PutInHand()
           for j=0,i-1 do
            local TopCard = TopCards:Remove_RandomCardPtr()
            if TopCard ~= nil then
              TopCard:PutOnBottomOfLibrary()
            end
           end
           break
         else
           TopCards:Set_CardPtr(i, Card)
         end
        end
      end
   </RESOLUTION_TIME_ACTION>
Just wanna make sure you guys think it's working as intended/optimized.
Cause I'm getting the creature in hand but not the reveal until.

Also, with
Code: Select all
Remove_RandomCardPtr()
that you suggested Riiak, does that remove the card from the chest we created and then ignore that chest location upon iteration?
killkong1211
 
Posts: 38
Joined: 24 Jul 2015, 16:06
Has thanked: 0 time
Been thanked: 0 time

Re: Evolutionary Leap - A fitting first card

Postby killkong1211 » 26 Jul 2015, 03:08

Also, I can't seem to get the artwork to show.
Is there some trick I'm missing or is the artwork just not available?
killkong1211
 
Posts: 38
Joined: 24 Jul 2015, 16:06
Has thanked: 0 time
Been thanked: 0 time

Re: Evolutionary Leap - A fitting first card

Postby Xander9009 » 26 Jul 2015, 03:25

killkong1211 wrote:Also, I can't seem to get the artwork to show.
Is there some trick I'm missing or is the artwork just not available?
Well, without the code you're using, we can't see if there's something wrong with the art. Are you using the CW's art? Are you including it in your own loose files wad directory?

As for the reveal, that's because I forgot to include it (note that in the commented code I posted, there's nothing about revealing because it completely slipped my mind). Just put a Card:Reveal() right after the card is checked against nil and before it's checked for being a creature.

As for the last question about the Remove_RandomCardPtr() function, just try it and change it so they go to the graveyard instead of the bottom of the library for testing. Check that all of the revealed cards ended up in the graveyard.

NeoAnderson used this code for Aladdin's Lamp to put the cards on the bottom in a random order.
Code: Select all
<RESOLUTION_TIME_ACTION>
   local queryDC = EffectDC():Get_Chest(1)
   if queryDC ~= nil then
      local num_cards = queryDC:Count()
      for i=0,num_cards-1 do
         local card = queryDC:Remove_RandomCardPtr()
         if card ~= nil then
            card:PutOnBottomOfLibrary()
         else
            break
         end
      end
   end
</RESOLUTION_TIME_ACTION>
I would try that code, but putting them in the graveyard first to check that it works, and then switching it back to the bottom of the library.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2880
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 116 times
Been thanked: 435 times

Re: Evolutionary Leap - A fitting first card

Postby killkong1211 » 26 Jul 2015, 03:40

Here's the full code for the card so you can get a better look.
I'd added the suggested Card:Reveal() myself when I noticed you'd missed it but it didn't reveal.

I will test the go to grave though instead to see what's up with it.
Attachments
EVOLUTIONARY_LEAP_CW_398573.rar
(1.18 KiB) Downloaded 211 times
killkong1211
 
Posts: 38
Joined: 24 Jul 2015, 16:06
Has thanked: 0 time
Been thanked: 0 time

Re: Evolutionary Leap - A fitting first card

Postby killkong1211 » 26 Jul 2015, 03:49

I just did the test with PutInGraveyard replacing PutOnBottomOfLibrary and it did indeed put them into grave.
So it is digging and then putting to bottom.
It's just skipping the intervening reveals.
killkong1211
 
Posts: 38
Joined: 24 Jul 2015, 16:06
Has thanked: 0 time
Been thanked: 0 time

Re: Evolutionary Leap - A fitting first card

Postby Xander9009 » 26 Jul 2015, 03:50

killkong1211 wrote:Here's the full code for the card so you can get a better look.
I'd added the suggested Card:Reveal() myself when I noticed you'd missed it but it didn't reveal.

I will test the go to grave though instead to see what's up with it.
Not sure what's up with the reveal. I've noticed reveal often doesn't work as expected. As for the art, you are trying to use the CW, and that explains its absence. Origins art isn't in the CW, yet.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2880
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 116 times
Been thanked: 435 times

Re: Evolutionary Leap - A fitting first card

Postby killkong1211 » 26 Jul 2015, 04:10

Yeah, I noticed Balustrade Spy had the same issue with reveal.
Oh well, as long as it functions as intended I guess haha. And since it's random order doesn't much matter anyway :)

Ah, righteo, I thought it'd either be that or I'd done something profoundly stupid haha
Well then I guess Evolutionary Leap is done
killkong1211
 
Posts: 38
Joined: 24 Jul 2015, 16:06
Has thanked: 0 time
Been thanked: 0 time

Re: Evolutionary Leap - A fitting first card

Postby RiiakShiNal » 26 Jul 2015, 15:28

killkong1211 wrote:Also, with
Code: Select all
Remove_RandomCardPtr()
that you suggested Riiak, does that remove the card from the chest we created and then ignore that chest location upon iteration?
I believe it actually removes the card pointer and then shifts the remaining pointers down (much like removing an item from a linked list in regular programming). Regardless if you have 10 cards in a data chest (at least sequentially starting from 0) then iterate through 10 times calling Remove_RandomCardPtr() each time then yes it will give you each of the 10 cards in a random order without any nils in between.
Problems with base game cards: DotP 2014 Core Fixes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
RiiakShiNal
Programmer
 
Posts: 2115
Joined: 16 May 2011, 21:37
Has thanked: 73 times
Been thanked: 468 times

Re: Evolutionary Leap - A fitting first card

Postby killkong1211 » 28 Jul 2015, 06:08

I was trying to think of the right words before and couldn't haha.
Linked list was what I was thinking of, excellent, tyvm for the info Riiak :)
killkong1211
 
Posts: 38
Joined: 24 Jul 2015, 16:06
Has thanked: 0 time
Been thanked: 0 time


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 1 guest


Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 10 minutes)
Most users ever online was 287 on 31 Mar 2019, 04:11

Users browsing this forum: No registered users and 1 guest

Login Form