extends Node

var Weapons = {
	"knife" = {
		"number": 0,
		"magazine": -1,
		"ammo": -1
	},
	"pistol" = {
		"number": 1,
		"magazine": 50,
		"ammo": 200
	},
	"ak-47" = {
		"number": 2,
		"magazine": 30,
		"ammo": 100
	}
}

var client_settings
var server_settings

func read_settings():
	var user_dir = DirAccess.open(".")
	if(!user_dir.dir_exists("./settings")):
		user_dir.make_dir("settings")
	var client_settings_file
	
	if(!FileAccess.file_exists("./settings/client-settings.json")):
		print("Client-settings doesn't exist, creating one")
		var example = FileAccess.open("res://settings/client-settings.json", FileAccess.READ)
		client_settings_file = FileAccess.open("./settings/client-settings.json", FileAccess.WRITE_READ)
		client_settings_file.store_string(example.get_as_text())
	else:
		client_settings_file = FileAccess.open("./settings/client-settings.json", FileAccess.READ)
	client_settings = JSON.parse_string(client_settings_file.get_as_text())
	
	
	var server_settings_file
	if(!FileAccess.file_exists("./settings/server-settings.json")):
		print("Server-settings doesn't exist, creating one")
		var example = FileAccess.open("res://settings/server-settings.json", FileAccess.READ)
		server_settings_file = FileAccess.open("./settings/server-settings.json", FileAccess.WRITE_READ)
		server_settings_file.store_string(example.get_as_text())
	else:
		server_settings_file = FileAccess.open("./settings/server-settings.json", FileAccess.READ)
	server_settings = JSON.parse_string(server_settings_file.get_as_text())
	
func save_client_settings():
	var client_settings_file = FileAccess.open("./settings/client-settings.json", FileAccess.WRITE)
	client_settings_file.store_string(str(client_settings))
