can now add and store leaderboards. started work on playlist loading

This commit is contained in:
derek
2025-02-28 11:58:10 -06:00
parent 096b505cfa
commit 3356f9e191
15 changed files with 143 additions and 45 deletions

View File

@@ -7,7 +7,8 @@ extends Node
@export var maps_in_rotation : Array[String] = []
@export var gamemodes_in_rotation : Array[gamemode]= []
@export var levels_per_round : int = 5
@export var rounds : int = 3
@export var rounds_per_match : int = 3
@export var matches_per_year : int = 52
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@@ -27,17 +28,19 @@ func generate_playlist() -> void:
var playlist_name = only_valid_chars(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id])
var playlist = []
print("PLAYLIST CREATED FOR THE : ",playlist_name)
for i in rounds:
var round = []
for x in levels_per_round:
var level_details = {
"map" : maps_in_rotation.pick_random(),
"gamemode" : gamemodes_in_rotation.pick_random()
}
round.append(level_details)
playlist.append(round)
print("PLAYLIST : ", playlist[0][0])
for h in matches_per_year:
var matches = []
for i in rounds_per_match:
var round = []
for x in levels_per_round:
var level_details = {
"map" : maps_in_rotation.pick_random(),
"gamemode" : gamemodes_in_rotation.pick_random()
}
round.append(level_details)
matches.append(round)
playlist.append(matches)
print("PLAYLIST : ", playlist)
save_playlist(playlist)
generate_playlist_now = false
@@ -63,13 +66,14 @@ func save_playlist(playlist):
file.close()
func load_playlist():
var playlist_path : String = "user://" + str(only_valid_chars(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id])) + "_playlist.save"
var playlist_path : String = "user://" + str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]) + "_playlist.save"
if FileAccess.file_exists(playlist_path):
var file = FileAccess.open(playlist_path, FileAccess.READ)
var key = file.get_var()
var playlist = file.get_var()
print("KEY : ",key)
GameGlobals.playlist_test = playlist
GameGlobals.current_match = playlist[0]
file.close()
print("PLAYLIST: ")
print("------------------------------------------------------------------------------------")