chests are saved to playlist
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user