Save/Load rework
This commit is contained in:
@@ -24,7 +24,10 @@ var symptoms_arrays: Array[Array] = [
|
||||
["VISUAL HALLUCINATIONS", "HETERO-AGRESSIVE BEHAVIOUR"]
|
||||
]
|
||||
#Lists of possible patients sorted by floor
|
||||
var patient_list : Array[Dictionary]
|
||||
var og_patient_list : Array[Dictionary]
|
||||
var patient_list: Array[Dictionary]
|
||||
var og_its_patient_list = ["its_01"]
|
||||
var its_patient_list = []
|
||||
|
||||
#Supervisor file path
|
||||
var supervisor_name = "loeveth"
|
||||
@@ -36,8 +39,10 @@ func _ready() -> void:
|
||||
marker.resize(100)
|
||||
marker.fill(0)
|
||||
|
||||
#Setting up patient list
|
||||
#Setting up patient lists
|
||||
og_patient_list.resize(len(symptoms_arrays))
|
||||
patient_list.resize(len(symptoms_arrays))
|
||||
its_patient_list = og_its_patient_list
|
||||
|
||||
original_color = texture.modulate #Saving original modulation color to reset it after modification
|
||||
|
||||
@@ -58,6 +63,11 @@ func new_patient(patient_id):
|
||||
|
||||
var file_path: String
|
||||
|
||||
#Updating Global variables
|
||||
Globals.patient_id = patient_id
|
||||
Globals.patients_seen.append(patient_id)
|
||||
print("Patients seen list: " + str(Globals.patients_seen))
|
||||
|
||||
#Loading Patient Files
|
||||
var config := ConfigFile.new()
|
||||
file_path = "res://Dialogues/Patients/patient_" + patient_id + "_file.cfg"
|
||||
@@ -151,11 +161,12 @@ func sort_patients():
|
||||
break
|
||||
if symptom_matched:
|
||||
for k in range(j, symptoms_arrays.size()):
|
||||
patient_list[k].merge({patient_id: j+1}) # Adds the patient to every floor compatible
|
||||
og_patient_list[k].merge({patient_id: j+1}) # Adds the patient to every floor compatible
|
||||
symptom_matched = false
|
||||
break
|
||||
|
||||
for i in range(len(patient_list)):
|
||||
patient_list[i] = og_patient_list[i]
|
||||
print("Floor " + str(i) + " possible patients: " + str(patient_list[i]))
|
||||
|
||||
|
||||
@@ -186,16 +197,30 @@ func generate_patient_id() -> String: #Generates a patient ID
|
||||
var floor_index = -Globals.floor_count -1
|
||||
print("Floor Index: " + str(floor_index))
|
||||
var patient_id = weighted_random(patient_list[floor_index]) #Picks a random patient depending on floor, with weighted odds
|
||||
|
||||
for j in range(len(patient_list)):
|
||||
if len(patient_list[j]) > 1:
|
||||
patient_list[j].erase(patient_id) #Removes picked patient from unseen patients list
|
||||
print("Updated Floor " + str(j) + " list: " + str(patient_list[j]))
|
||||
|
||||
#Removes picked patient from patients list
|
||||
for i in range(len(patient_list)):
|
||||
if len(patient_list[i]) > 1:
|
||||
patient_list[i].erase(patient_id)
|
||||
print("Updated Floor " + str(i) + " list: " + str(patient_list[i]))
|
||||
|
||||
|
||||
return patient_id
|
||||
|
||||
|
||||
func generate_its_patient_id() -> String: #Generates an ITS patient ID
|
||||
|
||||
#Generating ITS patient ID
|
||||
var its_patient_id = its_patient_list.pick_random()
|
||||
print("ITS Patient selected: " + str(its_patient_id))
|
||||
#Remove picked ITS patient from ITS patient list
|
||||
if len(its_patient_list) > 1:
|
||||
its_patient_list.erase(its_patient_id)
|
||||
print("Updated ITS Patient list: " + str(its_patient_list))
|
||||
|
||||
return its_patient_id
|
||||
|
||||
|
||||
func next_patient() -> String: #Decides next patient ID
|
||||
|
||||
var next_patient_id: String
|
||||
@@ -204,6 +229,8 @@ func next_patient() -> String: #Decides next patient ID
|
||||
-2:
|
||||
if Globals.patient_count == 0:
|
||||
next_patient_id = "its_00"
|
||||
elif Globals.its_patient_count < 1:
|
||||
next_patient_id = generate_its_patient_id()
|
||||
else:
|
||||
next_patient_id = generate_patient_id()
|
||||
_:
|
||||
@@ -211,4 +238,21 @@ func next_patient() -> String: #Decides next patient ID
|
||||
|
||||
|
||||
return next_patient_id
|
||||
|
||||
|
||||
func update_patient_list():
|
||||
|
||||
#Erasing patients already seen from patient lists
|
||||
for patient_id in Globals.patients_seen:
|
||||
for i in range(len(patient_list)):
|
||||
if len(patient_list[i]) > 1:
|
||||
patient_list[i].erase(patient_id)
|
||||
|
||||
#Erasing its patients already seen from its patient list
|
||||
for its_patient_id in Globals.its_patients_seen:
|
||||
if len(its_patient_list) > 1:
|
||||
its_patient_list.erase(its_patient_id)
|
||||
|
||||
for j in range(len(patient_list)):
|
||||
print("Loaded Floor " + str(j) + " list: " + str(patient_list[j]))
|
||||
print("Loaded ITS Patient list: " + str(its_patient_list))
|
||||
|
||||
Reference in New Issue
Block a user