question

Max Guernsey, III avatar image
Max Guernsey, III asked

What is the best way to model nothing in a drop table?

I have a set of rewards I want users to get occasionally when they win a game. Since I'm already building a drop table to deal with the various rewards and setting weights to manage their probabilities, I was hoping to also have nothing occupy some of the probability space. I'm wondering what the PlayFab recommended way to do this is.

It seems like my best bet is to create a catalog item called "nothing" and make it so it doesn't show up in any stores. Then have that catalog item be consumable and set to expire as quickly as possible (1s?).

Is there a better way to do this?

In-Game EconomyPlayer Inventory
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

On the basis of your workaround, you can add the server logic to prevent the “empty” item from being granted to players. As the documentation says, you can use this Server API method EvaluateRandomResultTable on CloudScript to get the result of an evaluation of a Random Result Table. So you can add the processing logic for “empty” items in the CloudScript functions. Please refer to the following testing function.

handlers.EvaluateTable = function (args, context) {

    var evaluateTableResult = server.EvaluateRandomResultTable({
        TableId: "Test Table"
    });
    var itemId = evaluateTableResult.ResultItemId;

    if (itemId == "EmptyItem") {
        return "Granted nothing."
    } else {
        var request = {
            PlayFabId: currentPlayerId,
            ItemIds: [itemId]
        }
        var GrantResult = server.GrantItemsToUser(request);
        return "Granted " + itemId;
    }

}

For clarification, as our documentation says, the API methods about Drop Table can't be called by clients directly. The sample code shows a workflow that automatically granting all the result item. So you can add a condition judgment to prevent the server from granting items whose name is "nothing" or "EmptyItem".

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Max Guernsey, III avatar image Max Guernsey, III commented ·

If "nothing" is an inert, stackable item that "burns up" after three seconds, what is the advantage of adding code to avoid granting it?

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Max Guernsey, III commented ·

It can reduce a certain amount of Profile Writes that is a part of pricing meters.

You can also grant these items if it is your game design. In terms of game logic, there is no problem to grant these “nothing” items.

1 Like 1 ·
Martin Messerschmidt avatar image Martin Messerschmidt Sarah Zhang commented ·

Wouldn't calling the API to evaluate the DT also count towards the pricing meters? Plus you run the risk of having too many API calls in a single request, especially if you have stacked drop tables.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.