Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs/update prizewheel docs #58

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Recipes/PrizeWheel/Example-JavaScipt/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
74 changes: 57 additions & 17 deletions Recipes/PrizeWheel/PlayFab-JSON/Catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,7 +21,10 @@
"CanBecomeCharacter": false,
"IsStackable": false,
"IsTradable": false,
"ItemImageUrl": null
"ItemImageUrl": null,
"IsLimitedEdition": false,
"InitialLimitedEditionCount": 0,
"ActivatedMembership": null
},
{
"ItemId": "Card2",
Expand All @@ -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,
Expand All @@ -43,7 +46,10 @@
"CanBecomeCharacter": false,
"IsStackable": false,
"IsTradable": false,
"ItemImageUrl": null
"ItemImageUrl": null,
"IsLimitedEdition": false,
"InitialLimitedEditionCount": 0,
"ActivatedMembership": null
},
{
"ItemId": "Card1",
Expand All @@ -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,
Expand All @@ -65,7 +71,10 @@
"CanBecomeCharacter": false,
"IsStackable": false,
"IsTradable": false,
"ItemImageUrl": null
"ItemImageUrl": null,
"IsLimitedEdition": false,
"InitialLimitedEditionCount": 0,
"ActivatedMembership": null
},
{
"ItemId": "SpinAgain",
Expand All @@ -75,7 +84,7 @@
"Description": "You just got one free Spin Ticket!",
"VirtualCurrencyPrices": null,
"RealCurrencyPrices": null,
"Tags": [],
"Tags": null,
"CustomData": "null",
"Consumable": {
"UsageCount": 1,
Expand All @@ -93,7 +102,10 @@
"CanBecomeCharacter": false,
"IsStackable": false,
"IsTradable": false,
"ItemImageUrl": null
"ItemImageUrl": null,
"IsLimitedEdition": false,
"InitialLimitedEditionCount": 0,
"ActivatedMembership": null
},
{
"ItemId": "PrizeWheel1",
Expand All @@ -102,10 +114,10 @@
"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": [],
"Tags": null,
"CustomData": "null",
"Consumable": {
"UsageCount": 1,
Expand All @@ -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
}
]
}
]
}
25 changes: 0 additions & 25 deletions Recipes/PrizeWheel/PlayFab-JSON/DropTable.json

This file was deleted.

102 changes: 54 additions & 48 deletions Recipes/PrizeWheel/README.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,68 @@
## 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)

* [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)

### 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)
### Preparation

###Preparation:
1. Under the **Economy > Currencies** section of the Game Manager add a Virtual Currency to match the following parameters:
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. 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)

> 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:
Import the following asset packages into a new or existing Unity project:
### JavaScript Example Setup Instructions

* 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. 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

#### 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
* 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.
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)

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.