Add player names and account deletion
This commit is contained in:
1 parent
32594c7f81
commit
1b5b8dc0a4
10 files changed
+299
-11
No files matched your search
+31
-1
@@ -129,7 +129,7 @@ func submit_run(record: Dictionary) -> bool:
|
||||
if not is_authenticated():
|
||||
return false
|
||||
var payload := record.duplicate(true)
|
||||
payload["client_version"] = "0.21"
|
||||
payload["client_version"] = "0.22"
|
||||
var result = await client.rpc_async(session, "submit_run", JSON.stringify(payload))
|
||||
var parsed := _parse_rpc_result(result)
|
||||
if parsed.is_empty() or not bool(parsed.get("accepted", false)):
|
||||
@@ -149,6 +149,36 @@ func flush_pending_scores() -> void:
|
||||
await submit_run(record)
|
||||
|
||||
|
||||
func update_display_name(value: String) -> Dictionary:
|
||||
if not account_manager:
|
||||
return {"accepted": false, "error": "Lokales Profil fehlt."}
|
||||
var validation_error := account_manager.validate_display_name(value)
|
||||
if not validation_error.is_empty():
|
||||
return {"accepted": false, "error": validation_error}
|
||||
var normalized := account_manager.normalize_display_name(value)
|
||||
if is_authenticated():
|
||||
var result = await client.rpc_async(session, "update_display_name", JSON.stringify({"display_name": normalized}))
|
||||
var parsed := _parse_rpc_result(result)
|
||||
if parsed.is_empty() or not bool(parsed.get("accepted", false)):
|
||||
return {"accepted": false, "error": str(parsed.get("error", "Der Name konnte online nicht gespeichert werden."))}
|
||||
normalized = str(parsed.get("display_name", normalized))
|
||||
account_manager.set_display_name(normalized)
|
||||
return {"accepted": true, "display_name": normalized, "online": is_authenticated()}
|
||||
|
||||
|
||||
func delete_online_account() -> Dictionary:
|
||||
if not is_authenticated():
|
||||
return {"accepted": false, "error": "Für die Kontolöschung ist eine Serververbindung erforderlich."}
|
||||
var result = await client.rpc_async(session, "delete_account", "{}")
|
||||
var parsed := _parse_rpc_result(result)
|
||||
if parsed.is_empty() or not bool(parsed.get("accepted", false)):
|
||||
return {"accepted": false, "error": str(parsed.get("error", "Das Online-Konto konnte nicht gelöscht werden."))}
|
||||
disconnect_from_server()
|
||||
if account_manager:
|
||||
account_manager.reset_after_account_deletion()
|
||||
return {"accepted": true}
|
||||
|
||||
|
||||
func load_leaderboard(map_index: int, difficulty_index: int, endless: bool, limit := 20) -> Array:
|
||||
if not is_authenticated():
|
||||
return []
|
||||
|
||||
Reference in new issue
Block a user