As the title says i have this scenario:
I have a cards.json with an array of cards (array of objects). I want to generate 3 cards "opponents" to the player without the possibility to choose the same element.
Example:
cards.json
[{ "id": 1, "name": "Goblin" }, { "id": 2, "name": "Another Goblin" }, { "id": 3, "name": "Healing Potion" }, { "id": 4, "name": "Ogre" }, { "id": 5, "name": "Healing Potion Super" }]
I want to choose randomly three of this five elements and throw it to player without repetitive of the same object.
Of course i'm doing a for loop in cards array and i know i can use round((random(0, max_size_of_array))), but how i can prevent the repetition?
Thanks a lot for the help! :)