Code reorganizing
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bcyf1r7eb45en"
|
||||
path="res://.godot/imported/prime_supervisor_dredar_neutral.png-c58a4c44ee95bc92ca0442633e5799d6.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Art/Patients/prime_supervisor_dredar/prime_supervisor_dredar_neutral.png"
|
||||
dest_files=["res://.godot/imported/prime_supervisor_dredar_neutral.png-c58a4c44ee95bc92ca0442633e5799d6.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
+29
-18
@@ -25,7 +25,7 @@ var symptoms_arrays: Array[Array] = [
|
||||
["HETERO-AGRESSIVE BEHAVIOUR", "VISUAL HALLUCINATIONS"]
|
||||
]
|
||||
#Lists of possible patients sorted by floor
|
||||
var patient_list : Array[Array]
|
||||
var patient_list : Array[Dictionary]
|
||||
|
||||
#Supervisor file path
|
||||
var supervisor_name = "loeveth"
|
||||
@@ -55,18 +55,10 @@ func build_dialog_tree(tree_model: Array[int]) -> Dictionary: #Builds the dialog
|
||||
return tree
|
||||
|
||||
|
||||
func new_patient():
|
||||
func new_patient(patient_id):
|
||||
|
||||
var file_path: String
|
||||
|
||||
#Generating patient_id
|
||||
var floor_index = -Globals.floor_count -1
|
||||
print("Floor Index: " + str(floor_index))
|
||||
var patient_id = weighted_random(patient_list[floor_index])
|
||||
Globals.patient_id = patient_id
|
||||
Globals.patient_list.erase(patient_id) #Line to be reenabled when there is more than one patient in the list
|
||||
Globals.patients_seen.append(patient_id)
|
||||
|
||||
#Loading Patient Files
|
||||
var config := ConfigFile.new()
|
||||
file_path = "res://Dialogues/Patients/patient_" + patient_id + "_file.cfg"
|
||||
@@ -154,7 +146,7 @@ func sort_patients():
|
||||
break
|
||||
if symptom_matched:
|
||||
for k in range(j, symptoms_arrays.size()):
|
||||
patient_list[k].append({"patient_id": patient_id, "weight": j+1})
|
||||
patient_list[k].merge({patient_id: j+1}) # Adds the patient to every floor compatible
|
||||
symptom_matched = false
|
||||
break
|
||||
|
||||
@@ -163,22 +155,41 @@ func sort_patients():
|
||||
|
||||
|
||||
#Weighted random selection from an Array
|
||||
func weighted_random(array: Array):
|
||||
func weighted_random(patients: Dictionary):
|
||||
|
||||
#Calculating total weight
|
||||
var total_weight : int
|
||||
for item in array:
|
||||
total_weight += item.weight
|
||||
for weight in patients.values():
|
||||
total_weight += weight
|
||||
print("Total weight: " + str(total_weight))
|
||||
|
||||
var r = randf() * total_weight
|
||||
print("r :" + str(r))
|
||||
|
||||
var weight_sum : int
|
||||
for item in array:
|
||||
weight_sum += item.weight
|
||||
for patient_id in patients:
|
||||
weight_sum += patients[patient_id]
|
||||
if weight_sum >= r:
|
||||
print("Patient selected: " + item.patient_id + ", Weight: " + str(item.weight))
|
||||
return item.patient_id
|
||||
print("Patient selected: " + patient_id + ", Weight: " + str(patients[patient_id]))
|
||||
return patient_id
|
||||
return null
|
||||
|
||||
|
||||
func generate_patient_id() -> String: #Generates a patient ID
|
||||
|
||||
#Generating 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]))
|
||||
|
||||
#Updates global variables
|
||||
Globals.patient_id = patient_id
|
||||
Globals.patients_seen.append(patient_id)
|
||||
|
||||
return patient_id
|
||||
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func new_patient():
|
||||
Patient.new_patient()
|
||||
Patient.new_patient(Patient.generate_patient_id())
|
||||
patient_file.text = Patient.file_text
|
||||
patient_file_title.text = Patient.file_title
|
||||
patient_recording.text = ""
|
||||
|
||||
Reference in New Issue
Block a user