Results 1 to 4 of 4

Thread: Avoiding Deck Destruction

  1. #1

    Avoiding Deck Destruction

    I have a game which uses references to decks in order to user scripts.

    The problem is that if the deck ever runs out it seems that the GUID for the deck is released (which makes sense since the deck no longer exists) and thus all scripts related to the deck will stop working.

    As such I was thinking of putting two dummy card at the bottom of the deck and preventing those cards from being taken. I assume I will need two cards because if a deck gets down to one object in it I believe the container (deck) is destroyed and the last object is instanced as an object, correct?

    That way, for example, a draw deck would never run out and when the dummy card is reached the players (or a script) can re-shuffle the discards back into the draw pile maintaining the GUID of the deck.

    If the user use a button script to draw from the deck then implementing this prevention is easy (check the quantity of cards in the deck and don't perform the draw if it is only one left). However, can the same be done for a manual draw? What if the player grabs the card from the deck manually? There is a onPickedUp event but when does the automatic takeObject occur: before or after the onPickedUp event is fired. If before, who can I cause the player's pickedUp card to be dropped?

  2. #2
    Fairly certain the onPickedUp fires after the card has already been removed from the deck. I don't know of a way to force the player pointer to release an item it has picked up. The best I've seen is to catch it in onDropped() and send it back to where it came from, but that won't fix your situation.

    But you have 3 dummy cards instead of 2.

  3. #3
    Join Date
    May 2016
    Posts
    1,072
    Place 2 dummy cards on the bottom of the deck. Then, using onObjectPickedUp, every time a person picks up an object, count how many cards are in the deck. If the count of cards == 2 then spawn a locked object (a flat token or something else square and flat) right over the deck. If you want the deck rebuilt or something, a button could appear on top of that blocker token to reshuffle the deck or whatnot.

    The object will physically block people from selecting the final 2 cards, and onObjectPickedUp triggers the instant an item is grabbed (after a card has exited the deck) so there is no way somebody else could slip in and grab one of the last 2 cards.

    To make sure those dummy cards stay at the bottom, you could have the script grab find them based on their GUIDs in the deck, pull them out, and then stack the deck on top of them. Just a thought.

  4. #4
    Quote Originally Posted by MrStump View Post
    Place 2 dummy cards on the bottom of the deck. Then, using onObjectPickedUp, every time a person picks up an object, count how many cards are in the deck. If the count of cards == 2 then spawn a locked object (a flat token or something else square and flat) right over the deck. If you want the deck rebuilt or something, a button could appear on top of that blocker token to reshuffle the deck or whatnot.

    The object will physically block people from selecting the final 2 cards, and onObjectPickedUp triggers the instant an item is grabbed (after a card has exited the deck) so there is no way somebody else could slip in and grab one of the last 2 cards.
    I like it...Thanks for the idea.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •