From ce075e566dc303adb66034db0d9345dbe0b4d320 Mon Sep 17 00:00:00 2001 From: Daniel Heinze Date: Mon, 17 May 2021 17:14:59 +0200 Subject: [PATCH 1/3] docs: updated json and readme in prizewheel --- Recipes/PrizeWheel/PlayFab-JSON/Catalog.json | 72 +++++++++++---- .../PrizeWheel/PlayFab-JSON/DropTable.json | 25 ----- Recipes/PrizeWheel/README.md | 91 ++++++++++--------- 3 files changed, 104 insertions(+), 84 deletions(-) delete mode 100644 Recipes/PrizeWheel/PlayFab-JSON/DropTable.json diff --git a/Recipes/PrizeWheel/PlayFab-JSON/Catalog.json b/Recipes/PrizeWheel/PlayFab-JSON/Catalog.json index 08be7aa3..32507bbf 100644 --- a/Recipes/PrizeWheel/PlayFab-JSON/Catalog.json +++ b/Recipes/PrizeWheel/PlayFab-JSON/Catalog.json @@ -9,8 +9,8 @@ "Description": "This card bears three distinct red marks.", "VirtualCurrencyPrices": null, "RealCurrencyPrices": null, - "Tags": [], - "CustomData": "null", + "Tags": null, + "CustomData": null, "Consumable": { "UsageCount": null, "UsagePeriod": null, @@ -21,7 +21,10 @@ "CanBecomeCharacter": false, "IsStackable": false, "IsTradable": false, - "ItemImageUrl": null + "ItemImageUrl": null, + "IsLimitedEdition": false, + "InitialLimitedEditionCount": 0, + "ActivatedMembership": null }, { "ItemId": "Card2", @@ -31,8 +34,8 @@ "Description": "This card has two holes of equal volume.", "VirtualCurrencyPrices": null, "RealCurrencyPrices": null, - "Tags": [], - "CustomData": "null", + "Tags": null, + "CustomData": null, "Consumable": { "UsageCount": null, "UsagePeriod": null, @@ -43,7 +46,10 @@ "CanBecomeCharacter": false, "IsStackable": false, "IsTradable": false, - "ItemImageUrl": null + "ItemImageUrl": null, + "IsLimitedEdition": false, + "InitialLimitedEditionCount": 0, + "ActivatedMembership": null }, { "ItemId": "Card1", @@ -53,8 +59,8 @@ "Description": "This card is blank.", "VirtualCurrencyPrices": null, "RealCurrencyPrices": null, - "Tags": [], - "CustomData": "null", + "Tags": null, + "CustomData": null, "Consumable": { "UsageCount": null, "UsagePeriod": null, @@ -65,7 +71,10 @@ "CanBecomeCharacter": false, "IsStackable": false, "IsTradable": false, - "ItemImageUrl": null + "ItemImageUrl": null, + "IsLimitedEdition": false, + "InitialLimitedEditionCount": 0, + "ActivatedMembership": null }, { "ItemId": "SpinAgain", @@ -75,7 +84,7 @@ "Description": "You just got one free Spin Ticket!", "VirtualCurrencyPrices": null, "RealCurrencyPrices": null, - "Tags": [], + "Tags": null, "CustomData": "null", "Consumable": { "UsageCount": 1, @@ -93,7 +102,10 @@ "CanBecomeCharacter": false, "IsStackable": false, "IsTradable": false, - "ItemImageUrl": null + "ItemImageUrl": null, + "IsLimitedEdition": false, + "InitialLimitedEditionCount": 0, + "ActivatedMembership": null }, { "ItemId": "PrizeWheel1", @@ -105,7 +117,7 @@ "ST": 1 }, "RealCurrencyPrices": null, - "Tags": [], + "Tags": null, "CustomData": "null", "Consumable": { "UsageCount": 1, @@ -115,15 +127,43 @@ "Container": null, "Bundle": { "BundledItems": [], - "BundledResultTables": [ - "PrizeWheel1" - ], + "BundledResultTables": [], "BundledVirtualCurrencies": null }, "CanBecomeCharacter": false, "IsStackable": false, "IsTradable": false, - "ItemImageUrl": null + "ItemImageUrl": null, + "IsLimitedEdition": false, + "InitialLimitedEditionCount": 0, + "ActivatedMembership": null + } + ], + "DropTables": [ + { + "TableId": "PrizeWheel1", + "Nodes": [ + { + "ResultItemType": "ItemId", + "ResultItem": "Card1", + "Weight": 10000 + }, + { + "ResultItemType": "ItemId", + "ResultItem": "Card2", + "Weight": 10000 + }, + { + "ResultItemType": "ItemId", + "ResultItem": "Card3", + "Weight": 10000 + }, + { + "ResultItemType": "ItemId", + "ResultItem": "SpinAgain", + "Weight": 303 + } + ] } ] } \ No newline at end of file diff --git a/Recipes/PrizeWheel/PlayFab-JSON/DropTable.json b/Recipes/PrizeWheel/PlayFab-JSON/DropTable.json deleted file mode 100644 index 91a9fbd0..00000000 --- a/Recipes/PrizeWheel/PlayFab-JSON/DropTable.json +++ /dev/null @@ -1,25 +0,0 @@ -[{ - "TableId": "PrizeWheel1", - "Nodes": [ - { - "ResultItemType": "ItemId", - "ResultItem": "Card1", - "Weight": 10000 - }, - { - "ResultItemType": "ItemId", - "ResultItem": "Card2", - "Weight": 10000 - }, - { - "ResultItemType": "ItemId", - "ResultItem": "Card3", - "Weight": 10000 - }, - { - "ResultItemType": "ItemId", - "ResultItem": "SpinAgain", - "Weight": 303 - } - ] -}] \ No newline at end of file diff --git a/Recipes/PrizeWheel/README.md b/Recipes/PrizeWheel/README.md index a2001d37..c3eda9bb 100644 --- a/Recipes/PrizeWheel/README.md +++ b/Recipes/PrizeWheel/README.md @@ -1,62 +1,67 @@ -## Daily Prize Wheel -### Description: +# Daily Prize Wheel + +## Description + A daily prize wheel gives players a 'spin' to receive a prize in exchange for a ticket. Tickets in this example are using PlayFab's regenerating Virtual Currency to ensure that the player is granted 1 ticket each day. The simplest way to achieve our intended "wheel of prizes' mechanic is to use a bundle or container with a drop table to control the distribution odds to receiving each item. -This technique ensures that players can only 'spin' at most one time per 24 hour period. Additionally, you can easily cap how many 'spin' tickets can be saved through the Virtual Currency settings. In this example we are allowing the player to bank up to 5 spin tickets +This technique ensures that players can only 'spin' at most one time per 24 hour period. Additionally, you can easily cap how many 'spin' tickets can be saved through the Virtual Currency settings. In this example we are allowing the player to bank up to 5 spin tickets. + +### Ingredients (Building Blocks) -### Ingredients (Building Blocks): - * [Accounts](https://api.playfab.com/docs/building-blocks#Accounts) - * [Player Inventory](https://api.playfab.com/docs/building-blocks#Player_Inventory) - * [Virtual Currency](https://api.playfab.com/docs/building-blocks#Virtual_Currency) - * [Catalog & CatalogItems (Bundle / Container)](https://api.playfab.com/docs/building-blocks#Catalog) - * [Drop Table](https://api.playfab.com/docs/building-blocks#Drop_Table) +* [Accounts](https://api.playfab.com/docs/building-blocks#Accounts) +* [Player Inventory](https://api.playfab.com/docs/building-blocks#Player_Inventory) +* [Virtual Currency](https://api.playfab.com/docs/building-blocks#Virtual_Currency) +* [Catalog & CatalogItems (Bundle / Container)](https://api.playfab.com/docs/building-blocks#Catalog) +* [Drop Table](https://api.playfab.com/docs/building-blocks#Drop_Table) -###Preparation: - 1. Under the **Economy > Currencies** section of the Game Manager add a Virtual Currency to match the following parameters: +### Preparation + +1. Under the **Economy > Currencies** section of the Game Manager add a Virtual Currency to match the following parameters: | Property | Value | Detail - ---: | :---: | --- - Code | ST | Abbreviation for our VC - Name | Spin Ticket | Name of our VC - Initial Deposit | 1 | ensure that the player can spin on their first login - Recharge Rate | 1 | this sets the VC to regenerate 1 unit per day - Recharge Max | 5 | this caps the regeneration to the specified number, this is useful for allowing players to bank up to 5 spin tickets at a time - - 2. Next, under the Catalog tab, add a new catalog called **PrizeWheel**. - 3. After the catalog is created, navigate within the catalog to the **Drop Tables** tab. - 4. Upload [this JSON file](/Recipes/PrizeWheel/PlayFab-JSON/DropTable.json). The drop table should contain all of the items on the 'wheel'. - 5. Finally, navigate back to the top-level catalogs view and click on the small black arrow in the top-right corner of the "PrizeWheel Catalog". Choose the Upload JSON option and provide [this catalog file](/Recipes/PrizeWheel/PlayFab-JSON/Catalog.json) or use your own. - * If using your own, ensure that you have items that can be granted to a player. - -### Mechanic Walkthrough: - 1. Client obtains a valid session ticket via one of the various authentication pathways (required to make Client API Calls) - 2. After logging-in the client needs a mechanism to trigger a spin - 3. After triggering the spin, the client attempts to purchase a SpinResult in exchange for 1 Spin Ticket - 4. After receiving the client's request, PlayFab will: + | --- | --- | --- | + | Code | ST | Abbreviation for our VC | + | Name | Spin Ticket | Name of our VC | + | Initial Deposit | 1 | ensure that the player can spin on their first login | + | Recharge Rate | 1 | this sets the VC to regenerate 1 unit per day | + | Recharge Max | 5 | this caps the regeneration to the specified number, this is useful for allowing players to bank up to 5 spin tickets at a time | + +1. Next, under the Catalog tab, choose Upload JSON and upload [this file](PlayFab-JSON/Catalog.json) + +> If using your own, ensure that you have items that can be granted to a player. + +### Mechanic Walkthrough + +1. Client obtains a valid session ticket via one of the various authentication pathways (required to make Client API Calls) +1. After logging-in the client needs a mechanism to trigger a spin +1. After triggering the spin, the client attempts to purchase a SpinResult in exchange for 1 Spin Ticket +1. After receiving the client's request, PlayFab will: * Deduct a Spin Ticket from the Player's VC balance - * Award the bundle / container to the player's inventory + * Award the bundle / container to the player's inventory * Send a response with the updated information back to the client - 5. Upon receiving the response, the client can display the award to the player. +1. Upon receiving the response, the client can display the award to the player. ---- -#### Unity 3d Example Setup Instructions: +### Unity 3d Example Setup Instructions + Import the following asset packages into a new or existing Unity project: - * Ensure you have the latest SDK [here](https://github.com/PlayFab/UnitySDK/raw/versioned/Packages/UnitySDK.unitypackage). - * Ensure you have the recipe files [here](https://github.com/PlayFab/PlayFab-Samples/raw/master/Recipes/PrizeWheel/Example-Unity3d/PrizeWheelRecipe.unitypackage) +* Ensure you have the latest SDK [here](https://github.com/PlayFab/UnitySDK/raw/versioned/Packages/UnitySDK.unitypackage). +* Ensure you have the recipe files [here](https://github.com/PlayFab/PlayFab-Samples/raw/master/Recipes/PrizeWheel/Example-Unity3d/PrizeWheelRecipe.unitypackage) - 1. Add assets to your project. - 2. Open the PrizeWheel scene. - 3. Add your title ID to the PrizeWheel.cs script via the Unity Inspector. - 4. Run the scene and observe the console for call-by-call status updates. +1. Add assets to your project. +1. Open the PrizeWheel scene. +1. Add your title ID to the PrizeWheel.cs script via the Unity Inspector. +1. Run the scene and observe the console for call-by-call status updates. ---- -#### JavaScript Example Setup Instructions: - 1. Copy [this folder](/Recipes/SimpleCrossPromotion/Example-JavaScript) to your web server. - 2. Navigate to index.html - 3. Enter in your title ID +### JavaScript Example Setup Instructions + +1. Copy [this folder](/Recipes/SimpleCrossPromotion/Example-JavaScript) to your web server. +1. Navigate to index.html +1. Enter in your title ID * This example automatically generates a GUID on login; however, You may choose any id you like. * After logging in whatever id was used will be saved into your browser's localstorage - 4. Observe your browser's developer console for call-by-call status updates. +1. Observe your browser's developer console for call-by-call status updates. From 9a7dacfe886214cb5109c926698a75c73618d81f Mon Sep 17 00:00:00 2001 From: Daniel Heinze Date: Mon, 17 May 2021 19:10:30 +0200 Subject: [PATCH 2/3] docs: changed price to 0 and adapted Readme --- Recipes/PrizeWheel/Example-JavaScipt/code.js | 6 ++--- Recipes/PrizeWheel/PlayFab-JSON/Catalog.json | 2 +- Recipes/PrizeWheel/README.md | 23 ++++++++++---------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Recipes/PrizeWheel/Example-JavaScipt/code.js b/Recipes/PrizeWheel/Example-JavaScipt/code.js index 9d7e1597..8cf9a06b 100644 --- a/Recipes/PrizeWheel/Example-JavaScipt/code.js +++ b/Recipes/PrizeWheel/Example-JavaScipt/code.js @@ -127,9 +127,9 @@ function TryToSpin() { console.log("Attempting to spin..."); var PurchaseItemRequest = { - "ItemId" : "PrizeWheel1", - "VirtualCurrency" : "ST", - "Price" : 1 + "ItemId": "PrizeWheel1", + "VirtualCurrency": "ST", + "Price": 0 }; PlayFabClientSDK.PurchaseItem(PurchaseItemRequest, TryToSpinCallback); } diff --git a/Recipes/PrizeWheel/PlayFab-JSON/Catalog.json b/Recipes/PrizeWheel/PlayFab-JSON/Catalog.json index 32507bbf..81da64f5 100644 --- a/Recipes/PrizeWheel/PlayFab-JSON/Catalog.json +++ b/Recipes/PrizeWheel/PlayFab-JSON/Catalog.json @@ -114,7 +114,7 @@ "DisplayName": "Prize Wheel No. 1", "Description": "Press your luck at the prize wheel. Every spin is a winner. 1-in-100 win a free spin!", "VirtualCurrencyPrices": { - "ST": 1 + "ST": 0 }, "RealCurrencyPrices": null, "Tags": null, diff --git a/Recipes/PrizeWheel/README.md b/Recipes/PrizeWheel/README.md index c3eda9bb..a9c5349c 100644 --- a/Recipes/PrizeWheel/README.md +++ b/Recipes/PrizeWheel/README.md @@ -43,6 +43,18 @@ This technique ensures that players can only 'spin' at most one time per 24 hour ---- +### JavaScript Example Setup Instructions + +1. Copy [this folder](/Recipes/SimpleCrossPromotion/Example-JavaScript) to your web server. +1. Navigate to index.html +1. Enter in your title ID (the id of your PlayFab studio, e.g. 8AB4D) + * This example automatically generates a GUID for *User Id* on login; however, You may choose any id you like. + * After logging in whatever id was used will be saved into your browser's localstorage + * Please observe your browsers console for return messages + * For debugging, we recommend a price of 0 for your PriceWheel1 bundle. You have to set this in the Economy -> Catalogs -> Bundles -> PriceWheel1 under Prices + * Additionally, you need to adjust the price in the code.js file, under *PurchaseItemRequest* to 0 +1. Observe your browser's developer console for call-by-call status updates. + ### Unity 3d Example Setup Instructions Import the following asset packages into a new or existing Unity project: @@ -54,14 +66,3 @@ Import the following asset packages into a new or existing Unity project: 1. Open the PrizeWheel scene. 1. Add your title ID to the PrizeWheel.cs script via the Unity Inspector. 1. Run the scene and observe the console for call-by-call status updates. - ----- - -### JavaScript Example Setup Instructions - -1. Copy [this folder](/Recipes/SimpleCrossPromotion/Example-JavaScript) to your web server. -1. Navigate to index.html -1. Enter in your title ID - * This example automatically generates a GUID on login; however, You may choose any id you like. - * After logging in whatever id was used will be saved into your browser's localstorage -1. Observe your browser's developer console for call-by-call status updates. From 4708406ec50017ee2e92c7593c8051aecbe84256 Mon Sep 17 00:00:00 2001 From: Daniel Heinze Date: Mon, 17 May 2021 19:29:29 +0200 Subject: [PATCH 3/3] docs: added recharge rate options --- Recipes/PrizeWheel/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Recipes/PrizeWheel/README.md b/Recipes/PrizeWheel/README.md index a9c5349c..e1fdffb1 100644 --- a/Recipes/PrizeWheel/README.md +++ b/Recipes/PrizeWheel/README.md @@ -23,7 +23,7 @@ This technique ensures that players can only 'spin' at most one time per 24 hour | Code | ST | Abbreviation for our VC | | Name | Spin Ticket | Name of our VC | | Initial Deposit | 1 | ensure that the player can spin on their first login | - | Recharge Rate | 1 | this sets the VC to regenerate 1 unit per day | + | Recharge Rate | 1 | this sets the VC to regenerate 1 unit per day. You can set to 1440 to a recharge per minute or 86400 for a recharge per second. | | Recharge Max | 5 | this caps the regeneration to the specified number, this is useful for allowing players to bank up to 5 spin tickets at a time | 1. Next, under the Catalog tab, choose Upload JSON and upload [this file](PlayFab-JSON/Catalog.json)