Ensure proper initialization of all Arrays and Dictionaries
This commit is contained in:
@@ -18,9 +18,9 @@ const label_settings: LabelSettings = preload("res://resources/themes/minigames_
|
||||
@onready var ants: Node2D = %Ants
|
||||
@onready var words: Node2D = %Words
|
||||
|
||||
var current_sentence: Dictionary
|
||||
var answered: Array[bool]
|
||||
var answers: Array[bool]
|
||||
var current_sentence: Dictionary = {}
|
||||
var answered: Array[bool] = []
|
||||
var answers: Array[bool] = []
|
||||
|
||||
|
||||
func _find_stimuli_and_distractions() -> void:
|
||||
@@ -28,8 +28,8 @@ func _find_stimuli_and_distractions() -> void:
|
||||
if sentences_list.is_empty():
|
||||
return
|
||||
|
||||
var current_lesson_sentences: Array[Dictionary]
|
||||
var previous_lesson_sentences: Array[Dictionary]
|
||||
var current_lesson_sentences: Array[Dictionary] = []
|
||||
var previous_lesson_sentences: Array[Dictionary] = []
|
||||
|
||||
for sentence_in_list: Dictionary in sentences_list:
|
||||
if sentence_in_list.LessonNb == lesson_nb:
|
||||
@@ -98,7 +98,7 @@ func _get_new_sentence() -> void:
|
||||
|
||||
|
||||
func _next_sentence() -> void:
|
||||
var nodes: Array[Node]
|
||||
var nodes: Array[Node] = []
|
||||
nodes.append_array(sentence_container.get_children())
|
||||
nodes.append_array(words.get_children())
|
||||
for node: Node in nodes:
|
||||
@@ -118,7 +118,7 @@ func _next_sentence() -> void:
|
||||
|
||||
var current_words: PackedStringArray = (current_sentence.Sentence as String).replace("'", " ' ").replace("-", " - ").split(" ")
|
||||
|
||||
var inds_to_remove: Array[int]
|
||||
var inds_to_remove: Array[int] = []
|
||||
for index: int in range(1, current_words.size()):
|
||||
var word: String = current_words[index]
|
||||
if word in ["?", "!", ":"]:
|
||||
|
||||
@@ -103,8 +103,8 @@ var win_kalulu_speech: AudioStreamMP3
|
||||
var lose_kalulu_speech: AudioStreamMP3
|
||||
|
||||
# data to go back to the right place in gardens
|
||||
var gardens_data: Dictionary
|
||||
static var transition_data: Dictionary
|
||||
var gardens_data: Dictionary = {}
|
||||
static var transition_data: Dictionary = {}
|
||||
|
||||
#region Initialisation
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ func _find_stimuli_and_distractions() -> void:
|
||||
if not all_syllables:
|
||||
return
|
||||
|
||||
var current_lesson_stimuli: Array[Dictionary]
|
||||
var previous_lesson_stimuli: Array[Dictionary]
|
||||
var current_lesson_stimuli: Array[Dictionary] = []
|
||||
var previous_lesson_stimuli: Array[Dictionary] = []
|
||||
|
||||
# Find the syllables for current lesson
|
||||
for syllable: Dictionary in all_syllables:
|
||||
@@ -203,7 +203,7 @@ func _on_stimulus_pressed(stimulus : Dictionary, _node : Node) -> bool:
|
||||
else:
|
||||
var right_answer_GPs: Array[Dictionary] = _get_current_stimulus().GPs
|
||||
|
||||
var stimulus_GPs: Array[Dictionary]
|
||||
var stimulus_GPs: Array[Dictionary] = []
|
||||
if stimulus.has("GPs"):
|
||||
stimulus_GPs = stimulus.GPs
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class_name WordsMinigame
|
||||
var current_word_progression: int = 0: set = _set_current_word_progression
|
||||
var max_word_progression: int = 0
|
||||
|
||||
var current_gp_distractors_queue: Array[Dictionary]
|
||||
var current_gp_distractors_queue: Array[Dictionary] = []
|
||||
|
||||
# Find the stimuli and distractions of the minigame.
|
||||
func _find_stimuli_and_distractions() -> void:
|
||||
@@ -21,8 +21,8 @@ func _find_stimuli_and_distractions() -> void:
|
||||
if words_list.is_empty():
|
||||
return
|
||||
|
||||
var current_lesson_words: Array[Dictionary]
|
||||
var previous_lesson_words: Array[Dictionary]
|
||||
var current_lesson_words: Array[Dictionary] = []
|
||||
var previous_lesson_words: Array[Dictionary] = []
|
||||
|
||||
for word: Dictionary in words_list:
|
||||
if not FileAccess.file_exists(Database.get_word_sound_path(word)):
|
||||
@@ -82,7 +82,7 @@ func _find_stimuli_and_distractions() -> void:
|
||||
# Find the GPs and distractors for each word
|
||||
for stimulus: Dictionary in stimuli:
|
||||
stimulus.GPs = Database.get_GP_from_word(stimulus.ID as int)
|
||||
var grapheme_distractions: Array
|
||||
var grapheme_distractions: Array = []
|
||||
for GP: Dictionary in stimulus.GPs:
|
||||
grapheme_distractions.append(Database.get_distractors_for_grapheme(GP.ID as int, lesson_nb))
|
||||
distractions.append(grapheme_distractions)
|
||||
|
||||
@@ -8,7 +8,7 @@ signal pressed(gp: Dictionary)
|
||||
@onready var highlight_fx: HighlightFX = $HighlightFX
|
||||
@onready var wrong_fx: WrongFX = $WrongFX
|
||||
|
||||
var gp: Dictionary:
|
||||
var gp: Dictionary = {}:
|
||||
set(value):
|
||||
gp = value
|
||||
if gp.has("Grapheme"):
|
||||
|
||||
@@ -5,7 +5,7 @@ extends Node2D
|
||||
@onready var label: Label = $Label
|
||||
@onready var right_FX: RightFX = $RightFX
|
||||
|
||||
var gp: Dictionary:
|
||||
var gp: Dictionary = {}:
|
||||
set(value):
|
||||
gp = value
|
||||
if gp.has("Grapheme"):
|
||||
|
||||
@@ -125,7 +125,7 @@ func _on_berry_timer_timeout() -> void:
|
||||
var branch: Branch = branches[index]
|
||||
|
||||
# Define if the berry is a stimulus or a distraction
|
||||
var gp: Dictionary
|
||||
var gp: Dictionary = {}
|
||||
var is_stimulus: bool = randf() < _get_difficulty_settings().stimuli_ratio
|
||||
if is_stimulus:
|
||||
gp = _get_GP()
|
||||
|
||||
@@ -26,8 +26,8 @@ const fish_texture_rect_scene: PackedScene = preload("res://sources/minigames/fi
|
||||
@export var max_words_count: int = 15
|
||||
|
||||
var tween: Tween
|
||||
var words_to_present: Array[String]
|
||||
var words_to_present_next: Array[String]
|
||||
var words_to_present: Array[String] = []
|
||||
var words_to_present_next: Array[String] = []
|
||||
var progress_gauge_max_margin: float = 0.95
|
||||
var total_number_of_words: int = 30
|
||||
var tutorial_count: int = 0
|
||||
|
||||
@@ -10,7 +10,7 @@ signal disappeared()
|
||||
@onready var right_fx: RightFX = %RightFX
|
||||
@onready var wrong_fx: WrongFX = %WrongFX
|
||||
|
||||
var stimulus: Dictionary:
|
||||
var stimulus: Dictionary = {}:
|
||||
set = _set_stimulus
|
||||
var disabled: bool = false:
|
||||
set = _set_disabled
|
||||
|
||||
@@ -38,7 +38,7 @@ const scale_factor : float = 0.2
|
||||
@onready var right_fx: RightFX = %RightFX
|
||||
@onready var wrong_fx: WrongFX = %WrongFX
|
||||
|
||||
var stimulus: Dictionary :
|
||||
var stimulus: Dictionary = {}:
|
||||
set(value):
|
||||
stimulus = value
|
||||
if label:
|
||||
|
||||
@@ -24,7 +24,7 @@ var stunned: bool = false:
|
||||
locked = true
|
||||
|
||||
|
||||
var stimulus: Dictionary :
|
||||
var stimulus: Dictionary = {}:
|
||||
set(value):
|
||||
stimulus = value
|
||||
if value:
|
||||
|
||||
@@ -35,7 +35,7 @@ signal pressed()
|
||||
@onready var right_FX: RightFX = $RightFX
|
||||
@onready var wrong_FX: WrongFX = $WrongFX
|
||||
|
||||
var stimulus: Dictionary :
|
||||
var stimulus: Dictionary = {}:
|
||||
set(value):
|
||||
stimulus = value
|
||||
var grapheme: String = value.Grapheme as String
|
||||
|
||||
@@ -40,9 +40,9 @@ const audio_streams: Array[AudioStreamMP3] = [
|
||||
fly_away_position_2.global_position
|
||||
]
|
||||
|
||||
var possible_branch_positions: Array[Vector2]
|
||||
var parakeets: Array[Parakeet]
|
||||
var selected: Array[Parakeet]
|
||||
var possible_branch_positions: Array[Vector2] = []
|
||||
var parakeets: Array[Parakeet] = []
|
||||
var selected: Array[Parakeet] = []
|
||||
var state: State = State.Locked
|
||||
|
||||
const difficulty_settings: Dictionary[int, Dictionary] = {
|
||||
|
||||
@@ -6,7 +6,7 @@ signal pressed(pos: Vector2)
|
||||
@onready var wrong_fx: WrongFX = %WrongFX
|
||||
@onready var button: Button = $Button
|
||||
|
||||
var gp: Dictionary
|
||||
var gp: Dictionary = {}
|
||||
var capitalized: bool = false
|
||||
var is_pressed: bool = false
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ func _find_stimuli_and_distractions() -> void:
|
||||
|
||||
if sentences_list.is_empty():
|
||||
return
|
||||
var current_lesson_sentences: Array[Dictionary]
|
||||
var previous_lesson_sentences: Array[Dictionary]
|
||||
var current_lesson_sentences: Array[Dictionary] = []
|
||||
var previous_lesson_sentences: Array[Dictionary] = []
|
||||
|
||||
for sentence: Dictionary in sentences_list:
|
||||
if sentence.LessonNb == lesson_nb:
|
||||
|
||||
@@ -3,7 +3,7 @@ extends Area2D
|
||||
@onready var label : Label = $Label
|
||||
@onready var collision: CollisionPolygon2D = $CollisionPolygon2D
|
||||
|
||||
var stimulus: Dictionary:
|
||||
var stimulus: Dictionary = {}:
|
||||
set(value):
|
||||
stimulus = value
|
||||
progress = 0
|
||||
|
||||
@@ -14,7 +14,7 @@ signal animation_changed(position: Vector2)
|
||||
@onready var delete_timer: Timer = $DeleteTimer
|
||||
@onready var audio_stream_player: AudioStreamPlayer2D = $AudioStreamPlayer2D
|
||||
|
||||
var gp: Dictionary:
|
||||
var gp: Dictionary = {}:
|
||||
set(value):
|
||||
gp = value
|
||||
if gp and gp.has("Grapheme"):
|
||||
|
||||
Reference in New Issue
Block a user