Added item resource
This commit is contained in:
parent
a46e5eb53a
commit
679a3187f7
3 changed files with 50 additions and 22 deletions
|
|
@ -2,33 +2,35 @@ extends Node
|
|||
|
||||
class_name Game
|
||||
|
||||
enum ITEM_TYPE {VALUABLE, WEAPON, MODULE}
|
||||
|
||||
static var gameversion = "Ictar 1.1"
|
||||
|
||||
static func profile_create(profile_name):
|
||||
var path = "user://"+profile_name+".cosmic"
|
||||
if not FileAccess.file_exists(path):
|
||||
var profile_meta = {
|
||||
'hash' : {},
|
||||
'meta' : {
|
||||
'created_in_version' : gameversion,
|
||||
'creation_date' : Time.get_datetime_string_from_system(),
|
||||
'last_version' : gameversion,
|
||||
'last_updated' : Time.get_datetime_string_from_system(),
|
||||
'profile_name' : profile_name,
|
||||
'legit' : true
|
||||
}
|
||||
}
|
||||
var profile_meta_keys = profile_meta['meta'].keys()
|
||||
for i in range(len(profile_meta_keys)):
|
||||
if profile_meta_keys[i][0] == "_":
|
||||
profile_meta_keys.remove_at(i)
|
||||
for i in range(len(profile_meta_keys)):
|
||||
profile_meta['hash'][i] = str(profile_meta['meta'][profile_meta_keys[i]]).sha256_buffer().hex_encode()
|
||||
var file = FileAccess.open(path, FileAccess.WRITE)
|
||||
var json_string = JSON.stringify(profile_meta, "\t")
|
||||
file.store_string(json_string)
|
||||
else:
|
||||
if FileAccess.file_exists(path):
|
||||
profile_save(profile_name, "menu")
|
||||
return
|
||||
var profile_meta = {
|
||||
'hash' : {},
|
||||
'meta' : {
|
||||
'created_in_version' : gameversion,
|
||||
'creation_date' : Time.get_datetime_string_from_system(),
|
||||
'last_version' : gameversion,
|
||||
'last_updated' : Time.get_datetime_string_from_system(),
|
||||
'profile_name' : profile_name,
|
||||
'legit' : true
|
||||
}
|
||||
}
|
||||
var profile_meta_keys = profile_meta['meta'].keys()
|
||||
for i in range(len(profile_meta_keys)):
|
||||
if profile_meta_keys[i][0] == "_":
|
||||
profile_meta_keys.remove_at(i)
|
||||
for i in range(len(profile_meta_keys)):
|
||||
profile_meta['hash'][i] = str(profile_meta['meta'][profile_meta_keys[i]]).sha256_buffer().hex_encode()
|
||||
var file = FileAccess.open(path, FileAccess.WRITE)
|
||||
var json_string = JSON.stringify(profile_meta, "\t")
|
||||
file.store_string(json_string)
|
||||
|
||||
static func profile_save(profile_name, _gamestate):
|
||||
var path = "user://"+profile_name+".cosmic"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue