question

contact-18 avatar image
contact-18 asked

AddItemPlayerInventory + DisplayProperties

Hey guys, how can I pass the DisplayProperties for an item created using AddInventoryItemsAsync? Here is what my Azure Function currently looks like:

 namespace UsurpatorCompany.UsurpatorFunction
 {
     public static class CMDAzureAddItemPlayerInventory
      {
          [FunctionName("CMDAzureAddItemPlayerInventory")]
          public static async Task Run(
              [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
              ILogger log)
          {
             var context = JsonConvert.DeserializeObject<FunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync());
             var api = new PlayFabEconomyInstanceAPI(context.ApiSettings, context.AuthenticationContext);
             var itemFriendlyName =context.FunctionArgument["FriendlyName"];
             var targetEntityId =context.FunctionArgument["TargetEntityID"];
             var amount =context.FunctionArgument["Amount"];
             var collectionIDString =context.FunctionArgument["CollectionIDString"];
                
             var result = await api.AddInventoryItemsAsync(new PlayFab.EconomyModels.AddInventoryItemsRequest
             {
                 CollectionId = collectionIDString,
                 Item = new PlayFab.EconomyModels.InventoryItemReference
                 {                    
                     AlternateId=new PlayFab.EconomyModels.AlternateId
                     {
                         Type= "FriendlyId",
                         Value= itemFriendlyName
                     }
                 },
                 Amount = amount,
                 Entity = new PlayFab.EconomyModels.EntityKey{
                     Id = targetEntityId,
                     Type=context.CallerEntityProfile.Entity.Type
                 }
             });
         }
     }
 }
Player 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

·
kylemc@microsoft.com avatar image
kylemc@microsoft.com answered
2 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.

Abhishek Agrawal avatar image Abhishek Agrawal commented ·

Is there a way to know if the NewStackValues were applied or not?

Since they are only applied if a new stack is created, if user already had the item and we are adding more, NewStackValues are not applied. Which is fair, but is there any way to know that the values weren't applied from the add item request's result? So we can check and if needed we can make another request to force update the display properties?

0 Likes 0 ·
kylemc@microsoft.com avatar image kylemc@microsoft.com Abhishek Agrawal commented ·

No. There isn't anything in the response that provides this info. The assumption in the design is that you likely have read the inventory already and know whether you're creating a stack or not.

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.