I am trying to create a game where each player is dealt 2 cards. I am aware of how to do this, but currently it would take 4 triggers, each with blocks, to do this for every card the players will be dealt. Hereโs what it would look like with my system.
and at the end it would set a property to the card that was selected. This would also trigger a different chain of triggers to select the second card for the players and so on. I was wondering if there was any way I could make this more efficient, both saving time and memory.
You could have a property that stores all of the cards in the beginning, and then you use the sub string block to grab the selected letter from the card text string. Does that make sense?
This will retrieve the randomly selected card from the string of text. You could also use a property that holds all of the cards, and when a player draws that card, it could be removed from the property to ensure that nobody else gets the same card.
This could cause a range error if the random number selected is greater than the total number of cards remaining in the deck.
Instead of just having the random number being from 1 to 52, have it be from 1 to len(cards), cards being the property storing the remaining cards in the deck.
Are the cards not one character each? Why do we need to multiply our random number? In fact, the substring doesnโt need to use math, just get the character in the string with the index of the random number that was generated.