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
@@ -4,6 +4,9 @@ extends Node
|
||||
signal profile_changed
|
||||
|
||||
const ACCOUNT_PATH := "user://void_bastion_account.json"
|
||||
const MIN_DISPLAY_NAME_LENGTH := 3
|
||||
const MAX_DISPLAY_NAME_LENGTH := 20
|
||||
const RESERVED_DISPLAY_NAMES := ["ADMIN", "ADMINISTRATOR", "GERGAMES", "MODERATOR", "SUPPORT", "SYSTEM"]
|
||||
|
||||
var player_id := ""
|
||||
var display_name := ""
|
||||
@@ -100,6 +103,42 @@ func attach_online_identity(online_user_id: String, online_username: String) ->
|
||||
profile_changed.emit()
|
||||
|
||||
|
||||
func normalize_display_name(value: String) -> String:
|
||||
var normalized := " ".join(value.strip_edges().split(" ", false))
|
||||
return normalized.left(MAX_DISPLAY_NAME_LENGTH)
|
||||
|
||||
|
||||
func validate_display_name(value: String) -> String:
|
||||
var normalized := normalize_display_name(value)
|
||||
if normalized.length() < MIN_DISPLAY_NAME_LENGTH:
|
||||
return "Der Spielername muss mindestens %d Zeichen lang sein." % MIN_DISPLAY_NAME_LENGTH
|
||||
if normalized.length() > MAX_DISPLAY_NAME_LENGTH:
|
||||
return "Der Spielername darf höchstens %d Zeichen lang sein." % MAX_DISPLAY_NAME_LENGTH
|
||||
if normalized.to_upper() in RESERVED_DISPLAY_NAMES:
|
||||
return "Dieser Spielername ist reserviert."
|
||||
var allowed_characters := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 _-ÄÖÜäöüß"
|
||||
for character in normalized:
|
||||
if not allowed_characters.contains(character):
|
||||
return "Erlaubt sind Buchstaben, Zahlen, Leerzeichen, _ und -."
|
||||
return ""
|
||||
|
||||
|
||||
func set_display_name(value: String) -> bool:
|
||||
var normalized := normalize_display_name(value)
|
||||
if not validate_display_name(normalized).is_empty():
|
||||
return false
|
||||
display_name = normalized
|
||||
_save_profile()
|
||||
profile_changed.emit()
|
||||
return true
|
||||
|
||||
|
||||
func reset_after_account_deletion() -> void:
|
||||
_create_guest_profile()
|
||||
_save_profile()
|
||||
profile_changed.emit()
|
||||
|
||||
|
||||
func mark_submission_complete(record: Dictionary) -> void:
|
||||
for index in range(pending_submissions.size() - 1, -1, -1):
|
||||
var queued = pending_submissions[index]
|
||||
|
||||
Reference in new issue
Block a user