Connect the database to parakeets
This commit is contained in:
@@ -57,13 +57,13 @@ func _setup_minigame() -> void:
|
||||
|
||||
# Find the stimuli and distractions of the minigame.
|
||||
func _find_stimuli_and_distractions() -> void:
|
||||
stimuli = Database.get_GP_for_lesson(lesson_nb)
|
||||
distractions = Database.get_GP_before_lesson(lesson_nb)
|
||||
stimuli = Database.copy_without_double_graphemes(Database.get_GP_for_lesson(lesson_nb))
|
||||
distractions = Database.copy_without_double_graphemes(Database.get_GP_before_lesson(lesson_nb))
|
||||
|
||||
|
||||
# Launch the minigame
|
||||
func _start() -> void:
|
||||
super._start()
|
||||
super()
|
||||
|
||||
_on_hole_timer_timeout(stimuli[0])
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ signal pressed()
|
||||
var stimulus: Dictionary :
|
||||
set(value):
|
||||
stimulus = value
|
||||
label.text = value.label
|
||||
label.text = value.Grapheme
|
||||
|
||||
const animations: = [
|
||||
preload("res://sources/minigames/parakeets/red_parakeet_animations.tres"),
|
||||
|
||||
@@ -24,6 +24,7 @@ const audio_streams: = [
|
||||
]
|
||||
|
||||
@export var difficulty: = 1
|
||||
@export var lesson_nb: = 4
|
||||
@export var fly_duration: = 3.0
|
||||
|
||||
@onready var possible_positions_parent: = $GameRoot/PossiblePositions
|
||||
@@ -79,7 +80,7 @@ func _setup_minigame() -> void:
|
||||
parakeets.append_array([new_parakeet1, new_parakeet2])
|
||||
var stimulus: Dictionary = stimuli2.pop_back()
|
||||
var stimulus_up: = stimulus.duplicate()
|
||||
stimulus_up.label = stimulus_up.label.to_upper()
|
||||
stimulus_up.label = stimulus_up.Grapheme.to_upper()
|
||||
new_parakeet1.stimulus = stimulus
|
||||
new_parakeet2.stimulus = stimulus_up
|
||||
new_parakeet1.pressed.connect(_on_parakeet_pressed.bind(new_parakeet1))
|
||||
@@ -88,13 +89,10 @@ func _setup_minigame() -> void:
|
||||
|
||||
# Find the stimuli and distractions of the minigame.
|
||||
func _find_stimuli_and_distractions() -> void:
|
||||
# TODO: fake stimuli and distractor for testing
|
||||
# Replace in the future by a proper research
|
||||
stimuli = [
|
||||
{"label": "a", "sound": ""},
|
||||
{"label": "b", "sound": ""},
|
||||
{"label": "c", "sound": ""},
|
||||
]
|
||||
var before: = Database.get_GP_before_lesson(lesson_nb)
|
||||
var current: = Database.get_GP_for_lesson(lesson_nb)
|
||||
before.append_array(current)
|
||||
stimuli = Database.copy_without_double_graphemes(before)
|
||||
|
||||
|
||||
func _start() -> void:
|
||||
@@ -129,7 +127,7 @@ func _on_parakeet_pressed(parakeet: Parakeet) -> void:
|
||||
|
||||
|
||||
func _on_selected_two() -> void:
|
||||
if selected[0].stimulus.label.to_upper() == selected[1].stimulus.label.to_upper():
|
||||
if selected[0].stimulus.Grapheme.to_upper() == selected[1].stimulus.Grapheme.to_upper():
|
||||
_correct()
|
||||
else:
|
||||
_wrong()
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
[node name="Parakeets" instance=ExtResource("1_oeg4r")]
|
||||
script = ExtResource("2_x6xn5")
|
||||
difficulty = 1
|
||||
lesson_nb = 4
|
||||
fly_duration = 3.0
|
||||
max_number_of_lives = 5
|
||||
help_kalulu_speech = ExtResource("3_ofxb4")
|
||||
|
||||
@@ -15,12 +15,12 @@ func _exit_tree() -> void:
|
||||
|
||||
|
||||
func get_GP_for_lesson(lesson_nb: int) -> Array:
|
||||
db.query_with_bindings("Select Grapheme, Phoneme FROM GPs INNER JOIN Lessons ON Lessons.GPID = GPs.ID AND Lessons.LessonNb == ?", [lesson_nb])
|
||||
db.query_with_bindings("Select Grapheme, Phoneme, LessonNb FROM GPs INNER JOIN Lessons ON Lessons.GPID = GPs.ID AND Lessons.LessonNb == ?", [lesson_nb])
|
||||
return db.query_result
|
||||
|
||||
|
||||
func get_GP_before_lesson(lesson_nb: int) -> Array:
|
||||
db.query_with_bindings("Select Grapheme, Phoneme FROM GPs INNER JOIN Lessons ON Lessons.GPID = GPs.ID AND Lessons.LessonNb < ?", [lesson_nb])
|
||||
db.query_with_bindings("Select Grapheme, Phoneme, LessonNb FROM GPs INNER JOIN Lessons ON Lessons.GPID = GPs.ID AND Lessons.LessonNb < ?", [lesson_nb])
|
||||
return db.query_result
|
||||
|
||||
|
||||
@@ -34,6 +34,16 @@ func get_words_containing_grapheme(grapheme: String) -> Array:
|
||||
return db.query_result
|
||||
|
||||
|
||||
func copy_without_double_graphemes(input: Array) -> Array:
|
||||
var output: = []
|
||||
var graphemes: = {}
|
||||
for val in input:
|
||||
if not graphemes.has(val.Grapheme):
|
||||
output.append(val)
|
||||
graphemes[val.Grapheme] = true
|
||||
return output
|
||||
|
||||
|
||||
# Import data from previous Kalulu version
|
||||
|
||||
func _import_gps() -> void:
|
||||
|
||||
Reference in New Issue
Block a user