Random card drop

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Create your own trading card game with this Fantasy TCG Card Template
  • Hi. I'm hung up on an easy system that I can't do.

    I have a json type array, with a display of card names, drop chance, and information.

    Each row, is the information for a card.

    I need to make it so that on push, the game compares all the data in the array, and adds by pushing, one card from this json, if there is a drop chance, from the second column.

    The game should do a push of the full row. For example, if the random chance is 15%, the game takes into account the cell with the number 15, the one with card 4, and makes a push.

    The result is: Card 4, 15 , id5.

    If you have more other and convenient ways I would be glad to listen. I need to create a system of dropping items-cards from the box. With random.

    My stupid system that didn't work.

    Tagged:

  • You didn't mention what the incorrect outcome was but I think I see a problem that I also came across. So in the array sheets the rows are actually Y and the columns are X, so the reverse of the array. In the sheet you have to put the data in rows as columns and columns as rows. When you look at your array in debug view, the data will not be what you expect where columns are at X and rows are at Y, I think ?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Also, your chances are confusing. The first three cards have 100% chance, right? So whatever the chance value is, only the first card will always be picked.

    Or did you mean that the card should be selected at random from the entire array, but the smaller the chance number, the less likely it will be picked? In this case you need to use the Advanced Random plugin, its probability tables feature. Create a probability table with card indices and their chances.

    You can actually load the whole table as a JSON string. Then use AdvancedRandom.weighted expression to pick a random card (its Y-index in the array):

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)