chests are saved to playlist

This commit is contained in:
derek
2025-03-27 17:03:08 -05:00
parent 91f58c4dfc
commit 97bb2c9852
8 changed files with 45 additions and 56 deletions

View File

@@ -93,7 +93,7 @@ func _ready():
var chest_loc = chest_spawners.pick_random()
var instance_chest = CHEST_1.instantiate()
print("SPAWNING CHEST AT : ",chest_loc.name)
get_tree().current_scene.add_child(instance_chest)
add_child(instance_chest)
instance_chest.basis = chest_loc.basis
instance_chest.global_position = chest_loc.global_position
instance_chest.global_rotation = chest_loc.global_rotation

View File

@@ -1,26 +1,27 @@
@tool
extends Node
@export_tool_button("Generate Playlist")
var playlist_action : Callable = func(): generate_test_playlist()
@export var checksum_test = false
@export var load_playlist_from_file = false
@export var hub_world : level_resource
@export var maps_in_rotation : Array[level_resource] = []
@export var gamemodes_in_rotation : Array[gamemode]= []
@export var chest_drops : Array[Resource]
@export var levels_per_round : int = 5
@export var rounds_per_match : int = 3
@export var chests_per_match : int = 100
@export var matches_per_year : int = 52
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)
set_seed(playlist_name)
for h in matches_per_year:
var matches = []
var chests = []
var round = []
for i in rounds_per_match:
var round = []
for x in levels_per_round:
var gamemode_path = gamemodes_in_rotation.pick_random().resource_path
var level_selection = maps_in_rotation.pick_random()
@@ -30,40 +31,26 @@ func generate_playlist() -> void:
"gamemode_path" : gamemode_path
}
round.append(level_details)
matches.append(round)
playlist.append(matches)
save_playlist(playlist)
func generate_test_playlist():
var playlist_name = "TEST2"
var playlist = []
var seed_to_use
if playlist_name:
seed_to_use = hash(playlist_name)
else:
seed_to_use = randi()
seed(seed_to_use)
var chest_serial_no : int = 1
for y in chests_per_match:
var drop = chest_drops.pick_random()
var chest_details = {
"serial" : chest_serial_no,
"drop" : drop
}
chests.append(chest_details)
chest_serial_no += 1
var match_details = {"round" : round,"chests" : chests}
matches.append(match_details)
for h in matches_per_year:
var matches = []
for i in rounds_per_match:
var round = []
for x in levels_per_round:
var gamemode_path = gamemodes_in_rotation.pick_random().resource_path
var level_selection = maps_in_rotation.pick_random()
var level_details = {
"level_path" : level_selection.level_path,
"level_name" : level_selection.level_name,
"gamemode_path" : gamemode_path
}
round.append(level_details)
matches.append(round)
playlist.append(matches)
print(playlist[0][0]["round"][0])
print(playlist[0][0]["chests"][3])
GameGlobals.playlist = playlist
func only_valid_chars(input_string: String) -> String:
@@ -86,20 +73,19 @@ func save_playlist(playlist):
file.close()
func load_playlist():
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()
else:
print("no data saved, generating new playlist...")
generate_playlist()
generate_playlist()
GameGlobals.current_match = GameGlobals.playlist[0]
func set_seed(playlist_name):
var seed_to_use
if playlist_name:
seed_to_use = hash(playlist_name)
else:
seed_to_use = randi()
seed(seed_to_use)
func _on_gui_input(event: InputEvent) -> void:
generate_playlist()

View File

@@ -91,7 +91,6 @@ func check_user_data_exists():
return false
func load_user_data():
print("ALL LEADERBOARDS: ",GameGlobals.all_user_leaderboards[0][0])
var user_save_path = str("user://user_",str(GameGlobals.user_id),"_",str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]),"_data.save")
if FileAccess.file_exists(user_save_path):
var file = FileAccess.open(user_save_path, FileAccess.READ)
@@ -127,10 +126,7 @@ func load_user_data():
get_tree().current_scene.gun_spawn(GameGlobals.current_gun_index)
var checksum = file.get_var()
print("Checksum : ",checksum)
var check_data = [user_save_path,file_leaderboard_name,money,deposited_money,health,high_score,player_deaths,shots_fired]
print("CHECK DATA : ",check_data)
print("CHECKSUM CALC : ",HelperFuncs.checksum(check_data))
file.close()
await !file.is_open()
if checksum == HelperFuncs.checksum(check_data):