Track real player sessions and tower builds
This commit is contained in:
1 parent
8777f28595
commit
1294000348
8 files changed
+213
-8
No files matched your search
@@ -14,6 +14,8 @@ var primary_provider := "guest"
|
||||
var linked_identities: Array = []
|
||||
var highscores: Dictionary = {}
|
||||
var pending_submissions: Array = []
|
||||
var pending_player_events: Array = []
|
||||
var next_player_event_sequence := 0
|
||||
var created_at := 0
|
||||
var storage_enabled := true
|
||||
|
||||
@@ -34,6 +36,8 @@ func _load_or_create_profile() -> void:
|
||||
linked_identities = data.get("linked_identities", [])
|
||||
highscores = data.get("highscores", {})
|
||||
pending_submissions = data.get("pending_submissions", [])
|
||||
pending_player_events = data.get("pending_player_events", [])
|
||||
next_player_event_sequence = int(data.get("next_player_event_sequence", 0))
|
||||
created_at = int(data.get("created_at", 0))
|
||||
if player_id.is_empty():
|
||||
_create_guest_profile()
|
||||
@@ -50,6 +54,8 @@ func _create_guest_profile() -> void:
|
||||
linked_identities = []
|
||||
highscores = {}
|
||||
pending_submissions = []
|
||||
pending_player_events = []
|
||||
next_player_event_sequence = 0
|
||||
created_at = int(Time.get_unix_time_from_system())
|
||||
|
||||
|
||||
@@ -66,6 +72,8 @@ func _save_profile() -> void:
|
||||
"linked_identities": linked_identities,
|
||||
"highscores": highscores,
|
||||
"pending_submissions": pending_submissions,
|
||||
"pending_player_events": pending_player_events,
|
||||
"next_player_event_sequence": next_player_event_sequence,
|
||||
"created_at": created_at
|
||||
}))
|
||||
|
||||
@@ -91,6 +99,29 @@ func record_run(map_index: int, difficulty_index: int, endless: bool, reached_wa
|
||||
return true
|
||||
|
||||
|
||||
func queue_player_event(event_name: String, tower_type := -1) -> void:
|
||||
if event_name != "play_start" and event_name != "tower_build":
|
||||
return
|
||||
next_player_event_sequence += 1
|
||||
pending_player_events.append({
|
||||
"event": event_name,
|
||||
"tower_type": tower_type,
|
||||
"source": player_id,
|
||||
"sequence": next_player_event_sequence,
|
||||
"at": int(Time.get_unix_time_from_system() * 1000.0)
|
||||
})
|
||||
_save_profile()
|
||||
|
||||
|
||||
func mark_player_event_complete(sequence: int) -> void:
|
||||
for index in range(pending_player_events.size() - 1, -1, -1):
|
||||
var event = pending_player_events[index]
|
||||
if event is Dictionary and int(event.get("sequence", -1)) == sequence:
|
||||
pending_player_events.remove_at(index)
|
||||
_save_profile()
|
||||
return
|
||||
|
||||
|
||||
func attach_online_identity(online_user_id: String, online_username: String) -> void:
|
||||
if online_user_id.is_empty():
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user