Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mizunagikb/playfab_gdscriptsdk

PlayFabSDK for GDScriptSdk
https://github.com/mizunagikb/playfab_gdscriptsdk

gdscript godot godotengine playfab

Last synced: 4 days ago
JSON representation

PlayFabSDK for GDScriptSdk

Awesome Lists containing this project

README

        

= PlayFab_GDScriptSdk README
:lang: ja
:description: PlayFabSDK for GDScript
:url-repo: https://github.com/MizunagiKB/PlayFab_GDScriptSdk
:doctype: book
:author: [email protected]
:toc: left
:toclevels: 3
:icons: font
:imagesdir: res/image
:experimental:
:stem:

== About
This program is an *unofficial* implementation for using https://www.playfab.com[Microsoft PlayFab] from the GDScript(https://godotengine.org/[Godot Engine]).

CAUTION: Currently, only Godot 3.5 or higher is supported. +
Godot 4 is not supported.

This program can be used as-is by incorporating it into a Godot project.

This program is automatically generated based on the https://github.com/PlayFab/API_Specs[API_Specs] published by PlayFab.

If you want to customize the generated content, you can use the following to generate it on your own.

* https://nodejs.org/en/[Node.js]
* https://github.com/PlayFab/SDKGenerator[SDKGenerator]
* https://github.com/MizunagiKB/PlayFab_GDScriptTemplate[PlayFab_GDScriptTemplate]

NOTE: See the https://github.com/MizunagiKB/PlayFab_GDScriptTemplate/blob/main/README.md[README.md] at https://github.com/MizunagiKB/PlayFab_GDScriptTemplate[PlayFab_GDScriptTemplate] for easy generation instructions.

## Build

[source,bash]
----
cd ./work
conda create -n pyenv310_gdscript_sdk python=3.10
conda activate pyenv310_gdscript_sdk
pip install -r requirements.txt
scons
----

## Usage

1. Copy PlayFabSDK folder to GodotEngine project folder.
2. Added res://PlayFabSDK/PlayFab.gd to AutoLoad under the name PlayFab.
3. Added res://PlayFabSDK/PlayFabSettings.gd to AutoLoad under the name PlayFabSettings.
4. Create testTitleData.json to GodotEngine project folder.

[CAUTION]
====
- The testTitleData.json is intended for testing purposes.
- The `developerSecretKey` is intended for use by the server. Please ensure that it is not included in programs intended for clients.
====

[source,javascript]
----
{
"TitleId": "*****",
"developerSecretKey": "********",
"userEmail": "****@****.***"
}
----

Or, it can be embedded directly in the program as follows.

[source,gdscript]
----
PlayFabSettings.TitleId = "00000"
PlayFabSettings.DeveloperSecretKey = "XXXXXXXX"
----

### API Call

The API is called by _PlayFab_ . _{{category}}_ . _{{API name}}_.

To call the RegisterPlayFabUser function, write as follows.

[source,gdscript]
----
PlayFab.Client.RegisterPlayFabUser(...)
----

The parameters required to call the API are specified in the _Dictionary_.

[source,gdscript]
----
var dict_request = {
"TitleId": "00000",
"Username": "USERNAME",
"Password": "********"
}

PlayFab.Client.LoginWithPlayFab(dict_request)
----

If you do not want to deal directly with Dictionary, you can use the data model.

[source,gdscript]
----
var o_request := PlayFab.ClientDataModels.PFLoginWithPlayFabRequest.new()
o_request.TitleId = "00000"
o_request.Username = "USERNAME"
o_request.Password = "********"

PlayFab.Client.LoginWithPlayFab(o_request.get_dict())
----

### Result

Use funcref to get the results.

[source,gdscript]
----
# callback function
func _request_completed(
h_request: int,
response_code: int,
headers,
json_parse_result: JSONParseResult
):
if json_parse_result.error == OK:
# DataModel can also be used.
if json_parse_result.result.code == 200:
var res := PlayFab.ClientDataModels.PFLoginResult.new(json_parse_result.result.data)
else:
var res := PlayFab.ErrorDataModels.PFApiErrorWrapper.new(json_parse_result.result)

# on function call
func _on_btn_login_pressed():

var o_request := PlayFab.ClientDataModels.PFLoginWithPlayFabRequest.new()
o_request.TitleId = "00000"
o_request.Username = "USERNAME"
o_request.Password = "********"

PlayFab.Client.RegisterPlayFabUser(
o_request.get_dict(),
funcref(self, "_request_completed")
)
----

### Useful functions

PlayFab.is_valid()::
Check to see if you can call PlayFab from GDScript.
PlayFab.reset()::
Resets the current state and returns it to its initial state.
(Any information or requests in communication will be discarded.)
PlayFab.get_status()::
Returns the current communication status. HTTPClient.get_status information can be obtained from the data.
PlayFab.status_ntoa()::
get_status the information into readable information.
PlayFab.request_queue_size()::
Returns the number of waiting requests.

### Operating Specifications

DataModel has not been fully tested.::
The DateTime type is treated as a string.::
Be careful when handling DateTime as there is no correct DateTime to handle as JSON.
Names are different in some places to prevent reserved words from colliding.::
* The property named OS is renamed OperatingSystem.
* All data model names are prefixed with PF. +
ex) _GetFileMetadata_ to _PFGetFileMetadata_
API calls are serialized.::
API calls are made in the order in which they are registered and are not processed in parallel.
Multiple accounts cannot be used at the same time.::
Only one person can log in within a single program. This is because only one EntityToken or ClientSessionTicket is stored in PlayFabSettings.gd.

## PlayFab API Reference

See below for specific uses of the API.

https://docs.microsoft.com/en-us/gaming/playfab/api-references/