Page 1 of 1

Making a card undrawable

PostPosted: 10 Feb 2016, 23:04
by Dargenom
Is there some snippet of code you can add to a card to make it so you can't draw it in your starting hand or at all? Thanks in advance! :)

Re: Making a card undrawable

PostPosted: 10 Feb 2016, 23:30
by Xander9009
Why?

Re: Making a card undrawable

PostPosted: 10 Feb 2016, 23:41
by Dargenom
Been working on a custom story mode of sorts ever since I realized you could have a deck start out at any life total. For the boss I was thinking the AI would start with lands already in play, so I put leyline-esque effects on a few lands that trigger from anywhere. But then if said lands were drawn in the starting hand they're suddenly at less than 7 cards right off the bat.

Re: Making a card undrawable

PostPosted: 10 Feb 2016, 23:43
by Xander9009
There's no good way to prevent the player from drawing a card. Code can't run until the mulligan is complete, and by then the card will have already been drawn or not. However, it might be possible to make specific setups like how some vanilla encounters work. I'm not certain. RiiakShiNal might know. I'd look into any of the decks in the game that you play against (or as, in the case of the tutorial) and see if they have any useful info.

Re: Making a card undrawable

PostPosted: 10 Feb 2016, 23:50
by Dargenom
Ah, fair enough. Time to do some digging then. Thanks for the help!

Re: Making a card undrawable

PostPosted: 11 Feb 2016, 02:47
by RiiakShiNal
You can't make a card undrawable, but there is still something you can do. You said that you put leyline effects on the card(s), well before you have them enter the battlefield you can check their current zone and if that zone is ZONE_HAND then force that player to draw a card to replace the leyline-like card. It makes sure that any card (other than a true leyline) that is put on the battlefield doesn't cause the player to start with fewer cards in hand than normal.

That is the easiest (and probably the best) solution. There are other more complex solutions to do what you are asking, but I can't really say they are better.

Creating saved encounters really isn't an option at this point because no-one has analyzed the saved game files and there could be additional checks. Also creating a new campaign (to host any created encounters) could cause issues with the existing campaigns since there aren't any free campaign slots.

Re: Making a card undrawable

PostPosted: 11 Feb 2016, 03:24
by Xander9009
RiiakShiNal wrote:You can't make a card undrawable, but there is still something you can do. You said that you put leyline effects on the card(s), well before you have them enter the battlefield you can check their current zone and if that zone is ZONE_HAND then force that player to draw a card to replace the leyline-like card. It makes sure that any card (other than a true leyline) that is put on the battlefield doesn't cause the player to start with fewer cards in hand than normal.

That is the easiest (and probably the best) solution. There are other more complex solutions to do what you are asking, but I can't really say they are better.

Creating saved encounters really isn't an option at this point because no-one has analyzed the saved game files and there could be additional checks. Also creating a new campaign (to host any created encounters) could cause issues with the existing campaigns since there aren't any free campaign slots.
While it would require having his campaign be a standalone that is plainly said to be incompatible with the official one, but couldn't he basically just replace the campaign decks and personalities with his own? He'd have a set number of decks to create, which might limit it a bit, unfortunately, but better than nothing, perhaps. (I mean replace the deck lists and images and stuff with identically named files.) Just a thought.

Re: Making a card undrawable

PostPosted: 11 Feb 2016, 11:32
by RiiakShiNal
Xander9009 wrote:While it would require having his campaign be a standalone that is plainly said to be incompatible with the official one, but couldn't he basically just replace the campaign decks and personalities with his own? He'd have a set number of decks to create, which might limit it a bit, unfortunately, but better than nothing, perhaps. (I mean replace the deck lists and images and stuff with identically named files.) Just a thought.
He could replace the official campaign, but even then we don't yet understand how the encounter saves are set up so the idea of having a "save" where the AI starts with certain cards already on the battlefield is still out unless someone examines the saves and figures out how they work.

The best idea is still to have the cards automatically put themselves on the battlefield and if they were in hand replace themselves by forcing the player to draw a card. Now there are a few ways to go about that.
  1. Simple check before placing itself on battlefield (in RTA) to see if it was in hand and have player draw a card if it was.
  2. Have the card check to see how many cards are in hand at the beginning of resolution, then at end of resolution force player to draw cards until it matches how many cards were in hand at the beginning.
  3. If you want to always ensure 7 cards in hand for the player using the deck then at end of resolution draw cards until 7 are in hand.
  4. Write a special manager which will set up the "saved" game by manipulating all cards in deck, hand, graveyard, etc... on turn 0 (or 1, I can't remember which the game uses for first turn off hand) then either terminates itself or turns itself off.

For simple solutions option 1 is probably best, if you want total control then option 4 will give the best control for the least coding (though there can still be a lot of code for checking different scenarios such as FFA[2, 3, or 4 players], 2HG, etc...).

Re: Making a card undrawable

PostPosted: 12 Feb 2016, 19:59
by Dargenom
Making it draw you a card to replace it from the hand is a good idea, can't believe I didn't think of that myself. Shouldn't be that hard to piece together from other card code either. Thanks for the help guys. ^^