added firebase and rudimentary leaderboard support

This commit is contained in:
derek
2025-04-09 11:19:02 -05:00
parent ce08df66e6
commit 25eb9e725a
121 changed files with 4987 additions and 4 deletions

27
scripts/leaderboard.gd Normal file
View File

@@ -0,0 +1,27 @@
extends Node
var COLLECTION_ID = "leaderboard"
func save_leaderboard_data():
var auth = Firebase.Auth.auth
if auth.localid:
var collection: FirestoreCollection = Firebase.Firestore.collection(COLLECTION_ID)
var data : Dictionary = {
"user_name" : GameGlobals.user_names[GameGlobals.user_id],
"leaderboard" : GameGlobals.current_leaderboard_name,
"high_score" : GameGlobals.high_score,
"money" : GameGlobals.money,
"deposited_money" : GameGlobals.deposited_money
}
var task = await collection.get_doc(auth.localid)
if task:
await collection.update(FirestoreDocument.new(data))
else:
await collection.add(auth.localid,data)
func load_leaderboard_data():
var auth = Firebase.Auth.auth
if auth.localid:
var collection: FirestoreCollection = Firebase.Firestore.collection(COLLECTION_ID)
var task = await collection.get_doc(auth.localid)
var result = task.get_value("high_score")