Skip to main content

Source code and scenarios in Winter Starfall

This tutorial contains instructions for downloading and running the source code for Winter Starfall, and a walkthrough of the code samples demonstrating best practices for login and purchase scenarios.

Source code download

Prerequisites

  • Install Node JS
  • Install Visual Studio Code

Setup for local development

  1. Download the source code from GitHub.
  2. In VS Code, open the /website folder and opt to install all the extensions it recommends.
  3. In the /website directory, run npm install to install all dependencies.
  4. Use npm run dev to start the site. Select the link it offers to view the site.

Azure credentials

To update the AZURE_CREDENTIALS secrets, run this command in the Azure Portal shell: az ad sp create-for-rbac --name "VanguardOutrider2" --role contributor --scopes /subscriptions/YOUR_SUBSCRIPTION_ID/resourceGroups/YOUR_RESOURCE_GROUP_NAME --json-auth

Login flow

The player authentication flow in Winter Starfall has two steps: the login call and post-login functions that are used to get the player’s information from the service and load them into the correct location in the story.

Player authentication

For the login portion, the file use-login.ts defines a TypeScript wrapper function that handles the multiple authentication methods available to players. Lines 144-169 define the callback function for logging in with an email address, and call the post-login functions if login succeeds.
The game offers 3 recoverable methods for player authentication: email, Google, and Facebook, so that player accounts will never be lost. For more information, see Login best practices.

Post login: Getting player data

Once the security token has been retrieved, it is used to run the post login functions to get the saved game state. Lines 340-378 define postLoginFunctions, which calls various Economy and PlayFab Services APIs to load the correct story location, inventory items, currency, etc based on the player.
  • First ClientGetTitleData gets the secret key needed for all API calls
  • Then EconomySearchItems searches the catalog for currency and item types
  • Which is used as input to EconomyGetInventoryItems to return the player’s inventory items
  • Then ClientGetUserData retrieves the value that stores the story location as part of a player’s data.

Purchase flow

At certain points in the game, the player has the option to purchase and sell inventory items from the store. The purchase flow is implemented in another wrapper function. In the file use-store.ts, lines 40-69 bring up the correct store that the player encounters at a specific location and populates the items for sale by searching the catalog.
EconomyGetItem is defined in use-playfab.ts at lines 423-446, within which the PlayFab Economy API GetItems is used to search the catalog and return items.
When a purchase is conducted, a call to the PurchaseInventoryItems API is made. This is defined in use-playfab.ts at lines 540-565.

Selling items

The selling flow is an example of how to use Azure Functions driven CloudScript to extend the functionality of the Economy system. SellItem.cs defines the CloudScript function that executes when selling an item. Lines 49-61 are where PlayFab’s GetTitleData API is used to return the store multiplier and calculate the sale price.
The CloudScript function then gets called in lines 161-187 of use-store.ts.
To run Winter Starfall locally you’ll need an Azure account to support the CloudScript functions. You can sign up for a free Azure account and then follow the instructions above to reset the Azure credentials correctly.

See also

Last modified on August 7, 2026